1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 11:08:11 +00:00
serenity/Userland/Libraries/LibWeb/DOM
Linus Groh 09bd5f8772 LibJS: Rewrite most of Object for spec compliance :^)
This is a huge patch, I know. In hindsight this perhaps could've been
done slightly more incremental, but I started and then fixed everything
until it worked, and here we are. I tried splitting of some completely
unrelated changes into separate commits, however. Anyway.

This is a rewrite of most of Object, and by extension large parts of
Array, Proxy, Reflect, String, TypedArray, and some other things.

What we already had worked fine for about 90% of things, but getting the
last 10% right proved to be increasingly difficult with the current code
that sort of grew organically and is only very loosely based on the
spec - this became especially obvious when we started fixing a large
number of test262 failures.

Key changes include:

- 1:1 matching function names and parameters of all object-related
  functions, to avoid ambiguity. Previously we had things like put(),
  which the spec doesn't have - as a result it wasn't always clear which
  need to be used.
- Better separation between object abstract operations and internal
  methods - the former are always the same, the latter can be overridden
  (and are therefore virtual). The internal methods (i.e. [[Foo]] in the
  spec) are now prefixed with 'internal_' for clarity - again, it was
  previously not always clear which AO a certain method represents,
  get() could've been both Get and [[Get]] (I don't know which one it
  was closer to right now).
  Note that some of the old names have been kept until all code relying
  on them is updated, but they are now simple wrappers around the
  closest matching standard abstract operation.
- Simplifications of the storage layer: functions that write values to
  storage are now prefixed with 'storage_' to make their purpose clear,
  and as they are not part of the spec they should not contain any steps
  specified by it. Much functionality is now covered by the layers above
  it and was removed (e.g. handling of accessors, attribute checks).
- PropertyAttributes has been greatly simplified, and is being replaced
  by PropertyDescriptor - a concept similar to the current
  implementation, but more aligned with the actual spec. See the commit
  message of the previous commit where it was introduced for details.
- As a bonus, and since I had to look at the spec a whole lot anyway, I
  introduced more inline comments with the exact steps from the spec -
  this makes it super easy to verify correctness.
- East-const all the things.

As a result of all of this, things are much more correct but a bit
slower now. Retaining speed wasn't a consideration at all, I have done
no profiling of the new code - there might be low hanging fruits, which
we can then harvest separately.

Special thanks to Idan for helping me with this by tracking down bugs,
updating everything outside of LibJS to work with these changes (LibWeb,
Spreadsheet, HackStudio), as well as providing countless patches to fix
regressions I introduced - there still are very few (we got it down to
5), but we also get many new passing test262 tests in return. :^)

Co-authored-by: Idan Horowitz <idan.horowitz@gmail.com>
2021-07-04 22:07:36 +01:00
..
Attribute.h Everything: Move to SPDX license identifiers in all files. 2021-04-22 11:22:27 +02:00
CharacterData.cpp Everything: Move to SPDX license identifiers in all files. 2021-04-22 11:22:27 +02:00
CharacterData.h Everything: Move to SPDX license identifiers in all files. 2021-04-22 11:22:27 +02:00
CharacterData.idl Libraries: Move to Userland/Libraries/ 2021-01-12 12:17:46 +01:00
Comment.cpp Everything: Move to SPDX license identifiers in all files. 2021-04-22 11:22:27 +02:00
Comment.h Everything: Move to SPDX license identifiers in all files. 2021-04-22 11:22:27 +02:00
Comment.idl Libraries: Move to Userland/Libraries/ 2021-01-12 12:17:46 +01:00
Document.cpp LibWeb: Hook on_call_stack_emptied after m_interpreter was initialized 2021-07-04 14:23:25 +02:00
Document.h LibWeb: Add JSON serialization method to DOM::Node 2021-06-29 23:06:48 +02:00
Document.idl LibWeb: Add Document.{images,embeds,plugins,links,forms,scripts} 2021-05-04 23:40:43 +01:00
DocumentFragment.cpp LibWeb+HackStudio: Use lukew@serenityos.org for my copyright headers 2021-04-22 23:15:33 +02:00
DocumentFragment.h Everything: Move to SPDX license identifiers in all files. 2021-04-22 11:22:27 +02:00
DocumentFragment.idl LibWeb: Move element_child_count to ParentNode and add its IDL attribute 2021-04-11 18:32:42 +02:00
DocumentType.cpp Everything: Move to SPDX license identifiers in all files. 2021-04-22 11:22:27 +02:00
DocumentType.h LibWeb: Add createDocument and createDocumentType for DOMImplementation 2021-05-04 22:59:15 +01:00
DocumentType.idl Libraries: Move to Userland/Libraries/ 2021-01-12 12:17:46 +01:00
DOMException.h AK: Rename adopt() to adopt_ref() 2021-04-23 16:46:57 +02:00
DOMException.idl LibWeb: Add support for optional default values and optional bools in IDL 2021-04-11 18:27:52 +02:00
DOMImplementation.cpp LibWeb: Add createDocument and createDocumentType for DOMImplementation 2021-05-04 22:59:15 +01:00
DOMImplementation.h LibWeb: Add createDocument and createDocumentType for DOMImplementation 2021-05-04 22:59:15 +01:00
DOMImplementation.idl LibWeb: Add createDocument and createDocumentType for DOMImplementation 2021-05-04 22:59:15 +01:00
Element.cpp LibWeb: Support :active pseudo-class for hyperlinks, :focus possibly 2021-06-25 01:02:29 +02:00
Element.h LibWeb: Support :active pseudo-class for hyperlinks, :focus possibly 2021-06-25 01:02:29 +02:00
Element.idl LibWeb: Expose Element.{prefix,localName} 2021-05-11 18:01:36 +02:00
ElementFactory.cpp AK: Rename adopt() to adopt_ref() 2021-04-23 16:46:57 +02:00
ElementFactory.h Everything: Move to SPDX license identifiers in all files. 2021-04-22 11:22:27 +02:00
Event.cpp AK: Rename downcast<T> => verify_cast<T> 2021-06-24 19:57:01 +02:00
Event.h AK: Rename adopt() to adopt_ref() 2021-04-23 16:46:57 +02:00
Event.idl LibWeb: Add Event.initEvent 2021-04-11 18:27:52 +02:00
EventDispatcher.cpp LibJS: Rename Function => FunctionObject 2021-06-27 22:36:04 +02:00
EventDispatcher.h Everything: Move to SPDX license identifiers in all files. 2021-04-22 11:22:27 +02:00
EventListener.cpp LibJS: Rename Function => FunctionObject 2021-06-27 22:36:04 +02:00
EventListener.h LibJS: Rename Function => FunctionObject 2021-06-27 22:36:04 +02:00
EventTarget.cpp LibWeb: Implement EventTarget.dispatchEvent 2021-05-04 23:41:44 +01:00
EventTarget.h LibWeb: Implement EventTarget.dispatchEvent 2021-05-04 23:41:44 +01:00
EventTarget.idl LibWeb: Implement EventTarget.dispatchEvent 2021-05-04 23:41:44 +01:00
ExceptionOr.h LibWeb: Make ExceptionOr capable of holding all error types in the spec 2021-06-27 12:49:49 +01:00
HTMLCollection.cpp LibWeb: Implement a slow but functional HTMLCollection :^) 2021-04-22 21:21:46 +02:00
HTMLCollection.h AK: Rename adopt() to adopt_ref() 2021-04-23 16:46:57 +02:00
HTMLCollection.idl LibJS: Rewrite most of Object for spec compliance :^) 2021-07-04 22:07:36 +01:00
Node.cpp LibWeb: Do not encode "internal_id" in DOM JSON 2021-07-01 19:19:46 +02:00
Node.h LibWeb: Add JSON serialization method to DOM::Node 2021-06-29 23:06:48 +02:00
Node.idl LibWeb: Implement Node.replaceChild 2021-05-07 08:53:37 +02:00
NonDocumentTypeChildNode.h AK: Rename downcast<T> => verify_cast<T> 2021-06-24 19:57:01 +02:00
NonElementParentNode.h Everything: Move to SPDX license identifiers in all files. 2021-04-22 11:22:27 +02:00
ParentNode.cpp LibWeb+HackStudio: Use lukew@serenityos.org for my copyright headers 2021-04-22 23:15:33 +02:00
ParentNode.h Everything: Move to SPDX license identifiers in all files. 2021-04-22 11:22:27 +02:00
Position.cpp AK: Rename downcast<T> => verify_cast<T> 2021-06-24 19:57:01 +02:00
Position.h LibWeb: Frame/Position: Implement cursor increment/decrement methods 2021-05-21 21:57:03 +02:00
ProcessingInstruction.cpp Everything: Move to SPDX license identifiers in all files. 2021-04-22 11:22:27 +02:00
ProcessingInstruction.h Everything: Move to SPDX license identifiers in all files. 2021-04-22 11:22:27 +02:00
ProcessingInstruction.idl LibWeb: Add ProcessingInstruction node 2021-04-06 21:42:00 +02:00
Range.cpp AK: Rename adopt() to adopt_ref() 2021-04-23 16:46:57 +02:00
Range.h Everything: Move to SPDX license identifiers in all files. 2021-04-22 11:22:27 +02:00
Range.idl LibWeb: Add constructor to Range IDL interface 2021-02-17 23:45:07 +01:00
ShadowRoot.cpp AK: Rename downcast<T> => verify_cast<T> 2021-06-24 19:57:01 +02:00
ShadowRoot.h Everything: Move to SPDX license identifiers in all files. 2021-04-22 11:22:27 +02:00
ShadowRoot.idl Libraries: Move to Userland/Libraries/ 2021-01-12 12:17:46 +01:00
Text.cpp AK: Rename adopt() to adopt_ref() 2021-04-23 16:46:57 +02:00
Text.h Everything: Move to SPDX license identifiers in all files. 2021-04-22 11:22:27 +02:00
Text.idl Libraries: Move to Userland/Libraries/ 2021-01-12 12:17:46 +01:00
Timer.cpp LibJS: Rename Function => FunctionObject 2021-06-27 22:36:04 +02:00
Timer.h LibJS: Rename Function => FunctionObject 2021-06-27 22:36:04 +02:00
Window.cpp LibJS: Rename Function => FunctionObject 2021-06-27 22:36:04 +02:00
Window.h LibJS: Rename Function => FunctionObject 2021-06-27 22:36:04 +02:00