Bug 1478604 - Fix RepaintSelectionRunner so that it does something for non-presShell impls. r=masayuki, a=jcristau
authorEmilio Cobos Álvarez <emilio@crisal.io>
Tue, 07 Aug 2018 12:55:21 +0000
changeset 480838 7addc88e15b1e4abedddbbd2fd4fde9de5d4c637
parent 480837 708dd36ae354550076f56695764af5264c6938e8
child 480839 0fc394c4200944c32d4ee096010c16258d4399f8
push id1757
push userffxbld-merge
push dateFri, 24 Aug 2018 17:02:43 +0000
treeherdermozilla-release@736023aebdb1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmasayuki, jcristau
bugs1478604
milestone62.0
Bug 1478604 - Fix RepaintSelectionRunner so that it does something for non-presShell impls. r=masayuki, a=jcristau The regressing bug made RepaintSelectionRunner do nothing for any nsISelectionListener that wasn't a PresShell. Differential Revision: https://phabricator.services.mozilla.com/D2846
editor/libeditor/EditorBase.cpp
layout/base/PresShell.cpp
layout/reftests/selection/1478604-ref.html
layout/reftests/selection/1478604.html
layout/reftests/selection/reftest.list
--- a/editor/libeditor/EditorBase.cpp
+++ b/editor/libeditor/EditorBase.cpp
@@ -4721,21 +4721,16 @@ public:
   explicit RepaintSelectionRunner(nsISelectionController* aSelectionController)
     : Runnable("RepaintSelectionRunner")
     , mSelectionController(aSelectionController)
   {
   }
 
   NS_IMETHOD Run() override
   {
-    nsCOMPtr<nsIPresShell> shell = do_QueryInterface(mSelectionController);
-    if (!shell || shell->IsDestroying()) {
-      return NS_OK;
-    }
-
     mSelectionController->RepaintSelection(
                             nsISelectionController::SELECTION_NORMAL);
     return NS_OK;
   }
 
 private:
   nsCOMPtr<nsISelectionController> mSelectionController;
 };
--- a/layout/base/PresShell.cpp
+++ b/layout/base/PresShell.cpp
@@ -1676,18 +1676,23 @@ PresShell::ScrollSelectionIntoView(RawSe
   RefPtr<nsFrameSelection> frameSelection = mSelection;
   return frameSelection->ScrollSelectionIntoView(
                            ToSelectionType(aRawSelectionType), aRegion, aFlags);
 }
 
 NS_IMETHODIMP
 PresShell::RepaintSelection(RawSelectionType aRawSelectionType)
 {
-  if (!mSelection)
+  if (!mSelection) {
     return NS_ERROR_NULL_POINTER;
+  }
+
+  if (MOZ_UNLIKELY(mIsDestroying)) {
+    return NS_OK;
+  }
 
   RefPtr<nsFrameSelection> frameSelection = mSelection;
   return frameSelection->RepaintSelection(ToSelectionType(aRawSelectionType));
 }
 
 // Make shell be a document observer
 void
 nsIPresShell::BeginObservingDocument()
new file mode 100644
--- /dev/null
+++ b/layout/reftests/selection/1478604-ref.html
@@ -0,0 +1,20 @@
+<!doctype html>
+<html class="reftest-wait">
+<style>
+  input {
+    border: 0;
+  }
+</style>
+<label id="fooLabel" for="foo">Foo label</label>
+<input id="foo" type="text" value="foo" >
+<label id="barLabel" for="bar">Bar label</label>
+<input id="bar" type="text" value="bar">
+<script>
+onload = function() {
+  barLabel.click();
+  requestAnimationFrame(() => {
+    document.documentElement.className = "";
+  });
+}
+</script>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/selection/1478604.html
@@ -0,0 +1,23 @@
+<!doctype html>
+<html class="reftest-wait">
+<style>
+  input {
+    border: 0;
+  }
+</style>
+<label id="fooLabel" for="foo">Foo label</label>
+<input id="foo" type="text" value="foo" >
+<label id="barLabel" for="bar">Bar label</label>
+<input id="bar" type="text" value="bar">
+<script>
+onload = function() {
+  fooLabel.click();
+  requestAnimationFrame(() => {
+    barLabel.click();
+    requestAnimationFrame(() => {
+      document.documentElement.className = "";
+    });
+  });
+}
+</script>
+</html>
--- a/layout/reftests/selection/reftest.list
+++ b/layout/reftests/selection/reftest.list
@@ -46,8 +46,9 @@ fuzzy-if(OSX==1010,9,1) fuzzy-if(OSX&&sk
 == invalidation-2b.html invalidation-2-ref.html
 == invalidation-2c.html invalidation-2-ref.html
 == invalidation-2d.html invalidation-2-ref.html
 == invalidation-2e.html invalidation-2-ref.html
 == invalidation-2f.html invalidation-2-ref.html
 fuzzy(7,2) fuzzy-if(OSX,1,1) fails-if(isDebugBuild&&!browserIsRemote) fails-if(Android) random-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)) needs-focus == rtl-selection-with-decoration.html rtl-selection-with-decoration-ref.html # Bug 1392106
 fails-if(isDebugBuild&&!browserIsRemote) fails-if(Android) needs-focus == semitransparent-decoration-line.html semitransparent-decoration-line-ref.html
 fuzzy-if(OSX,1,6) fails-if(isDebugBuild&&!browserIsRemote) fails-if(Android) needs-focus == writing-mode.html writing-mode-ref.html
+needs-focus == 1478604.html 1478604-ref.html