Bug 1052900 - Restore -moz-win-exclude-glass handling to the way it worked before. r=tn, a=lsblakk
--- a/layout/base/nsDisplayList.h
+++ b/layout/base/nsDisplayList.h
@@ -671,17 +671,36 @@ public:
nsPresContext* CurrentPresContext() {
return CurrentPresShellState()->mPresShell->GetPresContext();
}
/**
* Accumulates the bounds of box frames that have moz-appearance
* -moz-win-exclude-glass style. Used in setting glass margins on
* Windows.
- */
+ *
+ * We set the window opaque region (from which glass margins are computed)
+ * to the intersection of the glass region specified here and the opaque
+ * region computed during painting. So the excluded glass region actually
+ * *limits* the extent of the opaque area reported to Windows. We limit it
+ * so that changes to the computed opaque region (which can vary based on
+ * region optimizations and the placement of UI elements) outside the
+ * -moz-win-exclude-glass area don't affect the glass margins reported to
+ * Windows; changing those margins willy-nilly can cause the Windows 7 glass
+ * haze effect to jump around disconcertingly.
+ */
+ void AddWindowExcludeGlassRegion(const nsRegion& bounds) {
+ mWindowExcludeGlassRegion.Or(mWindowExcludeGlassRegion, bounds);
+ }
+ const nsRegion& GetWindowExcludeGlassRegion() {
+ return mWindowExcludeGlassRegion;
+ }
+ /**
+ * Accumulates opaque stuff into the window opaque region.
+ */
void AddWindowOpaqueRegion(const nsRegion& bounds) {
mWindowOpaqueRegion.Or(mWindowOpaqueRegion, bounds);
}
/**
* Returns the window opaque region built so far. This may be incomplete
* since the opaque region is built during layer construction.
*/
const nsRegion& GetWindowOpaqueRegion() {
@@ -750,16 +769,17 @@ private:
// BuildDisplayList on.
const nsIFrame* mCurrentFrame;
// The reference frame for mCurrentFrame.
const nsIFrame* mCurrentReferenceFrame;
// The offset from mCurrentFrame to mCurrentReferenceFrame.
nsPoint mCurrentOffsetToReferenceFrame;
// Relative to mCurrentFrame.
nsRect mDirtyRect;
+ nsRegion mWindowExcludeGlassRegion;
nsRegion mWindowOpaqueRegion;
nsRegion mWindowDraggingRegion;
// The display item for the Windows window glass background, if any
nsDisplayItem* mGlassDisplayItem;
nsTArray<DisplayItemClip*> mDisplayItemClipsToDestroy;
Mode mMode;
ViewID mCurrentScrollParentId;
ViewID mCurrentScrollbarTarget;
--- a/layout/base/nsLayoutUtils.cpp
+++ b/layout/base/nsLayoutUtils.cpp
@@ -3132,21 +3132,22 @@ nsLayoutUtils::PaintFrame(nsRenderingCon
// Update the widget's opaque region information. This sets
// glass boundaries on Windows. Also set up the window dragging region
// and plugin clip regions and bounds.
if ((aFlags & PAINT_WIDGET_LAYERS) &&
!willFlushRetainedLayers &&
!(aFlags & PAINT_DOCUMENT_RELATIVE)) {
nsIWidget *widget = aFrame->GetNearestWidget();
if (widget) {
- nsRegion opaqueRegion = builder.GetWindowOpaqueRegion();
+ nsRegion opaqueRegion;
+ opaqueRegion.And(builder.GetWindowExcludeGlassRegion(), builder.GetWindowOpaqueRegion());
widget->UpdateOpaqueRegion(
opaqueRegion.ToNearestPixels(presContext->AppUnitsPerDevPixel()));
- nsRegion draggingRegion = builder.GetWindowDraggingRegion();
+ const nsRegion& draggingRegion = builder.GetWindowDraggingRegion();
widget->UpdateWindowDraggingRegion(
draggingRegion.ToNearestPixels(presContext->AppUnitsPerDevPixel()));
}
}
if (builder.WillComputePluginGeometry()) {
nsRefPtr<LayerManager> layerManager;
nsIWidget* widget = aFrame->GetNearestWidget();
--- a/layout/xul/nsBoxFrame.cpp
+++ b/layout/xul/nsBoxFrame.cpp
@@ -1320,17 +1320,17 @@ nsBoxFrame::BuildDisplayList(nsDisplayLi
forceLayer = (scrollTargetId != layers::FrameMetrics::NULL_SCROLL_ID);
nsLayoutUtils::SetScrollbarThumbLayerization(this, forceLayer);
}
}
// Check for frames that are marked as a part of the region used
// in calculating glass margins on Windows.
const nsStyleDisplay* styles = StyleDisplay();
if (styles && styles->mAppearance == NS_THEME_WIN_EXCLUDE_GLASS) {
- aBuilder->AddWindowOpaqueRegion(
+ aBuilder->AddWindowExcludeGlassRegion(
nsRect(aBuilder->ToReferenceFrame(this), GetSize()));
}
aBuilder->AdjustWindowDraggingRegion(this);
}
nsDisplayListCollection tempLists;
const nsDisplayListSet& destination = forceLayer ? tempLists : aLists;