summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibWeb
AgeCommit message (Collapse)Author
2021-08-02LibWeb: Implement CSS parsing convenience functionsSam Atkins
These mostly match the API in `DeprecatedCSSParser.h`. The exception is that `parse_selector()` returns a `SelectorList` instead of just one `Selector`. The only uses of that are in `ParentNode::query_selector[_all]()` which should be matching against a list, according to the spec. `parse_html_length()` is an odd case. It's used for `width="200"` cases in HTML, so is not really CSS related, but does produce a StyleValue. The values allowed in `width/height` in HTML vary per element, but they are a lot more restricted than in CSS, so it's slightly inappropriate to use the CSS parser for them, even though it's convenient. We also ignore a few functions: - `parse_line_width()` - `parse_line_style()` - `parse_color()` These are all only used in `StyleResolver`, when it is given a property value as a String. That won't happen once the old parser is removed.
2021-08-02LibWeb: Clarify naming and publicity of CSS Parser methodsSam Atkins
`parse_as_foo()` implies that the Parser's internal data is used, whereas `parse_a_foo()` implies that the passed-in data is used. Also, made all the `parse_a_foo()` methods private, as they are only required within the Parser, and this makes the API clearer to outsiders. The `parse_a(s)_foo()` naming is a little awkward, but it comes from section 5.3 of the spec, so seemed worth keeping: https://www.w3.org/TR/css-syntax-3/#parser-entry-points
2021-08-02LibWeb: Only dump parsed CSS stylesheet if logging is enabledSam Atkins
2021-08-02Userland: Make use of container version of any_ofLenny Maiorani
Problem: - New `any_of` implementation takes the entire container so the user does not need to pass explicit begin/end iterators. This is unused except is in tests. Solution: - Make use of the new and more user-friendly version where possible.
2021-08-02LibWeb: Remove unneccessary breaks from text-decoration-renderingTobias Christiansen
The returns in the switch-block don't need any breaks after them.
2021-08-02LibWeb: Don't draw zero-length line for text-decoration: blinkTobias Christiansen
This patch doesn't make any visible change but increases the correctness of the text-decoration: blink path. Previously the painter would be instructed to draw a line that doesn't have any length when encountering the blink property instead of simply doing nothing.
2021-08-01LibWeb: Remove unused header includesBrian Gianforcaro
2021-08-01LibJS: Remove unused includes out of Cell.h, move to the usersBrian Gianforcaro
Almost everything in LibJS includes Cell.h, don't force all code to include AK/TypeCasts.h + AK/String.h. Instead include them where they are actually used and required.
2021-07-31LibWeb: Fix regression of "contenteditable" attributeTheFightingCatfish
2021-07-31LibWeb: Ignore unquoted data urls in CSSSam Atkins
Previously we were only ignoring quoted ones (eg `url("data:...")`), so now we ignore unquoted ones (eg `url(data:...)`) too.
2021-07-31LibWeb: Parse calc() values in new CSS ParserSam Atkins
This is a port of the code from DeprecatedCSSParser, to work with CSS Tokens and TokenStream. I've modified it as little as possible.
2021-07-31LibWeb: Treat CSS calc() values as "builtin_or_dynamic"Sam Atkins
2021-07-31LibWeb: Allow peeking more than 1 token ahead in CSS ParserSam Atkins
2021-07-31LibWeb: Parse box-shadow property in new CSS ParserSam Atkins
Previous multi-value properties use a ValueListStyleValue, which then gets parsed into its sub-properties in the StyleResolver. However, that is not ideal, especially as it exposes StyleResolver to the inner workings of the Parser and Tokenizer, which it should not need to know about. The way `box-shadow` was implemented as a StyleValue subclass means that the parsing can happen inside the Parser instead, which seems like a better solution. Converting the other complicated cases (background, font, list-style) is on my todo list for later.
2021-07-31LibWeb: Convert CSS parse_{color,length}() lambdas into methodsSam Atkins
This lets us get the Length and Color values directly, without having to create a StyleValue object and then throw it away again, when parsing the box-shadow property in the next commit.
2021-07-31LibWeb: Fix issues with CSS attribute selector handlingSam Atkins
This is three small, related changes: 1. Element::has_attribute() now returns true if the attribute exists but has no value. (eg, `<div foo />` -> `has_attribute("foo")`) 2. SelectorEngine::matches_attribute() now makes sure there is a first segment before comparing it, fixing a crash. 3. CSS::Parser now converts attribute names in attribute selectors to lowercase, to match the expectations of the rest of the system. Converting to lowercase is not always correct, depending on language, but since we only currently support HTML, and that expects them to be case-insensitive, it is fine for now.
2021-07-31LibWeb: Make CSS 'An+B' parsing spec-compliantSam Atkins
Parsing this pattern from CSS tokens turns out to be slightly crazy, but thankfully well documented in the spec. The spec lists the cases in order of simple -> complicated, but this would cause problems in code, since `<n-dimension> <signed-.integer>` would never by reached, as `<n-dimension>` comes before. Instead, I have grouped them by their first token. Also renamed the NthChildPattern class to ANPlusBPattern, to match spec terminology.
2021-07-31LibWeb: Parse CSS selectors according to the specSam Atkins
The spec does not directly tell us how to parse selectors, so there are likely some bugs here, but I've used the spec language where possible. This is very much based on the previous selector parsing code. Any parse error inside a selector makes the entire SelectorList invalid, so nothing is returned.
2021-07-31LibWeb: Fix dump_selector() handling of attribute selectorsSam Atkins
Encountering an attribute selector was immediately ending the dump output by mistake, and it was assigning the match types to the wrong variable.
2021-07-31LibWeb: Bring Selector terminology in line with the CSS specSam Atkins
- CompoundSelector -> *deleted* - ComplexSelector -> CompoundSelector - Relation -> Combinator Our Selector is really a ComplexSelector, but only the Parser and SelectorEngine need to know that, so keeping it named Selector makes it more understandable for users. Our CompoundSelector is really a CompoundSelectorAndCombinator. Combining the two makes sense in our codebase, but the accurate name is so long that I think it makes the code less readable. Renamed some Combinators to also match the spec terminology: - AdjacentSibling -> NextSibling - GeneralSibling -> SubsequentSibling The previous names are somewhat ambiguous, so hopefully this is clearer.
2021-07-31LibWeb: Stop parsing integer CSS values as LengthsSam Atkins
This was a hack copied over from the old parser, but it was causing problems with flex-grow, and probably other properties that accept numbers. Removing it does not seem to break anything, so lets' remove it! :^)
2021-07-31LibWeb: Define proper debug symbols for CSS Parser and TokenizerSam Atkins
You can now turn debug logging for them on using `CSS_PARSER_DEBUG` and `CSS_TOKENIZER_DEBUG`.
2021-07-31LibWeb: Use references to CSS tokens instead of copying by valueSam Atkins
A couple of places required a logic change to make this work, but mostly it's a simple case of adding &.
2021-07-31LibWeb: Get CSS @import rules working in new parserSam Atkins
Also added css-import.html, which tests the 3 syntax variations on `@import` statements. Note that the optional media-query parameter to `@import` is not handled yet.
2021-07-29LibWeb: Remove unused enum value CSS::StyleValue::PositionAndreas Kling
CSS position values are just basic identifiers, they don't require a custom StyleValue type.
2021-07-29LibWeb: Add proper support for text-decoration-line property valuesTobias Christiansen
The code handling the rendering of the text-decoration-line got moved into its own function to reduce clutter. The CSS property text-decoration-line now supports underline, overline and line-through.
2021-07-29LibWeb: Handle comment blocks when skipping unknown @-rulesK-Adam
This css definition was parsed incorrectly before: ```css @media screen { /* Unclosed bracket in comment { */ body { background: red; } } ```
2021-07-28LibWeb: Fix incompatibility of attribute "contenteditable"SeekingBlues
The previous behavior of mapping a missing value to the "inherit" state is incompatible. Now, a missing value maps to the "true" state, which is the expected behavior.
2021-07-28LibWeb: Avoid assertion failure on parsing numeric character referencesovf
2021-07-27LibWeb: Return null if an unknown canvas context type is requestedK-Adam
2021-07-27LibGfx: Remove Gfx::ImageDecoder::bitmap() in favor of frame(index)Andreas Kling
To transparently support multi-frame images, all decoder plugins have already been updated to return their only bitmap for frame(0). This patch completes the remaining cleanup work by removing the ImageDecoder::bitmap() API and having all clients call frame() instead.
2021-07-27LibGfx: Improve ImageDecoder constructionAndreas Kling
Previously, ImageDecoder::create() would return a NonnullRefPtr and could not "fail", although the returned decoder may be "invalid" which you then had to check anyway. The new interface looks like this: static RefPtr<Gfx::ImageDecoder> try_create(ReadonlyBytes); This simplifies ImageDecoder since it no longer has to worry about its validity. Client code gets slightly clearer as well.
2021-07-27LibWeb: Fix parsing of character references in attribute valuesovf
2021-07-26LibWeb: Add blurring support to box-shadowTobias Christiansen
Now the box-shadow-rendering is done by using the new Gfx::FastBoxBlurFilter. :^)
2021-07-26LibWeb: Make functions and attributes in bindings writabledavidot
This allows overwriting of for example EventTarget.prototype.addEventListener as css3test does.
2021-07-26LibWeb: Fix that non-member calls to window gave the wrong this_valuedavidot
We treat all NativeFunctions as strict mode and thus window function which were called in a global context (i.e. `setTimeout(f, 0)`) got a null this_value. But we really need to treat all functions not defined by the ECMAScript specification as non-strict. In most cases this won't matter however since Window is also the global_object we have an extra bit of logic. To fix this more correctly we would need to track the strictness of NativeFunctions.
2021-07-26LibWeb: Make the custom CSSDeclaration methods only work on stringsdavidot
Otherwise it will try to convert it to a string later anyway. And as far as I'm aware there are no style properties with just a number or JavaScript symbol as name.
2021-07-26LibWeb: Add a CustomHasProperty trait to WrapperGeneratordavidot
We immediately use this in CSSStyleDeclaration to fix that "background" in element.style did not return true. This is the mechanism used in css3test.com for detecting support of features.
2021-07-26LibWeb: Convert WrapperGenerator and the generated code to east-constdavidot
2021-07-25LibGfx: Make Gfx::Bitmap::set_nonvolatile() report allocation failureAndreas Kling
Making a bitmap non-volatile after being volatile may fail to allocate physical pages after the kernel stole the old pages in a purge. This is different from the pages being purged, but reallocated. In that case, they are simply replaced with zero-fill-on-demand pages as if they were freshly allocated.
2021-07-24LibWeb: Add box-shadow renderingTobias Christiansen
This patch adds the box-shadow rendering to Boxes. We do parse the blur-radius of a box-shadow but we don't use it for now as the Filter in the system don't seem quite powerful enough yet to handle that.
2021-07-24LibWeb: Parse box-shadow in the DeprecatedCSSParserTobias Christiansen
This adds support for box-shadows to the DeprecatedCSSParser. When it encounters a box-shadow property, the following syntaxes can get parsed: - box-shadow: <offset_x> <offset_y> <color> - box-shadow: <offset_x> <offset_y> <blur_radius> <color> There is other possible data following the property, but those aren't supported for now.
2021-07-24LibWeb: Make box-shadow known throughout the CSS subsystemTobias Christiansen
This patch spreads box-shadows around: - The Values important to box-shadows are stored in a BoxShadowData struct - StyleProperties knows how to construct such a struct from a BoxShadowStyleValue and a Node knows how to ask for it - CalculatedValues contain BoxShadowData and expose them
2021-07-24LibWeb: Add box-shadow as a known ValueIDTobias Christiansen
2021-07-24LibWeb: Add BoxShadowStyleType as a CSS StyleTypeTobias Christiansen
This new StyleType stores values related to box-shadows, since they consist of multiple parts that isn't just a shorthand for other properties.
2021-07-24LibWeb: Draw elements with opacity in a separate stacking contextEgor Ananyin
2021-07-24LibWeb: Parse and store the opacity propertyEgor Ananyin
2021-07-24LibWeb: Don't paint children stacking contexts inside the current oneEgor Ananyin
2021-07-24LibWeb: Add calc() resolution to CSS::LengthTobias Christiansen
This patch finally adds the actual calculation that goes into calc() expressions. When the resolution of a Length that is a calculated value the parsed CalculatedStyleValue gets traversed and appropriate values get calculated.
2021-07-24LibWeb: Plumb calculated StyleValues into CSS::LengthTobias Christiansen
This is a bit hackish, but this way the existance of the calc() becomes transparent to the user who just wants a Length and doesn't care where it came from.