Bug 564991. Part 10: When NS_DOCUMENT_STATE_WINDOW_INACTIVE changes, flush the contents of all ThebesLayers. We need to do this because this change can change the rendering of themed content, and explicitly tracking and invalidating all such content would be way too expensive to justify. r=mats
authorRobert O'Callahan <robert@ocallahan.org>
Fri, 16 Jul 2010 09:07:51 +1200
changeset 47737 e7aa691d74e4797e86197e1b8379401d249a81c3
parent 47736 e284964e5bcf5d1951d67d6a1f9386b9f023d583
child 47738 c6ecff6b8a91a82306f63b48dc677b8351758902
push id14413
push userrocallahan@mozilla.com
push dateThu, 15 Jul 2010 21:12:02 +0000
treeherderautoland@e1d7fd5255fd [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmats
bugs564991
milestone2.0b2pre
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 564991. Part 10: When NS_DOCUMENT_STATE_WINDOW_INACTIVE changes, flush the contents of all ThebesLayers. We need to do this because this change can change the rendering of themed content, and explicitly tracking and invalidating all such content would be way too expensive to justify. r=mats
layout/base/nsPresShell.cpp
--- a/layout/base/nsPresShell.cpp
+++ b/layout/base/nsPresShell.cpp
@@ -223,16 +223,17 @@
 #endif
 
 #include "nsContentCID.h"
 static NS_DEFINE_IID(kRangeCID,     NS_RANGE_CID);
 
 /* for NS_MEMORY_REPORTER_IMPLEMENT */
 #include "nsIMemoryReporter.h"
 
+using namespace mozilla;
 using namespace mozilla::layers;
 using namespace mozilla::dom;
 
 PRBool nsIPresShell::gIsAccessibilityActive = PR_FALSE;
 CapturingContentInfo nsIPresShell::gCaptureInfo;
 
 // convert a color value to a string, in the CSS format #RRGGBB
 // *  - initially created for bugs 31816, 20760, 22963
@@ -4903,16 +4904,34 @@ PresShell::DocumentStatesChanged(nsIDocu
   if (mDidInitialReflow &&
       mStyleSet->HasDocumentStateDependentStyle(mPresContext,
                                                 mDocument->GetRootElement(),
                                                 aStateMask)) {
     mFrameConstructor->PostRestyleEvent(mDocument->GetRootElement(),
                                         eRestyle_Subtree, NS_STYLE_HINT_NONE);
     VERIFY_STYLE_TREE;
   }
+
+  if (aStateMask & NS_DOCUMENT_STATE_WINDOW_INACTIVE) {
+    nsIFrame* root = FrameManager()->GetRootFrame();
+    if (root) {
+      // It's a display root. So, invalidate the layer contents of
+      // everything we can find. We need to do this because the contents
+      // of controls etc can depend on whether the window is active,
+      // and when a window becomes (in)active it just gets repainted
+      // and we don't specifically invalidate each affected control.
+      nsIWidget* widget = root->GetNearestWidget();
+      if (widget) {
+        LayerManager* layerManager = widget->GetLayerManager();
+        if (layerManager) {
+          FrameLayerBuilder::InvalidateAllThebesLayerContents(layerManager);
+        }
+      }
+    }
+  }
 }
 
 void
 PresShell::AttributeWillChange(nsIDocument* aDocument,
                                nsIContent*  aContent,
                                PRInt32      aNameSpaceID,
                                nsIAtom*     aAttribute,
                                PRInt32      aModType)