Sam Atkins
c0d3f1a5e4
LibWeb: Use CSS::Number for CalculatedStyleValue numbers
2022-03-22 15:47:36 +01:00
Sam Atkins
fe372cd073
LibWeb: Use CSS::Number for Token numeric values
2022-03-22 15:47:36 +01:00
Sam Atkins
e8ab2dab11
LibWeb: Implement a CSS::Number class
...
We have the same "number and is-integer flag" structure in several
places, so let's put that in a class.
2022-03-22 15:47:36 +01:00
Sam Atkins
0795b9f7bb
LibWeb: Use floats instead of doubles for CSS numbers
...
Using doubles isn't necessary, and they make things slightly bigger and
slower, so let's use floats instead.
2022-03-22 15:47:36 +01:00
Sam Atkins
1f5b5d3f99
LibWeb: Use intermediate ints when converting strings to numbers in CSS
...
These three are all integers - we just repeatedly multiply them by 10
and then add a digit - so using an integer here is both faster and more
accurate. :^)
2022-03-22 15:47:36 +01:00
Sam Atkins
404a7cb63a
LibGfx+LibWeb: Use floats not doubles to create HSL colors
...
There's really no reason to use doubles here, except at the time I
wanted to use doubles everywhere in CSS. I now realize that is
excessive, so everything can be floats instead.
2022-03-22 15:47:36 +01:00
Sam Atkins
75ec960495
LibWeb: Initialize PseudoClass/PseudoElement selectors in one go
...
There was no real benefit to creating the SimpleSelector early and then
modifying it, and doing so made this code harder to follow than it
needs to be.
2022-03-22 15:47:36 +01:00
Sam Atkins
c0db19f63c
LibWeb: Use a Variant for SimpleSelector's contents
...
This reduces SimpleSelector's size from 112 bytes to 80 bytes. :^)
2022-03-22 15:47:36 +01:00
Sam Atkins
218a9af6b3
LibWeb: Make StyleComponentValueRule use a Variant
...
This shrinks its size from 96 bytes to 80. It's now limited by the size
of Token.
2022-03-22 15:47:36 +01:00
Sam Atkins
ca1b855d99
LibWeb: Allow percentages in word/letter-spacing properties
...
This is a change to CSS-TEXT-4, listed here:
https://www.w3.org/TR/2022/WD-css-text-4-20220318/#changes
We don't actually support these properties yet, but it doesn't hurt to
keep them up to date for when they get implemented in the future. :^)
2022-03-22 15:45:46 +01:00
Linus Groh
701d437205
LibWeb: Explicitly ignore [[nodiscard]] values returned from TRY(), pt 2
2022-03-22 13:36:44 +00:00
Linus Groh
70b1f18e58
LibWeb: Explicitly ignore [[nodiscard]] values returned from TRY()
...
This broke the clang build.
2022-03-22 13:20:06 +00:00
Timothy Flynn
c3f9cd6dbd
LibWeb: Convert Range to use TRY for error propagation
2022-03-22 12:09:27 +00:00
Timothy Flynn
f9cc5d1071
LibWeb: Convert HTMLOptionsCollection to use TRY for error propagation
2022-03-22 12:09:27 +00:00
Timothy Flynn
2d34216628
LibWeb: Make DOM::ExceptionOr compatible with the TRY macro
...
This will help reduce the quite repetitive pattern of:
auto result_or_error = dom_node->do_something();
if (result_or_error.is_exception())
return result_or_error.exception();
auto result = result_or_error.release_value();
Similar to LibJS completions, this adds an alias to the error accessors.
This also removes the requirement on release_value() for ValueType to
not be Empty, which we also had to do for TRY compatibility in LibJS.
2022-03-22 12:09:27 +00:00
Jamie Mansfield
9b9d32dfb2
LibWeb: Fix crash when removing event listeners
2022-03-22 02:35:07 +01:00
Timothy Flynn
27eb70cbba
LibWeb: Implement HTMLSelectElement.add()
...
HTMLSelectElement simply defers to its HTMLOptionsCollection.
2022-03-22 02:08:15 +01:00
Timothy Flynn
ff9856a214
LibWeb: Implement HTMLOptionsCollection.add()
2022-03-22 02:08:15 +01:00
Timothy Flynn
5133491714
LibWeb: Expose HTMLCollection's root element to its subclasses
...
For example, HTMLOptionsCollection will need to access its root
HTMLSelectElement.
2022-03-22 02:08:15 +01:00
Simon Wanner
dc94879b83
LibWeb: Support transform: translate(...)
by percentage
2022-03-22 02:06:21 +01:00
Simon Wanner
145efbe07a
LibWeb: Apply the CSS transform-origin property
...
We don't have transform-box yet, so this applies to the border-box
for now.
This also makes us pass a couple Web Platform Tests as well :^)
For example:
https://wpt.live/css/css-transforms/css3-transform-scale-002.html
2022-03-22 02:06:21 +01:00
Simon Wanner
63055ff5ad
LibWeb: Parse the CSS transform-origin property
...
This is almost a PositionStyleValue, but it's serialized differently,
so let's use a StyleValueList with 2 length-percentage values.
2022-03-22 02:06:21 +01:00
Andreas Kling
8ab25f8d8c
LibWeb: Implement Range.surroundContents(newParent)
...
Here goes another Acid3 point :^)
2022-03-21 23:28:46 +01:00
Karol Kosek
686507a38f
LibWeb: Translate table cells by their top left border
2022-03-21 21:55:21 +01:00
Karol Kosek
20730c164c
LibWeb: Include table cell border widths when calculating cell rects
...
Previously, table cells would overlap when they had CSS border or
padding properties defined.
2022-03-21 21:55:21 +01:00
Andreas Kling
68f3feb1d1
LibWeb: Fix two spec transcription mistakes in live range updating
...
This scores us another point on Acid3. :^)
2022-03-21 21:11:38 +01:00
Timothy Flynn
57296393ed
LibWeb: Begin implementing SVGRectElement's SVGAnimatedLength attributes
2022-03-21 21:04:39 +01:00
Timothy Flynn
7a6b4e33ba
LibWeb: Implement the SVGAnimatedLength type
2022-03-21 21:04:39 +01:00
Timothy Flynn
ebf3829f1c
LibWeb: Begin implementing the SVGLength type
...
There are a few unimplemented features for this type:
1. The value setter should throw a DOMException if it is invoked on an
SVGLength that was declared readonly in another IDL file.
2. SVG::AttributeParser does not parse unit types when it parses lengths
so all SVGLength will have an "unknown" unit for now.
3. Due to (2), methods which convert between units are unimplemented.
2022-03-21 21:04:39 +01:00
Andreas Kling
4d49c607f8
LibWeb: Fix spec transcription mistake in Range.extractContents()
...
The spec text and code didn't match up.
Thanks to Tim for spotting this! :^)
2022-03-21 21:01:47 +01:00
Andreas Kling
ac8a8459d0
LibWeb: Don't allow setting Range start/end to document being destroyed
2022-03-21 20:37:49 +01:00
Andreas Kling
3b6323340a
LibWeb: Update live ranges on Node insertion and removal
...
Taking care of some old FIXMEs :^)
2022-03-21 20:26:35 +01:00
Andreas Kling
1254758b00
LibWeb: Update live DOM ranges on Text and CharacterData mutations
...
Taking care of the FIXMEs I added in earlier patches. :^)
2022-03-21 20:06:59 +01:00
Andreas Kling
c74b1b6d65
LibWeb: Implement Range.insertNode(node)
2022-03-21 19:14:50 +01:00
Andreas Kling
d2f9f8bd4f
LibWeb: Implement Text.splitText(offset)
...
With FIXMEs about updating live ranges, but still.
2022-03-21 19:14:50 +01:00
Andreas Kling
8bc3f4c186
LibWeb: Fix logic mistakes in Range stringification
...
We were passing the wrong length argument to substring() when
stringifying a range where start and end are the same text node.
Also, make sure we visit all the contained text nodes when appending
them to the output.
This was caught by an Acid3 subtest.
2022-03-21 19:14:50 +01:00
Andreas Kling
16f4c76da6
LibWeb: Implement Range.extractContents()
...
Another point on Acid3 coming through! :^)
2022-03-21 18:06:28 +01:00
Andreas Kling
24e25fe3d0
LibWeb: Add CharacterData.replaceData(offset, count, data)
...
Note that we don't queue mutation records or update live ranges yet,
I've left those as FIXMEs.
2022-03-21 18:05:20 +01:00
Andreas Kling
e50c7de1b2
LibWeb: Add CharacterData.substringData(offset, count)
2022-03-21 17:20:42 +01:00
Andreas Kling
394cd77467
LibWeb: Implement stringifier for DOM Range :^)
2022-03-21 16:29:19 +01:00
Andreas Kling
c8bdac8736
LibWeb: Implement HTMLTableRowElement.{rowIndex,sectionRowIndex}
...
Another point on Acid3. :^)
2022-03-21 16:15:33 +01:00
Andreas Kling
1206dd2215
LibWeb: Make parse_html_length() accept floating point numbers
...
This makes stuff like <img width="12.5"> work. This code is not great,
so I've left a FIXME about improving it.
2022-03-21 15:58:21 +01:00
Andreas Kling
196a3eb239
LibWeb: Ignore invisible boxes and stacking contexts during hit testing
2022-03-21 15:43:37 +01:00
Andreas Kling
df8ef03957
LibWeb: Pick up the CSS "visibility" property an honor it when painting
2022-03-21 15:42:57 +01:00
Andreas Kling
01662b2320
LibWeb: Remove now-unused PaintableBox::for_each_child_in_paint_order()
2022-03-21 14:57:00 +01:00
Andreas Kling
a779ace6a1
LibWeb: Don't compute fragment absolute rect twice while hit testing
2022-03-21 13:03:33 +01:00
Andreas Kling
996f3228a2
LibWeb: Fix O(n^2) traversal in hit testing
...
We already walk the entire paint tree within each stacking context in
the main hit testing function (StackingContext::hit_test()), so there's
no need for each individual paintable to walk its own children again.
By not doing that, we remove a source of O(n^2) traversal which made hit
testing on deeply nested web pages unbearably slow.
2022-03-21 13:03:33 +01:00
Andreas Kling
f7cfd47b48
LibWeb: Add Paintable::dom_node() convenience accessor
2022-03-21 13:03:33 +01:00
Andreas Kling
b64b5fa8bd
LibWeb: Add Painting::HitTestResult::dom_node()
...
This is a convenience accessor to avoid having to say this everywhere:
result.paintable->layout_node().dom_node()
Instead, you can now do:
result.dom_node()
2022-03-21 13:03:33 +01:00
Andreas Kling
0ba785894c
LibWeb: Make hit testing functions return Optional<HitTestResult>
...
Using "HitTestResult with null paintable" as a way to signal misses was
unnecessarily confusing. Let's use Optional instead. :^)
2022-03-21 13:03:33 +01:00