Bug 1525509 - Don't rebuild the frame tree to un-suppress whitespace if we cannot flush layout. r=dholbert, a=lizzard
authorEmilio Cobos Álvarez <emilio@crisal.io>
Fri, 15 Feb 2019 06:29:54 +0000
changeset 516047 d720aecf3197eb9dc9a99f1e826122158e95bcd3
parent 516046 42c46d6cd486fca17442648ef856b8f700c13391
child 516048 e4f640b123bbcdd59396be184689db5dd0c6d69f
push id1953
push userffxbld-merge
push dateMon, 11 Mar 2019 12:10:20 +0000
treeherdermozilla-release@9c35dcbaa899 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdholbert, lizzard
bugs1525509
milestone66.0
Bug 1525509 - Don't rebuild the frame tree to un-suppress whitespace if we cannot flush layout. r=dholbert, a=lizzard The information we'd get would be meaningless anyway in a fully new frame tree if we don't run layout. We should consider whether we need to un-suppress whitespace at all here... Differential Revision: https://phabricator.services.mozilla.com/D19724
dom/base/nsRange.cpp
--- a/dom/base/nsRange.cpp
+++ b/dom/base/nsRange.cpp
@@ -2727,23 +2727,28 @@ static void ExtractRectFromOffset(nsIFra
 static nsTextFrame* GetTextFrameForContent(nsIContent* aContent,
                                            bool aFlushLayout) {
   Document* doc = aContent->OwnerDoc();
   nsIPresShell* presShell = doc->GetShell();
   if (!presShell) {
     return nullptr;
   }
 
-  const bool frameWillBeUnsuppressed =
-      presShell->FrameConstructor()->EnsureFrameForTextNodeIsCreatedAfterFlush(
-          static_cast<CharacterData*>(aContent));
+  // Try to un-suppress whitespace if needed, but only if we'll be able to flush
+  // to immediately see the results of the un-suppression. If we can't flush
+  // here, then calling EnsureFrameForTextNodeIsCreatedAfterFlush would be
+  // pointless anyway.
   if (aFlushLayout) {
-    doc->FlushPendingNotifications(FlushType::Layout);
-  } else if (frameWillBeUnsuppressed) {
-    doc->FlushPendingNotifications(FlushType::Frames);
+    const bool frameWillBeUnsuppressed =
+        presShell->FrameConstructor()
+            ->EnsureFrameForTextNodeIsCreatedAfterFlush(
+                static_cast<CharacterData*>(aContent));
+    if (frameWillBeUnsuppressed) {
+      doc->FlushPendingNotifications(FlushType::Layout);
+    }
   }
 
   nsIFrame* frame = aContent->GetPrimaryFrame();
   if (!frame || !frame->IsTextFrame()) {
     return nullptr;
   }
   return static_cast<nsTextFrame*>(frame);
 }