mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-19 15:32:31 +00:00
LibWeb/CSS: Add basic implementation of CSSMarginRule
This is a bit under-specced, specifically there's no definition of CSSMarginDescriptors so I've gone with CSSStyleProperties for now. Gets us 17 WPT subtests.
This commit is contained in:
parent
aa9fa88428
commit
870f24f181
Notes:
github-actions[bot]
2025-05-16 10:02:36 +00:00
Author: https://github.com/AtkinsSJ
Commit: 870f24f181
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/4746
21 changed files with 233 additions and 32 deletions
|
@ -14,6 +14,7 @@
|
|||
|
||||
#include <AK/Debug.h>
|
||||
#include <LibURL/Parser.h>
|
||||
#include <LibWeb/CSS/CSSMarginRule.h>
|
||||
#include <LibWeb/CSS/CSSStyleDeclaration.h>
|
||||
#include <LibWeb/CSS/CSSStyleProperties.h>
|
||||
#include <LibWeb/CSS/CSSStyleSheet.h>
|
||||
|
@ -1438,7 +1439,8 @@ bool Parser::is_valid_in_the_current_context(Declaration const&) const
|
|||
case RuleContext::AtFontFace:
|
||||
case RuleContext::AtPage:
|
||||
case RuleContext::AtProperty:
|
||||
// @font-face, @page, and @property have descriptor declarations
|
||||
case RuleContext::Margin:
|
||||
// These have descriptor declarations
|
||||
return true;
|
||||
|
||||
case RuleContext::AtKeyframes:
|
||||
|
@ -1455,9 +1457,9 @@ bool Parser::is_valid_in_the_current_context(Declaration const&) const
|
|||
|
||||
bool Parser::is_valid_in_the_current_context(AtRule const& at_rule) const
|
||||
{
|
||||
// All at-rules can appear at the top level
|
||||
// All at-rules can appear at the top level, except margin rules
|
||||
if (m_rule_context.is_empty())
|
||||
return true;
|
||||
return !is_margin_rule_name(at_rule.name);
|
||||
|
||||
// Only grouping rules can be nested within style rules
|
||||
if (m_rule_context.contains_slow(RuleContext::Style))
|
||||
|
@ -1482,13 +1484,16 @@ bool Parser::is_valid_in_the_current_context(AtRule const& at_rule) const
|
|||
// @supports cannot check for at-rules
|
||||
return false;
|
||||
|
||||
case RuleContext::AtPage:
|
||||
// @page rules can contain margin rules
|
||||
return is_margin_rule_name(at_rule.name);
|
||||
|
||||
case RuleContext::AtFontFace:
|
||||
case RuleContext::AtKeyframes:
|
||||
case RuleContext::Keyframe:
|
||||
case RuleContext::AtPage:
|
||||
case RuleContext::AtProperty:
|
||||
case RuleContext::Margin:
|
||||
// These can't contain any at-rules
|
||||
// FIXME: Eventually @page can contain margin-box at-rules: https://drafts.csswg.org/css-page-3/#margin-at-rules
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -1530,6 +1535,7 @@ bool Parser::is_valid_in_the_current_context(QualifiedRule const&) const
|
|||
case RuleContext::AtPage:
|
||||
case RuleContext::AtProperty:
|
||||
case RuleContext::Keyframe:
|
||||
case RuleContext::Margin:
|
||||
// These can't contain qualified rules
|
||||
return false;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue