Changeset 87952 in webkit


Ignore:
Timestamp:
Jun 2, 2011 2:35:16 PM (13 years ago)
Author:
rniwa@webkit.org
Message:

2011-06-02 Ryosuke Niwa <rniwa@webkit.org>

Reviewed by Enrica Casucci.

ApplyStyleCommand shouldn't call collapseTextDecorationProperties
https://bugs.webkit.org/show_bug.cgi?id=61887

Removed the call to collapseTextDecorationProperties in ApplyStyleCommand::applyInlineStyle.

No new tests because this is a code refactoring.

  • editing/ApplyStyleCommand.cpp: (WebCore::ApplyStyleCommand::applyInlineStyle): No loner calls collapseTextDecorationProperties. (WebCore::ApplyStyleCommand::pushDownInlineStyleAroundNode): Updated comment.
  • editing/EditingStyle.cpp: (WebCore::HTMLElementEquivalent::propertyExistsInStyle): Added to check both text-decoration and -webkit-text-decorations-in-effect. (WebCore::HTMLTextDecorationEquivalent::HTMLTextDecorationEquivalent): Added a comment. (WebCore::HTMLTextDecorationEquivalent::propertyExistsInStyle): Checks both text-decoration and -webkit-text-decorations-in-effect. (WebCore::HTMLTextDecorationEquivalent::valueIsPresentInStyle): Checks if a text decoration is present in -webkit-text-decorations-in-effect or text-decoration preferring the former. (WebCore::EditingStyle::conflictsWithInlineStyleOfElement): Merged loops for when conflictingProperties is false and true. Added a support for -webkit-text-decorations-in-effect.
Location:
trunk/Source/WebCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r87951 r87952  
     12011-06-02  Ryosuke Niwa  <rniwa@webkit.org>
     2
     3        Reviewed by Enrica Casucci.
     4
     5        ApplyStyleCommand shouldn't call collapseTextDecorationProperties
     6        https://bugs.webkit.org/show_bug.cgi?id=61887
     7
     8        Removed the call to collapseTextDecorationProperties in ApplyStyleCommand::applyInlineStyle.
     9
     10        No new tests because this is a code refactoring.
     11
     12        * editing/ApplyStyleCommand.cpp:
     13        (WebCore::ApplyStyleCommand::applyInlineStyle): No loner calls collapseTextDecorationProperties.
     14        (WebCore::ApplyStyleCommand::pushDownInlineStyleAroundNode): Updated comment.
     15        * editing/EditingStyle.cpp:
     16        (WebCore::HTMLElementEquivalent::propertyExistsInStyle): Added to check both text-decoration
     17        and -webkit-text-decorations-in-effect.
     18        (WebCore::HTMLTextDecorationEquivalent::HTMLTextDecorationEquivalent): Added a comment.
     19        (WebCore::HTMLTextDecorationEquivalent::propertyExistsInStyle): Checks both text-decoration
     20        and -webkit-text-decorations-in-effect.
     21        (WebCore::HTMLTextDecorationEquivalent::valueIsPresentInStyle): Checks if a text decoration
     22        is present in -webkit-text-decorations-in-effect or text-decoration preferring the former.
     23        (WebCore::EditingStyle::conflictsWithInlineStyleOfElement): Merged loops for when conflictingProperties
     24        is false and true. Added a support for -webkit-text-decorations-in-effect.
     25
    1262011-06-02  Ryosuke Niwa  <rniwa@webkit.org>
    227
  • trunk/Source/WebCore/editing/ApplyStyleCommand.cpp

    r86325 r87952  
    532532    Node* endDummySpanAncestor = 0;
    533533
    534     style->collapseTextDecorationProperties();
    535 
    536534    // update document layout once before removing styles
    537535    // so that we avoid the expense of updating before each and every call
     
    10071005            }
    10081006
    1009             // Apply text decoration to all nodes containing targetNode and their siblings but NOT to targetNode
     1007            // Apply style to all nodes containing targetNode and their siblings but NOT to targetNode
    10101008            // But if we've removed styledElement then go ahead and always apply the style.
    10111009            if (child != targetNode || styledElement)
  • trunk/Source/WebCore/editing/EditingStyle.cpp

    r87466 r87952  
    9999    virtual bool matches(Element* element) const { return !m_tagName || element->hasTagName(*m_tagName); }
    100100    virtual bool hasAttribute() const { return false; }
    101     bool propertyExistsInStyle(CSSStyleDeclaration* style) const { return style->getPropertyCSSValue(m_propertyID); }
     101    virtual bool propertyExistsInStyle(CSSStyleDeclaration* style) const { return style->getPropertyCSSValue(m_propertyID); }
    102102    virtual bool valueIsPresentInStyle(Element*, CSSStyleDeclaration*) const;
    103103    virtual void addToStyle(Element*, EditingStyle*) const;
     
    149149        return adoptPtr(new HTMLTextDecorationEquivalent(primitiveValue, tagName));
    150150    }
     151    virtual bool propertyExistsInStyle(CSSStyleDeclaration*) const;
    151152    virtual bool valueIsPresentInStyle(Element*, CSSStyleDeclaration*) const;
    152153
     
    157158HTMLTextDecorationEquivalent::HTMLTextDecorationEquivalent(int primitiveValue, const QualifiedName& tagName)
    158159    : HTMLElementEquivalent(CSSPropertyTextDecoration, primitiveValue, tagName)
    159 {
     160    // m_propertyID is used in HTMLElementEquivalent::addToStyle
     161{
     162}
     163
     164bool HTMLTextDecorationEquivalent::propertyExistsInStyle(CSSStyleDeclaration* style) const
     165{
     166    return style->getPropertyCSSValue(CSSPropertyWebkitTextDecorationsInEffect) || style->getPropertyCSSValue(CSSPropertyTextDecoration);
    160167}
    161168
    162169bool HTMLTextDecorationEquivalent::valueIsPresentInStyle(Element* element, CSSStyleDeclaration* style) const
    163170{
    164     RefPtr<CSSValue> styleValue = style->getPropertyCSSValue(m_propertyID);
     171    RefPtr<CSSValue> styleValue = style->getPropertyCSSValue(CSSPropertyWebkitTextDecorationsInEffect);
     172    if (!styleValue)
     173        styleValue = style->getPropertyCSSValue(CSSPropertyTextDecoration);
    165174    return matches(element) && styleValue && styleValue->isValueList() && static_cast<CSSValueList*>(styleValue.get())->hasValue(m_primitiveValue.get());
    166175}
     
    584593        return false;
    585594
    586     if (!conflictingProperties) {
    587         CSSMutableStyleDeclaration::const_iterator end = m_mutableStyle->end();
    588         for (CSSMutableStyleDeclaration::const_iterator it = m_mutableStyle->begin(); it != end; ++it) {
    589             CSSPropertyID propertyID = static_cast<CSSPropertyID>(it->id());
    590 
    591             // We don't override whitespace property of a tab span because that would collapse the tab into a space.
    592             if (propertyID == CSSPropertyWhiteSpace && isTabSpanNode(element))
    593                 continue;
    594 
    595             if (inlineStyle->getPropertyCSSValue(propertyID))
    596                 return true;
    597         }
    598 
    599         return false;
    600     }
    601 
    602595    CSSMutableStyleDeclaration::const_iterator end = m_mutableStyle->end();
    603596    for (CSSMutableStyleDeclaration::const_iterator it = m_mutableStyle->begin(); it != end; ++it) {
    604597        CSSPropertyID propertyID = static_cast<CSSPropertyID>(it->id());
    605         if ((propertyID == CSSPropertyWhiteSpace && isTabSpanNode(element)) || !inlineStyle->getPropertyCSSValue(propertyID))
     598
     599        // We don't override whitespace property of a tab span because that would collapse the tab into a space.
     600        if (propertyID == CSSPropertyWhiteSpace && isTabSpanNode(element))
    606601            continue;
    607602
     603        if (propertyID == CSSPropertyWebkitTextDecorationsInEffect && inlineStyle->getPropertyCSSValue(CSSPropertyTextDecoration)) {
     604            if (!conflictingProperties)
     605                return true;
     606            conflictingProperties->append(CSSPropertyTextDecoration);
     607            if (extractedStyle)
     608                extractedStyle->setProperty(CSSPropertyTextDecoration, inlineStyle->getPropertyValue(CSSPropertyTextDecoration), inlineStyle->getPropertyPriority(CSSPropertyTextDecoration));
     609            continue;
     610        }
     611
     612        if (!inlineStyle->getPropertyCSSValue(propertyID))
     613            continue;
     614
    608615        if (propertyID == CSSPropertyUnicodeBidi && inlineStyle->getPropertyCSSValue(CSSPropertyDirection)) {
     616            if (!conflictingProperties)
     617                return true;
     618            conflictingProperties->append(CSSPropertyDirection);
    609619            if (extractedStyle)
    610620                extractedStyle->setProperty(propertyID, inlineStyle->getPropertyValue(propertyID), inlineStyle->getPropertyPriority(propertyID));
    611             conflictingProperties->append(CSSPropertyDirection);
    612621        }
    613622
     623        if (!conflictingProperties)
     624            return true;
     625
    614626        conflictingProperties->append(propertyID);
     627
    615628        if (extractedStyle)
    616629            extractedStyle->setProperty(propertyID, inlineStyle->getPropertyValue(propertyID), inlineStyle->getPropertyPriority(propertyID));
    617630    }
    618631
    619     return !conflictingProperties->isEmpty();
     632    return conflictingProperties && !conflictingProperties->isEmpty();
    620633}
    621634
Note: See TracChangeset for help on using the changeset viewer.