LayoutTests:
authorjusting <justing@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 23 Jun 2006 21:19:59 +0000 (21:19 +0000)
committerjusting <justing@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 23 Jun 2006 21:19:59 +0000 (21:19 +0000)
        Reviewed by levi

        <http://bugzilla.opendarwin.org/show_bug.cgi?id=8074>
        Caret before/after block tables is too small
        <rdar://problem/4598331>
        right arrow out of a table shows cursor in a weird place

        Demonstrates 9557:
        * editing/input/range-for-empty-document-expected.txt:
        Added:
        * editing/selection/table-caret-1-expected.checksum: Added.
        * editing/selection/table-caret-1-expected.png: Added.
        * editing/selection/table-caret-1-expected.txt: Added.
        * editing/selection/table-caret-1.html: Added.
        * editing/selection/table-caret-2-expected.checksum: Added.
        * editing/selection/table-caret-2-expected.png: Added.
        * editing/selection/table-caret-2-expected.txt: Added.
        * editing/selection/table-caret-2.html: Added.
        * editing/selection/table-caret-3-expected.checksum: Added.
        * editing/selection/table-caret-3-expected.png: Added.
        * editing/selection/table-caret-3-expected.txt: Added.
        * editing/selection/table-caret-3.html: Added.

WebCore:

        Reviewed by levi

        <http://bugzilla.opendarwin.org/show_bug.cgi?id=8074>
        Caret before/after block tables is too small
        <rdar://problem/4598331>
        right arrow out of a table shows cursor in a weird place

        * rendering/RenderBox.cpp:
        (WebCore::RenderBox::caretRect): Don't propagate to children,
        VisiblePositions inside containers don't refer to children.
        Don't use the font height for tables.

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

17 files changed:
LayoutTests/ChangeLog
LayoutTests/editing/input/range-for-empty-document-expected.txt
LayoutTests/editing/selection/table-caret-1-expected.checksum [new file with mode: 0644]
LayoutTests/editing/selection/table-caret-1-expected.png [new file with mode: 0644]
LayoutTests/editing/selection/table-caret-1-expected.txt [new file with mode: 0644]
LayoutTests/editing/selection/table-caret-1.html [new file with mode: 0644]
LayoutTests/editing/selection/table-caret-2-expected.checksum [new file with mode: 0644]
LayoutTests/editing/selection/table-caret-2-expected.png [new file with mode: 0644]
LayoutTests/editing/selection/table-caret-2-expected.txt [new file with mode: 0644]
LayoutTests/editing/selection/table-caret-2.html [new file with mode: 0644]
LayoutTests/editing/selection/table-caret-3-expected.checksum [new file with mode: 0644]
LayoutTests/editing/selection/table-caret-3-expected.png [new file with mode: 0644]
LayoutTests/editing/selection/table-caret-3-expected.txt [new file with mode: 0644]
LayoutTests/editing/selection/table-caret-3.html [new file with mode: 0644]
WebCore/ChangeLog
WebCore/WebCore.xcodeproj/project.pbxproj
WebCore/rendering/RenderBox.cpp

index 2d5c8e7aa1047ea509e5aa8543725e076ec8a942..207c068878eaeb96cd0a3b3e0241cd7472761cd0 100644 (file)
@@ -1,3 +1,28 @@
+2006-06-23  Justin Garcia  <justin.garcia@apple.com>
+
+        Reviewed by levi
+        
+        <http://bugzilla.opendarwin.org/show_bug.cgi?id=8074>
+        Caret before/after block tables is too small
+        <rdar://problem/4598331>
+        right arrow out of a table shows cursor in a weird place
+
+        Demonstrates 9557:
+        * editing/input/range-for-empty-document-expected.txt:
+        Added:
+        * editing/selection/table-caret-1-expected.checksum: Added.
+        * editing/selection/table-caret-1-expected.png: Added.
+        * editing/selection/table-caret-1-expected.txt: Added.
+        * editing/selection/table-caret-1.html: Added.
+        * editing/selection/table-caret-2-expected.checksum: Added.
+        * editing/selection/table-caret-2-expected.png: Added.
+        * editing/selection/table-caret-2-expected.txt: Added.
+        * editing/selection/table-caret-2.html: Added.
+        * editing/selection/table-caret-3-expected.checksum: Added.
+        * editing/selection/table-caret-3-expected.png: Added.
+        * editing/selection/table-caret-3-expected.txt: Added.
+        * editing/selection/table-caret-3.html: Added.
+
 2006-06-22  Mitz Pettel  <opendarwin.org@mitzpettel.com>
 
         Reviewed by Hyatt.
index 93c138fb9d01093b2353a1b2440816b28a016596..544baa35d4e7197bf66e912fa49e7d0280d4f2df 100644 (file)
@@ -1,4 +1,4 @@
 EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
-(0, 0): 8,574,0,18
+(0, 0): 0,582,0,18
 
 
diff --git a/LayoutTests/editing/selection/table-caret-1-expected.checksum b/LayoutTests/editing/selection/table-caret-1-expected.checksum
new file mode 100644 (file)
index 0000000..f3177a4
--- /dev/null
@@ -0,0 +1 @@
+bc9379e0ea88ebbb35817d326d9bf892
\ No newline at end of file
diff --git a/LayoutTests/editing/selection/table-caret-1-expected.png b/LayoutTests/editing/selection/table-caret-1-expected.png
new file mode 100644 (file)
index 0000000..bc06d7e
Binary files /dev/null and b/LayoutTests/editing/selection/table-caret-1-expected.png differ
diff --git a/LayoutTests/editing/selection/table-caret-1-expected.txt b/LayoutTests/editing/selection/table-caret-1-expected.txt
new file mode 100644 (file)
index 0000000..aa0e071
--- /dev/null
@@ -0,0 +1,33 @@
+EDITING DELEGATE: shouldBeginEditingInDOMRange:range from 0 of DIV > BODY > HTML > #document to 3 of DIV > BODY > HTML > #document
+EDITING DELEGATE: webViewDidBeginEditing:WebViewDidBeginEditingNotification
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+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 784x18
+        RenderText {#text} at (0,0) size 381x18
+          text run at (0,0) width 381: "This tests the caret position for the caret before a block table."
+      RenderBlock {DIV} at (0,34) size 784x112
+        RenderBlock (anonymous) at (0,0) size 784x18
+          RenderText {#text} at (0,0) size 21x18
+            text run at (0,0) width 21: "foo"
+        RenderTable {TABLE} at (0,18) size 51x76 [border: (1px solid #999999)]
+          RenderTableSection {TBODY} at (1,1) size 49x74
+            RenderTableRow {TR} at (0,2) size 49x22
+              RenderTableCell {TD} at (2,2) size 45x22 [border: (1px solid #999999)] [r=0 c=0 rs=1 cs=1]
+                RenderText {#text} at (2,2) size 22x18
+                  text run at (2,2) width 22: "this"
+            RenderTableRow {TR} at (0,26) size 49x22
+              RenderTableCell {TD} at (2,26) size 45x22 [border: (1px solid #999999)] [r=1 c=0 rs=1 cs=1]
+                RenderText {#text} at (2,2) size 10x18
+                  text run at (2,2) width 10: "is"
+            RenderTableRow {TR} at (0,50) size 49x22
+              RenderTableCell {TD} at (2,50) size 45x22 [border: (1px solid #999999)] [r=2 c=0 rs=1 cs=1]
+                RenderText {#text} at (2,2) size 41x18
+                  text run at (2,2) width 41: "a table"
+        RenderBlock (anonymous) at (0,94) size 784x18
+          RenderText {#text} at (0,0) size 22x18
+            text run at (0,0) width 22: "baz"
+caret: position 0 of child 1 {TABLE} of child 2 {DIV} of child 1 {BODY} of child 0 {HTML} of document
diff --git a/LayoutTests/editing/selection/table-caret-1.html b/LayoutTests/editing/selection/table-caret-1.html
new file mode 100644 (file)
index 0000000..8ae81a9
--- /dev/null
@@ -0,0 +1,16 @@
+<style>
+table, td {
+    border: 1px solid #999;
+}
+</style>
+
+<p>This tests the caret position for the caret before a block table.</p>
+
+<div contenteditable="true">foo<table id="test"><tr><td>this</td></tr><tr><td>is</td></tr><tr><td>a table</td></tr></table>baz</div>
+
+<script>
+var s = window.getSelection();
+var e = document.getElementById("test");
+
+s.setPosition(e, 0);
+</script>
\ No newline at end of file
diff --git a/LayoutTests/editing/selection/table-caret-2-expected.checksum b/LayoutTests/editing/selection/table-caret-2-expected.checksum
new file mode 100644 (file)
index 0000000..f6876d3
--- /dev/null
@@ -0,0 +1 @@
+cfd9299efac2ecb61b3cabc3332b3792
\ No newline at end of file
diff --git a/LayoutTests/editing/selection/table-caret-2-expected.png b/LayoutTests/editing/selection/table-caret-2-expected.png
new file mode 100644 (file)
index 0000000..26c262f
Binary files /dev/null and b/LayoutTests/editing/selection/table-caret-2-expected.png differ
diff --git a/LayoutTests/editing/selection/table-caret-2-expected.txt b/LayoutTests/editing/selection/table-caret-2-expected.txt
new file mode 100644 (file)
index 0000000..de2def7
--- /dev/null
@@ -0,0 +1,33 @@
+EDITING DELEGATE: shouldBeginEditingInDOMRange:range from 0 of DIV > BODY > HTML > #document to 3 of DIV > BODY > HTML > #document
+EDITING DELEGATE: webViewDidBeginEditing:WebViewDidBeginEditingNotification
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+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 784x18
+        RenderText {#text} at (0,0) size 369x18
+          text run at (0,0) width 369: "This tests the caret position for the caret after a block table."
+      RenderBlock {DIV} at (0,34) size 784x112
+        RenderBlock (anonymous) at (0,0) size 784x18
+          RenderText {#text} at (0,0) size 21x18
+            text run at (0,0) width 21: "foo"
+        RenderTable {TABLE} at (0,18) size 51x76 [border: (1px solid #999999)]
+          RenderTableSection {TBODY} at (1,1) size 49x74
+            RenderTableRow {TR} at (0,2) size 49x22
+              RenderTableCell {TD} at (2,2) size 45x22 [border: (1px solid #999999)] [r=0 c=0 rs=1 cs=1]
+                RenderText {#text} at (2,2) size 22x18
+                  text run at (2,2) width 22: "this"
+            RenderTableRow {TR} at (0,26) size 49x22
+              RenderTableCell {TD} at (2,26) size 45x22 [border: (1px solid #999999)] [r=1 c=0 rs=1 cs=1]
+                RenderText {#text} at (2,2) size 10x18
+                  text run at (2,2) width 10: "is"
+            RenderTableRow {TR} at (0,50) size 49x22
+              RenderTableCell {TD} at (2,50) size 45x22 [border: (1px solid #999999)] [r=2 c=0 rs=1 cs=1]
+                RenderText {#text} at (2,2) size 41x18
+                  text run at (2,2) width 41: "a table"
+        RenderBlock (anonymous) at (0,94) size 784x18
+          RenderText {#text} at (0,0) size 22x18
+            text run at (0,0) width 22: "baz"
+caret: position 1 of child 1 {TABLE} of child 2 {DIV} of child 1 {BODY} of child 0 {HTML} of document
diff --git a/LayoutTests/editing/selection/table-caret-2.html b/LayoutTests/editing/selection/table-caret-2.html
new file mode 100644 (file)
index 0000000..6004889
--- /dev/null
@@ -0,0 +1,16 @@
+<style>
+table, td {
+    border: 1px solid #999;
+}
+</style>
+
+<p>This tests the caret position for the caret after a block table.</p>
+
+<div contenteditable="true">foo<table id="test"><tr><td>this</td></tr><tr><td>is</td></tr><tr><td>a table</td></tr></table>baz</div>
+
+<script>
+var s = window.getSelection();
+var e = document.getElementById("test");
+
+s.setPosition(e, e.childNodes.length);
+</script>
\ No newline at end of file
diff --git a/LayoutTests/editing/selection/table-caret-3-expected.checksum b/LayoutTests/editing/selection/table-caret-3-expected.checksum
new file mode 100644 (file)
index 0000000..da10b87
--- /dev/null
@@ -0,0 +1 @@
+22b1cb5f021c8f7964e5ac84f7fdf4be
\ No newline at end of file
diff --git a/LayoutTests/editing/selection/table-caret-3-expected.png b/LayoutTests/editing/selection/table-caret-3-expected.png
new file mode 100644 (file)
index 0000000..477712b
Binary files /dev/null and b/LayoutTests/editing/selection/table-caret-3-expected.png differ
diff --git a/LayoutTests/editing/selection/table-caret-3-expected.txt b/LayoutTests/editing/selection/table-caret-3-expected.txt
new file mode 100644 (file)
index 0000000..14bc76d
--- /dev/null
@@ -0,0 +1,31 @@
+EDITING DELEGATE: shouldBeginEditingInDOMRange:range from 0 of DIV > BODY > HTML > #document to 3 of DIV > BODY > HTML > #document
+EDITING DELEGATE: webViewDidBeginEditing:WebViewDidBeginEditingNotification
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+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 784x18
+        RenderText {#text} at (0,0) size 377x18
+          text run at (0,0) width 377: "This tests the caret position for the caret after an inline table."
+      RenderBlock {DIV} at (0,34) size 784x80
+        RenderText {#text} at (0,62) size 21x18
+          text run at (0,62) width 21: "foo"
+        RenderTable {TABLE} at (21,0) size 51x76 [border: (1px solid #999999)]
+          RenderTableSection {TBODY} at (1,1) size 49x74
+            RenderTableRow {TR} at (0,2) size 49x22
+              RenderTableCell {TD} at (2,2) size 45x22 [border: (1px solid #999999)] [r=0 c=0 rs=1 cs=1]
+                RenderText {#text} at (2,2) size 22x18
+                  text run at (2,2) width 22: "this"
+            RenderTableRow {TR} at (0,26) size 49x22
+              RenderTableCell {TD} at (2,26) size 45x22 [border: (1px solid #999999)] [r=1 c=0 rs=1 cs=1]
+                RenderText {#text} at (2,2) size 10x18
+                  text run at (2,2) width 10: "is"
+            RenderTableRow {TR} at (0,50) size 49x22
+              RenderTableCell {TD} at (2,50) size 45x22 [border: (1px solid #999999)] [r=2 c=0 rs=1 cs=1]
+                RenderText {#text} at (2,2) size 41x18
+                  text run at (2,2) width 41: "a table"
+        RenderText {#text} at (72,62) size 22x18
+          text run at (72,62) width 22: "baz"
+caret: position 1 of child 1 {TABLE} of child 2 {DIV} of child 1 {BODY} of child 0 {HTML} of document
diff --git a/LayoutTests/editing/selection/table-caret-3.html b/LayoutTests/editing/selection/table-caret-3.html
new file mode 100644 (file)
index 0000000..3b10b68
--- /dev/null
@@ -0,0 +1,16 @@
+<style>
+table, td {
+    border: 1px solid #999;
+}
+</style>
+
+<p>This tests the caret position for the caret after an inline table.</p>
+
+<div contenteditable="true">foo<table style="display:inline" id="test"><tr><td>this</td></tr><tr><td>is</td></tr><tr><td>a table</td></tr></table>baz</div>
+
+<script>
+var s = window.getSelection();
+var e = document.getElementById("test");
+
+s.setPosition(e, e.childNodes.length);
+</script>
\ No newline at end of file
index 03927f3f688698686464745fb563906cddd11ac9..6dfafd65c5ac850ad4d635fd5ddbccdc3ef1369e 100644 (file)
@@ -1,3 +1,17 @@
+2006-06-23  Justin Garcia  <justin.garcia@apple.com>
+
+        Reviewed by levi
+        
+        <http://bugzilla.opendarwin.org/show_bug.cgi?id=8074>
+        Caret before/after block tables is too small
+        <rdar://problem/4598331>
+        right arrow out of a table shows cursor in a weird place
+
+        * rendering/RenderBox.cpp:
+        (WebCore::RenderBox::caretRect): Don't propagate to children, 
+        VisiblePositions inside containers don't refer to children.
+        Don't use the font height for tables.
+
 2006-06-23  Brady Eidson  <beidson@apple.com>
 
         Reviewed by Kevin.
index 9118da4a433dd4831fe72acf9606053eb2c276b6..aa2ba7cd296c9c5205eb2fd6e97e213c04f4d9d5 100644 (file)
                FAE04190097596C9000540BE /* SVGImageLoader.h in Headers */ = {isa = PBXBuildFile; fileRef = FAE0418E097596C9000540BE /* SVGImageLoader.h */; };
 /* End PBXBuildFile section */
 
+/* Begin PBXBuildStyle section */
+               D0DAA27B0A4C8EF100703DCF /* Development */ = {
+                       isa = PBXBuildStyle;
+                       buildSettings = {
+                               COPY_PHASE_STRIP = NO;
+                       };
+                       name = Development;
+               };
+               D0DAA27C0A4C8EF100703DCF /* Deployment */ = {
+                       isa = PBXBuildStyle;
+                       buildSettings = {
+                               COPY_PHASE_STRIP = YES;
+                       };
+                       name = Deployment;
+               };
+/* End PBXBuildStyle section */
+
 /* Begin PBXContainerItemProxy section */
                DD041FF009D9E3250010AF2A /* PBXContainerItemProxy */ = {
                        isa = PBXContainerItemProxy;
                0867D690FE84028FC02AAC07 /* Project object */ = {
                        isa = PBXProject;
                        buildConfigurationList = 149C284308902B11008A9EFC /* Build configuration list for PBXProject "WebCore" */;
+                       buildSettings = {
+                       };
+                       buildStyles = (
+                               D0DAA27B0A4C8EF100703DCF /* Development */,
+                               D0DAA27C0A4C8EF100703DCF /* Deployment */,
+                       );
                        hasScannedForEncodings = 1;
                        knownRegions = (
                                English,
index 09095fe9721e078657e45cfe114e8092d6059f5a..bdd5dcbcb92de485cdcc91a9e032d123bf702f0b 100644 (file)
@@ -2325,19 +2325,11 @@ void RenderBox::calcAbsoluteVerticalReplaced()
 
 IntRect RenderBox::caretRect(int offset, EAffinity affinity, int* extraWidthToEndOfLine)
 {
-    // FIXME: Is it OK to check only first child instead of picking
-    // right child based on offset? Is it OK to pass the same offset
-    // along to the child instead of offset 0 or whatever?
-
-    // propagate it downwards to its children, someone will feel responsible
-    if (RenderObject* child = firstChild()) {
-        IntRect result = child->caretRect(offset, affinity, extraWidthToEndOfLine);
-        if (!result.isEmpty())
-            return result;
-    }
-
-    // if not, use the extents of this box 
-    // offset 0 means left, offset 1 means right
+    // VisiblePositions at offsets inside containers either a) refer to the positions before/after
+    // those containers (tables and select elements) or b) refer to the position inside an empty block.
+    // 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?
     const int caretWidth = 1;
     IntRect rect(xPos(), yPos(), caretWidth, m_height);
@@ -2359,7 +2351,7 @@ IntRect RenderBox::caretRect(int offset, EAffinity affinity, int* extraWidthToEn
     //
     // FIXME: ignoring :first-line, missing good reason to take care of
     int fontHeight = style()->font().height();
-    if (fontHeight > rect.height() || !isReplaced())
+    if (fontHeight > rect.height() || !isReplaced() && !isTable())
         rect.setHeight(fontHeight);
 
     RenderObject* cb = containingBlock();