Bug 1510942 - Fix the position of the caret when the caret frame is a reference frame. r=mattwoodrow
authorEmilio Cobos Álvarez <emilio@crisal.io>
Fri, 30 Nov 2018 06:19:21 +0000
changeset 505360 1894e5ca0523dcf9b19985df4b8d1ad8659623ef
parent 505359 99426a6a77bf8ddfb334ed052eb18e2a9bc48122
child 505361 b8880c9c9151cdc85e8ce685d5667a57443da16b
push id10290
push userffxbld-merge
push dateMon, 03 Dec 2018 16:23:23 +0000
treeherdermozilla-beta@700bed2445e6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmattwoodrow
bugs1510942
milestone65.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 1510942 - Fix the position of the caret when the caret frame is a reference frame. r=mattwoodrow This is consistent with what we do for non-stacking-contexts. The GetCaretFrame() == child check may be able to go away, I'm not sure, so I've left it for now. Differential Revision: https://phabricator.services.mozilla.com/D13384
layout/base/tests/bug1510942-1-ref.html
layout/base/tests/bug1510942-1.html
layout/base/tests/bug1510942-2-ref.html
layout/base/tests/bug1510942-2.html
layout/base/tests/mochitest.ini
layout/base/tests/test_reftests_with_caret.html
layout/generic/nsFrame.cpp
new file mode 100644
--- /dev/null
+++ b/layout/base/tests/bug1510942-1-ref.html
@@ -0,0 +1,20 @@
+<!doctype html>
+<html class="reftest-wait">
+<meta charset="utf-8">
+<title>Test reference</title>
+<script src="/tests/SimpleTest/EventUtils.js"></script>
+<script src="/tests/SimpleTest/SimpleTest.js"></script>
+<style>
+  #editable {
+    height: 300px;
+    width: 100px;
+    outline: 1px solid black;
+  }
+</style>
+<div id="editable" contenteditable></div>
+<script>
+SimpleTest.waitForFocus(function() {
+  document.getElementById("editable").focus();
+  document.documentElement.className ="";
+});
+</script>
new file mode 100644
--- /dev/null
+++ b/layout/base/tests/bug1510942-1.html
@@ -0,0 +1,21 @@
+<!doctype html>
+<html class="reftest-wait">
+<meta charset="utf-8">
+<title>Test for bug 1510942: Caret in a transformed empty block</title>
+<script src="/tests/SimpleTest/EventUtils.js"></script>
+<script src="/tests/SimpleTest/SimpleTest.js"></script>
+<style>
+  #editable {
+    height: 300px;
+    width: 100px;
+    outline: 1px solid black;
+    transform: translateZ(0);
+  }
+</style>
+<div id="editable" contenteditable></div>
+<script>
+SimpleTest.waitForFocus(function() {
+  document.getElementById("editable").focus();
+  document.documentElement.className ="";
+});
+</script>
new file mode 100644
--- /dev/null
+++ b/layout/base/tests/bug1510942-2-ref.html
@@ -0,0 +1,4 @@
+<!doctype html>
+<meta charset="utf-8">
+<title>Test reference</title>
+<!-- intentionally blank -->
new file mode 100644
--- /dev/null
+++ b/layout/base/tests/bug1510942-2.html
@@ -0,0 +1,21 @@
+<!doctype html>
+<html class="reftest-wait">
+<meta charset="utf-8">
+<title>Test for bug 1510942: Caret in a transformed empty block</title>
+<script src="/tests/SimpleTest/EventUtils.js"></script>
+<script src="/tests/SimpleTest/SimpleTest.js"></script>
+<style>
+  #editable {
+    height: 300px;
+    width: 100px;
+    outline: 1px solid black;
+    opacity: 0;
+  }
+</style>
+<div id="editable" contenteditable></div>
+<script>
+SimpleTest.waitForFocus(function() {
+  document.getElementById("editable").focus();
+  document.documentElement.className ="";
+});
+</script>
--- a/layout/base/tests/mochitest.ini
+++ b/layout/base/tests/mochitest.ini
@@ -318,16 +318,20 @@ support-files =
   bug1423331-2.html
   bug1423331-2-ref.html
   bug1423331-3.html
   bug1423331-4.html
   bug1484094-1.html
   bug1484094-1-ref.html
   bug1484094-2.html
   bug1484094-2-ref.html
+  bug1510942-1.html
+  bug1510942-1-ref.html
+  bug1510942-2.html
+  bug1510942-2-ref.html
   image_rgrg-256x256.png
   input-invalid-ref.html
   input-maxlength-invalid-change.html
   input-maxlength-ui-invalid-change.html
   input-maxlength-ui-valid-change.html
   input-maxlength-valid-before-change.html
   input-maxlength-valid-change.html
   input-minlength-invalid-change.html
--- a/layout/base/tests/test_reftests_with_caret.html
+++ b/layout/base/tests/test_reftests_with_caret.html
@@ -206,16 +206,18 @@ var tests = [
     // [ 'bug1423331-4.html' , 'bug1423331-2-ref.html' ] ,
     [ 'bug1484094-1.html' , 'bug1484094-1-ref.html' ] ,
     [ 'bug1484094-2.html' , 'bug1484094-2-ref.html' ] ,
     [ 'bug1506547-1.html' , 'bug1506547-2.html' ] ,
     [ 'bug1506547-2.html' , 'bug1506547-3.html' ] ,
     [ 'bug1506547-4.html' , 'bug1506547-4-ref.html' ] ,
     [ 'bug1506547-5.html' , 'bug1506547-5-ref.html' ] ,
     [ 'bug1506547-6.html' , 'bug1506547-5-ref.html' ] ,
+    [ 'bug1510942-1.html' , 'bug1510942-1-ref.html' ] ,
+    [ 'bug1510942-2.html' , 'bug1510942-2-ref.html' ] ,
     function() {SpecialPowers.pushPrefEnv({'clear': [['layout.accessiblecaret.enabled']]}, nextTest);} ,
 ];
 
 if (!navigator.appVersion.includes("Android")) {
   tests.push([ 'bug512295-1.html' , 'bug512295-1-ref.html' ]);
   tests.push([ 'bug512295-2.html' , 'bug512295-2-ref.html' ]);
   tests.push([ 'bug923376.html'   , 'bug923376-ref.html'   ]);
   tests.push(function() {SpecialPowers.pushPrefEnv({'set': [['layout.css.overflow-clip-box.enabled', true]]}, nextTest);});
--- a/layout/generic/nsFrame.cpp
+++ b/layout/generic/nsFrame.cpp
@@ -3177,16 +3177,17 @@ nsIFrame::BuildDisplayListForStackingCon
           hitTestInfo->mArea, hitTestInfo->mFlags);
       }
     }
 
     MarkAbsoluteFramesForDisplayList(aBuilder);
     aBuilder->Check();
     BuildDisplayList(aBuilder, set);
     aBuilder->Check();
+    aBuilder->DisplayCaret(this, set.Content());
 
     // Blend modes are a real pain for retained display lists. We build a blend
     // container item if the built list contains any blend mode items within
     // the current stacking context. This can change without an invalidation
     // to the stacking context frame, or the blend mode frame (e.g. by moving
     // an intermediate frame).
     // When we gain/remove a blend container item, we need to mark this frame
     // as invalid and have the full display list for merging to track
@@ -3851,17 +3852,17 @@ nsIFrame::BuildDisplayListForChild(nsDis
       aBuilder->SetContainsBlendMode(true);
     }
     // True stacking context.
     // For stacking contexts, BuildDisplayListForStackingContext handles
     // clipping and MarkAbsoluteFramesForDisplayList.
     nsDisplayListBuilder::AutoContainerASRTracker contASRTracker(aBuilder);
     child->BuildDisplayListForStackingContext(aBuilder, &list, &canSkipWrapList);
     wrapListASR = contASRTracker.GetContainerASR();
-    if (aBuilder->DisplayCaret(child, &list)) {
+    if (aBuilder->GetCaretFrame() == child) {
       canSkipWrapList = false;
     }
   } else {
     Maybe<nsRect> clipPropClip =
       child->GetClipPropClipRect(disp, effects, child->GetSize());
     if (clipPropClip) {
       aBuilder->IntersectVisibleRect(*clipPropClip);
       aBuilder->IntersectDirtyRect(*clipPropClip);