Skip to content

Commit

Permalink
[CSS] Use strongly-typed IsImportant instead of bool
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=276974
rdar://132359273

Reviewed by Tim Nguyen.

* Source/WebCore/animation/KeyframeEffect.cpp:
(WebCore::processIterableKeyframes):
(WebCore::processPropertyIndexedKeyframes):
* Source/WebCore/animation/WebAnimation.cpp:
(WebCore::WebAnimation::commitStyles):
* Source/WebCore/css/CSSComputedStyleDeclaration.cpp:
(WebCore::CSSComputedStyleDeclaration::setPropertyInternal):
* Source/WebCore/css/CSSComputedStyleDeclaration.h:
* Source/WebCore/css/CSSProperty.h:
(WebCore::StylePropertyMetadata::StylePropertyMetadata):
(WebCore::CSSProperty::CSSProperty):
* Source/WebCore/css/CSSStyleDeclaration.cpp:
(WebCore::CSSStyleDeclaration::setPropertyValueForCamelCasedIDLAttribute):
(WebCore::CSSStyleDeclaration::setPropertyValueForWebKitCasedIDLAttribute):
(WebCore::CSSStyleDeclaration::setPropertyValueForDashedIDLAttribute):
(WebCore::CSSStyleDeclaration::setPropertyValueForEpubCasedIDLAttribute):
(WebCore::CSSStyleDeclaration::setCssFloat):
* Source/WebCore/css/CSSStyleDeclaration.h:
* Source/WebCore/css/ComputedStyleExtractor.cpp:
(WebCore::ComputedStyleExtractor::copyProperties const):
* Source/WebCore/css/DOMCSSNamespace.cpp:
(WebCore::DOMCSSNamespace::supports):
* Source/WebCore/css/DOMMatrixReadOnly.cpp:
(WebCore::DOMMatrixReadOnly::parseStringIntoAbstractMatrix):
* Source/WebCore/css/MutableStyleProperties.cpp:
(WebCore::MutableStyleProperties::setProperty):
(WebCore::MutableStyleProperties::setCustomProperty):
* Source/WebCore/css/MutableStyleProperties.h:
* Source/WebCore/css/PropertySetCSSStyleDeclaration.cpp:
(WebCore::PropertySetCSSStyleDeclaration::setProperty):
(WebCore::PropertySetCSSStyleDeclaration::setPropertyInternal):
* Source/WebCore/css/PropertySetCSSStyleDeclaration.h:
* Source/WebCore/css/StyleProperties.cpp:
(WebCore::StyleProperties::propertyIsImportant const):
(WebCore::StyleProperties::copyProperties const):
* Source/WebCore/css/StyleProperties.h:
(WebCore::StyleProperties::PropertyReference::toCSSProperty const):
* Source/WebCore/css/parser/CSSParser.cpp:
(WebCore::CSSParser::parseValue):
(WebCore::CSSParser::parseCustomPropertyValue):
* Source/WebCore/css/parser/CSSParser.h:
* Source/WebCore/css/parser/CSSParserImpl.cpp:
(WebCore::CSSParserImpl::parseValue):
(WebCore::CSSParserImpl::parseCustomPropertyValue):
(WebCore::filterProperties):
(WebCore::createStyleProperties):
(WebCore::CSSParserImpl::parseDeclarationList):
(WebCore::CSSParserImpl::consumeTrailingImportantAndWhitespace):
(WebCore::CSSParserImpl::consumeDeclaration):
(WebCore::CSSParserImpl::consumeCustomPropertyValue):
(WebCore::CSSParserImpl::consumeDeclarationValue):
* Source/WebCore/css/parser/CSSParserImpl.h:
* Source/WebCore/css/parser/CSSPropertyParser.cpp:
(WebCore::CSSPropertyParser::addProperty):
* Source/WebCore/css/typedom/CSSStyleValueFactory.cpp:
(WebCore::CSSStyleValueFactory::extractCSSValue):
(WebCore::CSSStyleValueFactory::extractShorthandCSSValues):
* Source/WebCore/css/typedom/DeclaredStylePropertyMap.cpp:
(WebCore::DeclaredStylePropertyMap::setShorthandProperty):
(WebCore::DeclaredStylePropertyMap::setProperty):
(WebCore::DeclaredStylePropertyMap::setCustomProperty):
* Source/WebCore/css/typedom/InlineStylePropertyMap.cpp:
(WebCore::InlineStylePropertyMap::setShorthandProperty):
(WebCore::InlineStylePropertyMap::setProperty):
* Source/WebCore/dom/StyledElement.cpp:
(WebCore::StyledElement::setInlineStyleProperty):
(WebCore::StyledElement::setInlineStyleCustomProperty):
(WebCore::StyledElement::addPropertyToPresentationalHintStyle):
* Source/WebCore/dom/StyledElement.h:
* Source/WebCore/editing/ApplyStyleCommand.cpp:
(WebCore::ApplyStyleCommand::applyRelativeFontStyleChange):
* Source/WebCore/editing/EditingStyle.cpp:
(WebCore::EditingStyle::setProperty):
(WebCore::EditingStyle::extractAndRemoveTextDirection):
(WebCore::EditingStyle::collapseTextDecorationProperties):
(WebCore::EditingStyle::conflictsWithInlineStyleOfElement const):
(WebCore::EditingStyle::mergeStyle):
(WebCore::EditingStyle::forceInline):
(WebCore::EditingStyle::convertPositionStyle):
(WebCore::setTextDecorationProperty):
* Source/WebCore/editing/EditingStyle.h:
* Source/WebCore/editing/Editor.cpp:
(WebCore::Editor::setBaseWritingDirection):
* Source/WebCore/editing/ReplaceSelectionCommand.cpp:
(WebCore::ReplaceSelectionCommand::removeRedundantStylesAndKeepStyleSpanInline):
* Source/WebCore/html/AttachmentAssociatedElement.cpp:
(WebCore::AttachmentAssociatedElement::setAttachmentElement):
* Source/WebCore/html/ColorInputType.cpp:
(WebCore::ColorInputType::updateColorSwatch):
* Source/WebCore/html/TextFieldInputType.cpp:
(WebCore::TextFieldInputType::createShadowSubtree):
(WebCore::TextFieldInputType::createDataListDropdownIndicator):
(WebCore::TextFieldInputType::capsLockStateMayHaveChanged):
(WebCore::TextFieldInputType::updateAutoFillButton):
(WebCore::TextFieldInputType::dataListMayHaveChanged):
* Source/WebCore/html/shadow/MediaControlTextTrackContainerElement.cpp:
(WebCore::MediaControlTextTrackContainerElement::updateTextStrokeStyle):
* Source/WebCore/html/shadow/TextPlaceholderElement.cpp:
* Source/WebCore/html/track/VTTCue.cpp:
(WebCore::VTTCueBox::applyCSSProperties):
* Source/WebCore/page/DragController.cpp:
(WebCore::DragController::concludeEditDrag):
* Source/WebCore/style/PropertyCascade.cpp:
(WebCore::Style::PropertyCascade::addMatch):
(WebCore::Style::PropertyCascade::addNormalMatches):
(WebCore::Style::PropertyCascade::addImportantMatches):
* Source/WebCore/style/PropertyCascade.h:
* Source/WebCore/svg/properties/SVGAttributeAnimator.cpp:
(WebCore::SVGAttributeAnimator::applyAnimatedStylePropertyChange):

Canonical link: https://commits.webkit.org/281329@main
  • Loading branch information
mdubet committed Jul 25, 2024
1 parent 56a7860 commit 9e839b2
Show file tree
Hide file tree
Showing 41 changed files with 158 additions and 155 deletions.
8 changes: 4 additions & 4 deletions Source/WebCore/animation/KeyframeEffect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -380,9 +380,9 @@ static inline ExceptionOr<void> processIterableKeyframes(JSGlobalObject& lexical
auto stringValue = propertyAndValue.values[0];
if (cssPropertyId == CSSPropertyCustom) {
auto customProperty = propertyAndValue.customProperty;
if (keyframeOutput.style->setCustomProperty(customProperty, stringValue, false, parserContext))
if (keyframeOutput.style->setCustomProperty(customProperty, stringValue, parserContext))
keyframeOutput.customStyleStrings.set(customProperty, stringValue);
} else if (keyframeOutput.style->setProperty(cssPropertyId, stringValue, false, parserContext))
} else if (keyframeOutput.style->setProperty(cssPropertyId, stringValue, parserContext))
keyframeOutput.styleStrings.set(cssPropertyId, stringValue);
}

Expand Down Expand Up @@ -422,9 +422,9 @@ static inline ExceptionOr<void> processPropertyIndexedKeyframes(JSGlobalObject&
// 2. Add the property-value pair, property name → v, to k.
if (propertyName == CSSPropertyCustom) {
auto customProperty = m.customProperty;
if (k.style->setCustomProperty(customProperty, v, false, parserContext))
if (k.style->setCustomProperty(customProperty, v, parserContext))
k.customStyleStrings.set(customProperty, v);
} else if (k.style->setProperty(propertyName, v, false, parserContext))
} else if (k.style->setProperty(propertyName, v, parserContext))
k.styleStrings.set(propertyName, v);
// 3. Append k to property keyframes.
propertyKeyframes.append(WTFMove(k));
Expand Down
4 changes: 2 additions & 2 deletions Source/WebCore/animation/WebAnimation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1609,12 +1609,12 @@ ExceptionOr<void> WebAnimation::commitStyles()
return WTF::switchOn(property,
[&] (CSSPropertyID propertyId) {
if (auto cssValue = computedStyleExtractor.valueForPropertyInStyle(*animatedStyle, propertyId, nullptr, ComputedStyleExtractor::PropertyValueType::Computed))
return inlineStyle->setProperty(propertyId, cssValue->cssText(), false, { styledElement->document() });
return inlineStyle->setProperty(propertyId, cssValue->cssText(), { styledElement->document() });
return false;
},
[&] (const AtomString& customProperty) {
if (auto cssValue = computedStyleExtractor.customPropertyValue(customProperty))
return inlineStyle->setCustomProperty(customProperty, cssValue->cssText(), false, { styledElement->document() });
return inlineStyle->setCustomProperty(customProperty, cssValue->cssText(), { styledElement->document() });
return false;
}
);
Expand Down
2 changes: 1 addition & 1 deletion Source/WebCore/css/CSSComputedStyleDeclaration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ String CSSComputedStyleDeclaration::getPropertyValueInternal(CSSPropertyID prope
return getPropertyValue(propertyID);
}

ExceptionOr<void> CSSComputedStyleDeclaration::setPropertyInternal(CSSPropertyID, const String&, bool)
ExceptionOr<void> CSSComputedStyleDeclaration::setPropertyInternal(CSSPropertyID, const String&, IsImportant)
{
return Exception { ExceptionCode::NoModificationAllowedError };
}
Expand Down
2 changes: 1 addition & 1 deletion Source/WebCore/css/CSSComputedStyleDeclaration.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ class CSSComputedStyleDeclaration final : public CSSStyleDeclaration, public Ref
String cssText() const final;
ExceptionOr<void> setCssText(const String&) final;
String getPropertyValueInternal(CSSPropertyID) final;
ExceptionOr<void> setPropertyInternal(CSSPropertyID, const String& value, bool important) final;
ExceptionOr<void> setPropertyInternal(CSSPropertyID, const String& value, IsImportant) final;
Ref<MutableStyleProperties> copyProperties() const final;

RefPtr<CSSValue> getPropertyCSSValue(CSSPropertyID, ComputedStyleExtractor::UpdateLayout = ComputedStyleExtractor::UpdateLayout::Yes) const;
Expand Down
20 changes: 11 additions & 9 deletions Source/WebCore/css/CSSProperty.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,14 @@ namespace WebCore {

class CSSValueList;

enum class IsImportant : bool { No, Yes };

struct StylePropertyMetadata {
StylePropertyMetadata(CSSPropertyID propertyID, bool isSetFromShorthand, int indexInShorthandsVector, bool important, bool implicit, bool inherited)
StylePropertyMetadata(CSSPropertyID propertyID, bool isSetFromShorthand, int indexInShorthandsVector, IsImportant important, bool implicit, bool inherited)
: m_propertyID(propertyID)
, m_isSetFromShorthand(isSetFromShorthand)
, m_indexInShorthandsVector(indexInShorthandsVector)
, m_important(important)
, m_important(important == IsImportant::Yes)
, m_implicit(implicit)
, m_inherited(inherited)
{
Expand All @@ -48,17 +50,17 @@ struct StylePropertyMetadata {

friend bool operator==(const StylePropertyMetadata&, const StylePropertyMetadata&) = default;

uint16_t m_propertyID : 10;
uint16_t m_isSetFromShorthand : 1;
uint16_t m_indexInShorthandsVector : 2; // If this property was set as part of an ambiguous shorthand, gives the index in the shorthands vector.
uint16_t m_important : 1;
uint16_t m_implicit : 1; // Whether or not the property was set implicitly as the result of a shorthand.
uint16_t m_inherited : 1;
unsigned m_propertyID : 10;
unsigned m_isSetFromShorthand : 1;
unsigned m_indexInShorthandsVector : 2; // If this property was set as part of an ambiguous shorthand, gives the index in the shorthands vector.
unsigned m_important : 1;
unsigned m_implicit : 1; // Whether or not the property was set implicitly as the result of a shorthand.
unsigned m_inherited : 1;
};

class CSSProperty {
public:
CSSProperty(CSSPropertyID propertyID, RefPtr<CSSValue>&& value, bool important = false, bool isSetFromShorthand = false, int indexInShorthandsVector = 0, bool implicit = false)
CSSProperty(CSSPropertyID propertyID, RefPtr<CSSValue>&& value, IsImportant important = IsImportant::No, bool isSetFromShorthand = false, int indexInShorthandsVector = 0, bool implicit = false)
: m_metadata(propertyID, isSetFromShorthand, indexInShorthandsVector, important, implicit, isInheritedProperty(propertyID))
, m_value(WTFMove(value))
{
Expand Down
10 changes: 5 additions & 5 deletions Source/WebCore/css/CSSStyleDeclaration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ ExceptionOr<void> CSSStyleDeclaration::setPropertyValueForCamelCasedIDLAttribute
{
auto propertyID = lookupCSSPropertyFromIDLAttribute<CSSPropertyLookupMode::ConvertUsingNoDashPrefix>(attribute);
ASSERT_WITH_MESSAGE(propertyID != CSSPropertyInvalid, "Invalid attribute: %s", attribute.string().utf8().data());
return setPropertyInternal(propertyID, value, false);
return setPropertyInternal(propertyID, value, IsImportant::No);
}

String CSSStyleDeclaration::propertyValueForWebKitCasedIDLAttribute(const AtomString& attribute)
Expand All @@ -275,7 +275,7 @@ ExceptionOr<void> CSSStyleDeclaration::setPropertyValueForWebKitCasedIDLAttribut
{
auto propertyID = lookupCSSPropertyFromIDLAttribute<CSSPropertyLookupMode::ConvertUsingDashPrefix>(attribute);
ASSERT_WITH_MESSAGE(propertyID != CSSPropertyInvalid, "Invalid attribute: %s", attribute.string().utf8().data());
return setPropertyInternal(propertyID, value, false);
return setPropertyInternal(propertyID, value, IsImportant::No);
}

String CSSStyleDeclaration::propertyValueForDashedIDLAttribute(const AtomString& attribute)
Expand All @@ -289,7 +289,7 @@ ExceptionOr<void> CSSStyleDeclaration::setPropertyValueForDashedIDLAttribute(con
{
auto propertyID = lookupCSSPropertyFromIDLAttribute<CSSPropertyLookupMode::NoConversion>(attribute);
ASSERT_WITH_MESSAGE(propertyID != CSSPropertyInvalid, "Invalid attribute: %s", attribute.string().utf8().data());
return setPropertyInternal(propertyID, value, false);
return setPropertyInternal(propertyID, value, IsImportant::No);
}

String CSSStyleDeclaration::propertyValueForEpubCasedIDLAttribute(const AtomString& attribute)
Expand All @@ -303,7 +303,7 @@ ExceptionOr<void> CSSStyleDeclaration::setPropertyValueForEpubCasedIDLAttribute(
{
auto propertyID = lookupCSSPropertyFromIDLAttribute<CSSPropertyLookupMode::ConvertUsingDashPrefix>(attribute);
ASSERT_WITH_MESSAGE(propertyID != CSSPropertyInvalid, "Invalid attribute: %s", attribute.string().utf8().data());
return setPropertyInternal(propertyID, value, false);
return setPropertyInternal(propertyID, value, IsImportant::No);
}

String CSSStyleDeclaration::cssFloat()
Expand All @@ -313,7 +313,7 @@ String CSSStyleDeclaration::cssFloat()

ExceptionOr<void> CSSStyleDeclaration::setCssFloat(const String& value)
{
return setPropertyInternal(CSSPropertyFloat, value, false /* important */);
return setPropertyInternal(CSSPropertyFloat, value, IsImportant::No);
}

}
4 changes: 2 additions & 2 deletions Source/WebCore/css/CSSStyleDeclaration.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@

#pragma once

#include "CSSProperty.h"
#include "CSSPropertyNames.h"
#include "ExceptionOr.h"
#include "ScriptWrappable.h"
#include <wtf/CheckedRef.h>

namespace WebCore {

class CSSProperty;
class CSSRule;
class CSSStyleSheet;
class CSSValue;
Expand Down Expand Up @@ -67,7 +67,7 @@ class CSSStyleDeclaration : public ScriptWrappable, public CanMakeSingleThreadWe
// CSSPropertyID versions of the CSSOM functions to support bindings and editing.
// Use the non-virtual methods in the concrete subclasses when possible.
virtual String getPropertyValueInternal(CSSPropertyID) = 0;
virtual ExceptionOr<void> setPropertyInternal(CSSPropertyID, const String& value, bool important) = 0;
virtual ExceptionOr<void> setPropertyInternal(CSSPropertyID, const String& value, IsImportant) = 0;

virtual Ref<MutableStyleProperties> copyProperties() const = 0;

Expand Down
2 changes: 1 addition & 1 deletion Source/WebCore/css/ComputedStyleExtractor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4893,7 +4893,7 @@ Ref<MutableStyleProperties> ComputedStyleExtractor::copyProperties(std::span<con
{
auto vector = WTF::compactMap(properties, [&](auto& property) -> std::optional<CSSProperty> {
if (auto value = propertyValue(property))
return CSSProperty(property, WTFMove(value), false);
return CSSProperty(property, WTFMove(value));
return std::nullopt;
});
return MutableStyleProperties::create(WTFMove(vector));
Expand Down
5 changes: 2 additions & 3 deletions Source/WebCore/css/DOMCSSNamespace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,7 @@ bool DOMCSSNamespace::supports(Document& document, const String& property, const
CSSPropertyID propertyID = cssPropertyID(propertyNameWithoutWhitespace);
if (propertyID == CSSPropertyInvalid && isCustomPropertyName(propertyNameWithoutWhitespace)) {
auto dummyStyle = MutableStyleProperties::create();
constexpr bool importance = false;
return CSSParser::parseCustomPropertyValue(dummyStyle, AtomString { propertyNameWithoutWhitespace }, value, importance, parserContext) != CSSParser::ParseResult::Error;
return CSSParser::parseCustomPropertyValue(dummyStyle, AtomString { propertyNameWithoutWhitespace }, value, IsImportant::No, parserContext) != CSSParser::ParseResult::Error;
}

if (!isExposed(propertyID, &document.settings()))
Expand All @@ -70,7 +69,7 @@ bool DOMCSSNamespace::supports(Document& document, const String& property, const
return false;

auto dummyStyle = MutableStyleProperties::create();
return CSSParser::parseValue(dummyStyle, propertyID, value, false, parserContext) != CSSParser::ParseResult::Error;
return CSSParser::parseValue(dummyStyle, propertyID, value, IsImportant::No, parserContext) != CSSParser::ParseResult::Error;
}

bool DOMCSSNamespace::supports(Document& document, const String& conditionText)
Expand Down
2 changes: 1 addition & 1 deletion Source/WebCore/css/DOMMatrixReadOnly.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ ExceptionOr<DOMMatrixReadOnly::AbstractMatrix> DOMMatrixReadOnly::parseStringInt
return AbstractMatrix { };

auto styleDeclaration = MutableStyleProperties::create();
if (CSSParser::parseValue(styleDeclaration, CSSPropertyTransform, string, true, HTMLStandardMode) == CSSParser::ParseResult::Error)
if (CSSParser::parseValue(styleDeclaration, CSSPropertyTransform, string, IsImportant::Yes, HTMLStandardMode) == CSSParser::ParseResult::Error)
return Exception { ExceptionCode::SyntaxError };

// Convert to TransformOperations. This can fail if a property requires style (i.e., param uses 'ems' or 'exs')
Expand Down
12 changes: 6 additions & 6 deletions Source/WebCore/css/MutableStyleProperties.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ bool MutableStyleProperties::removeCustomProperty(const String& propertyName, St
return removePropertyAtIndex(findCustomPropertyIndex(propertyName), returnText);
}

bool MutableStyleProperties::setProperty(CSSPropertyID propertyID, const String& value, bool important, CSSParserContext parserContext, bool* didFailParsing)
bool MutableStyleProperties::setProperty(CSSPropertyID propertyID, const String& value, CSSParserContext parserContext, IsImportant important, bool* didFailParsing)
{
if (!isExposed(propertyID, &parserContext.propertySettings) && !isInternal(propertyID)) {
// Allow internal properties as we use them to handle certain DOM-exposed values
Expand All @@ -163,13 +163,13 @@ bool MutableStyleProperties::setProperty(CSSPropertyID propertyID, const String&
return parseResult == CSSParser::ParseResult::Changed;
}

bool MutableStyleProperties::setProperty(CSSPropertyID propertyID, const String& value, bool important, bool* didFailParsing)
bool MutableStyleProperties::setProperty(CSSPropertyID propertyID, const String& value, IsImportant important, bool* didFailParsing)
{
CSSParserContext parserContext(cssParserMode());
return setProperty(propertyID, value, important, parserContext, didFailParsing);
return setProperty(propertyID, value, parserContext, important, didFailParsing);
}

bool MutableStyleProperties::setCustomProperty(const String& propertyName, const String& value, bool important, CSSParserContext parserContext)
bool MutableStyleProperties::setCustomProperty(const String& propertyName, const String& value, CSSParserContext parserContext, IsImportant important)
{
// Setting the value to an empty string just removes the property in both IE and Gecko.
// Setting it to null seems to produce less consistent results, but we treat it just the same.
Expand All @@ -182,7 +182,7 @@ bool MutableStyleProperties::setCustomProperty(const String& propertyName, const
return CSSParser::parseCustomPropertyValue(*this, AtomString { propertyName }, value, important, parserContext) == CSSParser::ParseResult::Changed;
}

void MutableStyleProperties::setProperty(CSSPropertyID propertyID, RefPtr<CSSValue>&& value, bool important)
void MutableStyleProperties::setProperty(CSSPropertyID propertyID, RefPtr<CSSValue>&& value, IsImportant important)
{
if (isLonghand(propertyID)) {
setProperty(CSSProperty(propertyID, WTFMove(value), important));
Expand Down Expand Up @@ -235,7 +235,7 @@ bool MutableStyleProperties::setProperty(const CSSProperty& property, CSSPropert
return true;
}

bool MutableStyleProperties::setProperty(CSSPropertyID propertyID, CSSValueID identifier, bool important)
bool MutableStyleProperties::setProperty(CSSPropertyID propertyID, CSSValueID identifier, IsImportant important)
{
ASSERT(isLonghand(propertyID));
return setProperty(CSSProperty(propertyID, CSSPrimitiveValue::create(identifier), important));
Expand Down
10 changes: 5 additions & 5 deletions Source/WebCore/css/MutableStyleProperties.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,12 @@ class MutableStyleProperties final : public StyleProperties {
bool addParsedProperty(const CSSProperty&);

// These expand shorthand properties into multiple properties.
bool setProperty(CSSPropertyID, const String& value, bool important, CSSParserContext, bool* didFailParsing = nullptr);
bool setProperty(CSSPropertyID, const String& value, bool important = false, bool* didFailParsing = nullptr);
void setProperty(CSSPropertyID, RefPtr<CSSValue>&&, bool important = false);
bool setProperty(CSSPropertyID, const String& value, CSSParserContext, IsImportant = IsImportant::No, bool* didFailParsing = nullptr);
bool setProperty(CSSPropertyID, const String& value, IsImportant = IsImportant::No, bool* didFailParsing = nullptr);
void setProperty(CSSPropertyID, RefPtr<CSSValue>&&, IsImportant = IsImportant::No);

// These do not. FIXME: This is too messy, we can do better.
bool setProperty(CSSPropertyID, CSSValueID identifier, bool important = false);
bool setProperty(CSSPropertyID, CSSValueID identifier, IsImportant = IsImportant::No);
bool setProperty(const CSSProperty&, CSSProperty* slot = nullptr);

bool removeProperty(CSSPropertyID, String* returnText = nullptr);
Expand All @@ -86,7 +86,7 @@ class MutableStyleProperties final : public StyleProperties {
int findCustomPropertyIndex(StringView propertyName) const;

// Methods for querying and altering CSS custom properties.
bool setCustomProperty(const String& propertyName, const String& value, bool important, CSSParserContext);
bool setCustomProperty(const String& propertyName, const String& value, CSSParserContext, IsImportant = IsImportant::No);
bool removeCustomProperty(const String& propertyName, String* returnText = nullptr);

private:
Expand Down
8 changes: 4 additions & 4 deletions Source/WebCore/css/PropertySetCSSStyleDeclaration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -167,9 +167,9 @@ ExceptionOr<void> PropertySetCSSStyleDeclaration::setProperty(const String& prop

bool changed;
if (UNLIKELY(propertyID == CSSPropertyCustom))
changed = m_propertySet->setCustomProperty(propertyName, value, important, cssParserContext());
changed = m_propertySet->setCustomProperty(propertyName, value, cssParserContext(), important ? IsImportant::Yes : IsImportant::No);
else
changed = m_propertySet->setProperty(propertyID, value, important, cssParserContext());
changed = m_propertySet->setProperty(propertyID, value, cssParserContext(), important ? IsImportant::Yes : IsImportant::No);

didMutate(changed ? MutationType::PropertyChanged : MutationType::NoChanges);

Expand Down Expand Up @@ -217,7 +217,7 @@ String PropertySetCSSStyleDeclaration::getPropertyValueInternal(CSSPropertyID pr
return { };
}

ExceptionOr<void> PropertySetCSSStyleDeclaration::setPropertyInternal(CSSPropertyID propertyID, const String& value, bool important)
ExceptionOr<void> PropertySetCSSStyleDeclaration::setPropertyInternal(CSSPropertyID propertyID, const String& value, IsImportant important)
{
StyleAttributeMutationScope mutationScope { parentElement() };
if (!willMutate())
Expand All @@ -226,7 +226,7 @@ ExceptionOr<void> PropertySetCSSStyleDeclaration::setPropertyInternal(CSSPropert
if (!isExposed(propertyID))
return { };

if (m_propertySet->setProperty(propertyID, value, important, cssParserContext())) {
if (m_propertySet->setProperty(propertyID, value, cssParserContext(), important)) {
didMutate(MutationType::PropertyChanged);
mutationScope.enqueueMutationRecord();
} else
Expand Down
2 changes: 1 addition & 1 deletion Source/WebCore/css/PropertySetCSSStyleDeclaration.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ class PropertySetCSSStyleDeclaration : public CSSStyleDeclaration {
String cssText() const final;
ExceptionOr<void> setCssText(const String&) final;
String getPropertyValueInternal(CSSPropertyID) final;
ExceptionOr<void> setPropertyInternal(CSSPropertyID, const String& value, bool important) final;
ExceptionOr<void> setPropertyInternal(CSSPropertyID, const String& value, IsImportant) final;

Ref<MutableStyleProperties> copyProperties() const final;
bool isExposed(CSSPropertyID) const;
Expand Down
2 changes: 1 addition & 1 deletion Source/WebCore/css/StyleProperties.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ Ref<MutableStyleProperties> StyleProperties::copyProperties(std::span<const CSSP
{
auto vector = WTF::compactMap(properties, [&](auto& property) -> std::optional<CSSProperty> {
if (auto value = getPropertyCSSValue(property))
return CSSProperty(property, WTFMove(value), false);
return CSSProperty(property, WTFMove(value));
return std::nullopt;
});
return MutableStyleProperties::create(WTFMove(vector));
Expand Down
2 changes: 1 addition & 1 deletion Source/WebCore/css/StyleProperties.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class StyleProperties : public RefCounted<StyleProperties> {
CSSValue* value() { return const_cast<CSSValue*>(m_value); }

// FIXME: Remove this.
CSSProperty toCSSProperty() const { return CSSProperty(id(), const_cast<CSSValue*>(m_value), isImportant(), m_metadata.m_isSetFromShorthand, m_metadata.m_indexInShorthandsVector, isImplicit()); }
CSSProperty toCSSProperty() const { return CSSProperty(id(), const_cast<CSSValue*>(m_value), isImportant() ? IsImportant::Yes : IsImportant::No, m_metadata.m_isSetFromShorthand, m_metadata.m_indexInShorthandsVector, isImplicit()); }

private:
const StylePropertyMetadata& m_metadata;
Expand Down
Loading

0 comments on commit 9e839b2

Please sign in to comment.