Reviewed by Justin Garcia.
authoreric@webkit.org <eric@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 21 Jan 2009 23:37:08 +0000 (23:37 +0000)
committereric@webkit.org <eric@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 21 Jan 2009 23:37:08 +0000 (23:37 +0000)
        Remove the style='' turds left by some editing commands
        https://bugs.webkit.org/show_bug.cgi?id=23463

        Test: editing/execCommand/toggle-styles.html

        * editing/ApplyStyleCommand.cpp:
        (WebCore::ApplyStyleCommand::removeCSSStyle): check if we just removed the last CSS property and remove the style attribute as well
        * editing/CompositeEditCommand.cpp:
        (WebCore::CompositeEditCommand::removeNodeAttribute): remove extra ;

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@40101 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/editing/execCommand/toggle-styles-expected.txt
WebCore/ChangeLog
WebCore/editing/ApplyStyleCommand.cpp
WebCore/editing/CompositeEditCommand.cpp

index 1afe162..7efa695 100644 (file)
@@ -1,3 +1,12 @@
+2009-01-21  Eric Seidel  <eric@webkit.org>
+
+        Reviewed by Justin Garcia.
+
+        Remove the style='' turds left by some editing commands
+        https://bugs.webkit.org/show_bug.cgi?id=23463
+
+        * editing/execCommand/toggle-styles-expected.txt: updated results
+
 2009-01-21  Chris Fleizach  <cfleizach@apple.com>
 
         Reviewed by Beth Dakin.
index fb3bff6..e4c4db0 100644 (file)
@@ -6,25 +6,25 @@ On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE
 PASS document.compatMode is "BackCompat"
 PASS bold toggle
 PASS bold removing b
-FAIL bold removing font-weight: bold -- <span style="">test</span>
+FAIL bold removing font-weight: bold -- <span>test</span>
 FAIL bold removing strong -- <strong><span class="Apple-style-span" style="font-weight: normal;">test</span></strong>
 PASS italic toggle
 PASS italic removing i
-FAIL italic removing font-style: italic -- <span style="">test</span>
+FAIL italic removing font-style: italic -- <span>test</span>
 FAIL italic removing em -- <em><span class="Apple-style-span" style="font-style: normal;">test</span></em>
 PASS subscript toggle
 PASS subscript removing sub
-FAIL subscript removing vertical-align: sub -- <span style="">test</span>
+FAIL subscript removing vertical-align: sub -- <span>test</span>
 PASS superscript toggle
 PASS superscript removing sup
-FAIL superscript removing vertical-align: super -- <span style="">test</span>
+FAIL superscript removing vertical-align: super -- <span>test</span>
 PASS strikethrough toggle
-FAIL strikethrough removing strike -- <strike style=""><span class="Apple-style-span" style="text-decoration: none;">test</span></strike>
-FAIL strikethrough removing text-decoration: line-through -- <span style="">test</span>
-FAIL strikethrough removing s -- <s style=""><span class="Apple-style-span" style="text-decoration: none;">test</span></s>
+FAIL strikethrough removing strike -- <strike><span class="Apple-style-span" style="text-decoration: none;">test</span></strike>
+FAIL strikethrough removing text-decoration: line-through -- <span>test</span>
+FAIL strikethrough removing s -- <s><span class="Apple-style-span" style="text-decoration: none;">test</span></s>
 PASS underline toggle
-FAIL underline removing u -- <u style=""><span class="Apple-style-span" style="text-decoration: none;">test</span></u>
-FAIL underline removing text-decoration: underline -- <span style="">test</span>
+FAIL underline removing u -- <u><span class="Apple-style-span" style="text-decoration: none;">test</span></u>
+FAIL underline removing text-decoration: underline -- <span>test</span>
 PASS successfullyParsed is true
 
 TEST COMPLETE
index 5470b75..033a12f 100644 (file)
@@ -1,5 +1,19 @@
 2009-01-21  Eric Seidel  <eric@webkit.org>
 
+        Reviewed by Justin Garcia.
+
+        Remove the style='' turds left by some editing commands
+        https://bugs.webkit.org/show_bug.cgi?id=23463
+
+        Test: editing/execCommand/toggle-styles.html
+
+        * editing/ApplyStyleCommand.cpp:
+        (WebCore::ApplyStyleCommand::removeCSSStyle): check if we just removed the last CSS property and remove the style attribute as well
+        * editing/CompositeEditCommand.cpp:
+        (WebCore::CompositeEditCommand::removeNodeAttribute): remove extra ;
+
+2009-01-21  Eric Seidel  <eric@webkit.org>
+
         No review, build fix.
 
         Fix release-only build failure (and do a tiny code-cleanup).
index 39e9ee1..8c2dd1d 100644 (file)
@@ -1013,12 +1013,12 @@ void ApplyStyleCommand::removeHTMLBidiEmbeddingStyle(CSSMutableStyleDeclaration
         removeNodePreservingChildren(elem);
 }
 
-void ApplyStyleCommand::removeCSSStyle(CSSMutableStyleDeclaration *style, HTMLElement *elem)
+void ApplyStyleCommand::removeCSSStyle(CSSMutableStyleDeclaration* style, HTMLElement* elem)
 {
     ASSERT(style);
     ASSERT(elem);
 
-    CSSMutableStyleDeclaration *decl = elem->inlineStyleDecl();
+    CSSMutableStyleDeclarationdecl = elem->inlineStyleDecl();
     if (!decl)
         return;
 
@@ -1033,6 +1033,10 @@ void ApplyStyleCommand::removeCSSStyle(CSSMutableStyleDeclaration *style, HTMLEl
         }
     }
 
+    // No need to serialize <foo style=""> if we just removed the last css property
+    if (decl->length() == 0)
+        removeNodeAttribute(elem, styleAttr);
+
     if (isUnstyledStyleSpan(elem))
         removeNodePreservingChildren(elem);
 }
index 7ddb65b..ca69db9 100644 (file)
@@ -356,7 +356,7 @@ void CompositeEditCommand::removeCSSProperty(PassRefPtr<CSSMutableStyleDeclarati
 
 void CompositeEditCommand::removeNodeAttribute(PassRefPtr<Element> element, const QualifiedName& attribute)
 {
-    setNodeAttribute(element, attribute, AtomicString());;
+    setNodeAttribute(element, attribute, AtomicString());
 }
 
 void CompositeEditCommand::setNodeAttribute(PassRefPtr<Element> element, const QualifiedName& attribute, const AtomicString& value)