mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-11 08:13:35 +00:00
Bug 1667863 - Move EventRegion function bodies to .cpp file. r=mattwoodrow
Depends on D91649 Differential Revision: https://phabricator.services.mozilla.com/D91650
This commit is contained in:
parent
18d7f762aa
commit
efe7890d1b
@ -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) {
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -8,18 +8,14 @@
|
||||
#define GFX_LAYERSTYPES_H
|
||||
|
||||
#include <stdint.h> // for uint32_t
|
||||
#include <stdio.h> // 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 <stdio.h> // 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
|
||||
|
Loading…
Reference in New Issue
Block a user