Bug 1429027 - Include caret area for caret frames when calculating dirty region for retained display list r=mattwoodrow
authorMiko Mynttinen <mikokm@gmail.com>
Fri, 19 Jan 2018 18:08:27 +0100
changeset 454364 e41964b766df5a2e08ed161073ddfb085562732c
parent 454363 0eb38895885ae0dd84dc6021f40ea2db5024a30c
child 454365 86e363a748167d24901dff1bd6b41da7b6bd6f66
push id1648
push usermtabara@mozilla.com
push dateThu, 01 Mar 2018 12:45:47 +0000
treeherdermozilla-release@cbb9688c2eeb [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmattwoodrow
bugs1429027
milestone59.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1429027 - Include caret area for caret frames when calculating dirty region for retained display list r=mattwoodrow 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