Changeset 167967 in webkit


Ignore:
Timestamp:
Apr 29, 2014, 4:34:29 PM (11 years ago)
Author:
commit-queue@webkit.org
Message:

Move removeEquivalentProperties functions to EditingStyle
https://bugs.webkit.org/show_bug.cgi?id=131093

Patch by Zsolt Borbely <zsborbely.u-szeged@partner.samsung.com> on 2014-04-29
Reviewed by Darin Adler.

Moved the removeEquivalentProperties functions
from StyleProperties to EditingStyle class.

  • css/StyleProperties.cpp:

(WebCore::MutableStyleProperties::removeEquivalentProperties): Deleted.

  • css/StyleProperties.h:
  • editing/EditingStyle.cpp:

(WebCore::EditingStyle::removeStyleAddedByNode):
(WebCore::EditingStyle::removeStyleConflictingWithStyleOfNode):
(WebCore::EditingStyle::prepareToApplyAt):
(WebCore::EditingStyle::removeEquivalentProperties):
(WebCore::extractPropertiesNotIn):

  • editing/EditingStyle.h:
Location:
trunk/Source/WebCore
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r167965 r167967  
     12014-04-29  Zsolt Borbely  <zsborbely.u-szeged@partner.samsung.com>
     2
     3        Move removeEquivalentProperties functions to EditingStyle
     4        https://bugs.webkit.org/show_bug.cgi?id=131093
     5
     6        Reviewed by Darin Adler.
     7
     8        Moved the removeEquivalentProperties functions
     9        from StyleProperties to EditingStyle class.
     10
     11        * css/StyleProperties.cpp:
     12        (WebCore::MutableStyleProperties::removeEquivalentProperties): Deleted.
     13        * css/StyleProperties.h:
     14        * editing/EditingStyle.cpp:
     15        (WebCore::EditingStyle::removeStyleAddedByNode):
     16        (WebCore::EditingStyle::removeStyleConflictingWithStyleOfNode):
     17        (WebCore::EditingStyle::prepareToApplyAt):
     18        (WebCore::EditingStyle::removeEquivalentProperties):
     19        (WebCore::extractPropertiesNotIn):
     20        * editing/EditingStyle.h:
     21
    1222014-04-29  David Hyatt  <hyatt@apple.com>
    223
  • trunk/Source/WebCore/css/StyleProperties.cpp

    r167877 r167967  
    11741174}
    11751175
    1176 void MutableStyleProperties::removeEquivalentProperties(const StyleProperties* style)
    1177 {
    1178     Vector<CSSPropertyID> propertiesToRemove;
    1179     unsigned size = m_propertyVector.size();
    1180     for (unsigned i = 0; i < size; ++i) {
    1181         PropertyReference property = propertyAt(i);
    1182         if (style->propertyMatches(property.id(), property.value()))
    1183             propertiesToRemove.append(property.id());
    1184     }   
    1185     // FIXME: This should use mass removal.
    1186     for (unsigned i = 0; i < propertiesToRemove.size(); ++i)
    1187         removeProperty(propertiesToRemove[i]);
    1188 }
    1189 
    1190 void MutableStyleProperties::removeEquivalentProperties(const ComputedStyleExtractor* computedStyle)
    1191 {
    1192     Vector<CSSPropertyID> propertiesToRemove;
    1193     unsigned size = m_propertyVector.size();
    1194     for (unsigned i = 0; i < size; ++i) {
    1195         PropertyReference property = propertyAt(i);
    1196         if (computedStyle->propertyMatches(property.id(), property.value()))
    1197             propertiesToRemove.append(property.id());
    1198     }   
    1199     // FIXME: This should use mass removal.
    1200     for (unsigned i = 0; i < propertiesToRemove.size(); ++i)
    1201         removeProperty(propertiesToRemove[i]);
    1202 }
    1203 
    12041176PassRef<MutableStyleProperties> StyleProperties::mutableCopy() const
    12051177{
  • trunk/Source/WebCore/css/StyleProperties.h

    r164995 r167967  
    212212    bool removePropertiesInSet(const CSSPropertyID* set, unsigned length);
    213213
    214     // FIXME: These two can be moved to EditingStyle.cpp
    215     void removeEquivalentProperties(const StyleProperties*);
    216     void removeEquivalentProperties(const ComputedStyleExtractor*);
    217 
    218214    void mergeAndOverrideOnConflict(const StyleProperties&);
    219215
  • trunk/Source/WebCore/editing/EditingStyle.cpp

    r166294 r167967  
    594594    RefPtr<MutableStyleProperties> parentStyle = copyPropertiesFromComputedStyle(node->parentNode(), EditingPropertiesInEffect);
    595595    RefPtr<MutableStyleProperties> nodeStyle = copyPropertiesFromComputedStyle(node, EditingPropertiesInEffect);
    596     nodeStyle->removeEquivalentProperties(parentStyle.get());
    597     m_mutableStyle->removeEquivalentProperties(nodeStyle.get());
     596    removeEquivalentProperties(*parentStyle);
     597    removeEquivalentProperties(*nodeStyle);
    598598}
    599599
     
    604604
    605605    RefPtr<MutableStyleProperties> parentStyle = copyPropertiesFromComputedStyle(node->parentNode(), EditingPropertiesInEffect);
    606     RefPtr<MutableStyleProperties> nodeStyle = copyPropertiesFromComputedStyle(node, EditingPropertiesInEffect);
    607     nodeStyle->removeEquivalentProperties(parentStyle.get());
    608 
    609     unsigned propertyCount = nodeStyle->propertyCount();
     606    RefPtr<EditingStyle> nodeStyle = EditingStyle::create(node, EditingPropertiesInEffect);
     607    nodeStyle->removeEquivalentProperties(*parentStyle);
     608
     609    MutableStyleProperties* style = nodeStyle->style();
     610    unsigned propertyCount = style->propertyCount();
    610611    for (unsigned i = 0; i < propertyCount; ++i)
    611         m_mutableStyle->removeProperty(nodeStyle->propertyAt(i).id());
     612        m_mutableStyle->removeProperty(style->propertyAt(i).id());
    612613}
    613614
     
    917918    }
    918919
    919     m_mutableStyle->removeEquivalentProperties(styleAtPosition);
     920    removeEquivalentProperties(*styleAtPosition);
    920921
    921922    if (textAlignResolvingStartAndEnd(m_mutableStyle.get()) == textAlignResolvingStartAndEnd(styleAtPosition))
     
    11901191
    11911192    removePropertiesInStyle(m_mutableStyle.get(), defaultStyle.get());
     1193}
     1194
     1195template<typename T>
     1196void EditingStyle::removeEquivalentProperties(const T& style)
     1197{
     1198    Vector<CSSPropertyID> propertiesToRemove;
     1199    for (auto& property : m_mutableStyle->m_propertyVector) {
     1200        if (style.propertyMatches(property.id(), property.value()))
     1201            propertiesToRemove.append(property.id());
     1202    }
     1203    // FIXME: This should use mass removal.
     1204    for (auto& property : propertiesToRemove)
     1205        m_mutableStyle->removeProperty(property);
    11921206}
    11931207
     
    15431557{
    15441558    ASSERT(styleWithRedundantProperties);
    1545     RefPtr<MutableStyleProperties> result = styleWithRedundantProperties->mutableCopy();
    1546 
    1547     result->removeEquivalentProperties(baseStyle);
     1559    RefPtr<EditingStyle> result = EditingStyle::create(styleWithRedundantProperties);
     1560    result->removeEquivalentProperties(*baseStyle);
     1561    RefPtr<MutableStyleProperties> mutableStyle = result->style();
    15481562
    15491563    RefPtr<CSSValue> baseTextDecorationsInEffect = extractPropertyValue(baseStyle, CSSPropertyWebkitTextDecorationsInEffect);
    1550     diffTextDecorations(result.get(), CSSPropertyTextDecoration, baseTextDecorationsInEffect.get());
    1551     diffTextDecorations(result.get(), CSSPropertyWebkitTextDecorationsInEffect, baseTextDecorationsInEffect.get());
    1552 
    1553     if (extractPropertyValue(baseStyle, CSSPropertyFontWeight) && fontWeightIsBold(result.get()) == fontWeightIsBold(baseStyle))
    1554         result->removeProperty(CSSPropertyFontWeight);
    1555 
    1556     if (extractPropertyValue(baseStyle, CSSPropertyColor) && textColorFromStyle(result.get()) == textColorFromStyle(baseStyle))
    1557         result->removeProperty(CSSPropertyColor);
     1564    diffTextDecorations(mutableStyle.get(), CSSPropertyTextDecoration, baseTextDecorationsInEffect.get());
     1565    diffTextDecorations(mutableStyle.get(), CSSPropertyWebkitTextDecorationsInEffect, baseTextDecorationsInEffect.get());
     1566
     1567    if (extractPropertyValue(baseStyle, CSSPropertyFontWeight) && fontWeightIsBold(mutableStyle.get()) == fontWeightIsBold(baseStyle))
     1568        mutableStyle->removeProperty(CSSPropertyFontWeight);
     1569
     1570    if (extractPropertyValue(baseStyle, CSSPropertyColor) && textColorFromStyle(mutableStyle.get()) == textColorFromStyle(baseStyle))
     1571        mutableStyle->removeProperty(CSSPropertyColor);
    15581572
    15591573    if (extractPropertyValue(baseStyle, CSSPropertyTextAlign)
    1560         && textAlignResolvingStartAndEnd(result.get()) == textAlignResolvingStartAndEnd(baseStyle))
    1561         result->removeProperty(CSSPropertyTextAlign);
    1562 
    1563     if (extractPropertyValue(baseStyle, CSSPropertyBackgroundColor) && backgroundColorFromStyle(result.get()) == backgroundColorFromStyle(baseStyle))
    1564         result->removeProperty(CSSPropertyBackgroundColor);
    1565 
    1566     return result.release();
     1574        && textAlignResolvingStartAndEnd(mutableStyle.get()) == textAlignResolvingStartAndEnd(baseStyle))
     1575        mutableStyle->removeProperty(CSSPropertyTextAlign);
     1576
     1577    if (extractPropertyValue(baseStyle, CSSPropertyBackgroundColor) && backgroundColorFromStyle(mutableStyle.get()) == backgroundColorFromStyle(baseStyle))
     1578        mutableStyle->removeProperty(CSSPropertyBackgroundColor);
     1579
     1580    return mutableStyle.release();
    15671581}
    15681582
  • trunk/Source/WebCore/editing/EditingStyle.h

    r164521 r167967  
    4949class CSSPrimitiveValue;
    5050class CSSValue;
     51class ComputedStyleExtractor;
    5152class Document;
    5253class Element;
     
    109110    void removeStyleAddedByNode(Node*);
    110111    void removeStyleConflictingWithStyleOfNode(Node*);
     112    template<typename T>
     113    void removeEquivalentProperties(const T&);
    111114    void collapseTextDecorationProperties();
    112115    enum ShouldIgnoreTextOnlyProperties { IgnoreTextOnlyProperties, DoNotIgnoreTextOnlyProperties };
Note: See TracChangeset for help on using the changeset viewer.