summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibWeb/Painting/BackgroundPainting.cpp
AgeCommit message (Collapse)Author
2023-05-24LibWeb: Make CSSPixels and Length use 64-bit (double) floating pointAndreas Kling
This fixes a plethora of rounding problems on many websites. In the future, we may want to replace this with fixed-point arithmetic (bug #18566) for performance (and consistency with other engines), but in the meantime this makes the web look a bit better. :^) There's a lot more things that could be converted to doubles, which would reduce the amount of casting necessary in this patch. We can do that incrementally, however.
2023-05-23LibGfx+Everywhere: Change `Gfx::Rect` to be endpoint exclusiveJelle Raaijmakers
Previously, calling `.right()` on a `Gfx::Rect` would return the last column's coordinate still inside the rectangle, or `left + width - 1`. This is called 'endpoint inclusive' and does not make a lot of sense for `Gfx::Rect<float>` where a rectangle of width 5 at position (0, 0) would return 4 as its right side. This same problem exists for `.bottom()`. This changes `Gfx::Rect` to be endpoint exclusive, which gives us the nice property that `width = right - left` and `height = bottom - top`. It enables us to treat `Gfx::Rect<int>` and `Gfx::Rect<float>` exactly the same. All users of `Gfx::Rect` have been updated accordingly.
2023-05-06LibWeb: Use the new to_px() helpers in CSS, SVG and layout codeAndreas Kling
There should be no behavior change from this, only slightly less verbosity. :^)
2023-02-28LibWeb: Rename Layout::InitialContainingBlock to Layout::ViewportAndreas Kling
The name "initial containing block" was wrong for this, as it doesn't correspond to the HTML element, and that's specifically what it's supposed to do! :^)
2023-01-05LibWeb: Convert AbstractImageStyleValue to new pixel unitsSam Atkins
2023-01-05LibWeb+WebContent: Convert BrowsingContext to new pixel unitsSam Atkins
This fixes a few glitches. We no longer give the page double the width it should have, and we mark the correct area of the page as needing repainting.
2022-12-31LibWeb: Paint repeating background images over entire paint boxTimothy Flynn
We were previously missing the bottom- and right-most pixels. This fixes the errant red line showing on the Acid2 forehead.
2022-12-14LibWeb: Convert border painting to new pixel unitsSam Atkins
2022-12-14LibWeb: Convert background painting to new pixel unitsSam Atkins
2022-12-14LibWeb: Split PaintContext::viewport_rect() into device/css variantsSam Atkins
For now, everyone uses `device_viewport_rect()`, until I convert them.
2022-08-23LibWeb: Remove done TODO and fix typoMacDue
2022-08-23LibWeb: Avoid infinite loops in background paintingMacDue
Previously if `background-size` was 0px in any dimension we would go into in infinite loop whilst painting.
2022-08-10LibWeb: Follow `image-rendering` when painting image style valuesMacDue
2022-08-08LibWeb: Avoid painting background-images under opaque bordersMacDue
Without this the background-image can be painted up to 8 extra times, that contribute nothing to the final image.
2022-08-08LibWeb: Convert images to common AbstractImageStyleValue baseMacDue
This commit moves both the ImageStyleValue and LinearGradientStyleValue to a common base class of AbstractImageStyleValue. This abstracts getting the natural_width/height, loading/resolving, and painting the image. Now for 'free' you get: - Linear gradients working with the various background sizing/repeat properties. - Linear gradients working as list-markers :^) -- best feature ever! P.s. This commit is a little large as it's tricky to make this change incrementally without breaking things.
2022-07-26LibWeb: Simplify more code with CSS::LengthPercentage::is_auto()Andreas Kling
2022-07-18LibWeb: Replace LibGfx gradient painting with new GradientPaintingMacDue
2022-07-18LibWeb: Calculate to <corner> angles for linear-gradientsMacDue
This also renames LinearGradientStyleValue::angle() to LinearGradientStyleValue::angle_degrees() to make the unit more obvious.
2022-07-17LibWeb: Support painting simple linear-gradientsMacDue
This is just a quick test that everything is working. Currently it paints the gradients with the existing painter.fill_rect_with_gradient(). This can only handle two-color orthogonal gradients.
2022-07-17LibWeb: Allow having a linear-gradient() as a background-imageMacDue
2022-07-04LibWeb: Use ScopedCornerRadiusClip for background paintingMacDue
2022-07-04LibWeb: Shrink border radii for background-clip and support with imagesMacDue
Since background layers can have different clipping this has also required doing the corner clipping for each layer, rather than just once.
2022-06-17LibWeb: Fix 'background-repeat: round' calculationMacDue
Previously, this was slightly off and not doing what the spec comment above asked for. This led to really small values for x_step and y_step, making the `backgrounds.html' example use crazy amounts of CPU whist painting.
2022-06-17LibWeb: Only paint the background image on integer stepsMacDue
This avoids excessive over painting.
2022-06-16LibWeb: Support using border-radius with a background-imageMacDue
2022-06-14LibWeb: Bring border painting much closer to the spec/other browsersMacDue
This commit adds some much nicer border painting, which now supports: - Elliptical corners - Blending between different border thicknesses, with rounded corners - Anti-aliasing There are some little TODOs left to tackle: - Painting the corners with line styles other than solid - Blending between colors on the corners (see comments) The painting requires allocating a small bitmap, that only fits the corners (so in most cases this is very small). This bitmap is then cached so for all paints but the first there will be no further allocations.
2022-06-13LibWeb: Support elliptical background cornersMacDue
2022-06-13LibWeb: Keep both horizontal and vertical border radii till paintingMacDue
2022-06-11LibWeb: Paint background border radius antialiasedMacDue
2022-03-29LibWeb: Don't round numbers too early when painting backgroundsAndreas Kling
Preserve floating point precision and delay rounding until the last moment when figuring out where to paint background layers. This fixes an issue on Acid3 where a thin sliver of red was visible because the background X position was incorrectly rounded by 1px.
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-25LibWeb: Attach BackgroundAttachment::Fixed to the window view portTimothy Flynn
This fixes the placement of several background images on Acid2, most notably the background of the eyes and the red rectangle near the bottom of the head.
2022-02-18LibWeb: Remove redundant Length::resolved() callsSam Atkins
Now that calc() is also resolved in to_px(), code in the form `foo.resolved(bar).to_px(bar)` can be simplified to `foo.to_px(bar)`.
2022-02-18LibWeb: Remove fallback value from Length::resolved()Sam Atkins
Nobody makes undefined Lengths now, (although actually removing Undefined will come in a later commit) so we can remove this parameter, and `resolved_or_auto()`/`resolved_or_zero()`.
2022-02-04LibWeb: Allow LengthPercentage to hold a calculated valueSam Atkins
Most of the time, we cannot resolve a `calc()` expression until we go to use it. Since any `<length-percentage>` can legally be a `calc ()`, let's store it in `LengthPercentage` rather than make every single user care about this distinction.
2022-01-20LibWeb: Remove reference_for_percent parameter from Length::resolved()Sam Atkins
Despite looking like it was still needed, it was only used for passing to other calls to Length::resolved() recursively. This makes the various `foo.resolved().resolved()` calls a lot less awkward. (Though, still quite awkward.) I think we'd need to separate calculated lengths out to properly tidy these calls up, but one yak at a time. :^)
2022-01-20LibWeb: Convert background-position to LengthPercentageSam Atkins
Not much needed changing this time, hurrah! :^)
2022-01-20LibWeb: Convert background-size from Length to LengthPercentageSam Atkins
Checking these for `auto` is awkward, but separating that will come later. :^)
2021-11-17LibWeb: Implement `background-repeat: round` :^)Sam Atkins
2021-11-17LibWeb: Implement `background-repeat: space`Sam Atkins
2021-11-17LibWeb: Implement background-size :^)Sam Atkins
This is including the `cover` and `contain` modes.
2021-11-17LibWeb: Implement background-position and background-origin :^)Sam Atkins
2021-11-17LibWeb: Manually tile background imagesSam Atkins
This reimplements image tiling instead of using `Painter::blit_tiled()`, so that we will be able to handle CSS's more complicated repetition rules. (Like `background-repeat: space`) Otherwise this does the same as before. :^)
2021-11-17LibWeb: Implement background-clip :^)Sam Atkins
We now pass in the Layout Node so that we can read the BoxModelMetrics. Renamed a couple of variables too for clarity.
2021-11-17LibWeb: Paint backgrounds with multiple layers :^)Sam Atkins
2021-11-17LibWeb: Stop 'no-repeat' from expanding the background areaSam Atkins
Previously, a `background-repeat` value of `no-repeat` in a direction would cause the image to be drawn at exactly that size. This was fine if the image was smaller than the element, but if it was larger, it would draw outside its bounds. Now, it behaves itself. :^)
2021-09-19LibWeb: Move background painting from Box to its own fileSam Atkins
This makes the code accessible to things that aren't a Box, such as InlineNode.