Bug 1429027 - Include caret area for caret frames when calculating dirty region for retained display list draft
authorMiko Mynttinen <mikokm@gmail.com>
Fri, 19 Jan 2018 18:08:27 +0100
changeset 722746 355acf7483f9a759bf181616ffface759df0a1fb
parent 722672 6ffbba9ce0ef9ec77a63445f068f2e218ed4830f
child 746680 22b0bac54e889be24cfaf761b7e925ee9ab1f57a
push id96225
push userbmo:mikokm@gmail.com
push dateFri, 19 Jan 2018 19:25:00 +0000
bugs1429027
milestone59.0a1
Bug 1429027 - Include caret area for caret frames when calculating dirty region for retained display list MozReview-Commit-ID: JGs31sHNBvf
layout/painting/RetainedDisplayListBuilder.cpp
layout/reftests/display-list/1429027-1-ref.html
layout/reftests/display-list/1429027-1.html
layout/reftests/display-list/reftest.list
--- a/layout/painting/RetainedDisplayListBuilder.cpp
+++ b/layout/painting/RetainedDisplayListBuilder.cpp
@@ -863,16 +863,23 @@ RetainedDisplayListBuilder::ComputeRebui
     // We store that as a dirty rect on that stacking context so that we build
     // all items that intersect the changed frame within the stacking context,
     // and then we use MarkFrameForDisplayIfVisible to make sure the stacking
     // context itself gets built. We don't need to build items that intersect outside
     // of the stacking context, since we know the stacking context item exists in
     // the old list, so we can trivially merge without needing other items.
     nsRect overflow = f->GetVisualOverflowRectRelativeToSelf();
 
+    // If the modified frame is also a caret frame, include the caret area.
+    // This is needed because some frames (for example text frames without text)
+    // might have an empty overflow rect.
+    if (f == mBuilder.GetCaretFrame()) {
+      overflow.UnionRect(overflow, mBuilder.GetCaretRect());
+    }
+
     ProcessFrame(f, mBuilder, &agr, overflow, mBuilder.RootReferenceFrame(),
                  aOutFramesWithProps, true);
 
     aOutDirty->UnionRect(*aOutDirty, overflow);
     CRR_LOG("Adding area to root draw area: %d %d %d %d\n",
             overflow.x, overflow.y, overflow.width, overflow.height);
 
     // If we get changed frames from multiple AGRS, then just give up as it gets really complex to
new file mode 100644
--- /dev/null
+++ b/layout/reftests/display-list/1429027-1-ref.html
@@ -0,0 +1,19 @@
+<!DOCTYPE html>
+<html class="reftest-wait">
+<head>
+  <title>Bug 1429027 - No caret</title>
+  <meta charset="utf-8">
+</head>
+<body>
+<form autocomplete="off">
+  <input autofocus value="" onfocus="done()">
+</form>
+
+<script type="text/javascript">
+function done() {
+  document.documentElement.removeAttribute("class");
+}
+window.addEventListener("MozReftestInvalidate", doTest);
+</script>
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/display-list/1429027-1.html
@@ -0,0 +1,35 @@
+<!DOCTYPE html>
+<html class="reftest-wait">
+<head>
+  <title>Bug 1429027 - No caret</title>
+  <meta charset="utf-8">
+</head>
+<body>
+<form autocomplete="off">
+  <input autofocus value="test">
+</form>
+
+<script type="text/javascript">
+function done() {
+  document.documentElement.removeAttribute("class");
+}
+
+function focus() {
+  document.querySelector("input").focus();
+  setTimeout(done, 0);
+}
+
+function clearInput() {
+  document.querySelector("input").value = "";
+  setTimeout(focus, 0);
+}
+
+function doTest() {
+  document.querySelector("input").focus();
+  setTimeout(clearInput, 0);
+}
+
+window.addEventListener("MozReftestInvalidate", doTest);
+</script>
+</body>
+</html>
--- a/layout/reftests/display-list/reftest.list
+++ b/layout/reftests/display-list/reftest.list
@@ -11,8 +11,9 @@ skip-if(!retainedDisplayList) == retaine
 == retained-dl-zindex-1.html retained-dl-zindex-1-ref.html
 == retained-dl-zindex-2.html retained-dl-zindex-2-ref.html
 fuzzy(1,235200) == 1413073.html 1413073-ref.html
 == 1416291.html 1416291-ref.html
 == 1417601-1.html 1417601-1-ref.html
 == 1418945-1.html 1418945-1-ref.html
 skip-if(Android) == 1428993-1.html 1428993-1-ref.html
 == 1428993-2.html 1428993-2-ref.html
+needs-focus == 1429027-1.html 1429027-1-ref.html