Bug 1125422 - Fold touch and scroll listener flags into a single apz-aware flag for better code reuse. r=roc
--- a/layout/base/nsDisplayList.cpp
+++ b/layout/base/nsDisplayList.cpp
@@ -582,18 +582,17 @@ nsDisplayListBuilder::nsDisplayListBuild
mAllowMergingAndFlattening(true),
mWillComputePluginGeometry(false),
mInTransform(false),
mIsInChromePresContext(false),
mSyncDecodeImages(false),
mIsPaintingToWindow(false),
mIsCompositingCheap(false),
mContainsPluginItem(false),
- mAncestorHasTouchEventHandler(false),
- mAncestorHasScrollEventHandler(false),
+ mAncestorHasApzAwareEventHandler(false),
mHaveScrollableDisplayPort(false),
mWindowDraggingAllowed(false),
mIsBuildingForPopup(nsLayoutUtils::IsPopup(aReferenceFrame))
{
MOZ_COUNT_CTOR(nsDisplayListBuilder);
PL_InitArenaPool(&mPool, "displayListArena", 1024,
std::max(NS_ALIGNMENT_OF(void*),NS_ALIGNMENT_OF(double))-1);
RecomputeCurrentAnimatedGeometryRoot();
@@ -3146,19 +3145,17 @@ nsDisplayLayerEventRegions::AddFrame(nsD
}
}
if (borderBoxHasRoundedCorners ||
(aFrame->GetStateBits() & NS_FRAME_SVG_LAYOUT)) {
mMaybeHitRegion.Or(mMaybeHitRegion, borderBox);
} else {
mHitRegion.Or(mHitRegion, borderBox);
}
- if (aBuilder->GetAncestorHasTouchEventHandler() ||
- aBuilder->GetAncestorHasScrollEventHandler())
- {
+ if (aBuilder->GetAncestorHasApzAwareEventHandler()) {
mDispatchToContentHitRegion.Or(mDispatchToContentHitRegion, borderBox);
}
}
void
nsDisplayLayerEventRegions::AddInactiveScrollPort(const nsRect& aRect)
{
mDispatchToContentHitRegion.Or(mDispatchToContentHitRegion, aRect);
--- a/layout/base/nsDisplayList.h
+++ b/layout/base/nsDisplayList.h
@@ -340,25 +340,20 @@ public:
{
return (gfxPrefs::LayoutEventRegionsEnabled() && mMode == PAINTING);
}
bool IsInsidePointerEventsNoneDoc()
{
return CurrentPresShellState()->mInsidePointerEventsNoneDoc;
}
- bool GetAncestorHasTouchEventHandler() { return mAncestorHasTouchEventHandler; }
- void SetAncestorHasTouchEventHandler(bool aValue)
+ bool GetAncestorHasApzAwareEventHandler() { return mAncestorHasApzAwareEventHandler; }
+ void SetAncestorHasApzAwareEventHandler(bool aValue)
{
- mAncestorHasTouchEventHandler = aValue;
- }
- bool GetAncestorHasScrollEventHandler() { return mAncestorHasScrollEventHandler; }
- void SetAncestorHasScrollEventHandler(bool aValue)
- {
- mAncestorHasScrollEventHandler = aValue;
+ mAncestorHasApzAwareEventHandler = aValue;
}
bool HaveScrollableDisplayPort() const { return mHaveScrollableDisplayPort; }
void SetHaveScrollableDisplayPort() { mHaveScrollableDisplayPort = true; }
bool SetIsCompositingCheap(bool aCompositingCheap) {
bool temp = mIsCompositingCheap;
mIsCompositingCheap = aCompositingCheap;
@@ -573,18 +568,17 @@ public:
: mBuilder(aBuilder),
mPrevFrame(aBuilder->mCurrentFrame),
mPrevReferenceFrame(aBuilder->mCurrentReferenceFrame),
mPrevAnimatedGeometryRoot(mBuilder->mCurrentAnimatedGeometryRoot),
mPrevLayerEventRegions(aBuilder->mLayerEventRegions),
mPrevOffset(aBuilder->mCurrentOffsetToReferenceFrame),
mPrevDirtyRect(aBuilder->mDirtyRect),
mPrevIsAtRootOfPseudoStackingContext(aBuilder->mIsAtRootOfPseudoStackingContext),
- mPrevAncestorHasTouchEventHandler(aBuilder->mAncestorHasTouchEventHandler),
- mPrevAncestorHasScrollEventHandler(aBuilder->mAncestorHasScrollEventHandler)
+ mPrevAncestorHasApzAwareEventHandler(aBuilder->mAncestorHasApzAwareEventHandler)
{
if (aForChild->IsTransformed()) {
aBuilder->mCurrentOffsetToReferenceFrame = nsPoint();
aBuilder->mCurrentReferenceFrame = aForChild;
} else if (aBuilder->mCurrentFrame == aForChild->GetParent()) {
aBuilder->mCurrentOffsetToReferenceFrame += aForChild->GetPosition();
} else {
aBuilder->mCurrentReferenceFrame =
@@ -619,31 +613,29 @@ public:
}
~AutoBuildingDisplayList() {
mBuilder->mCurrentFrame = mPrevFrame;
mBuilder->mCurrentReferenceFrame = mPrevReferenceFrame;
mBuilder->mLayerEventRegions = mPrevLayerEventRegions;
mBuilder->mCurrentOffsetToReferenceFrame = mPrevOffset;
mBuilder->mDirtyRect = mPrevDirtyRect;
mBuilder->mIsAtRootOfPseudoStackingContext = mPrevIsAtRootOfPseudoStackingContext;
- mBuilder->mAncestorHasTouchEventHandler = mPrevAncestorHasTouchEventHandler;
- mBuilder->mAncestorHasScrollEventHandler = mPrevAncestorHasScrollEventHandler;
+ mBuilder->mAncestorHasApzAwareEventHandler = mPrevAncestorHasApzAwareEventHandler;
mBuilder->mCurrentAnimatedGeometryRoot = mPrevAnimatedGeometryRoot;
}
private:
nsDisplayListBuilder* mBuilder;
const nsIFrame* mPrevFrame;
const nsIFrame* mPrevReferenceFrame;
nsIFrame* mPrevAnimatedGeometryRoot;
nsDisplayLayerEventRegions* mPrevLayerEventRegions;
nsPoint mPrevOffset;
nsRect mPrevDirtyRect;
bool mPrevIsAtRootOfPseudoStackingContext;
- bool mPrevAncestorHasTouchEventHandler;
- bool mPrevAncestorHasScrollEventHandler;
+ bool mPrevAncestorHasApzAwareEventHandler;
};
/**
* A helper class to temporarily set the value of mInTransform.
*/
class AutoInTransformSetter;
friend class AutoInTransformSetter;
class AutoInTransformSetter {
@@ -915,18 +907,17 @@ private:
// True when we're building a display list that's directly or indirectly
// under an nsDisplayTransform
bool mInTransform;
bool mIsInChromePresContext;
bool mSyncDecodeImages;
bool mIsPaintingToWindow;
bool mIsCompositingCheap;
bool mContainsPluginItem;
- bool mAncestorHasTouchEventHandler;
- bool mAncestorHasScrollEventHandler;
+ bool mAncestorHasApzAwareEventHandler;
// True when the first async-scrollable scroll frame for which we build a
// display list has a display port. An async-scrollable scroll frame is one
// which WantsAsyncScroll().
bool mHaveScrollableDisplayPort;
bool mWindowDraggingAllowed;
bool mIsBuildingForPopup;
};
--- a/layout/base/nsLayoutUtils.cpp
+++ b/layout/base/nsLayoutUtils.cpp
@@ -7833,8 +7833,21 @@ nsLayoutUtils::SetBSizeFromFontMetrics(c
} else {
NS_WARNING("Cannot get font metrics - defaulting sizes to 0");
aMetrics.SetBlockStartAscent(aMetrics.BSize(aLineWM) = 0);
}
aMetrics.SetBlockStartAscent(aMetrics.BlockStartAscent() +
aFramePadding.BStart(aFrameWM));
aMetrics.BSize(aLineWM) += aFramePadding.BStartEnd(aFrameWM);
}
+
+/* static */ bool
+nsLayoutUtils::HasApzAwareListeners(EventListenerManager* aElm)
+{
+ if (!aElm) {
+ return false;
+ }
+ return aElm->HasListenersFor(nsGkAtoms::ontouchstart) ||
+ aElm->HasListenersFor(nsGkAtoms::ontouchmove) ||
+ aElm->HasListenersFor(nsGkAtoms::onwheel) ||
+ aElm->HasListenersFor(nsGkAtoms::onDOMMouseScroll) ||
+ aElm->HasListenersFor(nsHtml5Atoms::onmousewheel);
+}
--- a/layout/base/nsLayoutUtils.h
+++ b/layout/base/nsLayoutUtils.h
@@ -58,16 +58,17 @@ class nsPIDOMWindow;
class imgIRequest;
class nsIDocument;
struct gfxPoint;
struct nsStyleFont;
struct nsStyleImageOrientation;
struct nsOverflowAreas;
namespace mozilla {
+class EventListenerManager;
class SVGImageContext;
struct IntrinsicSize;
struct ContainerLayerParameters;
class WritingMode;
namespace dom {
class DOMRectList;
class Element;
class HTMLImageElement;
@@ -2546,16 +2547,18 @@ public:
static bool IsOutlineStyleAutoEnabled();
static void SetBSizeFromFontMetrics(const nsIFrame* aFrame,
nsHTMLReflowMetrics& aMetrics,
const mozilla::LogicalMargin& aFramePadding,
mozilla::WritingMode aLineWM,
mozilla::WritingMode aFrameWM);
+ static bool HasApzAwareListeners(mozilla::EventListenerManager* aElm);
+
private:
static uint32_t sFontSizeInflationEmPerLine;
static uint32_t sFontSizeInflationMinTwips;
static uint32_t sFontSizeInflationLineThreshold;
static int32_t sFontSizeInflationMappingIntercept;
static uint32_t sFontSizeInflationMaxRatio;
static bool sFontSizeInflationForceEnabled;
static bool sFontSizeInflationDisabledInMasterProcess;
--- a/layout/generic/nsFrame.cpp
+++ b/layout/generic/nsFrame.cpp
@@ -1904,28 +1904,18 @@ public:
static void
CheckForApzAwareEventHandlers(nsDisplayListBuilder* aBuilder, nsIFrame* aFrame)
{
nsIContent* content = aFrame->GetContent();
if (!content) {
return;
}
EventListenerManager* elm = nsContentUtils::GetExistingListenerManagerForNode(content);
- if (!elm) {
- return;
- }
- if (elm->HasListenersFor(nsGkAtoms::ontouchstart) ||
- elm->HasListenersFor(nsGkAtoms::ontouchmove)) {
- aBuilder->SetAncestorHasTouchEventHandler(true);
- }
- if (elm->HasListenersFor(nsGkAtoms::onwheel) ||
- elm->HasListenersFor(nsGkAtoms::onDOMMouseScroll) ||
- elm->HasListenersFor(nsHtml5Atoms::onmousewheel))
- {
- aBuilder->SetAncestorHasScrollEventHandler(true);
+ if (nsLayoutUtils::HasApzAwareListeners(elm)) {
+ aBuilder->SetAncestorHasApzAwareEventHandler(true);
}
}
void
nsIFrame::BuildDisplayListForStackingContext(nsDisplayListBuilder* aBuilder,
const nsRect& aDirtyRect,
nsDisplayList* aList) {
if (GetStateBits() & NS_FRAME_TOO_DEEP_IN_FRAME_TREE)
--- a/layout/generic/nsSubDocumentFrame.cpp
+++ b/layout/generic/nsSubDocumentFrame.cpp
@@ -482,18 +482,17 @@ nsSubDocumentFrame::BuildDisplayList(nsD
if (subdocRootFrame) {
nsIFrame* rootScrollFrame = presShell->GetRootScrollFrame();
nsDisplayListBuilder::AutoCurrentScrollParentIdSetter idSetter(
aBuilder,
ignoreViewportScrolling && rootScrollFrame && rootScrollFrame->GetContent()
? nsLayoutUtils::FindOrCreateIDFor(rootScrollFrame->GetContent())
: aBuilder->GetCurrentScrollParentId());
- aBuilder->SetAncestorHasTouchEventHandler(false);
- aBuilder->SetAncestorHasScrollEventHandler(false);
+ aBuilder->SetAncestorHasApzAwareEventHandler(false);
subdocRootFrame->
BuildDisplayListForStackingContext(aBuilder, dirty, &childItems);
}
if (!aBuilder->IsForEventDelivery()) {
// If we are going to use a displayzoom below then any items we put under
// it need to have underlying frames from the subdocument. So we need to
// calculate the bounds based on which frame will be the underlying frame