diff --git a/layout/generic/nsFrame.cpp b/layout/generic/nsFrame.cpp index 9380d4043505..bfadc33ea2ad 100644 --- a/layout/generic/nsFrame.cpp +++ b/layout/generic/nsFrame.cpp @@ -10479,6 +10479,44 @@ nsIFrame::IsScrolledOutOfView() return IsFrameScrolledOutOfView(this); } +static already_AddRefed +GetWindowWidget(nsPresContext* aPresContext) +{ + // We want to obtain the widget for the window. We can't use any of these + // methods: nsPresContext::GetRootWidget, nsPresContext::GetNearestWidget, + // nsIFrame::GetNearestWidget because those deal with child widgets and + // there is no parent widget connection between child widgets and the + // window widget that contains them. + nsCOMPtr container = aPresContext->Document()->GetContainer(); + nsCOMPtr baseWindow = do_QueryInterface(container); + if (!baseWindow) { + return nullptr; + } + + nsCOMPtr mainWidget; + baseWindow->GetMainWidget(getter_AddRefs(mainWidget)); + return mainWidget.forget(); +} + +void +nsIFrame::UpdateWidgetProperties() +{ + nsPresContext* presContext = PresContext(); + if (presContext->IsRoot() || !presContext->IsChrome()) { + // Don't do anything for documents that aren't the root chrome document. + return; + } + nsIFrame* rootFrame = + presContext->FrameConstructor()->GetRootElementStyleFrame(); + if (this != rootFrame) { + // Only the window's root style frame is relevant for widget properties. + return; + } + if (nsCOMPtr widget = GetWindowWidget(presContext)) { + widget->SetWindowOpacity(StyleUIReset()->mWindowOpacity); + } +} + void nsIFrame::DoUpdateStyleOfOwnedAnonBoxes(ServoStyleSet& aStyleSet, nsStyleChangeList& aChangeList, diff --git a/layout/generic/nsIFrame.h b/layout/generic/nsIFrame.h index 0c30fbea9fce..73b8b8d6564e 100644 --- a/layout/generic/nsIFrame.h +++ b/layout/generic/nsIFrame.h @@ -3934,7 +3934,10 @@ public: */ bool IsScrolledOutOfView(); - virtual void UpdateWidgetProperties() {} + /** + * Applies the values from the -moz-window-* properties to the widget. + */ + virtual void UpdateWidgetProperties(); /** * @return true iff this frame has one or more associated image requests. diff --git a/layout/xul/nsMenuPopupFrame.cpp b/layout/xul/nsMenuPopupFrame.cpp index 1a6cb5d667bf..cabfe5ab771a 100644 --- a/layout/xul/nsMenuPopupFrame.cpp +++ b/layout/xul/nsMenuPopupFrame.cpp @@ -456,6 +456,14 @@ nsMenuPopupFrame::IsLeafDynamic() const !parentContent->HasAttr(kNameSpaceID_None, nsGkAtoms::sizetopopup)); } +void +nsMenuPopupFrame::UpdateWidgetProperties() +{ + if (nsIWidget* widget = GetWidget()) { + widget->SetWindowOpacity(StyleUIReset()->mWindowOpacity); + } +} + void nsMenuPopupFrame::LayoutPopup(nsBoxLayoutState& aState, nsIFrame* aParentMenu, nsIFrame* aAnchor, bool aSizedToPopup) diff --git a/layout/xul/nsMenuPopupFrame.h b/layout/xul/nsMenuPopupFrame.h index 6df5e2342933..25b893e24ba8 100644 --- a/layout/xul/nsMenuPopupFrame.h +++ b/layout/xul/nsMenuPopupFrame.h @@ -248,6 +248,8 @@ public: virtual bool IsLeafDynamic() const override; + virtual void UpdateWidgetProperties() override; + // layout, position and display the popup as needed void LayoutPopup(nsBoxLayoutState& aState, nsIFrame* aParentMenu, nsIFrame* aAnchor, bool aSizedToPopup);