2011-01-25 Levi Weintraub <leviw@chromium.org>
authorleviw@chromium.org <leviw@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 27 Jan 2011 22:38:10 +0000 (22:38 +0000)
committerleviw@chromium.org <leviw@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 27 Jan 2011 22:38:10 +0000 (22:38 +0000)
        Reviewed by Darin Adler.

        Updating the expected result for 5408255 and adding tests for caret positioning at the
        beginning and end of RenderBoxes.

        Undo moves caret to invalid position
        https://bugs.webkit.org/show_bug.cgi?id=49744

        * editing/selection/caret-painting-after-paste-undo-rtl.html: Added.
        * editing/selection/caret-painting-after-paste-undo.html: Added.
        * platform/mac/editing/deleting/5408255-expected.png:
        * platform/mac/editing/selection/caret-painting-after-paste-undo-expected.checksum: Added.
        * platform/mac/editing/selection/caret-painting-after-paste-undo-expected.png: Added.
        * platform/mac/editing/selection/caret-painting-after-paste-undo-expected.txt: Added.
        * platform/mac/editing/selection/caret-painting-after-paste-undo-rtl-expected.checksum: Added.
        * platform/mac/editing/selection/caret-painting-after-paste-undo-rtl-expected.png: Added.
        * platform/mac/editing/selection/caret-painting-after-paste-undo-rtl-expected.txt: Added.
2011-01-25  Levi Weintraub  <leviw@chromium.org>

        Reviewed by Darin Adler.

        Adding border and padding to the calculation of the local caret rect for RenderBoxes.
        Corrected for mistake in r76625

        Undo moves caret to invalid position
        https://bugs.webkit.org/show_bug.cgi?id=49744

        Tests: editing/selection/caret-painting-after-paste-undo-rtl.html
               editing/selection/caret-painting-after-paste-undo.html

        * rendering/RenderBox.cpp:
        (WebCore::RenderBox::localCaretRect):

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

12 files changed:
LayoutTests/ChangeLog
LayoutTests/editing/selection/caret-painting-after-paste-undo-rtl.html [new file with mode: 0644]
LayoutTests/editing/selection/caret-painting-after-paste-undo.html [new file with mode: 0644]
LayoutTests/platform/mac/editing/deleting/5408255-expected.png
LayoutTests/platform/mac/editing/selection/caret-painting-after-paste-undo-expected.checksum [new file with mode: 0644]
LayoutTests/platform/mac/editing/selection/caret-painting-after-paste-undo-expected.png [new file with mode: 0644]
LayoutTests/platform/mac/editing/selection/caret-painting-after-paste-undo-expected.txt [new file with mode: 0644]
LayoutTests/platform/mac/editing/selection/caret-painting-after-paste-undo-rtl-expected.checksum [new file with mode: 0644]
LayoutTests/platform/mac/editing/selection/caret-painting-after-paste-undo-rtl-expected.png [new file with mode: 0644]
LayoutTests/platform/mac/editing/selection/caret-painting-after-paste-undo-rtl-expected.txt [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/rendering/RenderBox.cpp

index 6906b6f..2cdc857 100644 (file)
@@ -1,3 +1,23 @@
+2011-01-25  Levi Weintraub  <leviw@chromium.org>
+
+        Reviewed by Darin Adler.
+
+        Updating the expected result for 5408255 and adding tests for caret positioning at the
+        beginning and end of RenderBoxes.
+
+        Undo moves caret to invalid position
+        https://bugs.webkit.org/show_bug.cgi?id=49744
+
+        * editing/selection/caret-painting-after-paste-undo-rtl.html: Added.
+        * editing/selection/caret-painting-after-paste-undo.html: Added.
+        * platform/mac/editing/deleting/5408255-expected.png:
+        * platform/mac/editing/selection/caret-painting-after-paste-undo-expected.checksum: Added.
+        * platform/mac/editing/selection/caret-painting-after-paste-undo-expected.png: Added.
+        * platform/mac/editing/selection/caret-painting-after-paste-undo-expected.txt: Added.
+        * platform/mac/editing/selection/caret-painting-after-paste-undo-rtl-expected.checksum: Added.
+        * platform/mac/editing/selection/caret-painting-after-paste-undo-rtl-expected.png: Added.
+        * platform/mac/editing/selection/caret-painting-after-paste-undo-rtl-expected.txt: Added.
+
 2011-01-27  Ryosuke Niwa  <rniwa@webkit.org>
 
         Unreviewed Chromium rebaseline and text expectation update.
diff --git a/LayoutTests/editing/selection/caret-painting-after-paste-undo-rtl.html b/LayoutTests/editing/selection/caret-painting-after-paste-undo-rtl.html
new file mode 100644 (file)
index 0000000..14d3f63
--- /dev/null
@@ -0,0 +1,21 @@
+<html>
+<head>
+<script src="../editing.js" language="JavaScript" type="text/JavaScript"></script>
+<script>
+function editingTest() {
+ doubleClick(0, 0);
+ copyCommand();
+ var editor = document.getElementById("editor");
+ editor.focus();
+ pasteCommand();
+ undoCommand();
+}
+</script>
+</head>
+<body onLoad="runEditingTest();">
+<div>To run this test, copy some text, paste it into the box below, and then undo.
+ The caret should be positioned respecting the box's border and padding.</div><br>
+<div id="editor" contenteditable=true style="direction: rtl; border:2px inset #eee; padding: 5px;">
+</div>
+</body>
+</html>
diff --git a/LayoutTests/editing/selection/caret-painting-after-paste-undo.html b/LayoutTests/editing/selection/caret-painting-after-paste-undo.html
new file mode 100644 (file)
index 0000000..db83154
--- /dev/null
@@ -0,0 +1,21 @@
+<html>
+<head>
+<script src="../editing.js" language="JavaScript" type="text/JavaScript"></script>
+<script>
+function editingTest() {
+ doubleClick(0, 0);
+ copyCommand();
+ var editor = document.getElementById("editor");
+ editor.focus();
+ pasteCommand();
+ undoCommand();
+}
+</script>
+</head>
+<body onLoad="runEditingTest();">
+<div>To run this test, copy some text, paste it into the box below, and then undo.
+ The caret should be positioned respecting the box's border and padding.</div><br>
+<div id="editor" contenteditable=true style="border:2px inset #eee; padding: 5px;">
+</div>
+</body>
+</html>
index 3d4ab0e..ac59a5c 100644 (file)
Binary files a/LayoutTests/platform/mac/editing/deleting/5408255-expected.png and b/LayoutTests/platform/mac/editing/deleting/5408255-expected.png differ
diff --git a/LayoutTests/platform/mac/editing/selection/caret-painting-after-paste-undo-expected.checksum b/LayoutTests/platform/mac/editing/selection/caret-painting-after-paste-undo-expected.checksum
new file mode 100644 (file)
index 0000000..e2c3859
--- /dev/null
@@ -0,0 +1 @@
+c9d3f8bdb370e1321e835f10e57d0f12
\ No newline at end of file
diff --git a/LayoutTests/platform/mac/editing/selection/caret-painting-after-paste-undo-expected.png b/LayoutTests/platform/mac/editing/selection/caret-painting-after-paste-undo-expected.png
new file mode 100644 (file)
index 0000000..74ebc63
Binary files /dev/null and b/LayoutTests/platform/mac/editing/selection/caret-painting-after-paste-undo-expected.png differ
diff --git a/LayoutTests/platform/mac/editing/selection/caret-painting-after-paste-undo-expected.txt b/LayoutTests/platform/mac/editing/selection/caret-painting-after-paste-undo-expected.txt
new file mode 100644 (file)
index 0000000..9c8422f
--- /dev/null
@@ -0,0 +1,32 @@
+EDITING DELEGATE: shouldChangeSelectedDOMRange:(null) toDOMRange:range from 0 of DIV > BODY > HTML > #document to 0 of DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 0 of DIV > BODY > HTML > #document to 0 of DIV > BODY > HTML > #document toDOMRange:range from 0 of #text > DIV > BODY > HTML > #document to 2 of #text > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: shouldBeginEditingInDOMRange:range from 0 of DIV > BODY > HTML > #document to 1 of DIV > BODY > HTML > #document
+EDITING DELEGATE: webViewDidBeginEditing:WebViewDidBeginEditingNotification
+EDITING DELEGATE: shouldChangeSelectedDOMRange:(null) toDOMRange:range from 0 of DIV > BODY > HTML > #document to 0 of DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+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 2 of #text > DIV > BODY > HTML > #document to 2 of #text > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: shouldChangeSelectedDOMRange:(null) toDOMRange:range from 0 of DIV > BODY > HTML > #document to 0 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 {DIV} at (0,0) size 784x36
+        RenderText {#text} at (0,0) size 761x36
+          text run at (0,0) width 477: "To run this test, copy some text, paste it into the box below, and then undo. "
+          text run at (477,0) width 284: "The caret should be positioned respecting the"
+          text run at (0,18) width 164: "box's border and padding."
+      RenderBlock (anonymous) at (0,36) size 784x18
+        RenderBR {BR} at (0,0) size 0x18
+      RenderBlock {DIV} at (0,54) size 784x32 [border: (2px inset #EEEEEE)]
+        RenderText {#text} at (0,0) size 0x0
+caret: position 0 of child 4 {DIV} of body
diff --git a/LayoutTests/platform/mac/editing/selection/caret-painting-after-paste-undo-rtl-expected.checksum b/LayoutTests/platform/mac/editing/selection/caret-painting-after-paste-undo-rtl-expected.checksum
new file mode 100644 (file)
index 0000000..b1e1408
--- /dev/null
@@ -0,0 +1 @@
+648036b0929b7b02e5909f58dbc19196
\ No newline at end of file
diff --git a/LayoutTests/platform/mac/editing/selection/caret-painting-after-paste-undo-rtl-expected.png b/LayoutTests/platform/mac/editing/selection/caret-painting-after-paste-undo-rtl-expected.png
new file mode 100644 (file)
index 0000000..aab614f
Binary files /dev/null and b/LayoutTests/platform/mac/editing/selection/caret-painting-after-paste-undo-rtl-expected.png differ
diff --git a/LayoutTests/platform/mac/editing/selection/caret-painting-after-paste-undo-rtl-expected.txt b/LayoutTests/platform/mac/editing/selection/caret-painting-after-paste-undo-rtl-expected.txt
new file mode 100644 (file)
index 0000000..9c8422f
--- /dev/null
@@ -0,0 +1,32 @@
+EDITING DELEGATE: shouldChangeSelectedDOMRange:(null) toDOMRange:range from 0 of DIV > BODY > HTML > #document to 0 of DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 0 of DIV > BODY > HTML > #document to 0 of DIV > BODY > HTML > #document toDOMRange:range from 0 of #text > DIV > BODY > HTML > #document to 2 of #text > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: shouldBeginEditingInDOMRange:range from 0 of DIV > BODY > HTML > #document to 1 of DIV > BODY > HTML > #document
+EDITING DELEGATE: webViewDidBeginEditing:WebViewDidBeginEditingNotification
+EDITING DELEGATE: shouldChangeSelectedDOMRange:(null) toDOMRange:range from 0 of DIV > BODY > HTML > #document to 0 of DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+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 2 of #text > DIV > BODY > HTML > #document to 2 of #text > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: shouldChangeSelectedDOMRange:(null) toDOMRange:range from 0 of DIV > BODY > HTML > #document to 0 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 {DIV} at (0,0) size 784x36
+        RenderText {#text} at (0,0) size 761x36
+          text run at (0,0) width 477: "To run this test, copy some text, paste it into the box below, and then undo. "
+          text run at (477,0) width 284: "The caret should be positioned respecting the"
+          text run at (0,18) width 164: "box's border and padding."
+      RenderBlock (anonymous) at (0,36) size 784x18
+        RenderBR {BR} at (0,0) size 0x18
+      RenderBlock {DIV} at (0,54) size 784x32 [border: (2px inset #EEEEEE)]
+        RenderText {#text} at (0,0) size 0x0
+caret: position 0 of child 4 {DIV} of body
index ad72ca4..ecdb922 100644 (file)
@@ -1,3 +1,19 @@
+2011-01-25  Levi Weintraub  <leviw@chromium.org>
+
+        Reviewed by Darin Adler.
+
+        Adding border and padding to the calculation of the local caret rect for RenderBoxes.
+        Corrected for mistake in r76625
+
+        Undo moves caret to invalid position
+        https://bugs.webkit.org/show_bug.cgi?id=49744
+
+        Tests: editing/selection/caret-painting-after-paste-undo-rtl.html
+               editing/selection/caret-painting-after-paste-undo.html
+
+        * rendering/RenderBox.cpp:
+        (WebCore::RenderBox::localCaretRect):
+
 2011-01-27  Sheriff Bot  <webkit.review.bot@gmail.com>
 
         Unreviewed, rolling out r76825.
index 9428519..8545bf4 100644 (file)
@@ -2960,12 +2960,16 @@ IntRect RenderBox::localCaretRect(InlineBox* box, int caretOffset, int* extraWid
     // They never refer to children.
     // FIXME: Paint the carets inside empty blocks differently than the carets before/after elements.
 
-    // FIXME: What about border and padding?
     IntRect rect(x(), y(), caretWidth, height());
     bool ltr = box ? box->isLeftToRightDirection() : style()->isLeftToRightDirection();
 
-    if ((!caretOffset) ^ ltr)
-        rect.move(IntSize(width() - caretWidth, 0));
+    if (isTable()) {
+        if ((!caretOffset) ^ ltr)
+            rect.move(IntSize(width() - caretWidth, 0));
+    } else if ((!caretOffset) ^ ltr)
+        rect.move(IntSize(width() - caretWidth - borderRight() - paddingRight(), borderTop() + paddingTop()));
+    else
+        rect.move(IntSize(borderLeft() + paddingLeft(), borderTop() + paddingTop()));
 
     if (box) {
         RootInlineBox* rootBox = box->root();