Skip to content

Commit

Permalink
Adopt more smart pointers in EditingStyle.cpp
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=269194

Reviewed by Darin Adler.

* Source/WebCore/css/CSSProperty.h:
(WebCore::CSSProperty::protectedValue const):
* Source/WebCore/css/StyleRule.cpp:
(WebCore::StyleRule::protectedProperties const):
* Source/WebCore/css/StyleRule.h:
* Source/WebCore/dom/StyledElement.cpp:
(WebCore::StyledElement::protectedInlineStyle const):
* Source/WebCore/dom/StyledElement.h:
* Source/WebCore/editing/EditingStyle.cpp:
(WebCore::EditingStyle::EditingStyle):
(WebCore::EditingStyle::removeStyleAddedByNode):
(WebCore::EditingStyle::removeStyleConflictingWithStyleOfNode):
(WebCore::EditingStyle::triStateOfStyle const):
(WebCore::EditingStyle::styleIsPresentInComputedStyleOfNode const):
(WebCore::EditingStyle::prepareToApplyAt):
(WebCore::EditingStyle::protectedStyle):
(WebCore::EditingStyle::mergeTypingStyle):
(WebCore::EditingStyle::mergeInlineStyleOfElement):
(WebCore::elementMatchesAndPropertyIsNotInInlineStyleDecl):
(WebCore::EditingStyle::mergeInlineAndImplicitStyleOfElement):
(WebCore::styleFromMatchedRulesForElement):
(WebCore::EditingStyle::mergeStyleFromRules):
(WebCore::loneFontFamilyName):
(WebCore::EditingStyle::mergeStyleFromRulesForSerialization):
(WebCore::EditingStyle::removeStyleFromRulesAndContext):
(WebCore::EditingStyle::removePropertiesInElementDefaultStyle):
(WebCore::EditingStyle::removeEquivalentProperties):
(WebCore::EditingStyle::styleAtSelectionStart):
(WebCore::EditingStyle::inverseTransformColorIfNeeded):
(WebCore::StyleChange::StyleChange):
* Source/WebCore/editing/EditingStyle.h:

Canonical link: https://commits.webkit.org/274465@main
  • Loading branch information
cdumez committed Feb 12, 2024
1 parent 41a2e3c commit 0b368a6
Show file tree
Hide file tree
Showing 7 changed files with 98 additions and 71 deletions.
1 change: 1 addition & 0 deletions Source/WebCore/css/CSSProperty.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ class CSSProperty {
bool isImportant() const { return m_metadata.m_important; }

CSSValue* value() const { return m_value.get(); }
RefPtr<CSSValue> protectedValue() const { return m_value; }

static CSSPropertyID resolveDirectionAwareProperty(CSSPropertyID, TextDirection, WritingMode);
static CSSPropertyID unresolvePhysicalProperty(CSSPropertyID, TextDirection, WritingMode);
Expand Down
5 changes: 5 additions & 0 deletions Source/WebCore/css/StyleRule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,11 @@ Ref<StyleRule> StyleRule::copy() const
return adoptRef(*new StyleRule(*this));
}

Ref<const StyleProperties> StyleRule::protectedProperties() const
{
return m_properties;
}

void StyleRule::setProperties(Ref<StyleProperties>&& properties)
{
m_properties = WTFMove(properties);
Expand Down
1 change: 1 addition & 0 deletions Source/WebCore/css/StyleRule.h
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ class StyleRule : public StyleRuleBase {

const CSSSelectorList& selectorList() const { return m_selectorList; }
const StyleProperties& properties() const { return m_properties.get(); }
Ref<const StyleProperties> protectedProperties() const;
MutableStyleProperties& mutableProperties();

bool isSplitRule() const { return m_isSplitRule; }
Expand Down
5 changes: 5 additions & 0 deletions Source/WebCore/dom/StyledElement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,11 @@ void StyledElement::invalidateStyleAttribute()
}
}

RefPtr<StyleProperties> StyledElement::protectedInlineStyle() const
{
return elementData() ? elementData()->m_inlineStyle : nullptr;
}

void StyledElement::inlineStyleChanged()
{
invalidateStyleAttribute();
Expand Down
1 change: 1 addition & 0 deletions Source/WebCore/dom/StyledElement.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ class StyledElement : public Element {
void invalidateStyleAttribute();

const StyleProperties* inlineStyle() const { return elementData() ? elementData()->m_inlineStyle.get() : nullptr; }
RefPtr<StyleProperties> protectedInlineStyle() const;

bool setInlineStyleProperty(CSSPropertyID, CSSValueID identifier, bool important = false);
bool setInlineStyleProperty(CSSPropertyID, CSSPropertyID identifier, bool important = false);
Expand Down
155 changes: 84 additions & 71 deletions Source/WebCore/editing/EditingStyle.cpp

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions Source/WebCore/editing/EditingStyle.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ class EditingStyle : public RefCounted<EditingStyle> {
WEBCORE_EXPORT ~EditingStyle();

MutableStyleProperties* style() { return m_mutableStyle.get(); }
RefPtr<MutableStyleProperties> protectedStyle();
Ref<MutableStyleProperties> styleWithResolvedTextDecorations() const;
std::optional<WritingDirection> textDirection() const;
bool isEmpty() const;
Expand Down

0 comments on commit 0b368a6

Please sign in to comment.