Bug 1125422 - Fold touch and scroll listener flags into a single apz-aware flag for better code reuse. r=roc

This commit is contained in:
Kartikaya Gupta 2015-02-10 16:28:07 -05:00
Родитель f5d90daf87
Коммит 3832470e38
6 изменённых файлов: 28 добавлений и 35 удалений

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

@ -587,8 +587,7 @@ nsDisplayListBuilder::nsDisplayListBuilder(nsIFrame* aReferenceFrame,
mIsPaintingToWindow(false),
mIsCompositingCheap(false),
mContainsPluginItem(false),
mAncestorHasTouchEventHandler(false),
mAncestorHasScrollEventHandler(false),
mAncestorHasApzAwareEventHandler(false),
mHaveScrollableDisplayPort(false),
mWindowDraggingAllowed(false),
mIsBuildingForPopup(nsLayoutUtils::IsPopup(aReferenceFrame))
@ -3151,9 +3150,7 @@ nsDisplayLayerEventRegions::AddFrame(nsDisplayListBuilder* aBuilder,
} else {
mHitRegion.Or(mHitRegion, borderBox);
}
if (aBuilder->GetAncestorHasTouchEventHandler() ||
aBuilder->GetAncestorHasScrollEventHandler())
{
if (aBuilder->GetAncestorHasApzAwareEventHandler()) {
mDispatchToContentHitRegion.Or(mDispatchToContentHitRegion, borderBox);
}
}

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

@ -345,15 +345,10 @@ public:
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; }
@ -578,8 +573,7 @@ public:
mPrevOffset(aBuilder->mCurrentOffsetToReferenceFrame),
mPrevDirtyRect(aBuilder->mDirtyRect),
mPrevIsAtRootOfPseudoStackingContext(aBuilder->mIsAtRootOfPseudoStackingContext),
mPrevAncestorHasTouchEventHandler(aBuilder->mAncestorHasTouchEventHandler),
mPrevAncestorHasScrollEventHandler(aBuilder->mAncestorHasScrollEventHandler)
mPrevAncestorHasApzAwareEventHandler(aBuilder->mAncestorHasApzAwareEventHandler)
{
if (aForChild->IsTransformed()) {
aBuilder->mCurrentOffsetToReferenceFrame = nsPoint();
@ -624,8 +618,7 @@ public:
mBuilder->mCurrentOffsetToReferenceFrame = mPrevOffset;
mBuilder->mDirtyRect = mPrevDirtyRect;
mBuilder->mIsAtRootOfPseudoStackingContext = mPrevIsAtRootOfPseudoStackingContext;
mBuilder->mAncestorHasTouchEventHandler = mPrevAncestorHasTouchEventHandler;
mBuilder->mAncestorHasScrollEventHandler = mPrevAncestorHasScrollEventHandler;
mBuilder->mAncestorHasApzAwareEventHandler = mPrevAncestorHasApzAwareEventHandler;
mBuilder->mCurrentAnimatedGeometryRoot = mPrevAnimatedGeometryRoot;
}
private:
@ -637,8 +630,7 @@ public:
nsPoint mPrevOffset;
nsRect mPrevDirtyRect;
bool mPrevIsAtRootOfPseudoStackingContext;
bool mPrevAncestorHasTouchEventHandler;
bool mPrevAncestorHasScrollEventHandler;
bool mPrevAncestorHasApzAwareEventHandler;
};
/**
@ -920,8 +912,7 @@ private:
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().

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

@ -7838,3 +7838,16 @@ nsLayoutUtils::SetBSizeFromFontMetrics(const nsIFrame* aFrame,
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);
}

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

@ -63,6 +63,7 @@ struct nsStyleImageOrientation;
struct nsOverflowAreas;
namespace mozilla {
class EventListenerManager;
class SVGImageContext;
struct IntrinsicSize;
struct ContainerLayerParameters;
@ -2551,6 +2552,8 @@ public:
mozilla::WritingMode aLineWM,
mozilla::WritingMode aFrameWM);
static bool HasApzAwareListeners(mozilla::EventListenerManager* aElm);
private:
static uint32_t sFontSizeInflationEmPerLine;
static uint32_t sFontSizeInflationMinTwips;

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

@ -1909,18 +1909,8 @@ CheckForApzAwareEventHandlers(nsDisplayListBuilder* aBuilder, nsIFrame* aFrame)
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);
}
}

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

@ -487,8 +487,7 @@ nsSubDocumentFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
? nsLayoutUtils::FindOrCreateIDFor(rootScrollFrame->GetContent())
: aBuilder->GetCurrentScrollParentId());
aBuilder->SetAncestorHasTouchEventHandler(false);
aBuilder->SetAncestorHasScrollEventHandler(false);
aBuilder->SetAncestorHasApzAwareEventHandler(false);
subdocRootFrame->
BuildDisplayListForStackingContext(aBuilder, dirty, &childItems);
}