Skip to content

Commit

Permalink
Backed out changeset 115b43608ec1 (bug 1736441) for causing build bus…
Browse files Browse the repository at this point in the history
…tages on nsWindow.cpp. CLOSED TREE
  • Loading branch information
Marian-Vasile Laza committed Oct 19, 2021
1 parent 289126a commit 6bacc35
Show file tree
Hide file tree
Showing 22 changed files with 872 additions and 5 deletions.
4 changes: 4 additions & 0 deletions gfx/tests/gtest/MockWidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@ class MockWidget : public nsBaseWidget {
virtual void Enable(bool aState) override {}
virtual bool IsEnabled() const override { return true; }
virtual void SetFocus(Raise, mozilla::dom::CallerType aCallerType) override {}
virtual nsresult ConfigureChildren(
const nsTArray<Configuration>& aConfigurations) override {
return NS_OK;
}
virtual void Invalidate(const LayoutDeviceIntRect& aRect) override {}
virtual nsresult SetTitle(const nsAString& title) override { return NS_OK; }
virtual LayoutDeviceIntPoint WidgetToScreenOffset() override {
Expand Down
20 changes: 20 additions & 0 deletions widget/PuppetWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,26 @@ void PuppetWidget::Resize(double aWidth, double aHeight, bool aRepaint) {
}
}

nsresult PuppetWidget::ConfigureChildren(
const nsTArray<Configuration>& aConfigurations) {
for (uint32_t i = 0; i < aConfigurations.Length(); ++i) {
const Configuration& configuration = aConfigurations[i];
PuppetWidget* w = static_cast<PuppetWidget*>(configuration.mChild.get());
NS_ASSERTION(w->GetParent() == this, "Configured widget is not a child");
w->SetWindowClipRegion(configuration.mClipRegion, true);
LayoutDeviceIntRect bounds = w->GetBounds();
if (bounds.Size() != configuration.mBounds.Size()) {
w->Resize(configuration.mBounds.X(), configuration.mBounds.Y(),
configuration.mBounds.Width(), configuration.mBounds.Height(),
true);
} else if (bounds.TopLeft() != configuration.mBounds.TopLeft()) {
w->Move(configuration.mBounds.X(), configuration.mBounds.Y());
}
w->SetWindowClipRegion(configuration.mClipRegion, false);
}
return NS_OK;
}

void PuppetWidget::SetFocus(Raise aRaise, CallerType aCallerType) {
if (aRaise == Raise::Yes && mBrowserChild) {
mBrowserChild->SendRequestFocus(true, aCallerType);
Expand Down
3 changes: 3 additions & 0 deletions widget/PuppetWidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,9 @@ class PuppetWidget : public nsBaseWidget,

virtual void SetFocus(Raise, mozilla::dom::CallerType aCallerType) override;

virtual nsresult ConfigureChildren(
const nsTArray<Configuration>& aConfigurations) override;

virtual void Invalidate(const LayoutDeviceIntRect& aRect) override;

// PuppetWidgets don't have native data, as they're purely nonnative.
Expand Down
11 changes: 11 additions & 0 deletions widget/android/nsWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1819,6 +1819,17 @@ void nsWindow::Destroy() {
#endif
}

nsresult nsWindow::ConfigureChildren(
const nsTArray<nsIWidget::Configuration>& config) {
for (uint32_t i = 0; i < config.Length(); ++i) {
nsWindow* childWin = (nsWindow*)config[i].mChild.get();
childWin->Resize(config[i].mBounds.x, config[i].mBounds.y,
config[i].mBounds.width, config[i].mBounds.height, false);
}

return NS_OK;
}

mozilla::widget::EventDispatcher* nsWindow::GetEventDispatcher() const {
if (mAndroidView) {
return mAndroidView->mEventDispatcher;
Expand Down
2 changes: 2 additions & 0 deletions widget/android/nsWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,8 @@ class nsWindow final : public nsBaseWidget {
const LayoutDeviceIntRect& aRect,
nsWidgetInitData* aInitData) override;
virtual void Destroy() override;
virtual nsresult ConfigureChildren(
const nsTArray<nsIWidget::Configuration>&) override;
virtual void SetParent(nsIWidget* aNewParent) override;
virtual nsIWidget* GetParent(void) override;
virtual float GetDPI() override;
Expand Down
1 change: 1 addition & 0 deletions widget/cocoa/nsChildView.h
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,7 @@ class nsChildView final : public nsBaseWidget {
void EnsureContentLayerForMainThreadPainting();

virtual void* GetNativeData(uint32_t aDataType) override;
virtual nsresult ConfigureChildren(const nsTArray<Configuration>& aConfigurations) override;
virtual LayoutDeviceIntPoint WidgetToScreenOffset() override;
virtual bool ShowsResizeIndicator(LayoutDeviceIntRect* aResizerRect) override { return false; }

Expand Down
4 changes: 4 additions & 0 deletions widget/cocoa/nsChildView.mm
Original file line number Diff line number Diff line change
Expand Up @@ -1250,6 +1250,10 @@ static void blinkRgn(RgnHandle rgn) {

#pragma mark -

nsresult nsChildView::ConfigureChildren(const nsTArray<Configuration>& aConfigurations) {
return NS_OK;
}

// Invokes callback and ProcessEvent methods on Event Listener object
nsresult nsChildView::DispatchEvent(WidgetGUIEvent* event, nsEventStatus& aStatus) {
RefPtr<nsChildView> kungFuDeathGrip(this);
Expand Down
1 change: 1 addition & 0 deletions widget/cocoa/nsCocoaWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,7 @@ class nsCocoaWindow final : public nsBaseWidget, public nsPIWidgetCocoa {
virtual nsresult SetTitle(const nsAString& aTitle) override;

virtual void Invalidate(const LayoutDeviceIntRect& aRect) override;
virtual nsresult ConfigureChildren(const nsTArray<Configuration>& aConfigurations) override;
virtual WindowRenderer* GetWindowRenderer() override;
virtual nsresult DispatchEvent(mozilla::WidgetGUIEvent* aEvent, nsEventStatus& aStatus) override;
virtual void CaptureRollupEvents(nsIRollupListener* aListener, bool aDoCapture) override;
Expand Down
8 changes: 8 additions & 0 deletions widget/cocoa/nsCocoaWindow.mm
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,7 @@ static unsigned int WindowMaskForBorderStyle(nsBorderStyle aBorderStyle) {
switch (mWindowType) {
case eWindowType_invisible:
case eWindowType_child:
case eWindowType_plugin:
break;
case eWindowType_popup:
if (aBorderStyle != eBorderStyle_default && mBorderStyle & eBorderStyle_title) {
Expand Down Expand Up @@ -1035,6 +1036,13 @@ static unsigned int WindowMaskForBorderStyle(nsBorderStyle aBorderStyle) {
return (mWindowType == eWindowType_popup) && mWasShown && ([[NSScreen screens] count] > 1);
}

nsresult nsCocoaWindow::ConfigureChildren(const nsTArray<Configuration>& aConfigurations) {
if (mPopupContentView) {
mPopupContentView->ConfigureChildren(aConfigurations);
}
return NS_OK;
}

WindowRenderer* nsCocoaWindow::GetWindowRenderer() {
if (mPopupContentView) {
return mPopupContentView->GetWindowRenderer();
Expand Down
78 changes: 78 additions & 0 deletions widget/gtk/nsWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5367,9 +5367,16 @@ nsresult nsWindow::Create(nsIWidget* aParent, nsNativeWidget aNativeParent,
SetWindowMouseTransparent(aInitData->mMouseTransparent);
}
} break;

case eWindowType_plugin:
case eWindowType_plugin_ipc_chrome:
case eWindowType_plugin_ipc_content:
MOZ_ASSERT_UNREACHABLE("Unexpected eWindowType_plugin*");
return NS_ERROR_FAILURE;
default:
MOZ_ASSERT_UNREACHABLE("Unexpected eWindowType");
return NS_ERROR_FAILURE;
break;
}

// label the drawing window with this object so we can find our way home
Expand Down Expand Up @@ -6175,6 +6182,77 @@ bool nsWindow::DoDrawTilebarCorners() {
!mIsTiled;
}

nsresult nsWindow::ConfigureChildren(
const nsTArray<Configuration>& aConfigurations) {
// If this is a remotely updated widget we receive clipping, position, and
// size information from a source other than our owner. Don't let our parent
// update this information.
if (mWindowType == eWindowType_plugin_ipc_chrome) {
return NS_OK;
}

for (uint32_t i = 0; i < aConfigurations.Length(); ++i) {
const Configuration& configuration = aConfigurations[i];
auto* w = static_cast<nsWindow*>(configuration.mChild.get());
NS_ASSERTION(w->GetParent() == this, "Configured widget is not a child");
w->SetWindowClipRegion(configuration.mClipRegion, true);
if (w->mBounds.Size() != configuration.mBounds.Size()) {
w->Resize(configuration.mBounds.x, configuration.mBounds.y,
configuration.mBounds.width, configuration.mBounds.height,
true);
} else if (w->mBounds.TopLeft() != configuration.mBounds.TopLeft()) {
w->Move(configuration.mBounds.x, configuration.mBounds.y);
}
w->SetWindowClipRegion(configuration.mClipRegion, false);
}
return NS_OK;
}

nsresult nsWindow::SetWindowClipRegion(
const nsTArray<LayoutDeviceIntRect>& aRects, bool aIntersectWithExisting) {
const nsTArray<LayoutDeviceIntRect>* newRects = &aRects;

AutoTArray<LayoutDeviceIntRect, 1> intersectRects;
if (aIntersectWithExisting) {
AutoTArray<LayoutDeviceIntRect, 1> existingRects;
GetWindowClipRegion(&existingRects);

LayoutDeviceIntRegion existingRegion = RegionFromArray(existingRects);
LayoutDeviceIntRegion newRegion = RegionFromArray(aRects);
LayoutDeviceIntRegion intersectRegion;
intersectRegion.And(newRegion, existingRegion);

// If mClipRects is null we haven't set a clip rect yet, so we
// need to set the clip even if it is equal.
if (mClipRects && intersectRegion.IsEqual(existingRegion)) {
return NS_OK;
}

if (!intersectRegion.IsEqual(newRegion)) {
ArrayFromRegion(intersectRegion, intersectRects);
newRects = &intersectRects;
}
}

if (IsWindowClipRegionEqual(*newRects)) return NS_OK;

StoreWindowClipRegion(*newRects);

if (!mGdkWindow) return NS_OK;

cairo_region_t* region = cairo_region_create();
for (uint32_t i = 0; i < newRects->Length(); ++i) {
const LayoutDeviceIntRect& r = newRects->ElementAt(i);
cairo_rectangle_int_t rect = {r.x, r.y, r.width, r.height};
cairo_region_union_rectangle(region, &rect);
}

gdk_window_shape_combine_region(mGdkWindow, region, 0, 0);
cairo_region_destroy(region);

return NS_OK;
}

void nsWindow::ResizeTransparencyBitmap() {
if (!mTransparencyBitmap) return;

Expand Down
5 changes: 5 additions & 0 deletions widget/gtk/nsWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,9 @@ class nsWindow final : public nsBaseWidget {
virtual void CaptureRollupEvents(nsIRollupListener* aListener,
bool aDoCapture) override;
[[nodiscard]] virtual nsresult GetAttention(int32_t aCycleCount) override;
virtual nsresult SetWindowClipRegion(
const nsTArray<LayoutDeviceIntRect>& aRects,
bool aIntersectWithExisting) override;
virtual bool HasPendingInputEvent() override;

virtual bool PrepareForFullscreenTransition(nsISupports** aData) override;
Expand Down Expand Up @@ -289,6 +292,8 @@ class nsWindow final : public nsBaseWidget {
virtual void SetTransparencyMode(nsTransparencyMode aMode) override;
virtual nsTransparencyMode GetTransparencyMode() override;
virtual void SetWindowMouseTransparent(bool aIsTransparent) override;
virtual nsresult ConfigureChildren(
const nsTArray<Configuration>& aConfigurations) override;
nsresult UpdateTranslucentWindowAlphaInternal(const nsIntRect& aRect,
uint8_t* aAlphas,
int32_t aStride);
Expand Down
6 changes: 6 additions & 0 deletions widget/headless/HeadlessWidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,12 @@ class HeadlessWidget : public nsBaseWidget {
virtual void Enable(bool aState) override;
virtual bool IsEnabled() const override;
virtual void SetFocus(Raise, mozilla::dom::CallerType aCallerType) override;
virtual nsresult ConfigureChildren(
const nsTArray<Configuration>& aConfigurations) override {
MOZ_ASSERT_UNREACHABLE(
"Headless widgets do not support configuring children.");
return NS_ERROR_FAILURE;
}
virtual void Invalidate(const LayoutDeviceIntRect& aRect) override {
// TODO: see if we need to do anything here.
}
Expand Down
Loading

0 comments on commit 6bacc35

Please sign in to comment.