Commit Graph

21 Commits

Author SHA1 Message Date
Tobias Christiansen
5471c87246 LibWeb: Add box-shadow rendering
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-24 22:16:48 +02:00
Andreas Kling
ee3a73ddbb AK: Rename downcast<T> => verify_cast<T>
This makes it much clearer what this cast actually does: it will
VERIFY that the thing we're casting is a T (using is<T>()).
2021-06-24 19:57:01 +02:00
Andreas Kling
4190fd2199 LibWeb: Rename Web::Frame to Web::BrowsingContext
Our "frame" concept very closely matches what the web specs call a
"browsing context", so let's rename it to that. :^)

The "main frame" becomes the "top-level browsing context",
and "sub-frames" are now "nested browsing contexts".
2021-05-30 12:39:53 +02:00
Tobias Christiansen
adfdfd6aba LibWeb: Deal with Boxes that have a background, border and -radius
This hack allows for Boxes that have a background to be painted and a
border to accurately paint their border-radii if needed.
For that the box in with the background is drawn is extended to the
bordered_rect. The border is later drawn over this regardless.
Previously when drawing a Box that had all three, background, border
and a border-radius, there could be some white between the filling and
the border.
2021-05-20 22:08:02 +02:00
Tobias Christiansen
7a566e54e5 LibWeb: Introduce struct to hold border radii and normalize once
The struct BorderRadiusData contains the four radii of the box.
In case the specified borders are too large for the dimensions of the
box, they get scaled down.
2021-05-20 22:08:02 +02:00
Tobias Christiansen
c31046d952 LibWeb: Draw rounded corners for the backgrounds of Boxes
Even if the Box doesn't have a border-radius, we'll pass the rendering
of the Box and its corners to the Painter.
2021-05-20 22:08:02 +02:00
Tobias Christiansen
9e04c0598b LibWeb: Basic rendering of border-radius
It supports all four corners.
2021-05-20 22:08:02 +02:00
Tobias Christiansen
d13526e1e7 LibWeb: Handle background-painting of Box in seperate function 2021-05-20 22:08:02 +02:00
Tobias Christiansen
ff0b3518fa LibWeb: Move the painting of the border out of paint()
So other Boxes can override this function.
2021-05-20 22:08:02 +02:00
Timothy Flynn
dba261f79b LibWeb: Propagate body background properties to root HTML element
The Acid1 test has a bit of an unusual background - the html and body
tags have different background colors. Our painting order of the DOM was
such that the body background was painted first, then all other elements
were painted in-phase according to Appendix E of CSS 2.1. So the html
element's background color was painted over the body background.

This removes the special handling of the body background from
InitialContainingBlockBox and now all boxes are painted in-phase. Doing
this also exposed that we weren't handling Section 2.11.2 of the spec;
when the html background is unset, the body's background should be
propagated to the html element.
2021-05-13 16:16:25 +02:00
Egor Ananyin
d2b6148787 LibWeb: Make painting order more spec-compliant
Now our painting order inside stacking contexts is closer to the
algorithm specified by CSS 2.1 (see section 9.9 and Appendix E)
2021-05-07 22:27:48 +02:00
Matthew Olsson
88cfaf7bf0 LibGfx: Unify Rect, Point, and Size
This commit unifies methods and method/param names between the above
classes, as well as adds [[nodiscard]] and ALWAYS_INLINE where
appropriate. It also renamed the various move_by methods to
translate_by, as that more closely matches the transformation
terminology.
2021-05-02 22:48:06 +02:00
Brian Gianforcaro
1682f0b760 Everything: Move to SPDX license identifiers in all files.
SPDX License Identifiers are a more compact / standardized
way of representing file license information.

See: https://spdx.dev/resources/use/#identifiers

This was done with the `ambr` search and replace tool.

 ambr --no-parent-ignore --key-from-file --rep-from-file key.txt rep.txt *
2021-04-22 11:22:27 +02:00
Timothy Flynn
5de0e0068c LibWeb: Support two-value background-repeat
The background-repeat value may be specified as either one- or two-value
identifiers (to be interpreted as horizontal and vertical repeat). This
adds two pseudo-properties, background-repeat-x and background-repeat-y,
to handle this. One-value identifiers are mapped to two-value in
accordance with the spec.
2021-04-05 18:49:04 +02:00
Timothy Flynn
735829f694 LibWeb: Move painting of background images to common location
For now, painting of background color is kept separate. The ICB needs to
perform a "translate" call between painting the color and background,
whereas other divs must not make that call.
2021-04-05 18:49:04 +02:00
Timothy Flynn
fa9ba8bce5 LibWeb: Support rendering background images with 'background-repeat'
Update the painting of background images for both <body> nodes and other
non-initial nodes. Currently, only the following values are supported:
    repeat, repeat-x, repeat-y, no-repeat

This also doesn't support the two-value syntax which allows for setting
horizontal and vertical repetition separately.
2021-04-03 11:24:33 +02:00
Mihai Parparita
c2f3d3afe1 LibWeb: Make CSS background image painting respect destination origin and transparency
It was previously using draw_tiled_bitmap, which always aligns the
tiles with the global origin and does not respect the alpha of the
source. Switch to a new Painter::blit_tiled helper which uses
Painter::blit under the hood, which has more correct behavior.
2021-03-06 14:56:31 +01:00
Andreas Kling
5d180d1f99 Everywhere: Rename ASSERT => VERIFY
(...and ASSERT_NOT_REACHED => VERIFY_NOT_REACHED)

Since all of these checks are done in release builds as well,
let's rename them to VERIFY to prevent confusion, as everyone is
used to assertions being compiled out in release.

We can introduce a new ASSERT macro that is specifically for debug
checks, but I'm doing this wholesale conversion first since we've
accumulated thousands of these already, and it's not immediately
obvious which ones are suitable for ASSERT.
2021-02-23 20:56:54 +01:00
Andreas Kling
543dd54a1d LibWeb: Add bordered_rect() and padded_rect() helpers in Layout::Box 2021-02-22 18:52:58 +01:00
Andreas Kling
794ebb699c LibWeb: Remove low-hanging LibGUI fruit from LibWeb
We'll want to remove the LibGUI dependency from the WebContent process.
This is the first basic step of removing unnecessary LibGUI includes
and swapping out GUI::Painter for Gfx::Painter.
2021-02-10 09:13:29 +01:00
Andreas Kling
13d7c09125 Libraries: Move to Userland/Libraries/ 2021-01-12 12:17:46 +01:00