Commit Graph

30 Commits

Author SHA1 Message Date
Sam Atkins
ffc81cbfad LibWeb: Use Selectors instead of a String for :not() selectors
Rather than parsing the selector every time we want to check it, we
now parse it once at the beginning.

A bonus effect of this is that we now support a selector list in
:not(), instead of just a single selector, though only when using
the new parser.
2021-07-14 13:31:00 +02:00
Sam Atkins
8cae79cc8d LibWeb: Add 'PseudoElement' as a CSS SimpleSelector::Type
Same reasoning again! This is the last one.

While I was at it, I added the two remaining CSS2.2 pseudo-elements,
::first-line and ::first-letter. All 4 are handled in the new CSS
parser, including with the compatibility single-colon syntax. I have
not added support to the old parser.
2021-07-14 13:31:00 +02:00
Sam Atkins
4af7d41879 LibWeb: Add 'PseudoClass' as a CSS SimpleSelector::Type
Same reasoning as the previous commit.
2021-07-14 13:31:00 +02:00
Sam Atkins
96b2356cbb LibWeb: Add 'Attribute' as a CSS SimpleSelector::Type
Previously, SimpleSelectors optionally had Attribute-selector data
as well as their main type. Now, they're either one or the other,
which better matches the spec, and makes parsing and matching more
straightforward.
2021-07-14 13:31:00 +02:00
Sam Atkins
dadcb46344 LibWeb: Convert CSS Dump, Selector, & SelectorEngine to east const 2021-07-14 13:31:00 +02:00
Sam Atkins
7fefe34797 LibWeb: Add remaining CSS AttributeMatchTypes
This adds:
- ContainsString     [att*=val]
- StartsWithSegment  [att|=val]
- StartsWithString   [att^=val]
- EndsWithString     [att$=val]

Renamed AttributeMatchType::Contains to ::ContainsWord for clarity.
2021-07-11 23:19:56 +02:00
Paul Irwin
5eb65286b6 LibWeb: Support :active pseudo-class for hyperlinks, :focus possibly
Adds support for the :active pseudo-class for hyperlinks (<a> tags
only).

Also, since it was very similar to :focus and an element having a
focused state was already implemented, I went ahead and implemented
that pseudo-class too, although I cannot come up with a working
example to validate it.
2021-06-25 01:02:29 +02:00
Andreas Kling
e59bf87374 Userland: Replace VERIFY(is<T>) with verify_cast<T>
Instead of doing a VERIFY(is<T>(x)) and *then* casting it to T, we can
just do the cast right away with verify_cast<T>. :^)
2021-06-24 21:13:09 +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
Tobias Christiansen
7f81c8fba2 LibWeb: LayoutNodes know whether they are flex-items
This is useful for debugging when dumping the layout tree.
2021-06-06 01:46:06 +04:30
Tobias Christiansen
1ab82afee6 LibWeb: Add :not pseudoclass to the CSS parser
The selector given in the :not() is stored in the SimpleSelector as a
String.
2021-05-24 22:10:08 +01:00
Tobias Christiansen
b53dac6e88 LibWeb: Add support for more pseudoclasses
:disabled, :enabled and :checked are now parsed and matched. There
surely are more nuances to consider.
2021-05-24 02:14:11 +04:30
miere43
c4bd4cbd76 LibWeb: Implement :nth-last-child pseudo-class 2021-05-11 21:17:16 +01:00
miere43
aa83539d7b LibWeb: Implement :nth-child pseudo-class 2021-05-09 11:24:04 +02:00
Andreas Kling
c7e9b6d00f LibWeb: Convert StringBuilder::appendf() => AK::Format 2021-05-07 21:12:09 +02:00
stelar7
55446172cb LibWeb: Add selector support to the new CSSParser
This is stolen from the old parser, but it seems to parse fine :^)
2021-04-30 08:52:36 +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
Nicholas-Baron
73dd293ec4 Everywhere: Add -Wdouble-promotion warning
This warning informs of float-to-double conversions. The best solution
seems to be to do math *either* in 32-bit *or* in 64-bit, and only to
cross over when absolutely necessary.
2021-04-16 19:01:54 +02:00
Andreas Kling
1d065aa51b LibWeb: Support the :last-of-type CSS selector :^) 2021-04-06 13:06:42 +02:00
Andreas Kling
0eb9a9dd13 LibWeb: Support the :first-of-type CSS selector :^) 2021-04-06 13:06:42 +02:00
Andreas Kling
fefb05f6f3 LibWeb: Split CSS::StyleSheet into StyleSheet and CSSStyleSheet
This is a little convoluted but matches the CSSOM specification.
2021-03-07 17:45:15 +01:00
Andreas Kling
0af4762662 LibWeb: Rename StyleRule => CSSStyleRule
This matches the CSSOM specification.
2021-03-07 17:45:15 +01:00
Sviatoslav Peleshko
54617e1a91 LibWeb: Added simple parsing for (at)import rules
For now, the parsing is very crude, and parses only the document url.
The meta queries for the import are ignored.
2021-02-28 10:27:32 +01:00
Sviatoslav Peleshko
04d67d0239 LibWeb: Create base class CSSRule for all CSS rules
This is a foundation for handling other ("at") CSS rules.
2021-02-28 10:27:32 +01:00
AnotherTest
c989e55195 LibWeb: Fix a tiny appendff() format issue
This would've just left the colour on for a few characters, nothing _too_ bad.
2021-02-23 13:59:33 +01:00
Andreas Kling
2d64ba7b9d LibWeb: Convert dbgprintf() => dbgln() 2021-02-17 15:59:13 +01:00
Andreas Kling
e4e325ff61 LibWeb: Include shadow DOM subtrees in DOM dumps 2021-02-10 19:06:20 +01:00
Andreas Kling
bbce1ab1c1 LibWeb: Use the DOM::Node::node_name() a bit more in dumps 2021-02-10 17:15:16 +01:00
Andreas Kling
140463e833 LibWeb: Parse "display: flex" and create BlockBox layout nodes for them
I'm not 100% sure that BlockBox is the right layout node for flex
containers, but it's the most obviously fitting one we already have.
2021-01-18 20:20:00 +01:00
Andreas Kling
13d7c09125 Libraries: Move to Userland/Libraries/ 2021-01-12 12:17:46 +01:00