Bug 1370034 - Implement UpdateWidgetProperties for top level windows and for popups, and call nsIWidget::SetWindowShadow. r=dbaron

MozReview-Commit-ID: 9ooCdDRLOSq

--HG--
extra : rebase_source : 9394de7379c628cd5cd3d993b1902f59876801c2
This commit is contained in:
Markus Stange 2017-06-16 15:08:30 -04:00
Родитель 195251f3db
Коммит 24f428aed3
4 изменённых файлов: 52 добавлений и 1 удалений

Просмотреть файл

@ -10479,6 +10479,44 @@ nsIFrame::IsScrolledOutOfView()
return IsFrameScrolledOutOfView(this);
}
static already_AddRefed<nsIWidget>
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<nsISupports> container = aPresContext->Document()->GetContainer();
nsCOMPtr<nsIBaseWindow> baseWindow = do_QueryInterface(container);
if (!baseWindow) {
return nullptr;
}
nsCOMPtr<nsIWidget> 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<nsIWidget> widget = GetWindowWidget(presContext)) {
widget->SetWindowOpacity(StyleUIReset()->mWindowOpacity);
}
}
void
nsIFrame::DoUpdateStyleOfOwnedAnonBoxes(ServoStyleSet& aStyleSet,
nsStyleChangeList& aChangeList,

Просмотреть файл

@ -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.

Просмотреть файл

@ -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)

Просмотреть файл

@ -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);