Skip to content
Permalink
Browse files
CSSMotionPathEnabled setting does not prevent parsing of CSS Motion P…
…ath properties

https://bugs.webkit.org/show_bug.cgi?id=240594
<rdar://93522039>

Patch by Antoine Quint <graouts@apple.com> on 2022-05-19
Reviewed by Antti Koivisto.

* Source/WebCore/css/CSSComputedStyleDeclaration.cpp:
(WebCore::ComputedStyleExtractor::valueForPropertyInStyle):
* Source/WebCore/css/CSSProperties.json:
* Source/WebCore/css/parser/CSSParserContext.cpp:
(WebCore::operator==):
(WebCore::add):
(WebCore::CSSParserContext::isPropertyRuntimeDisabled const):
* Source/WebCore/css/parser/CSSParserContext.h:
* Source/WebCore/css/parser/CSSPropertyParser.cpp:
(WebCore::CSSPropertyParser::parseSingleValue):
(WebCore::CSSPropertyParser::parseShorthand):

Canonical link: https://commits.webkit.org/250789@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@294534 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
graouts authored and webkit-commit-queue committed May 20, 2022
1 parent 9b805e8 commit 144605fe6247537d545b2f9fc5408e6f1370b86e
Showing 5 changed files with 36 additions and 3 deletions.
@@ -3464,16 +3464,28 @@ RefPtr<CSSValue> ComputedStyleExtractor::valueForPropertyInStyle(const RenderSty
case CSSPropertyOffsetPath:
// The computed value of offset-path must only contain absolute draw commands.
// https://github.com/w3c/fxtf-drafts/issues/225#issuecomment-334322738
if (!m_element->document().settings().cssMotionPathEnabled())
return nullptr;
return valueForPathOperation(style, style.offsetPath(), SVGPathConversion::ForceAbsolute);
case CSSPropertyOffsetDistance:
if (!m_element->document().settings().cssMotionPathEnabled())
return nullptr;
return cssValuePool.createValue(style.offsetDistance(), style);
case CSSPropertyOffsetPosition:
if (!m_element->document().settings().cssMotionPathEnabled())
return nullptr;
return valueForPositionOrAuto(style, style.offsetPosition());
case CSSPropertyOffsetAnchor:
if (!m_element->document().settings().cssMotionPathEnabled())
return nullptr;
return valueForPositionOrAuto(style, style.offsetAnchor());
case CSSPropertyOffsetRotate:
if (!m_element->document().settings().cssMotionPathEnabled())
return nullptr;
return valueForOffsetRotate(style.offsetRotate());
case CSSPropertyOffset:
if (!m_element->document().settings().cssMotionPathEnabled())
return nullptr;
return valueForOffsetShorthand(style);
case CSSPropertyOpacity:
return cssValuePool.createValue(style.opacity(), CSSUnitType::CSS_NUMBER);
@@ -3726,7 +3726,8 @@
"offset-position",
"offset-anchor",
"offset-rotate"
]
],
"settings-flag": "cssMotionPathEnabled"
},
"specification": {
"category": "css-motion-path",
@@ -113,6 +113,7 @@ CSSParserContext::CSSParserContext(const Document& document, const URL& sheetBas
, inputSecurityEnabled { document.settings().cssInputSecurityEnabled() }
, subgridEnabled { document.settings().subgridEnabled() }
, containIntrinsicSizeEnabled { document.settings().cssContainIntrinsicSizeEnabled() }
, motionPathEnabled { document.settings().cssMotionPathEnabled() }
#if ENABLE(ATTACHMENT_ELEMENT)
, attachmentEnabled { RuntimeEnabledFeatures::sharedFeatures().attachmentElementEnabled() }
#endif
@@ -167,6 +168,7 @@ bool operator==(const CSSParserContext& a, const CSSParserContext& b)
#endif
&& a.subgridEnabled == b.subgridEnabled
&& a.containIntrinsicSizeEnabled == b.containIntrinsicSizeEnabled
&& a.motionPathEnabled == b.motionPathEnabled
;
}

@@ -212,8 +214,8 @@ void add(Hasher& hasher, const CSSParserContext& context)
| context.inputSecurityEnabled << 30
| context.subgridEnabled << 31
| (uint64_t)context.containIntrinsicSizeEnabled << 32
| (uint64_t)context.mode << 33; // This is multiple bits, so keep it last.

| (uint64_t)context.motionPathEnabled << 33
| (uint64_t)context.mode << 34; // This is multiple bits, so keep it last.
add(hasher, context.baseURL, context.charset, bits);
}

@@ -266,6 +268,13 @@ bool CSSParserContext::isPropertyRuntimeDisabled(CSSPropertyID property) const
case CSSPropertyContainIntrinsicBlockSize:
case CSSPropertyContainIntrinsicInlineSize:
return !containIntrinsicSizeEnabled;
case CSSPropertyOffset:
case CSSPropertyOffsetPath:
case CSSPropertyOffsetDistance:
case CSSPropertyOffsetPosition:
case CSSPropertyOffsetAnchor:
case CSSPropertyOffsetRotate:
return !motionPathEnabled;
default:
return false;
}
@@ -90,6 +90,7 @@ struct CSSParserContext {
bool inputSecurityEnabled { false };
bool subgridEnabled { false };
bool containIntrinsicSizeEnabled { false };
bool motionPathEnabled { false };

// RuntimeEnabledFeatures.
#if ENABLE(ATTACHMENT_ELEMENT)
@@ -4594,13 +4594,21 @@ RefPtr<CSSValue> CSSPropertyParser::parseSingleValue(CSSPropertyID property, CSS
return parsedValue;
return consumePercent(m_range, ValueRange::All);
case CSSPropertyOffsetPath:
if (!m_context.motionPathEnabled)
return nullptr;
return consumePathOperation(m_range, m_context, ConsumeRay::Include);
case CSSPropertyOffsetDistance:
if (!m_context.motionPathEnabled)
return nullptr;
return consumeLengthOrPercent(m_range, m_context.mode, ValueRange::All, UnitlessQuirk::Forbid);
case CSSPropertyOffsetPosition:
case CSSPropertyOffsetAnchor:
if (!m_context.motionPathEnabled)
return nullptr;
return consumePositionOrAuto(m_range, m_context.mode, UnitlessQuirk::Forbid, PositionSyntax::Position);
case CSSPropertyOffsetRotate:
if (!m_context.motionPathEnabled)
return nullptr;
return consumeOffsetRotate(m_range, m_context.mode);
case CSSPropertyWebkitBoxFlex:
return consumeNumber(m_range, ValueRange::All);
@@ -6437,6 +6445,8 @@ bool CSSPropertyParser::parseShorthand(CSSPropertyID property, bool important)
case CSSPropertyOutline:
return consumeShorthandGreedily(outlineShorthand(), important);
case CSSPropertyOffset:
if (!m_context.motionPathEnabled)
return false;
return consumeOffset(important);
case CSSPropertyBorderInline: {
RefPtr<CSSValue> width;

0 comments on commit 144605f

Please sign in to comment.