LayoutTests:
authorjusting <justing@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 27 Jul 2006 23:50:51 +0000 (23:50 +0000)
committerjusting <justing@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 27 Jul 2006 23:50:51 +0000 (23:50 +0000)
        Reviewed by levi

        <rdar://problem/4242293>
        Poor paste fidelity of http://www.google.com/

        * editing/pasteboard/styled-element-markup-expected.checksum: Added.
        * editing/pasteboard/styled-element-markup-expected.png: Added.
        * editing/pasteboard/styled-element-markup-expected.txt: Added.
        * editing/pasteboard/styled-element-markup.html: Added.

WebCore:

        Reviewed by levi

        <rdar://problem/4242293>
        Poor paste fidelity of http://www.google.com/

        * editing/ApplyStyleCommand.cpp:
        (WebCore::ApplyStyleCommand::applyInlineStyle):  Fixed crasher with nil-check.
        * editing/markup.cpp:
        (WebCore::startMarkup): Style information wasn't added to an element if it had
        attributes but no style attribute.

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

LayoutTests/ChangeLog
LayoutTests/editing/pasteboard/styled-element-markup-expected.checksum [new file with mode: 0644]
LayoutTests/editing/pasteboard/styled-element-markup-expected.png [new file with mode: 0644]
LayoutTests/editing/pasteboard/styled-element-markup-expected.txt [new file with mode: 0644]
LayoutTests/editing/pasteboard/styled-element-markup.html [new file with mode: 0644]
WebCore/ChangeLog
WebCore/editing/ApplyStyleCommand.cpp
WebCore/editing/markup.cpp

index 4bdda20..272da63 100644 (file)
@@ -1,3 +1,15 @@
+2006-07-27  Justin Garcia  <justin.garcia@apple.com>
+
+        Reviewed by levi
+        
+        <rdar://problem/4242293>
+        Poor paste fidelity of http://www.google.com/
+
+        * editing/pasteboard/styled-element-markup-expected.checksum: Added.
+        * editing/pasteboard/styled-element-markup-expected.png: Added.
+        * editing/pasteboard/styled-element-markup-expected.txt: Added.
+        * editing/pasteboard/styled-element-markup.html: Added.
+
 2006-07-27  Alexander Kellett  <lypanov@kde.org>
 
         Reviewed by Darin.
diff --git a/LayoutTests/editing/pasteboard/styled-element-markup-expected.checksum b/LayoutTests/editing/pasteboard/styled-element-markup-expected.checksum
new file mode 100644 (file)
index 0000000..07737b5
--- /dev/null
@@ -0,0 +1 @@
+4671eea1bf36a528bc452bb10459d536
\ No newline at end of file
diff --git a/LayoutTests/editing/pasteboard/styled-element-markup-expected.png b/LayoutTests/editing/pasteboard/styled-element-markup-expected.png
new file mode 100644 (file)
index 0000000..1428d1b
Binary files /dev/null and b/LayoutTests/editing/pasteboard/styled-element-markup-expected.png differ
diff --git a/LayoutTests/editing/pasteboard/styled-element-markup-expected.txt b/LayoutTests/editing/pasteboard/styled-element-markup-expected.txt
new file mode 100644 (file)
index 0000000..eb4b2e7
--- /dev/null
@@ -0,0 +1,30 @@
+EDITING DELEGATE: shouldBeginEditingInDOMRange:range from 0 of DIV > BODY > HTML > #document to 1 of DIV > BODY > HTML > #document
+EDITING DELEGATE: webViewDidBeginEditing:WebViewDidBeginEditingNotification
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 0 of CENTER > DIV > BODY > HTML > #document to 0 of CENTER > DIV > BODY > HTML > #document toDOMRange:range from 0 of CENTER > DIV > BODY > HTML > #document to 1 of CENTER > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: shouldEndEditingInDOMRange:range from 0 of DIV > BODY > HTML > #document to 1 of DIV > BODY > HTML > #document
+EDITING DELEGATE: webViewDidEndEditing:WebViewDidEndEditingNotification
+EDITING DELEGATE: shouldBeginEditingInDOMRange:range from 0 of DIV > BODY > HTML > #document to 0 of DIV > BODY > HTML > #document
+EDITING DELEGATE: webViewDidBeginEditing:WebViewDidBeginEditingNotification
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: shouldInsertNode:#document-fragment replacingDOMRange:range from 0 of DIV > BODY > HTML > #document to 0 of DIV > BODY > HTML > #document givenAction:WebViewInsertActionPasted
+EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 0 of DIV > BODY > HTML > #document to 0 of DIV > BODY > HTML > #document toDOMRange:range from 1 of DIV > BODY > HTML > #document to 1 of DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
+layer at (0,0) size 800x600
+  RenderView at (0,0) size 800x600
+layer at (0,0) size 800x600
+  RenderBlock {HTML} at (0,0) size 800x600
+    RenderBody {BODY} at (8,8) size 784x584
+      RenderBlock {P} at (0,0) size 784x36
+        RenderText {#text} at (0,0) size 772x36
+          text run at (0,0) width 334: "This tests copy/paste of styled elements, like images. "
+          text run at (334,0) width 438: "The image in the region below should be centered after its copied and"
+          text run at (0,18) width 44: "pasted."
+      RenderBlock {DIV} at (0,52) size 784x103
+        RenderBlock {CENTER} at (0,0) size 784x103
+          RenderImage {IMG} at (354,0) size 76x103
+      RenderBlock {DIV} at (0,155) size 784x103
+        RenderImage {IMG} at (354,0) size 76x103
+caret: position 1 of child 0 {IMG} of child 4 {DIV} of child 0 {BODY} of child 0 {HTML} of document
diff --git a/LayoutTests/editing/pasteboard/styled-element-markup.html b/LayoutTests/editing/pasteboard/styled-element-markup.html
new file mode 100644 (file)
index 0000000..101714b
--- /dev/null
@@ -0,0 +1,11 @@
+<p>This tests copy/paste of styled elements, like images.  The image in the region below should be centered after its copied and pasted.</p>
+<div contenteditable="true" id="copy"><center><img src="../resources/abe.jpg"></center></div>
+<div contenteditable="true" id="paste"></div>
+
+<script>;
+window.getSelection().setPosition(document.getElementById("copy"));
+document.execCommand("SelectAll");
+document.execCommand("Copy");
+window.getSelection().setPosition(document.getElementById("paste"));
+document.execCommand("Paste");
+</script>
index 11945bd..195199d 100644 (file)
@@ -1,3 +1,16 @@
+2006-07-27  Justin Garcia  <justin.garcia@apple.com>
+
+        Reviewed by levi
+        
+        <rdar://problem/4242293>
+        Poor paste fidelity of http://www.google.com/
+
+        * editing/ApplyStyleCommand.cpp:
+        (WebCore::ApplyStyleCommand::applyInlineStyle):  Fixed crasher with nil-check.
+        * editing/markup.cpp:
+        (WebCore::startMarkup): Style information wasn't added to an element if it had
+        attributes but no style attribute.
+
 2006-07-27  Alexander Kellett  <lypanov@kde.org>
 
         Reviewed by Darin.
index 1ea906c..9e4fe49 100644 (file)
@@ -589,7 +589,7 @@ void ApplyStyleCommand::applyInlineStyle(CSSMutableStyleDeclaration *style)
     if (start.offset() >= start.node()->caretMaxOffset())
         node = node->traverseNextNode();
 
-    if (end.node()->renderer()->isTable() && end.offset() == maxDeepOffset(end.node()))
+    if (end.node()->renderer() && end.node()->renderer()->isTable() && end.offset() == maxDeepOffset(end.node()))
         endNode = end.node()->lastDescendant();
     
     if (start.node() == endNode) {
index 2b364c4..db1f394 100644 (file)
@@ -171,25 +171,26 @@ static DeprecatedString startMarkup(const Node *node, const Range *range, EAnnot
             }
             NamedAttrMap *attrs = el->attributes();
             unsigned length = attrs->length();
-            if (length == 0 && additionalStyle.length() > 0) {
-                // FIXME: Handle case where additionalStyle has illegal characters in it, like "
-                markup += " " +  styleAttr.localName().deprecatedString() + "=\"" + additionalStyle.deprecatedString() + "\"";
-            }
-            else {
-                for (unsigned int i=0; i<length; i++) {
-                    Attribute *attr = attrs->attributeItem(i);
-                    String value = attr->value();
-                    if (attr->name() == styleAttr && additionalStyle.length() > 0)
-                        value += "; " + additionalStyle;
-                    // FIXME: Handle case where value has illegal characters in it, like "
-                    if (documentIsHTML)
-                        markup += " " + attr->name().localName().deprecatedString();
-                    else
-                        markup += " " + attr->name().toString().deprecatedString();
-                    markup += "=\"" + escapeTextForMarkup(value.deprecatedString()) + "\"";
+
+            for (unsigned int i = 0; i < length; i++) {
+                Attribute *attr = attrs->attributeItem(i);
+                String value = attr->value();
+                if (attr->name() == styleAttr && additionalStyle.length() > 0) {
+                    value += "; " + additionalStyle;
+                    additionalStyle = "";
                 }
+                // FIXME: Handle case where value has illegal characters in it, like "
+                if (documentIsHTML)
+                    markup += " " + attr->name().localName().deprecatedString();
+                else
+                    markup += " " + attr->name().toString().deprecatedString();
+                markup += "=\"" + escapeTextForMarkup(value.deprecatedString()) + "\"";
             }
             
+            if (additionalStyle.length() > 0)
+                // FIXME: Handle case where additionalStyle has illegal characters in it, like "
+                markup += " " +  styleAttr.localName().deprecatedString() + "=\"" + additionalStyle.deprecatedString() + "\"";
+            
             if (shouldSelfClose(el)) {
                 if (el->isHTMLElement())
                     markup += " "; // XHTML 1.0 <-> HTML compatibility.