Reviewed by Adele.
authordarin <darin@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 12 May 2006 16:45:02 +0000 (16:45 +0000)
committerdarin <darin@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 12 May 2006 16:45:02 +0000 (16:45 +0000)
        - fix http://bugzilla.opendarwin.org/show_bug.cgi?id=8715
          REGRESSION: Caret to the right of an image is a big black rectangle.

        * rendering/RenderBox.cpp: (WebCore::RenderBox::caretRect): Move caret to the
        right side of the rect when the offset is non-zero, rather than expanding it.

        * manual-tests/caret-image.html: Added.

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

WebCore/ChangeLog
WebCore/manual-tests/caret-image.html [new file with mode: 0644]
WebCore/rendering/RenderBox.cpp

index 54308a9a94f7a1a63f29fd88c2e5d6f6890735e3..bfa7174d3ceb8bbab3bc3f8276f76b8f89f3db3e 100644 (file)
@@ -1,3 +1,15 @@
+2006-05-12  Darin Adler  <darin@apple.com>
+
+        Reviewed by Adele.
+
+        - fix http://bugzilla.opendarwin.org/show_bug.cgi?id=8715
+          REGRESSION: Caret to the right of an image is a big black rectangle.
+
+        * rendering/RenderBox.cpp: (WebCore::RenderBox::caretRect): Move caret to the
+        right side of the rect when the offset is non-zero, rather than expanding it.
+
+        * manual-tests/caret-image.html: Added.
+
 2006-05-12  Mitz Pettel  <opendarwin.org@mitzpettel.com>
 
         Reviewed and landed by Anders.
diff --git a/WebCore/manual-tests/caret-image.html b/WebCore/manual-tests/caret-image.html
new file mode 100644 (file)
index 0000000..a6dff5e
--- /dev/null
@@ -0,0 +1,9 @@
+<p>
+Test to see if caret works correctly to the right of an image.
+If the test is successful, the caret will look thin as usual.
+If the test fails, the caret will be a big black box the size of the image.
+</p>
+
+<div id="test" contenteditable="true">free<img src="resources/webkit-background.png">lunch</div>
+
+<script>window.getSelection().setPosition(document.getElementById("test"), 2);</script>
index b130356176da2b8954c80755eb44b4f8a635bc63..95502842d748bbe164b0d13ce7b8cda87e02630f 100644 (file)
@@ -1791,7 +1791,7 @@ IntRect RenderBox::caretRect(int offset, EAffinity affinity, int* extraWidthToEn
     const int caretWidth = 1;
     IntRect rect(xPos(), yPos(), caretWidth, m_height);
     if (offset != 0)
-        rect.setWidth(m_width - caretWidth);
+        rect.move(IntSize(m_width - caretWidth, 0));
     if (InlineBox* box = inlineBoxWrapper()) {
         RootInlineBox* rootBox = box->root();
         int top = rootBox->topOverflow();
@@ -1816,11 +1816,11 @@ IntRect RenderBox::caretRect(int offset, EAffinity affinity, int* extraWidthToEn
     if (!cb || !cb->absolutePosition(cbx, cby))
         // No point returning a relative position.
         return IntRect();
-    rect.move(cbx, cby);
 
     if (extraWidthToEndOfLine)
-        *extraWidthToEndOfLine = m_width - rect.right();
+        *extraWidthToEndOfLine = xPos() + m_width - rect.right();
 
+    rect.move(cbx, cby);
     return rect;
 }