Bug 805331. Only chrome display items that are leaves should be treated as especially opaque. r=mats,a=bajaj
authorRobert O'Callahan <robert@ocallahan.org>
Sat, 03 Nov 2012 01:59:03 +1300
changeset 116832 af90ef6d15d4b5f786686a078aa116dbd339a483
parent 116831 2ed2cc2f321bed8766564977f3af54a9842c8f56
child 116833 43eef80d5a9373363334e15d4f8a716f61689b84
push id1708
push userakeybl@mozilla.com
push dateMon, 19 Nov 2012 21:10:21 +0000
treeherdermozilla-beta@27b14fe50103 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmats, bajaj
bugs805331
milestone18.0a2
Bug 805331. Only chrome display items that are leaves should be treated as especially opaque. r=mats,a=bajaj
layout/base/nsDisplayList.cpp
--- a/layout/base/nsDisplayList.cpp
+++ b/layout/base/nsDisplayList.cpp
@@ -859,22 +859,28 @@ nsDisplayList::ComputeVisibilityForRoot(
 }
 
 static nsRegion
 TreatAsOpaque(nsDisplayItem* aItem, nsDisplayListBuilder* aBuilder)
 {
   bool snap;
   nsRegion opaque = aItem->GetOpaqueRegion(aBuilder, &snap);
   if (aBuilder->IsForPluginGeometry()) {
-    // Treat all chrome items as opaque, unless their frames are opacity:0.
+    // Treat all leaf chrome items as opaque, unless their frames are opacity:0.
     // Since opacity:0 frames generate an nsDisplayOpacity, that item will
     // not be treated as opaque here, so opacity:0 chrome content will be
     // effectively ignored, as it should be.
+    // We treat leaf chrome items as opaque to ensure that they cover
+    // content plugins, for security reasons.
+    // Non-leaf chrome items don't render contents of their own so shouldn't
+    // be treated as opaque (and their bounds is just the union of their
+    // children, which might be a large area their contents don't really cover).
     nsIFrame* f = aItem->GetUnderlyingFrame();
-    if (f && f->PresContext()->IsChrome() && f->GetStyleDisplay()->mOpacity != 0.0) {
+    if (f && f->PresContext()->IsChrome() && !aItem->GetChildren() &&
+        f->GetStyleDisplay()->mOpacity != 0.0) {
       opaque = aItem->GetBounds(aBuilder, &snap);
     }
   }
   return opaque;
 }
 
 static nsRect
 GetDisplayPortBounds(nsDisplayListBuilder* aBuilder, nsDisplayItem* aItem)