Bug 1262930 - Remove "no inner window" warning during TabChild::Init() by skipping ShouldShowFocusRing check. r=khuey
☠☠ backed out by b4d52dc84179 ☠ ☠
authorBen Tian <btian@mozilla.com>
Wed, 20 Jul 2016 11:47:27 +0800
changeset 305836 ca723ddedfe522fbe0857083a63a5a2483cf0173
parent 305835 44888990d2df44e5f81ccd48fe9bee2416142c5a
child 305837 1afe2708eef591cbef2b709fe6bff6371d7dc3ab
push id79679
push userryanvm@gmail.com
push dateWed, 20 Jul 2016 14:30:49 +0000
treeherdermozilla-inbound@2bb2126f4034 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskhuey
bugs1262930
milestone50.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 1262930 - Remove "no inner window" warning during TabChild::Init() by skipping ShouldShowFocusRing check. r=khuey
dom/base/nsGlobalWindow.cpp
dom/base/nsPIDOMWindow.h
dom/ipc/TabChild.cpp
--- a/dom/base/nsGlobalWindow.cpp
+++ b/dom/base/nsGlobalWindow.cpp
@@ -3687,16 +3687,48 @@ nsPIDOMWindow<T>::MaybeCreateDoc()
   if (nsIDocShell* docShell = GetDocShell()) {
     // Note that |document| here is the same thing as our mDoc, but we
     // don't have to explicitly set the member variable because the docshell
     // has already called SetNewDocument().
     nsCOMPtr<nsIDocument> document = docShell->GetDocument();
   }
 }
 
+void
+nsPIDOMWindowOuter::SetInitialKeyboardIndicators(
+  UIStateChangeType aShowAccelerators, UIStateChangeType aShowFocusRings)
+{
+  MOZ_ASSERT(IsOuterWindow());
+  MOZ_ASSERT(!GetCurrentInnerWindow());
+
+  nsPIDOMWindowOuter* piWin = GetPrivateRoot();
+  if (!piWin) {
+    return;
+  }
+
+  MOZ_ASSERT(piWin == AsOuter());
+
+  // only change the flags that have been modified
+  nsCOMPtr<nsPIWindowRoot> windowRoot = do_QueryInterface(mChromeEventHandler);
+  if (!windowRoot) {
+    return;
+  }
+
+  if (aShowAccelerators != UIStateChangeType_NoChange) {
+    windowRoot->SetShowAccelerators(aShowAccelerators == UIStateChangeType_Set);
+  }
+  if (aShowFocusRings != UIStateChangeType_NoChange) {
+    windowRoot->SetShowFocusRings(aShowFocusRings == UIStateChangeType_Set);
+  }
+
+  nsContentUtils::SetKeyboardIndicatorsOnRemoteChildren(GetOuterWindow(),
+                                                        aShowAccelerators,
+                                                        aShowFocusRings);
+}
+
 Element*
 nsPIDOMWindowOuter::GetFrameElementInternal() const
 {
   MOZ_ASSERT(IsOuterWindow());
   return mFrameElement;
 }
 
 void
--- a/dom/base/nsPIDOMWindow.h
+++ b/dom/base/nsPIDOMWindow.h
@@ -316,17 +316,17 @@ public:
   /**
    * Call this to check whether some node (this window, its document,
    * or content in that document) has a paint event listener.
    */
   bool HasPaintEventListeners()
   {
     return mMayHavePaintEventListener;
   }
-  
+
   /**
    * Call this to indicate that some node (this window, its document,
    * or content in that document) has a touch event listener.
    */
   void SetHasTouchEventListeners()
   {
     if (!mMayHaveTouchEventListener) {
       mMayHaveTouchEventListener = true;
@@ -842,16 +842,22 @@ public:
   nsPIDOMWindowInner* EnsureInnerWindow()
   {
     MOZ_ASSERT(IsOuterWindow());
     // GetDoc forces inner window creation if there isn't one already
     GetDoc();
     return GetCurrentInnerWindow();
   }
 
+  /**
+   * Set initial keyboard indicator state for accelerators and focus rings.
+   */
+  void SetInitialKeyboardIndicators(UIStateChangeType aShowAccelerators,
+                                    UIStateChangeType aShowFocusRings);
+
   // Internal getter/setter for the frame element, this version of the
   // getter crosses chrome boundaries whereas the public scriptable
   // one doesn't for security reasons.
   mozilla::dom::Element* GetFrameElementInternal() const;
   void SetFrameElementInternal(mozilla::dom::Element* aFrameElement);
 
   bool IsActive()
   {
--- a/dom/ipc/TabChild.cpp
+++ b/dom/ipc/TabChild.cpp
@@ -838,17 +838,17 @@ TabChild::Init()
   // XXX: ideally, we would set a chrome event handler earlier,
   // and all windows, even the root one, will use the docshell one.
   nsCOMPtr<nsPIDOMWindowOuter> window = do_GetInterface(WebNavigation());
   NS_ENSURE_TRUE(window, NS_ERROR_FAILURE);
   nsCOMPtr<EventTarget> chromeHandler =
     do_QueryInterface(window->GetChromeEventHandler());
   docShell->SetChromeEventHandler(chromeHandler);
 
-  window->SetKeyboardIndicators(ShowAccelerators(), ShowFocusRings());
+  window->SetInitialKeyboardIndicators(ShowAccelerators(), ShowFocusRings());
 
   // Set prerender flag if necessary.
   if (mIsPrerendered) {
     docShell->SetIsPrerendered();
   }
 
   nsContentUtils::SetScrollbarsVisibility(window->GetDocShell(),
     !!(mChromeFlags & nsIWebBrowserChrome::CHROME_SCROLLBARS));