Bug 1504592 - Mark the right frame modified when caret changes. r=tnikkel, a=jcristau
authorMiko Mynttinen <mikokm@gmail.com>
Thu, 08 Nov 2018 23:28:49 +0000
changeset 501216 c6949142e640b8d3727055053ee471b3eeb7d2e6
parent 501215 b9bddcf6d4659e0c6b764de1dc6fdcc7727db3e0
child 501217 23d0264564e5dd6a1ed4f9cce45188f7c60d28c2
push id1864
push userffxbld-merge
push dateMon, 03 Dec 2018 15:51:40 +0000
treeherdermozilla-release@f040763d99ad [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstnikkel, jcristau
bugs1504592
milestone64.0
Bug 1504592 - Mark the right frame modified when caret changes. r=tnikkel, a=jcristau Differential Revision: https://phabricator.services.mozilla.com/D11316
layout/base/nsCaret.cpp
--- a/layout/base/nsCaret.cpp
+++ b/layout/base/nsCaret.cpp
@@ -428,34 +428,24 @@ void
 nsCaret::SchedulePaint(Selection* aSelection)
 {
   Selection* selection;
   if (aSelection) {
     selection = aSelection;
   } else {
     selection = GetSelection();
   }
-  nsINode* focusNode;
-  if (mOverrideContent) {
-    focusNode = mOverrideContent;
-  } else if (selection) {
-    focusNode = selection->GetFocusNode();
-  } else {
-    return;
+
+  int32_t frameOffset;
+  nsIFrame* frame = GetFrameAndOffset(
+    selection, mOverrideContent, mOverrideOffset, &frameOffset);
+
+  if (frame) {
+    frame->SchedulePaint();
   }
-  if (!focusNode || !focusNode->IsContent()) {
-    return;
-  }
-  nsIFrame* f = focusNode->AsContent()->GetPrimaryFrame();
-  if (!f) {
-    return;
-  }
-  // This may not be the correct continuation frame, but that's OK since we're
-  // just scheduling a paint of the window (or popup).
-  f->SchedulePaint();
 }
 
 void nsCaret::SetVisibilityDuringSelection(bool aVisibility)
 {
   mShowDuringSelection = aVisibility;
   SchedulePaint();
 }