<rdar://problem/14637103> REGRESSION (r153060?): Microphone appears in the way
authorap@apple.com <ap@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 5 Aug 2013 21:56:15 +0000 (21:56 +0000)
committerap@apple.com <ap@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 5 Aug 2013 21:56:15 +0000 (21:56 +0000)
        of text when dictating an e-mail
        https://bugs.webkit.org/show_bug.cgi?id=119496

        Reviewed by Ryosuke Niwa.

        Test: platform/mac/editing/input/firstrectforcharacterrange-caret-in-br.html

        * rendering/RenderObject.cpp: (WebCore::RenderObject::absoluteBoundingBoxRectForRange):
        FloatRect::unite() doesn't preserve empty rects, which we need here.
        We alrady handle the case of collapsed range in Editor::firstRectForRange(), and
        this is similar, but we can't currently cover both with one simple fix.

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

LayoutTests/ChangeLog
LayoutTests/platform/mac/editing/input/firstrectforcharacterrange-caret-in-br-expected.txt [new file with mode: 0644]
LayoutTests/platform/mac/editing/input/firstrectforcharacterrange-caret-in-br.html [new file with mode: 0644]
LayoutTests/platform/wk2/TestExpectations
Source/WebCore/ChangeLog
Source/WebCore/rendering/RenderObject.cpp

index 055ec87..fb499a4 100644 (file)
@@ -1,3 +1,17 @@
+2013-08-05  Alexey Proskuryakov  <ap@apple.com>
+
+        <rdar://problem/14637103> REGRESSION (r153060?): Microphone appears in the way
+        of text when dictating an e-mail
+        https://bugs.webkit.org/show_bug.cgi?id=119496
+
+        Reviewed by Ryosuke Niwa.
+
+        * platform/mac/editing/input/firstrectforcharacterrange-caret-in-br-expected.txt: Added.
+        * platform/mac/editing/input/firstrectforcharacterrange-caret-in-br.html: Added.
+
+        * platform/wk2/TestExpectations: textInputController.firstRectForCharacterRange is
+        not available in WTR.
+
 2013-08-05  Morten Stenshorne  <mstensho@opera.com>
 
         Region based columns not painted correctly in non-default writing-modes
diff --git a/LayoutTests/platform/mac/editing/input/firstrectforcharacterrange-caret-in-br-expected.txt b/LayoutTests/platform/mac/editing/input/firstrectforcharacterrange-caret-in-br-expected.txt
new file mode 100644 (file)
index 0000000..3b28abc
--- /dev/null
@@ -0,0 +1,9 @@
+PASS xLocation > 0 is true
+PASS width is 0
+PASS height > 10 is true
+PASS height < 30 is true
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
+
diff --git a/LayoutTests/platform/mac/editing/input/firstrectforcharacterrange-caret-in-br.html b/LayoutTests/platform/mac/editing/input/firstrectforcharacterrange-caret-in-br.html
new file mode 100644 (file)
index 0000000..a2c313d
--- /dev/null
@@ -0,0 +1,32 @@
+<head>
+<script src="../../../../fast/js/resources/js-test-pre.js"></script>
+</head>
+<body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;">a
+<div><br></div>
+<script>
+document.designMode='on';
+window.getSelection().setPosition(document.body, 2);
+
+if (window.textInputController) {
+    var firstRect = textInputController.firstRectForCharacterRange(2, 1);
+
+    // This should be a reasonable rect for a caret.
+    var xLocation = firstRect[0];
+    var width = firstRect[2];
+    var height = firstRect[3];
+    shouldBeTrue("xLocation > 0");
+    shouldBe("width", "0");
+    shouldBeTrue("height > 10");
+    shouldBeTrue("height < 30");
+
+    // Delete test data for nicer output.
+    document.execCommand("Delete");
+    document.execCommand("Delete");
+} else {
+    debug("To test manually, invoke Dictation. Its popover should be positioned reasonably.");
+}
+</script>
+<div id=result></div>
+</body>
+<script src="../../../../fast/js/resources/js-test-post.js"></script>
+</html>
index 8dc3d5e..7c41b53 100644 (file)
@@ -125,6 +125,7 @@ fast/text/international/thai-cursor-position.html
 platform/mac/editing/input/5576619.html
 platform/mac/editing/input/bold-node.html
 platform/mac/editing/input/caret-primary-bidi.html
+platform/mac/editing/input/firstrectforcharacterrange-caret-in-br.html
 platform/mac/editing/input/firstrectforcharacterrange-plain.html
 platform/mac/editing/input/firstrectforcharacterrange-styled.html
 platform/mac/editing/input/firstrectforcharacterrange-vertical.html
index 39078a7..3bce35b 100644 (file)
@@ -1,3 +1,18 @@
+2013-08-05  Alexey Proskuryakov  <ap@apple.com>
+
+        <rdar://problem/14637103> REGRESSION (r153060?): Microphone appears in the way
+        of text when dictating an e-mail
+        https://bugs.webkit.org/show_bug.cgi?id=119496
+
+        Reviewed by Ryosuke Niwa.
+
+        Test: platform/mac/editing/input/firstrectforcharacterrange-caret-in-br.html
+
+        * rendering/RenderObject.cpp: (WebCore::RenderObject::absoluteBoundingBoxRectForRange):
+        FloatRect::unite() doesn't preserve empty rects, which we need here.
+        We alrady handle the case of collapsed range in Editor::firstRectForRange(), and
+        this is similar, but we can't currently cover both with one simple fix.
+
 2013-08-05  Morten Stenshorne  <mstensho@opera.com>
 
         Region based columns not painted correctly in non-default writing-modes
index b94db34..b937648 100644 (file)
@@ -1243,9 +1243,12 @@ FloatRect RenderObject::absoluteBoundingBoxRectForRange(const Range* range)
     Vector<FloatQuad> quads;
     range->textQuads(quads);
 
-    FloatRect result;
-    for (size_t i = 0; i < quads.size(); ++i)
-        result.unite(quads[i].boundingBox());
+    if (quads.isEmpty())
+        return FloatRect();
+
+    FloatRect result = quads[0].boundingBox();
+    for (size_t i = 1; i < quads.size(); ++i)
+        result.uniteEvenIfEmpty(quads[i].boundingBox());
 
     return result;
 }