[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:39:24 UTC 2010


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

    2010-09-22  Ryosuke Niwa  <rniwa at webkit.org>
    
            Reviewed by Darin Adler.
    
            queryCommandState returns false for Underline command when no selection is made
            https://bugs.webkit.org/show_bug.cgi?id=17594
    
            The bug was caused by selectionComputedStyle's adding -webkit-text-decorations-in-effect property
            to a dummy span used to obtain the computed style when there is a typing style.
            Since this property is for internal use only, the CSS parser always stripped the property.
            As a result, we were always ignoring the text decorations set by the typing style.
    
            Fixed the bug by making selectionComputedStyle directly merge the computed style of the current
            caret position and the typing style. This also eliminates the need for a dummy span element.
            Due to the merge, the return value of selectionComputedStyle had to be changed to CSSMutableStyleDeclaration
            from CSSComputedStyleDeclaration.
    
            Test: editing/execCommand/query-text-decoration-with-typing-style.html
    
            * editing/ApplyStyleCommand.cpp:
            (WebCore::StyleChange::init): Calls getPropertiesNotIn.
            (WebCore::getPropertiesNotIn): Renamed from getPropertiesNotInComputedStyle since it takes
            CSSStyleDeclaration* instead of CSSComputedStyleDeclaration* for the second argument.
            (WebCore::ApplyStyleCommand::removeNonEditingProperties): Extracted from editingStyleAtPosition.
            (WebCore::ApplyStyleCommand::editingStyleAtPosition): Calls removeNonEditingProperties.
            * editing/ApplyStyleCommand.h:
            * editing/Editor.cpp:
            (WebCore::triStateOfStyle): Calls getPropertiesNotIn. Renamed from triStateOfStyleInComputedStyle
            since it no longer takes CSSComputedStyleDeclaration.
            (WebCore::Editor::selectionStartHasStyle): Calls selectionComputedStyle and triStateOfStyle.
            (WebCore::Editor::selectionHasStyle): Ditto.
            (WebCore::Editor::selectionStartCSSPropertyValue): Calls selectionComputedStyle.
            (WebCore::Editor::selectionComputedStyle): See above.
            * editing/Editor.h:
            * editing/EditorCommand.cpp:
            (WebCore::executeToggleStyleInList): Calls selectionComputedStyle.
    2010-09-22  Ryosuke Niwa  <rniwa at webkit.org>
    
            Reviewed by Darin Adler.
    
            queryCommandState returns false for Underline command when no selection is made
            https://bugs.webkit.org/show_bug.cgi?id=17594
    
            Added a test to ensure queryCommandValue('underline') and queryCommandValue('strikeThrough')
            correctly incorporates the typing style.
    
            * editing/execCommand/query-text-decoration-with-typing-style-expected.txt: Added.
            * editing/execCommand/query-text-decoration-with-typing-style.html: Added.
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@68059 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index 82dd919..66141d5 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,3 +1,16 @@
+2010-09-22  Ryosuke Niwa  <rniwa at webkit.org>
+
+        Reviewed by Darin Adler.
+
+        queryCommandState returns false for Underline command when no selection is made
+        https://bugs.webkit.org/show_bug.cgi?id=17594
+
+        Added a test to ensure queryCommandValue('underline') and queryCommandValue('strikeThrough')
+        correctly incorporates the typing style.
+
+        * editing/execCommand/query-text-decoration-with-typing-style-expected.txt: Added.
+        * editing/execCommand/query-text-decoration-with-typing-style.html: Added.
+
 2010-09-22  Adam Barth  <abarth at webkit.org>
 
         Reviewed by Alexey Proskuryakov.
diff --git a/LayoutTests/editing/execCommand/query-text-decoration-with-typing-style-expected.txt b/LayoutTests/editing/execCommand/query-text-decoration-with-typing-style-expected.txt
new file mode 100644
index 0000000..cad77c6
--- /dev/null
+++ b/LayoutTests/editing/execCommand/query-text-decoration-with-typing-style-expected.txt
@@ -0,0 +1,146 @@
+
+Has strike before adding underline in:
+| 
+
+Has strike after adding underline in:
+| 
+
+Has strike in:
+| <u>
+|   "xx<#selection-caret>"
+
+Has strike in:
+| <u>
+|   "x<#selection-caret>x"
+
+Has strike after removing underline in:
+| <u>
+|   "x<#selection-caret>x"
+
+Has strike in:
+| <u>
+|   "x"
+| "x<#selection-caret>"
+| <u>
+|   "x"
+
+Has strike before removing underline in:
+| <u>
+|   "x"
+| "x"
+| <u>
+|   "x<#selection-caret>"
+
+Has strike after removing underline in:
+| <u>
+|   "x"
+| "x"
+| <u>
+|   "x<#selection-caret>"
+
+Has strike in:
+| <u>
+|   "x"
+| "x"
+| <u>
+|   "x"
+| "x<#selection-caret>"
+
+Has strike before adding strikeThrough in:
+| <u>
+|   "x"
+| "x"
+| <u>
+|   "x"
+| "x<#selection-caret>"
+
+Has strike after adding strikeThrough in:
+| <u>
+|   "x"
+| "x"
+| <u>
+|   "x"
+| "x<#selection-caret>"
+
+Has strike in:
+| <u>
+|   "x"
+| "x"
+| <u>
+|   "x"
+| "x"
+| <s>
+|   "xx<#selection-caret>"
+
+Has strike in:
+| <u>
+|   "x"
+| "x"
+| <u>
+|   "x"
+| "x"
+| <s>
+|   "x<#selection-caret>x"
+
+Has strike after removing strikeThrough in:
+| <u>
+|   "x"
+| "x"
+| <u>
+|   "x"
+| "x"
+| <s>
+|   "x<#selection-caret>x"
+
+Has strike in:
+| <u>
+|   "x"
+| "x"
+| <u>
+|   "x"
+| "x"
+| <s>
+|   "x"
+| "x<#selection-caret>"
+| <s>
+|   "x"
+
+Has strike before removing strikeThrough in:
+| <u>
+|   "x"
+| "x"
+| <u>
+|   "x"
+| "x"
+| <s>
+|   "x"
+| "x"
+| <s>
+|   "x<#selection-caret>"
+
+Has strike after removing strikeThrough in:
+| <u>
+|   "x"
+| "x"
+| <u>
+|   "x"
+| "x"
+| <s>
+|   "x"
+| "x"
+| <s>
+|   "x<#selection-caret>"
+
+Has strike in:
+| <u>
+|   "x"
+| "x"
+| <u>
+|   "x"
+| "x"
+| <s>
+|   "x"
+| "x"
+| <s>
+|   "x"
+| "x<#selection-caret>"
diff --git a/LayoutTests/editing/execCommand/query-text-decoration-with-typing-style.html b/LayoutTests/editing/execCommand/query-text-decoration-with-typing-style.html
new file mode 100644
index 0000000..f20ee0f
--- /dev/null
+++ b/LayoutTests/editing/execCommand/query-text-decoration-with-typing-style.html
@@ -0,0 +1,52 @@
+<html>
+<body>
+<script src="../../resources/dump-as-markup.js"></script>
+<div id="test" contenteditable></div>
+
+<script type="text/javascript">
+
+var test = document.getElementById('test');
+
+function printState(command, description) {
+    var underlineState = document.queryCommandState('underline');
+    var strikeThroughState = document.queryCommandState('strikeThrough');
+    var state = 'no text decorations';
+    if (underlineState && strikeThroughState)
+        state = 'underline and strike';
+    else if (underlineState)
+        state = 'underline';
+    else (strikeThroughState)
+        state = 'strike';
+    Markup.dump(test, 'Has ' + state + (description ? " " + description : "") + " in");
+}
+
+function runTextDecorationTest(command) {
+    printState(command, 'before adding ' + command);
+    document.execCommand(command, false, null);
+    printState(command, 'after adding ' + command);
+    document.execCommand("InsertText", false, 'x');
+    document.execCommand("InsertText", false, 'x');
+    printState(command);
+    window.getSelection().modify('move', 'backward', 'character');
+    printState(command);
+
+    document.execCommand(command, false, null);
+    printState(command, 'after removing ' + command);
+    document.execCommand("InsertText", false, 'x');
+    printState(command);
+
+    window.getSelection().modify('move', 'forward', 'line');
+    printState(command, 'before removing ' + command);
+    document.execCommand(command, false, null);
+    printState(command, 'after removing ' + command);
+    document.execCommand("InsertText", false, 'x');
+    printState(command);
+}
+
+window.getSelection().setPosition(test, 0);
+runTextDecorationTest('underline');
+runTextDecorationTest('strikeThrough');
+
+</script>
+</body>
+</html>
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 7715266..f9badac 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,40 @@
+2010-09-22  Ryosuke Niwa  <rniwa at webkit.org>
+
+        Reviewed by Darin Adler.
+
+        queryCommandState returns false for Underline command when no selection is made
+        https://bugs.webkit.org/show_bug.cgi?id=17594
+
+        The bug was caused by selectionComputedStyle's adding -webkit-text-decorations-in-effect property
+        to a dummy span used to obtain the computed style when there is a typing style.
+        Since this property is for internal use only, the CSS parser always stripped the property.
+        As a result, we were always ignoring the text decorations set by the typing style.
+
+        Fixed the bug by making selectionComputedStyle directly merge the computed style of the current
+        caret position and the typing style. This also eliminates the need for a dummy span element.
+        Due to the merge, the return value of selectionComputedStyle had to be changed to CSSMutableStyleDeclaration
+        from CSSComputedStyleDeclaration.
+
+        Test: editing/execCommand/query-text-decoration-with-typing-style.html
+
+        * editing/ApplyStyleCommand.cpp:
+        (WebCore::StyleChange::init): Calls getPropertiesNotIn.
+        (WebCore::getPropertiesNotIn): Renamed from getPropertiesNotInComputedStyle since it takes
+        CSSStyleDeclaration* instead of CSSComputedStyleDeclaration* for the second argument.
+        (WebCore::ApplyStyleCommand::removeNonEditingProperties): Extracted from editingStyleAtPosition.
+        (WebCore::ApplyStyleCommand::editingStyleAtPosition): Calls removeNonEditingProperties.
+        * editing/ApplyStyleCommand.h:
+        * editing/Editor.cpp:
+        (WebCore::triStateOfStyle): Calls getPropertiesNotIn. Renamed from triStateOfStyleInComputedStyle
+        since it no longer takes CSSComputedStyleDeclaration.
+        (WebCore::Editor::selectionStartHasStyle): Calls selectionComputedStyle and triStateOfStyle.
+        (WebCore::Editor::selectionHasStyle): Ditto.
+        (WebCore::Editor::selectionStartCSSPropertyValue): Calls selectionComputedStyle.
+        (WebCore::Editor::selectionComputedStyle): See above.
+        * editing/Editor.h:
+        * editing/EditorCommand.cpp:
+        (WebCore::executeToggleStyleInList): Calls selectionComputedStyle.
+
 2010-09-22  Jamey Hicks  <jamey.hicks at nokia.com>
 
         Reviewed by Kenneth Rohde Christiansen.
diff --git a/WebCore/editing/ApplyStyleCommand.cpp b/WebCore/editing/ApplyStyleCommand.cpp
index 6b7fd6a..f840fdb 100644
--- a/WebCore/editing/ApplyStyleCommand.cpp
+++ b/WebCore/editing/ApplyStyleCommand.cpp
@@ -145,7 +145,7 @@ void StyleChange::init(PassRefPtr<CSSStyleDeclaration> style, const Position& po
         return;
 
     RefPtr<CSSComputedStyleDeclaration> computedStyle = position.computedStyle();
-    RefPtr<CSSMutableStyleDeclaration> mutableStyle = getPropertiesNotInComputedStyle(style.get(), computedStyle.get());
+    RefPtr<CSSMutableStyleDeclaration> mutableStyle = getPropertiesNotIn(style.get(), computedStyle.get());
 
     reconcileTextDecorationProperties(mutableStyle.get());
     if (!document->frame()->editor()->shouldStyleWithCSS())
@@ -156,7 +156,7 @@ void StyleChange::init(PassRefPtr<CSSStyleDeclaration> style, const Position& po
         mutableStyle->removeProperty(CSSPropertyWhiteSpace);
 
     // If unicode-bidi is present in mutableStyle and direction is not, then add direction to mutableStyle.
-    // FIXME: Shouldn't this be done in getPropertiesNotInComputedStyle?
+    // FIXME: Shouldn't this be done in getPropertiesNotIn?
     if (mutableStyle->getPropertyCSSValue(CSSPropertyUnicodeBidi) && !style->getPropertyCSSValue(CSSPropertyDirection))
         mutableStyle->setProperty(CSSPropertyDirection, style->getPropertyValue(CSSPropertyDirection));
 
@@ -388,21 +388,21 @@ static bool fontWeightIsBold(CSSStyleDeclaration* style)
     return false; // Make compiler happy
 }
 
-RefPtr<CSSMutableStyleDeclaration> getPropertiesNotInComputedStyle(CSSStyleDeclaration* style, CSSComputedStyleDeclaration* computedStyle)
+RefPtr<CSSMutableStyleDeclaration> getPropertiesNotIn(CSSStyleDeclaration* styleWithRedundantProperties, CSSStyleDeclaration* baseStyle)
 {
-    ASSERT(style);
+    ASSERT(styleWithRedundantProperties);
     ASSERT(computedStyle);
-    RefPtr<CSSMutableStyleDeclaration> result = style->copy();
-    computedStyle->diff(result.get());
+    RefPtr<CSSMutableStyleDeclaration> result = styleWithRedundantProperties->copy();
+    baseStyle->diff(result.get());
 
-    RefPtr<CSSValue> computedTextDecorationsInEffect = computedStyle->getPropertyCSSValue(CSSPropertyWebkitTextDecorationsInEffect);
-    diffTextDecorations(result.get(), CSSPropertyTextDecoration, computedTextDecorationsInEffect.get());
-    diffTextDecorations(result.get(), CSSPropertyWebkitTextDecorationsInEffect, computedTextDecorationsInEffect.get());
+    RefPtr<CSSValue> baseTextDecorationsInEffect = baseStyle->getPropertyCSSValue(CSSPropertyWebkitTextDecorationsInEffect);
+    diffTextDecorations(result.get(), CSSPropertyTextDecoration, baseTextDecorationsInEffect.get());
+    diffTextDecorations(result.get(), CSSPropertyWebkitTextDecorationsInEffect, baseTextDecorationsInEffect.get());
 
-    if (fontWeightIsBold(result.get()) == fontWeightIsBold(computedStyle))
+    if (fontWeightIsBold(result.get()) == fontWeightIsBold(baseStyle))
         result->removeProperty(CSSPropertyFontWeight);
 
-    if (getRGBAFontColor(result.get()) == getRGBAFontColor(computedStyle))
+    if (getRGBAFontColor(result.get()) == getRGBAFontColor(baseStyle))
         result->removeProperty(CSSPropertyColor);
 
     return result;
@@ -439,6 +439,11 @@ static const int editingStyleProperties[] = {
 };
 size_t numEditingStyleProperties = sizeof(editingStyleProperties)/sizeof(editingStyleProperties[0]);
 
+RefPtr<CSSMutableStyleDeclaration> ApplyStyleCommand::removeNonEditingProperties(CSSStyleDeclaration* style)
+{
+    return style->copyPropertiesInSet(editingStyleProperties, numEditingStyleProperties);
+}
+
 PassRefPtr<CSSMutableStyleDeclaration> ApplyStyleCommand::editingStyleAtPosition(Position pos, ShouldIncludeTypingStyle shouldIncludeTypingStyle)
 {
     RefPtr<CSSComputedStyleDeclaration> computedStyleAtPosition = pos.computedStyle();
@@ -446,7 +451,7 @@ PassRefPtr<CSSMutableStyleDeclaration> ApplyStyleCommand::editingStyleAtPosition
     if (!computedStyleAtPosition)
         style = CSSMutableStyleDeclaration::create();
     else
-        style = computedStyleAtPosition->copyPropertiesInSet(editingStyleProperties, numEditingStyleProperties);
+        style = removeNonEditingProperties(computedStyleAtPosition.get());
 
     if (style && pos.node() && pos.node()->computedStyle()) {
         RenderStyle* renderStyle = pos.node()->computedStyle();
diff --git a/WebCore/editing/ApplyStyleCommand.h b/WebCore/editing/ApplyStyleCommand.h
index 603c78c..eb6a2bc 100644
--- a/WebCore/editing/ApplyStyleCommand.h
+++ b/WebCore/editing/ApplyStyleCommand.h
@@ -57,7 +57,8 @@ public:
     {
         return adoptRef(new ApplyStyleCommand(element, removeOnly, action));
     }
-    
+
+    static RefPtr<CSSMutableStyleDeclaration> removeNonEditingProperties(CSSStyleDeclaration* style);
     static PassRefPtr<CSSMutableStyleDeclaration> editingStyleAtPosition(Position pos, ShouldIncludeTypingStyle shouldIncludeTypingStyle = IgnoreTypingStyle);
 
 private:
@@ -125,7 +126,7 @@ private:
 
 bool isStyleSpan(const Node*);
 PassRefPtr<HTMLElement> createStyleSpanElement(Document*);
-RefPtr<CSSMutableStyleDeclaration> getPropertiesNotInComputedStyle(CSSStyleDeclaration* style, CSSComputedStyleDeclaration* computedStyle);
+RefPtr<CSSMutableStyleDeclaration> getPropertiesNotIn(CSSStyleDeclaration* styleWithRedundantProperties, CSSStyleDeclaration* baseStyle);
 
 void prepareEditingStyleToApplyAt(CSSMutableStyleDeclaration*, Position);
 void removeStylesAddedByNode(CSSMutableStyleDeclaration*, Node*);
diff --git a/WebCore/editing/Editor.cpp b/WebCore/editing/Editor.cpp
index 24c1680..f81367e 100644
--- a/WebCore/editing/Editor.cpp
+++ b/WebCore/editing/Editor.cpp
@@ -862,9 +862,9 @@ static const int textOnlyProperties[] = {
     CSSPropertyColor,
 };
 
-static TriState triStateOfStyleInComputedStyle(CSSStyleDeclaration* desiredStyle, CSSComputedStyleDeclaration* computedStyle, bool ignoreTextOnlyProperties = false)
+static TriState triStateOfStyle(CSSStyleDeclaration* desiredStyle, CSSStyleDeclaration* styleToCompare, bool ignoreTextOnlyProperties = false)
 {
-    RefPtr<CSSMutableStyleDeclaration> diff = getPropertiesNotInComputedStyle(desiredStyle, computedStyle);
+    RefPtr<CSSMutableStyleDeclaration> diff = getPropertiesNotIn(desiredStyle, styleToCompare);
 
     if (ignoreTextOnlyProperties)
         diff->removePropertiesInSet(textOnlyProperties, sizeof(textOnlyProperties) / sizeof(textOnlyProperties[0]));
@@ -878,17 +878,11 @@ static TriState triStateOfStyleInComputedStyle(CSSStyleDeclaration* desiredStyle
 
 bool Editor::selectionStartHasStyle(CSSStyleDeclaration* style) const
 {
-    Node* nodeToRemove;
-    RefPtr<CSSComputedStyleDeclaration> selectionStyle = selectionComputedStyle(nodeToRemove);
+    bool shouldUseFixedFontDefaultSize;
+    RefPtr<CSSMutableStyleDeclaration> selectionStyle = selectionComputedStyle(shouldUseFixedFontDefaultSize);
     if (!selectionStyle)
         return false;
-    TriState state = triStateOfStyleInComputedStyle(style, selectionStyle.get());
-    if (nodeToRemove) {
-        ExceptionCode ec = 0;
-        nodeToRemove->remove(ec);
-        ASSERT(!ec);
-    }
-    return state == TrueTriState;
+    return triStateOfStyle(style, selectionStyle.get()) == TrueTriState;
 }
 
 TriState Editor::selectionHasStyle(CSSStyleDeclaration* style) const
@@ -896,21 +890,16 @@ TriState Editor::selectionHasStyle(CSSStyleDeclaration* style) const
     TriState state = FalseTriState;
 
     if (!m_frame->selection()->isRange()) {
-        Node* nodeToRemove;
-        RefPtr<CSSComputedStyleDeclaration> selectionStyle = selectionComputedStyle(nodeToRemove);
+        bool shouldUseFixedFontDefaultSize;
+        RefPtr<CSSMutableStyleDeclaration> selectionStyle = selectionComputedStyle(shouldUseFixedFontDefaultSize);
         if (!selectionStyle)
             return FalseTriState;
-        state = triStateOfStyleInComputedStyle(style, selectionStyle.get());
-        if (nodeToRemove) {
-            ExceptionCode ec = 0;
-            nodeToRemove->remove(ec);
-            ASSERT(!ec);
-        }
+        state = triStateOfStyle(style, selectionStyle.get());
     } else {
         for (Node* node = m_frame->selection()->start().node(); node; node = node->traverseNextNode()) {
             RefPtr<CSSComputedStyleDeclaration> nodeStyle = computedStyle(node);
             if (nodeStyle) {
-                TriState nodeState = triStateOfStyleInComputedStyle(style, nodeStyle.get(), !node->isTextNode());
+                TriState nodeState = triStateOfStyle(style, nodeStyle.get(), !node->isTextNode());
                 if (node == m_frame->selection()->start().node())
                     state = nodeState;
                 else if (state != nodeState && node->isTextNode()) {
@@ -944,8 +933,8 @@ static bool hasTransparentBackgroundColor(CSSStyleDeclaration* style)
 
 String Editor::selectionStartCSSPropertyValue(int propertyID)
 {
-    Node* nodeToRemove;
-    RefPtr<CSSComputedStyleDeclaration> selectionStyle = selectionComputedStyle(nodeToRemove);
+    bool shouldUseFixedFontDefaultSize = false;
+    RefPtr<CSSMutableStyleDeclaration> selectionStyle = selectionComputedStyle(shouldUseFixedFontDefaultSize);
     if (!selectionStyle)
         return String();
 
@@ -958,7 +947,7 @@ String Editor::selectionStartCSSPropertyValue(int propertyID)
         RefPtr<Range> range(m_frame->selection()->toNormalizedRange());
         ExceptionCode ec = 0;
         for (Node* ancestor = range->commonAncestorContainer(ec); ancestor; ancestor = ancestor->parentNode()) {
-            selectionStyle = computedStyle(ancestor);
+            selectionStyle = computedStyle(ancestor)->copy();
             if (!hasTransparentBackgroundColor(selectionStyle.get())) {
                 value = selectionStyle->getPropertyValue(CSSPropertyBackgroundColor);
                 break;
@@ -970,16 +959,10 @@ String Editor::selectionStartCSSPropertyValue(int propertyID)
         RefPtr<CSSValue> cssValue = selectionStyle->getPropertyCSSValue(CSSPropertyFontSize);
         ASSERT(cssValue->isPrimitiveValue());
         int fontPixelSize = static_cast<CSSPrimitiveValue*>(cssValue.get())->getIntValue(CSSPrimitiveValue::CSS_PX);
-        int size = CSSStyleSelector::legacyFontSize(m_frame->document(), fontPixelSize, selectionStyle->useFixedFontDefaultSize());
+        int size = CSSStyleSelector::legacyFontSize(m_frame->document(), fontPixelSize, shouldUseFixedFontDefaultSize);
         value = String::number(size);
     }
 
-    if (nodeToRemove) {
-        ExceptionCode ec = 0;
-        nodeToRemove->remove(ec);
-        ASSERT(!ec);
-    }
-
     return value;
 }
 
@@ -3246,10 +3229,8 @@ void Editor::computeAndSetTypingStyle(CSSStyleDeclaration* style, EditAction edi
     m_frame->selection()->setTypingStyle(mutableStyle.release());
 }
 
-PassRefPtr<CSSComputedStyleDeclaration> Editor::selectionComputedStyle(Node*& nodeToRemove) const
+PassRefPtr<CSSMutableStyleDeclaration> Editor::selectionComputedStyle(bool& shouldUseFixedFontDefaultSize) const
 {
-    nodeToRemove = 0;
-
     if (m_frame->selection()->isNone())
         return 0;
 
@@ -3269,34 +3250,19 @@ PassRefPtr<CSSComputedStyleDeclaration> Editor::selectionComputedStyle(Node*& no
         return 0;
 
     RefPtr<Element> styleElement = element;
-    ExceptionCode ec = 0;
-
-    if (m_frame->selection()->typingStyle()) {
-        styleElement = m_frame->document()->createElement(spanTag, false);
-
-        styleElement->setAttribute(styleAttr, m_frame->selection()->typingStyle()->cssText(), ec);
-        ASSERT(!ec);
-
-        styleElement->appendChild(m_frame->document()->createEditingTextNode(""), ec);
-        ASSERT(!ec);
+    RefPtr<CSSComputedStyleDeclaration> style = computedStyle(styleElement.release());
+    RefPtr<CSSMutableStyleDeclaration> mutableStyle = style->copy();
+    shouldUseFixedFontDefaultSize = style->useFixedFontDefaultSize();
 
-        if (element->renderer() && element->renderer()->canHaveChildren())
-            element->appendChild(styleElement, ec);
-        else {
-            Node* parent = element->parent();
-            Node* next = element->nextSibling();
-
-            if (next)
-                parent->insertBefore(styleElement, next, ec);
-            else
-                parent->appendChild(styleElement, ec);
-        }
-        ASSERT(!ec);
+    if (!m_frame->selection()->typingStyle())
+        return mutableStyle;
 
-        nodeToRemove = styleElement.get();
-    }
+    RefPtr<CSSMutableStyleDeclaration> typingStyle = m_frame->selection()->typingStyle()->copy();
+    ApplyStyleCommand::removeNonEditingProperties(typingStyle.get());
+    prepareEditingStyleToApplyAt(typingStyle.get(), position);
+    mutableStyle->merge(typingStyle.get());
 
-    return computedStyle(styleElement.release());
+    return mutableStyle;
 }
 
 void Editor::textFieldDidBeginEditing(Element* e)
diff --git a/WebCore/editing/Editor.h b/WebCore/editing/Editor.h
index 7a4a185..ab8ff7d 100644
--- a/WebCore/editing/Editor.h
+++ b/WebCore/editing/Editor.h
@@ -347,7 +347,7 @@ public:
     bool markedTextMatchesAreHighlighted() const;
     void setMarkedTextMatchesAreHighlighted(bool);
 
-    PassRefPtr<CSSComputedStyleDeclaration> selectionComputedStyle(Node*& nodeToRemove) const;
+    PassRefPtr<CSSMutableStyleDeclaration> selectionComputedStyle(bool& shouldUseFixedFontDefaultSize) const;
 
     void textFieldDidBeginEditing(Element*);
     void textFieldDidEndEditing(Element*);
diff --git a/WebCore/editing/EditorCommand.cpp b/WebCore/editing/EditorCommand.cpp
index 1b1f14f..97e6ff5 100644
--- a/WebCore/editing/EditorCommand.cpp
+++ b/WebCore/editing/EditorCommand.cpp
@@ -131,8 +131,8 @@ static bool executeApplyStyle(Frame* frame, EditorCommandSource source, EditActi
 static bool executeToggleStyleInList(Frame* frame, EditorCommandSource source, EditAction action, int propertyID, CSSValue* value)
 {
     ExceptionCode ec = 0;
-    Node* nodeToRemove = 0;
-    RefPtr<CSSComputedStyleDeclaration> selectionStyle = frame->editor()->selectionComputedStyle(nodeToRemove);
+    bool shouldUseFixedFontDefaultSize;
+    RefPtr<CSSMutableStyleDeclaration> selectionStyle = frame->editor()->selectionComputedStyle(shouldUseFixedFontDefaultSize);
     if (!selectionStyle)
         return false;
 
@@ -148,12 +148,6 @@ static bool executeToggleStyleInList(Frame* frame, EditorCommandSource source, E
     } else if (selectedCSSValue->cssText() == "none")
         newStyle = value->cssText();
 
-    ASSERT(!ec);
-    if (nodeToRemove) {
-        nodeToRemove->remove(ec);
-        ASSERT(!ec);
-    }
-
     // FIXME: We shouldn't be having to convert new style into text.  We should have setPropertyCSSValue.
     RefPtr<CSSMutableStyleDeclaration> newMutableStyle = CSSMutableStyleDeclaration::create();
     newMutableStyle->setProperty(propertyID, newStyle, ec);

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list