[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc

rniwa at webkit.org rniwa at webkit.org
Wed Dec 22 13:38:11 UTC 2010


The following commit has been merged in the debian/experimental branch:
commit 47df2e0edd186cbe88454de2fbd6973de1f4e626
Author: rniwa at webkit.org <rniwa at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Wed Sep 22 05:36:45 2010 +0000

    2010-09-21  Ryosuke Niwa  <rniwa at webkit.org>
    
            Reviewed by Kent Tamura.
    
            cleanup: removeInlineStyleFromElement and extractInlineStyleToPushDown should be merged
            https://bugs.webkit.org/show_bug.cgi?id=46205
    
            Cleanup required to fix the bug 27818. Added the style extraction mechanism to removeInlineStyleFromElement
            and removeCSSStyle and replaced the call to extractInlineStyleToPushDown by a call to removeInlineStyleFromElement.
    
            * editing/ApplyStyleCommand.cpp:
            (WebCore::ApplyStyleCommand::removeInlineStyleFromElement): Added extractedStyle argument.
            (WebCore::ApplyStyleCommand::removeCSSStyle): Added extractedStyle argument.
            (WebCore::ApplyStyleCommand::pushDownInlineStyleAroundNode): Calls removeInlineStyleFromElement instead of
            extractInlineStyleToPushDown which has been deleted.
            * editing/ApplyStyleCommand.h:
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@68014 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 1f4f913..9446503 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,20 @@
+2010-09-21  Ryosuke Niwa  <rniwa at webkit.org>
+
+        Reviewed by Kent Tamura.
+
+        cleanup: removeInlineStyleFromElement and extractInlineStyleToPushDown should be merged
+        https://bugs.webkit.org/show_bug.cgi?id=46205
+
+        Cleanup required to fix the bug 27818. Added the style extraction mechanism to removeInlineStyleFromElement
+        and removeCSSStyle and replaced the call to extractInlineStyleToPushDown by a call to removeInlineStyleFromElement.
+
+        * editing/ApplyStyleCommand.cpp:
+        (WebCore::ApplyStyleCommand::removeInlineStyleFromElement): Added extractedStyle argument.
+        (WebCore::ApplyStyleCommand::removeCSSStyle): Added extractedStyle argument.
+        (WebCore::ApplyStyleCommand::pushDownInlineStyleAroundNode): Calls removeInlineStyleFromElement instead of
+        extractInlineStyleToPushDown which has been deleted.
+        * editing/ApplyStyleCommand.h:
+
 2010-09-21  Andrew Wilson  <atwilson at chromium.org>
 
         Unreviewed, rolling out r67982.
diff --git a/WebCore/editing/ApplyStyleCommand.cpp b/WebCore/editing/ApplyStyleCommand.cpp
index a1270ac..6b7fd6a 100644
--- a/WebCore/editing/ApplyStyleCommand.cpp
+++ b/WebCore/editing/ApplyStyleCommand.cpp
@@ -1161,19 +1161,22 @@ bool ApplyStyleCommand::removeStyleFromRunBeforeApplyingStyle(CSSMutableStyleDec
     return true;
 }
 
-bool ApplyStyleCommand::removeInlineStyleFromElement(CSSMutableStyleDeclaration* style, HTMLElement* element, InlineStyleRemovalMode mode)
+bool ApplyStyleCommand::removeInlineStyleFromElement(CSSMutableStyleDeclaration* style, HTMLElement* element, InlineStyleRemovalMode mode, CSSMutableStyleDeclaration* extractedStyle)
 {
     ASSERT(style);
     ASSERT(element);
 
     if (m_styledInlineElement && element->hasTagName(m_styledInlineElement->tagQName())) {
-        if (mode != RemoveNone)
+        if (mode != RemoveNone) {
+            if (extractedStyle && element->inlineStyleDecl())
+                extractedStyle->merge(element->inlineStyleDecl());
             removeNodePreservingChildren(element);
+        }
         return true;
     }
 
     bool removed = false;
-    if (removeImplicitlyStyledElement(style, element, mode))
+    if (removeImplicitlyStyledElement(style, element, mode, extractedStyle))
         removed = true;
 
     if (!element->inDocument())
@@ -1181,7 +1184,7 @@ bool ApplyStyleCommand::removeInlineStyleFromElement(CSSMutableStyleDeclaration*
 
     // If the node was converted to a span, the span may still contain relevant
     // styles which must be removed (e.g. <b style='font-weight: bold'>)
-    if (removeCSSStyle(style, element, mode))
+    if (removeCSSStyle(style, element, mode, extractedStyle))
         removed = true;
 
     return removed;
@@ -1313,27 +1316,35 @@ void ApplyStyleCommand::replaceWithSpanOrRemoveIfWithoutAttributes(HTMLElement*&
     }
 }
 
-bool ApplyStyleCommand::removeCSSStyle(CSSMutableStyleDeclaration* style, HTMLElement* elem, InlineStyleRemovalMode mode)
+bool ApplyStyleCommand::removeCSSStyle(CSSMutableStyleDeclaration* style, HTMLElement* element, InlineStyleRemovalMode mode, CSSMutableStyleDeclaration* extractedStyle)
 {
     ASSERT(style);
-    ASSERT(elem);
+    ASSERT(element);
 
-    CSSMutableStyleDeclaration* decl = elem->inlineStyleDecl();
+    CSSMutableStyleDeclaration* decl = element->inlineStyleDecl();
     if (!decl)
         return false;
 
     bool removed = false;
     CSSMutableStyleDeclaration::const_iterator end = style->end();
     for (CSSMutableStyleDeclaration::const_iterator it = style->begin(); it != end; ++it) {
-        CSSPropertyID propertyID = static_cast<CSSPropertyID>((*it).id());
+        CSSPropertyID propertyID = static_cast<CSSPropertyID>(it->id());
         RefPtr<CSSValue> value = decl->getPropertyCSSValue(propertyID);
-        if (value && (propertyID != CSSPropertyWhiteSpace || !isTabSpanNode(elem))) {
+        if (value && (propertyID != CSSPropertyWhiteSpace || !isTabSpanNode(element))) {
             removed = true;
             if (mode == RemoveNone)
                 return true;
-            removeCSSProperty(elem, propertyID);
-            if (propertyID == CSSPropertyUnicodeBidi && !decl->getPropertyValue(CSSPropertyDirection).isEmpty())
-                removeCSSProperty(elem, CSSPropertyDirection);
+
+            ExceptionCode ec = 0;
+            if (extractedStyle)
+                extractedStyle->setProperty(propertyID, value->cssText(), decl->getPropertyPriority(propertyID), ec);
+            removeCSSProperty(element, propertyID);
+
+            if (propertyID == CSSPropertyUnicodeBidi && !decl->getPropertyValue(CSSPropertyDirection).isEmpty()) {
+                if (extractedStyle)
+                    extractedStyle->setProperty(CSSPropertyDirection, decl->getPropertyValue(CSSPropertyDirection), decl->getPropertyPriority(CSSPropertyDirection), ec);
+                removeCSSProperty(element, CSSPropertyDirection);
+            }
         }
     }
 
@@ -1342,10 +1353,10 @@ bool ApplyStyleCommand::removeCSSStyle(CSSMutableStyleDeclaration* style, HTMLEl
 
     // No need to serialize <foo style=""> if we just removed the last css property
     if (decl->isEmpty())
-        removeNodeAttribute(elem, styleAttr);
+        removeNodeAttribute(element, styleAttr);
 
-    if (isSpanWithoutAttributesOrUnstyleStyleSpan(elem))
-        removeNodePreservingChildren(elem);
+    if (isSpanWithoutAttributesOrUnstyleStyleSpan(element))
+        removeNodePreservingChildren(element);
 
     return removed;
 }
@@ -1370,51 +1381,6 @@ HTMLElement* ApplyStyleCommand::highestAncestorWithConflictingInlineStyle(CSSMut
     return result;
 }
 
-PassRefPtr<CSSMutableStyleDeclaration> ApplyStyleCommand::extractInlineStyleToPushDown(CSSMutableStyleDeclaration* styleToApply, Node* node, bool isStyledElement)
-{
-    ASSERT(node);
-    ASSERT(node->isElementNode());
-    
-    // non-html elements not handled yet
-    if (!node->isHTMLElement())
-        return 0;
-
-    HTMLElement* element = static_cast<HTMLElement*>(node);
-    RefPtr<CSSMutableStyleDeclaration> style = element->inlineStyleDecl();
-    if (isStyledElement) {
-        removeNodePreservingChildren(element);
-        return style.release();
-    }
-
-    if (!style) {
-        style = CSSMutableStyleDeclaration::create();
-        removeImplicitlyStyledElement(styleToApply, element, RemoveIfNeeded, style.get());
-        return style.release();
-    }
-
-    Vector<int> properties;
-    CSSMutableStyleDeclaration::const_iterator end = styleToApply->end();
-    for (CSSMutableStyleDeclaration::const_iterator it = styleToApply->begin(); it != end; ++it)
-        properties.append(it->id());
-
-    style = style->copyPropertiesInSet(properties.data(), properties.size());
-    for (size_t i = 0; i < properties.size(); i++) {
-        RefPtr<CSSValue> property = style->getPropertyCSSValue(properties[i]);
-        if (property)
-            removeCSSProperty(element, static_cast<CSSPropertyID>(properties[i]));
-    }
-
-    if (element->inlineStyleDecl() && element->inlineStyleDecl()->isEmpty())
-        removeNodeAttribute(element, styleAttr);
-
-    if (isSpanWithoutAttributesOrUnstyleStyleSpan(element))
-        removeNodePreservingChildren(element);
-
-    removeImplicitlyStyledElement(styleToApply, element, RemoveIfNeeded, style.get());
-
-    return style.release();
-}
-
 void ApplyStyleCommand::applyInlineStyleToPushDown(Node* node, CSSMutableStyleDeclaration* style)
 {
     ASSERT(node);
@@ -1490,7 +1456,8 @@ void ApplyStyleCommand::pushDownInlineStyleAroundNode(CSSMutableStyleDeclaration
         RefPtr<StyledElement> styledElement;
         if (current->isStyledElement() && m_styledInlineElement && current->hasTagName(m_styledInlineElement->tagQName()))
             styledElement = static_cast<StyledElement*>(current);
-        RefPtr<CSSMutableStyleDeclaration> styleToPushDown = extractInlineStyleToPushDown(style, current, styledElement);
+        RefPtr<CSSMutableStyleDeclaration> styleToPushDown = CSSMutableStyleDeclaration::create();
+        removeInlineStyleFromElement(style, static_cast<HTMLElement*>(current), RemoveIfNeeded, styleToPushDown.get());
 
         // The inner loop will go through children on each level
         // FIXME: we should aggregate inline child elements together so that we don't wrap each child separately.
diff --git a/WebCore/editing/ApplyStyleCommand.h b/WebCore/editing/ApplyStyleCommand.h
index 78f592e..603c78c 100644
--- a/WebCore/editing/ApplyStyleCommand.h
+++ b/WebCore/editing/ApplyStyleCommand.h
@@ -72,13 +72,12 @@ private:
 
     // style-removal helpers
     bool removeStyleFromRunBeforeApplyingStyle(CSSMutableStyleDeclaration* style, Node*& runStart, Node*& runEnd);
-    bool removeInlineStyleFromElement(CSSMutableStyleDeclaration*, HTMLElement*, InlineStyleRemovalMode = RemoveIfNeeded);
+    bool removeInlineStyleFromElement(CSSMutableStyleDeclaration*, HTMLElement*, InlineStyleRemovalMode = RemoveIfNeeded, CSSMutableStyleDeclaration* extractedStyle = 0);
     inline bool shouldRemoveInlineStyleFromElement(CSSMutableStyleDeclaration* style, HTMLElement* element) {return removeInlineStyleFromElement(style, element, RemoveNone);}
-    bool removeImplicitlyStyledElement(CSSMutableStyleDeclaration*, HTMLElement*, InlineStyleRemovalMode, CSSMutableStyleDeclaration* extractedStyle = 0);
+    bool removeImplicitlyStyledElement(CSSMutableStyleDeclaration*, HTMLElement*, InlineStyleRemovalMode, CSSMutableStyleDeclaration* extractedStyle);
     void replaceWithSpanOrRemoveIfWithoutAttributes(HTMLElement*&);
-    bool removeCSSStyle(CSSMutableStyleDeclaration*, HTMLElement*, InlineStyleRemovalMode = RemoveIfNeeded);
+    bool removeCSSStyle(CSSMutableStyleDeclaration*, HTMLElement*, InlineStyleRemovalMode = RemoveIfNeeded, CSSMutableStyleDeclaration* extractedStyle = 0);
     HTMLElement* highestAncestorWithConflictingInlineStyle(CSSMutableStyleDeclaration*, Node*);
-    PassRefPtr<CSSMutableStyleDeclaration> extractInlineStyleToPushDown(CSSMutableStyleDeclaration*, Node*, bool isStyledElement);
     void applyInlineStyleToPushDown(Node*, CSSMutableStyleDeclaration *style);
     void pushDownInlineStyleAroundNode(CSSMutableStyleDeclaration*, Node*);
     void removeInlineStyle(PassRefPtr<CSSMutableStyleDeclaration>, const Position& start, const Position& end);

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list