summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibWeb/Painting/PaintableBox.cpp
AgeCommit message (Collapse)Author
2022-03-30LibWeb: Use more precise font metrics when doing inline layoutAndreas Kling
We now position inline-level boxes based on ascent and descent metrics from the font in use. This makes our basic text layouts look a lot more like those produced by other browsers. :^) I've tried to match the terminology used by the CSS Inline Layout spec. This will regress Acid2 a little bit, and probably various other sites, but on the whole it's the direction we should be heading, so let's go.
2022-03-30LibWeb: Draw inspector overlay label with default fontAndreas Kling
2022-03-30LibWeb: Use the new Gfx::Painter::draw_text_run() API for drawing textAndreas Kling
This avoids a bunch of unnecessary work in Painter which not only took time, but sometimes also led to alignment issues. draw_text_run() will draw the text where we tell it, and that's it.
2022-03-29LibWeb: Use rounding instead of enclosing_int_rect() when paintingAndreas Kling
By using enclosing_int_rect(), borders and backgrounds of boxes were sometimes 1 pixel off, making things slightly larger than they should be. Fix this by using to_rounded() instead of enclosing_int_rect(). There's definitely more of these type of issues lurking in the code, and we'll get to them in time.
2022-03-27LibWeb: Stop allowing position:relative to affect layoutAndreas Kling
Relatively positioned boxes should not affect the *layout* of their siblings. So instead of applying relative inset as a layout-time translation on the box, we now perform the adjustment at the paintable level instead. This makes position:relative actually work as expected, and exposes some new bugs we need to take care of for Acid2. :^)
2022-03-27LibWeb: Use Gfx::Font::pixel_size() when we want pixel metricsAndreas Kling
This gives us consistent results with both bitmap and scalable fonts.
2022-03-26LibWeb: Paint the focus outline using Painter::draw_focus_rect()Linus Groh
Now it actually looks like a classic focus outline and not some misplaced border :^)
2022-03-26LibWeb: Paint the focus outline actually *outside* the elementLinus Groh
Instead of using the absolute_rect(), use absolute_border_box_rect() - at least for PaintableBox - and inflate it by 2px on each side. This looks much nicer for text input elements, especially when they have padding, which would be applied outside the focus rect previously.
2022-03-24LibWeb: Treate SVG paintable coordinates as relative to <svg> elementAndreas Kling
Normally, paintable coordinates are relative to the nearest containing block, but in the SVG case, since <svg> doesn't form a containing block, we have to specialize the computation of SVGPaintable::absolute_rect().
2022-03-24LibWeb: Implement text-shadow paintingSam Atkins
We don't yet take the spread-distance parameter into account, since we don't have a way to "inflate" the text shadow. Also, I'm not sure if we need to inflate the shadow slightly anyway. Blurred shadows of our pixel fonts seem very faint. Part of this is that a blur of < 3px does nothing, see #13231, but even so we might want to inflate it a little.
2022-03-24LbWeb: Rename BoxShadowFoo => ShadowFooSam Atkins
The `text-shadow` property is almost identical to `box-shadow`: > Values are interpreted as for box-shadow [CSS-BACKGROUNDS-3]. > (But note that the inset keyword are not allowed.) So, let's use the same data structures and parsing code for both. :^)
2022-03-21LibWeb: Ignore invisible boxes and stacking contexts during hit testingAndreas Kling
2022-03-21LibWeb: Remove now-unused PaintableBox::for_each_child_in_paint_order()Andreas Kling
2022-03-21LibWeb: Don't compute fragment absolute rect twice while hit testingAndreas Kling
2022-03-21LibWeb: Fix O(n^2) traversal in hit testingAndreas Kling
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-21LibWeb: Make hit testing functions return Optional<HitTestResult>Andreas Kling
Using "HitTestResult with null paintable" as a way to signal misses was unnecessarily confusing. Let's use Optional instead. :^)
2022-03-21LibWeb: Build stacking context tree lazilyAndreas Kling
There's no actual need to build the stacking context tree before performing layout. Instead, make it lazy and build the tree when it's actually needed for something. This avoids a bunch of work in situations where multiple synchronous layouts are forced (typically by JavaScript) without painting or hit testing taking place in between. It also opens up for style invalidations that only target the stacking context tree.
2022-03-20LibWeb: Always call Layout::Box::did_set_rect()Andreas Kling
Since paintables have a default content size of 0x0, we were neglecting to notify the corresponding layout node about size changes, if the used content size came out to 0x0. This fixes an issue where resizing an iframe to 0x0 didn't take effect.
2022-03-18LibWeb: Update hit_test for CSS TransformsSimon Wanner
This now also takes a FloatPoint instead of an IntPoint to avoid excessive rounding when multiple transforms apply on top of each other.
2022-03-18LibWeb: Make PaintableBox::enclosing_stacking_context() cheaperAndreas Kling
No need to call the expensive establishes_stacking_context() here, as we've already built the stacking context tree and can simply test for the presence of existing stacking contexts.
2022-03-16LibWeb: Move text fragment painting to PaintableWithLinesAndreas Kling
All the other painting code has moved to paintables already.
2022-03-12LibWeb: Let paintables cache their containing block and absolute rectAndreas Kling
The absolute rect of a paintable is somewhat expensive to compute. This is because all coordinates are relative to the nearest containing block, so we have to traverse the containing block chain and apply each offset to get the final rect. Paintables will never move between containing blocks, nor will their absolute rect change. If anything changes, we'll simpl make a new paintable and replace the old one. Take advantage of this by caching the containing block and absolute rect after first access.
2022-03-11LibWeb: Move hit testing to the painting treeAndreas Kling
2022-03-11LibWeb: Move PaintingBox to its own .cpp and .h filesAndreas Kling