summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibWeb
AgeCommit message (Collapse)Author
2021-07-11LibWeb: Remove broken CSS:Parser::is_combinator()Sam Atkins
A single DELIM token is only one character long, so the check for a "||" DELIM didn't work. We now just do the check inline.
2021-07-11LibWeb: Fix greedy CSS Tokenizer whitespace parsingSam Atkins
Whitespace parsing was too greedy, consuming the first non- whitespace character after it.
2021-07-11LibWeb: Fix Off-by-one error in CSS::Parser::next_token()Sam Atkins
2021-07-11LibWeb: Convert QualifiedStyleRule to a RefPtr type in new ParserSam Atkins
2021-07-11LibWeb: Add new CSS attribute match types to new parserSam Atkins
2021-07-11LibWeb: Add remaining CSS AttributeMatchTypesSam Atkins
This adds: - ContainsString [att*=val] - StartsWithSegment [att|=val] - StartsWithString [att^=val] - EndsWithString [att$=val] Renamed AttributeMatchType::Contains to ::ContainsWord for clarity.
2021-07-11LibWeb: Use StyleComponentValueRules for StyleBlockRule's valuesSam Atkins
Noticed while doing this that attribute selectors have two different ways of saying "starts with", and so AttributeMatchType::StartsWith needs a better name. But I'll change that when I add the missing types. These class names are a mouthful to fit in a commit message. :^)
2021-07-11LibWeb: Convert some CSS parser *Rule classes to using pointersSam Atkins
Previously these were all passed around by value, but some of them (StyleComponentValueRule and StyleBlockRule) want to include each other as fields, so this had to change.
2021-07-11LibWeb: Make CSS selector parsing use StyleComponentValueRulesSam Atkins
Also added some pseudo-classes that were handled in the deprecated parser: - :disabled - :enabled - :checked - :nth-child - :nth-last-child - :not
2021-07-11LibWeb: Add convenience methods to CSS::Parser::TokenSam Atkins
Some of these will be removed later, when we move to using is() exclusively.
2021-07-11LibWeb: Make CSS::QualifiedStyleRule's prelude StyleComponentValueRuleSam Atkins
2021-07-11LibWeb: Fix syntax for Table testAdam Hodgen
The parser fixes this by inserting the <tr> tags, but for this test it's better to have perfect syntax - we're not testing the parser here.
2021-07-11LibWeb: Fix HTMLTable Element attributesAdam Hodgen
`Element::tag_name` return an uppercase version of the tag name. However the `Web::HTML::TagNames` values are all lowercase. This change fixes that using `Element::local_name`, which returns a lowercase value.
2021-07-10LibWeb: Avoid HashMap copy in BrowsingContext::set_frame_nesting_levelsAndreas Kling
2021-07-08Everywhere: Add break after the last case label before `default`Daniel Bertalan
We already do this in most places, so the style should be consistent. Also, Clang does not like it, as this could cause an unexpected compile error if some statements are added to the default label or a new label is added above it.
2021-07-08Everywhere: Forward declare structs as structsDaniel Bertalan
While structs being forward declared as classes is not strictly an issue, Clang complains as this is not portable code, since some ABIs treat classes declared as `class` and `struct` differently. It's easier to fix these than to reason about explicitly disabling another warning.
2021-07-08AK+Userland: Add generic `AK::abs()` function and use itDaniel Bertalan
Previously, in LibGFX's `Point` class, calculated distances were passed to the integer `abs` function, even if the stored type was a float. This caused the value to unexpectedly be truncated. Luckily, this API was not used with floating point types, but that can change in the future, so why not fix it now :^) Since we are in C++, we can use function overloading to make things easy, and to automatically use the right version. This is even better than the LibC/LibM functions, as using a bit of hackery, they are able to be constant-evaluated. They use compiler intrinsics, so they do not depend on external code and the compiler can emit the most optimized code by default. Since we aren't using the C++ standard library's trick of importing everything into the `AK` namespace, this `abs` function cannot be exported to the global namespace, as the names would clash.
2021-07-08Everywhere: Remove unused local variables and lambda capturesDaniel Bertalan
2021-07-08Everywhere: Mark debug-only functions `[[maybe_unused]]`Daniel Bertalan
These functions are only used from within `dbgln_if` calls, so in certain build configurations, they go unused. Similarly to variables, we now signal to the compiler that we understand that these are not always in use.
2021-07-07LibJS: Remove the NativeProperty mechanism from LibJSIdan Horowitz
These were an ad-hoc way to implement special behaviour when reading or writing to specific object properties. Because these were effectively replaced by the abillity to override the internal methods of Object, they are no longer needed.
2021-07-06LibJS: Remove the non-standard put helper and replace it's usagesIdan Horowitz
This removes all usages of the non-standard put helper method and replaces all of it's usages with the specification required alternative or with define_direct_property where appropriate.
2021-07-06LibJS: Remove the default length & attributes from define_native_*Idan Horowitz
These are usually incorrect, and people sometimes forget to add the correct values as a result of them being optional, so they should just be specified explicitly.
2021-07-06LibJS: Add define_direct_property and remove the define_property helperIdan Horowitz
This removes all usages of the non-standard define_property helper method and replaces all it's usages with the specification required alternative or with define_direct_property where appropriate.
2021-07-05LibWeb: Use is_nullish instead of is_null for nullable typesLuke
As according to: https://heycam.github.io/webidl/#es-nullable-type Both null and undefined are treated as IDL null, but we were only treating null as IDL null.
2021-07-05LibWeb: Replace usage of native properties with accessors in WindowIdan Horowitz
This is required by the WebIDL specification.
2021-07-05LibWeb: Replace usage of native properties with accessors in NavigatorIdan Horowitz
This is required by the WebIDL specification.
2021-07-05LibWeb: Replace usage of native properties with accessors in LocationIdan Horowitz
This is required by the WebIDL specification.
2021-07-05LibWeb: Use JS_DECLARE_NATIVE_FUNCTION for WebAssembly accessorsLinus Groh
2021-07-05LibWeb: Make WebAssembly.Memory.prototype.buffer an accessor propertyLinus Groh
2021-07-05LibWeb: Make WebAssembly.Instance.prototype.exports an accessor propertyLinus Groh
2021-07-05LibWeb: Use "WebAssembly.Foo" in exception error messagesLinus Groh
Not just "Foo" or "WebAssemblyFoo". This is how it's accessed from the outside (JS). Also fix one case of "not an" => "not a".
2021-07-05LibWeb: Implement Node.containsLuke
Used by Web Components Polyfills.
2021-07-05LibWeb: Make WrapperGenerator generate nullable wrapper typesLuke
Previously it was not doing so, and some code relied on this not being the case. In particular, set_caption, set_t_head and set_t_foot in HTMLTableElement relied on this. This commit is not here to fix this, so I added an assertion to make it equivalent to a reference for now.
2021-07-05LibWeb: Implement the adoption steps for <template> elementsLuke
While I'm here with the cloning steps, let's implement this too.
2021-07-05LibWeb: Implement the cloning steps for <template> elementsLuke
2021-07-05LibWeb: Make adopted_from no longer take a const Document referenceLuke
Nodes implementing the adoption steps can modify the passed in document, for example HTMLTemplateElement does so to adopt it's contents into the new document.
2021-07-05LibWeb: Add the cloning steps in clone_nodeLuke
This will be used in HTMLTemplateElement later to clone template contents. This makes the clone functions non-const in the process, as the cloning steps can have side effects.
2021-07-05LibWeb: Use the element factory in clone_nodeLuke
It was directly creating a new Element object instead of creating the appropriate element. For example, document.body.cloneNode(true) would return an Element instead of an HTMLBodyElement.
2021-07-05LibWeb: Make clone_node capable of cloning document fragmentsLuke
Used by Web Components Polyfills.
2021-07-05LibWeb: Add DOMParserLuke
This allows you to invoke the HTML document parser and retrieve a document as though it was loaded as a web page, minus any scripting ability. This does not currently support XML parsing. This is used by YouTube (or more accurately, Web Components Polyfills) to polyfill templates.
2021-07-05LibWeb: Check if scripting is disabled before running scriptLuke
This is not a full check, it's just enough to prevent script execution in DOMParser.
2021-07-04LibWeb: Change WrapperGenerator to emit acessor propertiesLinus Groh
This is how the Web IDL spec defines it. We might eventually not need native properties anymore, but that's another change for another day. Co-authored-by: Idan Horowitz <idan.horowitz@gmail.com>
2021-07-04LibJS: Rewrite most of Object for spec compliance :^)Linus Groh
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-04LibWeb/WebAssembly+test-wasm: Use get_without_side_effects() moreLinus Groh
2021-07-04LibWeb: Add roman numerals as a list-style for ol'sTobias Christiansen
This patch adds support for the identifiers upper-roman and lower-roman of the list-style property.
2021-07-04LibWeb: Hook on_call_stack_emptied after m_interpreter was initializedIdan Horowitz
We must hook `on_call_stack_emptied` after the interpreter was created, as the initialization of the WindowsObject can invoke some internal calls, which will eventually lead to this hook being called without `m_interpreter` being fully initialized yet.
2021-07-04LibJS: Bring ArrayCreate and ArrayConstructor closer to specIdan Horowitz
Specifically, this now explicitly takes the length, adds missing exceptions checks to calls with user-supplied lengths, takes and uses the prototype argument, and fixes some spec non-conformance in ArrayConstructor and its native functions around the use of ArrayCreate
2021-07-02AK: Implement String::find_any_of() and StringView::find_any_of()Max Wipfli
This implements StringUtils::find_any_of() and uses it in String::find_any_of() and StringView::find_any_of(). All uses of find_{first,last}_of have been replaced with find_any_of(), find() or find_last(). find_{first,last}_of have subsequently been removed.
2021-07-02LibWasm: Give traps a reason and display it when neededAli Mohammad Pur
This makes debugging wasm code a bit easier, as we now know what fails instead of just "too bad, something went wrong".
2021-07-02LibWeb: Add the WebAssembly.Module constructorAli Mohammad Pur