Bug 1525509 - Don't rebuild the frame tree to un-suppress whitespace if we cannot flush layout. r=dholbert
authorEmilio Cobos Álvarez <emilio@crisal.io>
Fri, 15 Feb 2019 06:29:54 +0000
changeset 459517 15158d921194d94000045378b00d8944d6dbb0e3
parent 459516 c5f15b5682b546a9b770fc2bcb355de32d79b089
child 459518 996e8765c85a16605c098144e8e95f97e89b70ea
push id111964
push usercsabou@mozilla.com
push dateFri, 15 Feb 2019 18:54:44 +0000
treeherdermozilla-inbound@db3c4f905082 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdholbert
bugs1525509
milestone67.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 1525509 - Don't rebuild the frame tree to un-suppress whitespace if we cannot flush layout. r=dholbert 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);
 }