From efe7890d1b6637f578dd355fb91800f2c0f0ccd0 Mon Sep 17 00:00:00 2001 From: Kartikaya Gupta Date: Tue, 29 Sep 2020 02:54:51 +0000 Subject: [PATCH] Bug 1667863 - Move EventRegion function bodies to .cpp file. r=mattwoodrow Depends on D91649 Differential Revision: https://phabricator.services.mozilla.com/D91650 --- gfx/layers/Layers.cpp | 10 ++++ gfx/layers/Layers.h | 10 +--- gfx/layers/LayersTypes.cpp | 83 +++++++++++++++++++++++++++++++++ gfx/layers/LayersTypes.h | 94 +++++--------------------------------- 4 files changed, 106 insertions(+), 91 deletions(-) diff --git a/gfx/layers/Layers.cpp b/gfx/layers/Layers.cpp index bea45c3db6da..626aac7e33e9 100644 --- a/gfx/layers/Layers.cpp +++ b/gfx/layers/Layers.cpp @@ -227,6 +227,16 @@ Layer::Layer(LayerManager* aManager, void* aImplData) Layer::~Layer() = default; +void Layer::SetEventRegions(const EventRegions& aRegions) { + if (mEventRegions != aRegions) { + MOZ_LAYERS_LOG_IF_SHADOWABLE( + this, ("Layer::Mutated(%p) eventregions were %s, now %s", this, + mEventRegions.ToString().get(), aRegions.ToString().get())); + mEventRegions = aRegions; + Mutated(); + } +} + void Layer::SetCompositorAnimations( const LayersId& aLayersId, const CompositorAnimations& aCompositorAnimations) { diff --git a/gfx/layers/Layers.h b/gfx/layers/Layers.h index 4a201bc9f3ee..d89a2f6a237d 100644 --- a/gfx/layers/Layers.h +++ b/gfx/layers/Layers.h @@ -1037,15 +1037,7 @@ class Layer { * CONSTRUCTION PHASE ONLY * Set the event handling region. */ - void SetEventRegions(const EventRegions& aRegions) { - if (mEventRegions != aRegions) { - MOZ_LAYERS_LOG_IF_SHADOWABLE( - this, ("Layer::Mutated(%p) eventregions were %s, now %s", this, - mEventRegions.ToString().get(), aRegions.ToString().get())); - mEventRegions = aRegions; - Mutated(); - } - } + void SetEventRegions(const EventRegions& aRegions); /** * CONSTRUCTION PHASE ONLY diff --git a/gfx/layers/LayersTypes.cpp b/gfx/layers/LayersTypes.cpp index 2ea9474aaac6..b561b8fb17ca 100644 --- a/gfx/layers/LayersTypes.cpp +++ b/gfx/layers/LayersTypes.cpp @@ -36,6 +36,11 @@ const char* GetLayersBackendName(LayersBackend aBackend) { } } +EventRegions::EventRegions() : mDTCRequiresTargetConfirmation(false) {} + +EventRegions::EventRegions(nsIntRegion aHitRegion) + : mHitRegion(aHitRegion), mDTCRequiresTargetConfirmation(false) {} + EventRegions::EventRegions(const nsIntRegion& aHitRegion, const nsIntRegion& aMaybeHitRegion, const nsIntRegion& aDispatchToContentRegion, @@ -57,5 +62,83 @@ EventRegions::EventRegions(const nsIntRegion& aHitRegion, mDTCRequiresTargetConfirmation = aDTCRequiresTargetConfirmation; } +bool EventRegions::operator==(const EventRegions& aRegions) const { + return mHitRegion == aRegions.mHitRegion && + mDispatchToContentHitRegion == aRegions.mDispatchToContentHitRegion && + mNoActionRegion == aRegions.mNoActionRegion && + mHorizontalPanRegion == aRegions.mHorizontalPanRegion && + mVerticalPanRegion == aRegions.mVerticalPanRegion && + mDTCRequiresTargetConfirmation == + aRegions.mDTCRequiresTargetConfirmation; +} + +bool EventRegions::operator!=(const EventRegions& aRegions) const { + return !(*this == aRegions); +} + +void EventRegions::ApplyTranslationAndScale(float aXTrans, float aYTrans, + float aXScale, float aYScale) { + mHitRegion.ScaleRoundOut(aXScale, aYScale); + mDispatchToContentHitRegion.ScaleRoundOut(aXScale, aYScale); + mNoActionRegion.ScaleRoundOut(aXScale, aYScale); + mHorizontalPanRegion.ScaleRoundOut(aXScale, aYScale); + mVerticalPanRegion.ScaleRoundOut(aXScale, aYScale); + + mHitRegion.MoveBy(aXTrans, aYTrans); + mDispatchToContentHitRegion.MoveBy(aXTrans, aYTrans); + mNoActionRegion.MoveBy(aXTrans, aYTrans); + mHorizontalPanRegion.MoveBy(aXTrans, aYTrans); + mVerticalPanRegion.MoveBy(aXTrans, aYTrans); +} + +void EventRegions::Transform(const gfx::Matrix4x4& aTransform) { + mHitRegion.Transform(aTransform); + mDispatchToContentHitRegion.Transform(aTransform); + mNoActionRegion.Transform(aTransform); + mHorizontalPanRegion.Transform(aTransform); + mVerticalPanRegion.Transform(aTransform); +} + +void EventRegions::OrWith(const EventRegions& aOther) { + mHitRegion.OrWith(aOther.mHitRegion); + mDispatchToContentHitRegion.OrWith(aOther.mDispatchToContentHitRegion); + // See the comment in nsDisplayList::AddFrame, where the touch action + // regions are handled. The same thing applies here. + bool alreadyHadRegions = !mNoActionRegion.IsEmpty() || + !mHorizontalPanRegion.IsEmpty() || + !mVerticalPanRegion.IsEmpty(); + mNoActionRegion.OrWith(aOther.mNoActionRegion); + mHorizontalPanRegion.OrWith(aOther.mHorizontalPanRegion); + mVerticalPanRegion.OrWith(aOther.mVerticalPanRegion); + if (alreadyHadRegions) { + nsIntRegion combinedActionRegions; + combinedActionRegions.Or(mHorizontalPanRegion, mVerticalPanRegion); + combinedActionRegions.OrWith(mNoActionRegion); + mDispatchToContentHitRegion.OrWith(combinedActionRegions); + } + mDTCRequiresTargetConfirmation |= aOther.mDTCRequiresTargetConfirmation; +} + +bool EventRegions::IsEmpty() const { + return mHitRegion.IsEmpty() && mDispatchToContentHitRegion.IsEmpty() && + mNoActionRegion.IsEmpty() && mHorizontalPanRegion.IsEmpty() && + mVerticalPanRegion.IsEmpty(); +} + +void EventRegions::SetEmpty() { + mHitRegion.SetEmpty(); + mDispatchToContentHitRegion.SetEmpty(); + mNoActionRegion.SetEmpty(); + mHorizontalPanRegion.SetEmpty(); + mVerticalPanRegion.SetEmpty(); +} + +nsCString EventRegions::ToString() const { + nsCString result = mHitRegion.ToString(); + result.AppendLiteral(";dispatchToContent="); + result.Append(mDispatchToContentHitRegion.ToString()); + return result; +} + } // namespace layers } // namespace mozilla diff --git a/gfx/layers/LayersTypes.h b/gfx/layers/LayersTypes.h index fd7acefce245..4aee15696208 100644 --- a/gfx/layers/LayersTypes.h +++ b/gfx/layers/LayersTypes.h @@ -8,18 +8,14 @@ #define GFX_LAYERSTYPES_H #include // for uint32_t +#include // FILE #include "Units.h" -#include "mozilla/DefineEnum.h" // for MOZ_DEFINE_ENUM -#include "mozilla/gfx/Point.h" // for IntPoint +#include "mozilla/DefineEnum.h" // for MOZ_DEFINE_ENUM_CLASS_WITH_BASE #include "mozilla/Maybe.h" #include "mozilla/TimeStamp.h" // for TimeStamp -#include "mozilla/TypedEnumBits.h" #include "nsRegion.h" -#include // FILE -#include "mozilla/Logging.h" // for PR_LOG - #ifndef MOZ_LAYERS_HAVE_LOG # define MOZ_LAYERS_HAVE_LOG #endif @@ -238,10 +234,9 @@ struct EventRegions { // EventRegions are going to be deprecated anyways. bool mDTCRequiresTargetConfirmation; - EventRegions() : mDTCRequiresTargetConfirmation(false) {} + EventRegions(); - explicit EventRegions(nsIntRegion aHitRegion) - : mHitRegion(aHitRegion), mDTCRequiresTargetConfirmation(false) {} + explicit EventRegions(nsIntRegion aHitRegion); // This constructor takes the maybe-hit region and uses it to update the // hit region and dispatch-to-content region. It is useful from converting @@ -254,83 +249,18 @@ struct EventRegions { const nsIntRegion& aVerticalPanRegion, bool aDTCRequiresTargetConfirmation); - bool operator==(const EventRegions& aRegions) const { - return mHitRegion == aRegions.mHitRegion && - mDispatchToContentHitRegion == - aRegions.mDispatchToContentHitRegion && - mNoActionRegion == aRegions.mNoActionRegion && - mHorizontalPanRegion == aRegions.mHorizontalPanRegion && - mVerticalPanRegion == aRegions.mVerticalPanRegion && - mDTCRequiresTargetConfirmation == - aRegions.mDTCRequiresTargetConfirmation; - } - bool operator!=(const EventRegions& aRegions) const { - return !(*this == aRegions); - } + bool operator==(const EventRegions& aRegions) const; + bool operator!=(const EventRegions& aRegions) const; void ApplyTranslationAndScale(float aXTrans, float aYTrans, float aXScale, - float aYScale) { - mHitRegion.ScaleRoundOut(aXScale, aYScale); - mDispatchToContentHitRegion.ScaleRoundOut(aXScale, aYScale); - mNoActionRegion.ScaleRoundOut(aXScale, aYScale); - mHorizontalPanRegion.ScaleRoundOut(aXScale, aYScale); - mVerticalPanRegion.ScaleRoundOut(aXScale, aYScale); + float aYScale); + void Transform(const gfx::Matrix4x4& aTransform); + void OrWith(const EventRegions& aOther); - mHitRegion.MoveBy(aXTrans, aYTrans); - mDispatchToContentHitRegion.MoveBy(aXTrans, aYTrans); - mNoActionRegion.MoveBy(aXTrans, aYTrans); - mHorizontalPanRegion.MoveBy(aXTrans, aYTrans); - mVerticalPanRegion.MoveBy(aXTrans, aYTrans); - } + bool IsEmpty() const; + void SetEmpty(); - void Transform(const gfx::Matrix4x4& aTransform) { - mHitRegion.Transform(aTransform); - mDispatchToContentHitRegion.Transform(aTransform); - mNoActionRegion.Transform(aTransform); - mHorizontalPanRegion.Transform(aTransform); - mVerticalPanRegion.Transform(aTransform); - } - - void OrWith(const EventRegions& aOther) { - mHitRegion.OrWith(aOther.mHitRegion); - mDispatchToContentHitRegion.OrWith(aOther.mDispatchToContentHitRegion); - // See the comment in nsDisplayList::AddFrame, where the touch action - // regions are handled. The same thing applies here. - bool alreadyHadRegions = !mNoActionRegion.IsEmpty() || - !mHorizontalPanRegion.IsEmpty() || - !mVerticalPanRegion.IsEmpty(); - mNoActionRegion.OrWith(aOther.mNoActionRegion); - mHorizontalPanRegion.OrWith(aOther.mHorizontalPanRegion); - mVerticalPanRegion.OrWith(aOther.mVerticalPanRegion); - if (alreadyHadRegions) { - nsIntRegion combinedActionRegions; - combinedActionRegions.Or(mHorizontalPanRegion, mVerticalPanRegion); - combinedActionRegions.OrWith(mNoActionRegion); - mDispatchToContentHitRegion.OrWith(combinedActionRegions); - } - mDTCRequiresTargetConfirmation |= aOther.mDTCRequiresTargetConfirmation; - } - - bool IsEmpty() const { - return mHitRegion.IsEmpty() && mDispatchToContentHitRegion.IsEmpty() && - mNoActionRegion.IsEmpty() && mHorizontalPanRegion.IsEmpty() && - mVerticalPanRegion.IsEmpty(); - } - - void SetEmpty() { - mHitRegion.SetEmpty(); - mDispatchToContentHitRegion.SetEmpty(); - mNoActionRegion.SetEmpty(); - mHorizontalPanRegion.SetEmpty(); - mVerticalPanRegion.SetEmpty(); - } - - nsCString ToString() const { - nsCString result = mHitRegion.ToString(); - result.AppendLiteral(";dispatchToContent="); - result.Append(mDispatchToContentHitRegion.ToString()); - return result; - } + nsCString ToString() const; }; // Bit flags that go on a RefLayer and override the