Bug 1491448 - Maintain an internal opaque region in nsChildView that can be accessed from any thread. r=mattwoodrow

Differential Revision: https://phabricator.services.mozilla.com/D40554

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Markus Stange 2019-08-19 22:55:47 +00:00
Родитель 32ec0f3341
Коммит e65a6a7df9
4 изменённых файлов: 33 добавлений и 0 удалений

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

@ -73,6 +73,8 @@ class VibrancyManager {
bool HasVibrantRegions() { return !mVibrantRegions.IsEmpty(); }
LayoutDeviceIntRegion GetUnionOfVibrantRegions() const;
/**
* Return the fill color that should be drawn on top of the cleared window
* parts. Usually this would be drawn by -[NSVisualEffectView drawRect:].

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

@ -23,6 +23,14 @@ bool VibrancyManager::UpdateVibrantRegion(VibrancyType aType,
});
}
LayoutDeviceIntRegion VibrancyManager::GetUnionOfVibrantRegions() const {
LayoutDeviceIntRegion result;
for (auto it = mVibrantRegions.ConstIter(); !it.Done(); it.Next()) {
result.OrWith(it.UserData()->Region());
}
return result;
}
@interface NSView (CurrentFillColor)
- (NSColor*)_currentFillColor;
@end

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

@ -621,6 +621,8 @@ class nsChildView final : public nsBaseWidget {
void UpdateVibrancy(const nsTArray<ThemeGeometry>& aThemeGeometries);
mozilla::VibrancyManager& EnsureVibrancyManager();
void UpdateInternalOpaqueRegion();
nsIWidget* GetWidgetForListenerEvents();
struct SwipeInfo {
@ -736,6 +738,9 @@ class nsChildView final : public nsBaseWidget {
RefPtr<mozilla::CancelableRunnable> mUnsuspendAsyncCATransactionsRunnable;
// The widget's opaque region. Written on the main thread, read on any thread.
mozilla::DataMutex<mozilla::LayoutDeviceIntRegion> mOpaqueRegion;
// This flag is only used when APZ is off. It indicates that the current pan
// gesture was processed as a swipe. Sometimes the swipe animation can finish
// before momentum events of the pan gesture have stopped firing, so this

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

@ -338,6 +338,7 @@ nsChildView::nsChildView()
mIsDispatchPaint(false),
mPluginFocused{false},
mCompositingState("nsChildView::mCompositingState"),
mOpaqueRegion("nsChildView::mOpaqueRegion"),
mCurrentPanGestureBelongsToSwipe{false} {}
nsChildView::~nsChildView() {
@ -613,6 +614,8 @@ void nsChildView::SetTransparencyMode(nsTransparencyMode aMode) {
windowWidget->SetTransparencyMode(aMode);
}
UpdateInternalOpaqueRegion();
NS_OBJC_END_TRY_ABORT_BLOCK;
}
@ -2492,6 +2495,8 @@ void nsChildView::UpdateVibrancy(const nsTArray<ThemeGeometry>& aThemeGeometries
changed |= vm.UpdateVibrantRegion(VibrancyType::ACTIVE_SOURCE_LIST_SELECTION,
activeSourceListSelectionRegion);
UpdateInternalOpaqueRegion();
if (changed) {
SuspendAsyncCATransactions();
}
@ -2515,6 +2520,19 @@ mozilla::VibrancyManager& nsChildView::EnsureVibrancyManager() {
return *mVibrancyManager;
}
void nsChildView::UpdateInternalOpaqueRegion() {
MOZ_RELEASE_ASSERT(NS_IsMainThread(), "This should only be called on the main thread.");
auto opaqueRegion = mOpaqueRegion.Lock();
bool widgetIsOpaque = GetTransparencyMode() == eTransparencyOpaque;
if (!widgetIsOpaque) {
opaqueRegion->SetEmpty();
} else if (VibrancyManager::SystemSupportsVibrancy()) {
opaqueRegion->Sub(mBounds, EnsureVibrancyManager().GetUnionOfVibrantRegions());
} else {
*opaqueRegion = mBounds;
}
}
nsChildView::SwipeInfo nsChildView::SendMayStartSwipe(
const mozilla::PanGestureInput& aSwipeStartEvent) {
nsCOMPtr<nsIWidget> kungFuDeathGrip(this);