Bug 1082486 - Part 5 - Hide touch caret when PresShell is suppressing painting. r=roc
authorTing-Yu Lin <tlin@mozilla.com>
Thu, 16 Oct 2014 05:08:00 +0200
changeset 211106 2ec24bc9a5dd981f9db241322d92ea8ab5fde5dd
parent 211105 b66bcf105809c23610c6e9ad247efb7e2ad102d0
child 211107 c76f0ce30414aaac75bde463dd51f9e564e45300
push id50644
push usercbook@mozilla.com
push dateMon, 20 Oct 2014 08:01:27 +0000
treeherdermozilla-inbound@2c52ec780e67 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersroc
bugs1082486
milestone36.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 1082486 - Part 5 - Hide touch caret when PresShell is suppressing painting. r=roc When loading an html, painting is suppressed in PresShell. Therefore the rect of nsCaret or the rect of nearest ancestor scroll frames will not be correct. Touch caret will hide incorrectly because it cannot get the necessary rect to calculate its position. I added a condition in IsDisplayable() to skip when painting is suppressed. Touch caret should sync its visibility with nsCaret again when painting is unsuppressed, and those rects needed by touch caret should be ready then.
layout/base/TouchCaret.cpp
layout/base/nsPresShell.cpp
--- a/layout/base/TouchCaret.cpp
+++ b/layout/base/TouchCaret.cpp
@@ -401,16 +401,21 @@ TouchCaret::IsDisplayable()
   }
 
   dom::Element* touchCaretElement = presShell->GetTouchCaretElement();
   if (!touchCaretElement) {
     TOUCHCARET_LOG("No touch caret frame element!");
     return false;
   }
 
+  if (presShell->IsPaintingSuppressed()) {
+    TOUCHCARET_LOG("PresShell is suppressing painting!");
+    return false;
+  }
+
   if (!caret->IsVisible()) {
     TOUCHCARET_LOG("Caret is not visible!");
     return false;
   }
 
   nsRect focusRect;
   nsIFrame* focusFrame = caret->GetGeometry(&focusRect);
   if (!focusFrame) {
--- a/layout/base/nsPresShell.cpp
+++ b/layout/base/nsPresShell.cpp
@@ -3938,17 +3938,17 @@ PresShell::UnsuppressAndInvalidate()
 
   mPaintingSuppressed = false;
   nsIFrame* rootFrame = mFrameConstructor->GetRootFrame();
   if (rootFrame) {
     // let's assume that outline on a root frame is not supported
     rootFrame->InvalidateFrame();
 
     if (mTouchCaret) {
-      mTouchCaret->UpdatePositionIfNeeded();
+      mTouchCaret->SyncVisibilityWithCaret();
     }
   }
 
   // now that painting is unsuppressed, focus may be set on the document
   nsPIDOMWindow *win = mDocument->GetWindow();
   if (win)
     win->SetReadyForFocus();