Commit graph

21 commits

Author SHA1 Message Date
Andreas Kling
1f008c95b6 LibWeb: Move CSS classes into the Web::CSS namespace 2020-07-26 20:05:15 +02:00
Andreas Kling
11ff9d0f17 LibWeb: Move DOM classes into the Web::DOM namespace
LibWeb keeps growing and the Web namespace is filling up fast.
Let's put DOM stuff into Web::DOM, just like we already started doing
with SVG stuff in Web::SVG.
2020-07-26 20:05:15 +02:00
Andreas Kling
9e642827fc LibWeb: Don't tolerate unit-less lengths (except 0) in standards mode
"width: 500" is not a valid CSS property in standards mode and should
be ignored.

To plumb the quirks-mode flag into CSS parsing, this patch adds a new
CSS::ParsingContext object that must be passed to the CSS parser.
Currently it only allows you to check the quirks-mode flag. In the
future it will be a good place to put additional information needed
for things like relative URL resolution, etc.

This narrows <div class=parser> on ACID2 to the correct width. :^)
2020-06-28 12:46:40 +02:00
Andreas Kling
505b133fda LibWeb: Don't allow more than one color sub-value in CSS 'background' 2020-06-25 16:55:43 +02:00
Andreas Kling
49dd4b7e8a LibWeb: Compress specificity into a 32-bit unsigned int
Instead of storing the three-part specificy for every selector,
just mash them together into a 32-bit value instead.
This saves both space and time, and matches the behavior of other
browser engines.
2020-06-25 16:43:49 +02:00
Andreas Kling
246e0e47ec LibWeb: Make the specificity sort comparator a bit more readable 2020-06-14 22:09:35 +02:00
Andreas Kling
0e65fc3a6d LibWeb: Expand background:none into background-color:transparent 2020-06-13 20:03:41 +02:00
Andreas Kling
384b5f15c9 LibWeb: Sort matched style rules by specificity, document order
If two rules have equal specificity, they should be applied in the
order in which we encountered them.
2020-06-13 00:44:26 +02:00
Andreas Kling
365703e3f3 LibWeb: Allow url("foo") and url('foo') in CSS background-image values
This is very hackish and will be fixed by writing a proper CSS parser.
2020-06-13 00:11:38 +02:00
Andreas Kling
01bb6f0249 LibWeb: Don't try to expand shorthands from non-string CSS values
If something is already e.g a length or a color value, we don't need
to try to expand it by stringifying and looking at the parts.
2020-06-10 19:34:49 +02:00
Andreas Kling
9c786cd7e0 LibWeb: Expand "background: url()" into "background-image: url()"
This gives us a yellow forehead on ACID2! :^)
2020-06-10 17:47:04 +02:00
Andreas Kling
2622ead6c6 LibWeb: Expand 2-part border-width shorthand CSS properties 2020-06-10 16:42:58 +02:00
Andreas Kling
7fe2f5f170 LibWeb: Apply style rules in order of specificity (kinda)
We now sort the matched rules by the specificity of the first selector
in them. This is not perfect, since a rule can have multiple selectors,
but it is a nice chin-related progression on ACID2. :^)
2020-06-10 16:42:36 +02:00
Andreas Kling
4e1939c635 LibWeb: Expand border-{top,right,bottom-left} CSS shorthand properties
This code is pretty rough, but it's something that will also improve
with the eventual new CSS parser.
2020-06-10 16:14:31 +02:00
Andreas Kling
731685468a LibWeb: Start fleshing out support for relative CSS units
This patch introduces support for more than just "absolute px" units in
our Length class. It now also supports "em" and "rem", which are units
relative to the font-size of the current layout node and the <html>
element's layout node respectively.
2020-06-07 17:55:46 +02:00
Andreas Kling
959de19418 LibWeb: Process style sheets in document order
Until now we would simply apply stylesheets in the order they finished
loading. This patch adds a StyleSheetList object that hangs off of each
Document and contains all the style sheets in document order.

There's still a lot of work to do for a proper cascade, but at least
this makes us consistently wrong every time. :^)
2020-06-04 16:06:32 +02:00
Andreas Kling
7f22e2a3c4 LibWeb: Use the globals from HTML::AttributeNames in style resolution
Using these avoids the FlyString lookups, so we should basically always
prefer them over string literal attribute names.
2020-05-30 13:06:26 +02:00
Andreas Kling
0d5be35c1f LibWeb: Don't render list item markers for "list-style-type: none" 2020-05-30 12:04:15 +02:00
Andreas Kling
3c6801c3a5 LibWeb: Naive support for CSS "background" shorthand
Many sites simply use "background" as an alias for "background-color"
so let's at least support that.
2020-05-30 11:58:05 +02:00
myphs
0891f860f7 LibWeb: Add CSS property 'border'
This makes it possible to write shorter CSS. Instead of writing
.foo {
        border-width: 3px;
        border-style: solid;
        border-color: blue;
}
it is now possible to write
.foo {
        border: 3px solid blue;
}
while the order of values is irrelevant.
Currently only the basic values are supported. More values should be
added in the future.

Three more value specific parse functions were added:
parse_line_width, parse_color, and parse_line_style

Additionally a few test cases were added to borders.html.
2020-03-20 21:40:55 +01:00
Andreas Kling
830a57c6b2 LibWeb: Rename directory LibHTML => LibWeb
Let's rename this to LibWeb since it aims to provide more parts of the
web platform than just HTML. :^)
2020-03-07 10:32:51 +01:00
Renamed from Libraries/LibHTML/CSS/StyleResolver.cpp (Browse further)