Commit graph

13 commits

Author SHA1 Message Date
Sam Atkins
a99d02e14d LibWeb: Add an enum for !important 2022-02-12 16:13:27 +00:00
Sam Atkins
e8d4236bbd LibWeb: Use W3C urls for CSSOM spec links
https://www.w3.org/TR/cssom/ is the more permanent home of the CSSOM
specification's latest version, and is up to date with the draft spec.

Also, https://drafts.csswg.org/ has been down multiple times recently
which made looking things up a pain.
2021-10-15 21:05:35 +01:00
Brian Gianforcaro
027cbe6b89 LibWeb: Optimize CSS::StyleDeclaration for size
We can reduce the amount of padding the compiler adds in order to
ensure data alignment of member variables by ordering the types in
a struct by size in decending order.

Found By PVS-Studio: https://pvs-studio.com/en/docs/warnings/v802/
2021-10-10 13:48:04 +02:00
Andreas Kling
3db847c64a LibWeb: Implement CSSRule and CSSStyleDeclaration serialization
There are a handful of FIXME's here, but this seems generally good.
Note that CSS *values* don't get serialized in a spec-compliant way
since we currently rely on StyleValue::to_string() which is ad-hoc.
2021-10-01 20:17:15 +02:00
Andreas Kling
0ab31d8c84 LibWeb: Support simplest form of CSSStyleDeclaration.setProperty()
This patch adds the setProperty(name, value) API to CSSStyleDeclaration.
Setting an invalid or empty value will cause the property to be removed
from the declaration.

Note that this only works on mutable declarations (i.e element.style)
and not on resolved declarations (i.e window.getComputedStyle(element)).
2021-09-26 19:07:03 +02:00
Andreas Kling
a2f5589d3a LibWeb: Implement CSSStyleDeclaration.getPropertyValue(property) 2021-09-12 20:44:50 +02:00
Andreas Kling
0bcab60463 LibWeb: Make CSSStyleDeclaration an abstract class
This patch moves the CSS property+value storage down to a new subclass
of CSSStyleDeclaration called PropertyOwningCSSStyleDeclaration.

The JavaScript wrapper for CSSStyleDeclaration now calls virtual
functions on the C++ object.

This is preparation for supporting computed style CSSStyleDeclaration
objects which won't have internal property storage, but rather an
internal element pointer. :^)
2021-09-12 20:44:50 +02:00
DoubleNegation
0fdfdbed9f LibWeb: Ensure inline CSS loaded from HTML is ElementInline
This commit changes inline CSS loaded from style attributes of HTML
elements to be loaded as CSS::ElementInlineCSSStyleDeclaration instead
of CSS::CSSStyleDeclaration, fixing a crash when the style of that
element is changed from JavaScript.
2021-08-15 15:11:59 +02:00
Tobias Christiansen
0d7169b91a LibWeb: Store custom properties in CSSStyleDeclaration
Keep them around when parsing and store them in the CSSStyleDeclaration
when done.
2021-05-28 10:45:38 +01: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
Andreas Kling
cad4cc9a2a LibWeb: Invalidate element style after setting Element.style.foo
This makes us recompute style for the element so the change actually
takes effect. :^)
2021-03-16 19:00:42 +01:00
Andreas Kling
33e3f0c71f LibWeb: Expose barebones CSSStyleDeclaration to JavaScript
You can now access an element's inline style via Element.style.
The interface is not very capable yet though. :^)
2021-03-13 22:41:32 +01:00
Andreas Kling
0759f54bd3 LibWeb: Rename StyleDeclaration => CSSStyleDeclaration to match CSSOM 2021-03-13 22:41:32 +01:00
Renamed from Userland/Libraries/LibWeb/CSS/StyleDeclaration.cpp (Browse further)