Age | Commit message (Collapse) | Author |
|
We were only discarding at most one token when a declaration is
invalid, when we should discard all until we see a ; or EOF.
|
|
Calling is_valid_escape_sequence() with no arguments hides what it
is operating on, so I have removed that, so that you must explicitly
tell it what you are testing.
The call from consume_a_token() was using the wrong tokens, so it
returned false incorrectly. This was resulting in corrupted output
when faced with this code from Acid2. (Abbreviated)
```css
.parser { error: \}; }
.parser { }
```
|
|
|
|
This is a modified copy of the code from Selector.cpp, to work on a
TokenStream instead of a String.
|
|
The input is ComponentValues, and the output is too, so storing as
a String in the middle was inefficient and unnecessary.
|
|
Had to adjust some places that were using Token.to_string() for
non-debug-logging purposes. Changed its name to to_debug_string()
to make the usage clearer.
|
|
There were several crashes here from out-of-bounds memory access.
|
|
|
|
Whitespace marks the end of a compound-selector, no matter where
it occurs. `check_for_eof_or_whitespace()` reconsumes the whitespace
token for convenience.
|
|
|
|
|
|
A lot of this is not spec-compliant and copied from the old parser.
In future PRs, we can revise it.
|
|
It's feeling unwieldy having it everywhere.
|
|
|
|
|
|
Each method can either be called with a TokenStream, or with no
arguments to replicate the previous behaviour.
|
|
The entry points for CSS parsing in the spec are defined as accepting
any of a stream of Tokens, or a stream of ComponentValues, or a String.
TokenStream is an attempt to reduce the duplication of code for that.
|
|
The end goal here is to make the two classes mostly interchangeable, as
the CSS spec requires that the various parser algorithms can take a
stream of either class, and we want to have that functionality without
needing to duplicate all of the code.
|
|
|
|
Rather than passing a ComponentType, and then manually modifying the
data fields, we now create them initialized.
The constructor that takes a Token is intentionally left implicit,
so that we can automatically convert when using the TokenStream later.
|
|
AtStyleRule being a subclass of QualifiedStyleRule was causing
problems when trying to distinguish between them. Combining them
and then distinguishing between them with a Type enum makes that
check simpler, and is in line with how similar checks are done
elsewhere in the parser.
|
|
They're still using the same parsing code, so there's a lot of room
for improvement, but it's good for now.
|
|
The new one is the same as the old one, just in the new Parser's
source files. This isn't the most elegant solution but it seemed
like the best option. And it's all temporary, after all.
|
|
Previous implementation was returning everything in a single Vector,
when what we really want is a Vector of Vectors, one for each comma-
separated part of the list.
|
|
Optional seems like a good idea, but in many places we were not
checking if it had a value, which was causing crashes when the
Tokenizer was given malformed input. Using an EOF value along with
is_eof() makes things a lot simpler.
|
|
This is very much stubbed out for now. Most notably is
Parser::convert_rule() where most of the conversion will happen
from the parser's internal rule classes to CSSRule and its children.
|
|
A single DELIM token is only one character long, so the check for
a "||" DELIM didn't work. We now just do the check inline.
|
|
Whitespace parsing was too greedy, consuming the first non-
whitespace character after it.
|
|
|
|
|
|
|
|
This adds:
- ContainsString [att*=val]
- StartsWithSegment [att|=val]
- StartsWithString [att^=val]
- EndsWithString [att$=val]
Renamed AttributeMatchType::Contains to ::ContainsWord for clarity.
|
|
Noticed while doing this that attribute selectors have two different
ways of saying "starts with", and so AttributeMatchType::StartsWith
needs a better name. But I'll change that when I add the missing
types.
These class names are a mouthful to fit in a commit message. :^)
|
|
Previously these were all passed around by value, but some of them
(StyleComponentValueRule and StyleBlockRule) want to include each
other as fields, so this had to change.
|
|
Also added some pseudo-classes that were handled in the deprecated
parser:
- :disabled
- :enabled
- :checked
- :nth-child
- :nth-last-child
- :not
|
|
Some of these will be removed later, when we move to using is()
exclusively.
|
|
|
|
The parser fixes this by inserting the <tr> tags, but for this test it's
better to have perfect syntax - we're not testing the parser here.
|
|
`Element::tag_name` return an uppercase version of the tag name. However
the `Web::HTML::TagNames` values are all lowercase.
This change fixes that using `Element::local_name`, which returns a
lowercase value.
|
|
|
|
We already do this in most places, so the style should be consistent.
Also, Clang does not like it, as this could cause an unexpected compile
error if some statements are added to the default label or a new label
is added above it.
|
|
While structs being forward declared as classes is not strictly an
issue, Clang complains as this is not portable code, since some ABIs
treat classes declared as `class` and `struct` differently.
It's easier to fix these than to reason about explicitly disabling
another warning.
|
|
Previously, in LibGFX's `Point` class, calculated distances were passed
to the integer `abs` function, even if the stored type was a float. This
caused the value to unexpectedly be truncated. Luckily, this API was not
used with floating point types, but that can change in the future, so
why not fix it now :^)
Since we are in C++, we can use function overloading to make things
easy, and to automatically use the right version.
This is even better than the LibC/LibM functions, as using a bit of
hackery, they are able to be constant-evaluated. They use compiler
intrinsics, so they do not depend on external code and the compiler can
emit the most optimized code by default.
Since we aren't using the C++ standard library's trick of importing
everything into the `AK` namespace, this `abs` function cannot be
exported to the global namespace, as the names would clash.
|
|
|
|
These functions are only used from within `dbgln_if` calls, so in
certain build configurations, they go unused. Similarly to variables, we
now signal to the compiler that we understand that these are not always
in use.
|
|
These were an ad-hoc way to implement special behaviour when reading or
writing to specific object properties. Because these were effectively
replaced by the abillity to override the internal methods of Object,
they are no longer needed.
|
|
This removes all usages of the non-standard put helper method and
replaces all of it's usages with the specification required alternative
or with define_direct_property where appropriate.
|
|
These are usually incorrect, and people sometimes forget to add the
correct values as a result of them being optional, so they should just
be specified explicitly.
|
|
This removes all usages of the non-standard define_property helper
method and replaces all it's usages with the specification required
alternative or with define_direct_property where appropriate.
|
|
As according to: https://heycam.github.io/webidl/#es-nullable-type
Both null and undefined are treated as IDL null, but we were only
treating null as IDL null.
|