Bug 1125422 - Populate the ContainerLayer flag to force events to be dispatched to content. r=roc

This commit is contained in:
Kartikaya Gupta 2015-02-10 16:28:07 -05:00
Родитель 796beb9721
Коммит 4ea12e1645
6 изменённых файлов: 46 добавлений и 5 удалений

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

@ -1629,6 +1629,9 @@ already_AddRefed<LayerManager> nsDisplayList::PaintRoot(nsDisplayListBuilder* aB
1.0f/containerParameters.mYScale);
root->SetScaleToResolution(presShell->ScaleToResolution(),
containerParameters.mXScale);
root->SetForceDispatchToContentRegion(
aBuilder->IsBuildingLayerEventRegions() &&
nsLayoutUtils::HasDocumentLevelListenersForApzAwareEvents(presShell));
if (gfxPrefs::LayoutUseContainersForRootFrames()) {
bool isRoot = presContext->IsRootContentDocument();
@ -4061,6 +4064,9 @@ nsDisplaySubDocument::nsDisplaySubDocument(nsDisplayListBuilder* aBuilder,
, mScrollParentId(aBuilder->GetCurrentScrollParentId())
{
MOZ_COUNT_CTOR(nsDisplaySubDocument);
mForceDispatchToContentRegion =
aBuilder->IsBuildingLayerEventRegions() &&
nsLayoutUtils::HasDocumentLevelListenersForApzAwareEvents(aFrame->PresContext()->PresShell());
}
#ifdef NS_BUILD_REFCNT_LOGGING
@ -4082,7 +4088,9 @@ nsDisplaySubDocument::BuildLayer(nsDisplayListBuilder* aBuilder,
params.mInLowPrecisionDisplayPort = true;
}
return nsDisplayOwnLayer::BuildLayer(aBuilder, aManager, params);
nsRefPtr<Layer> layer = nsDisplayOwnLayer::BuildLayer(aBuilder, aManager, params);
layer->AsContainerLayer()->SetForceDispatchToContentRegion(mForceDispatchToContentRegion);
return layer.forget();
}
UniquePtr<FrameMetrics>

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

@ -3036,6 +3036,7 @@ public:
protected:
ViewID mScrollParentId;
bool mForceDispatchToContentRegion;
};
/**

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

@ -20,6 +20,7 @@
#include "nsIDOMHTMLElement.h"
#include "nsFrameList.h"
#include "nsGkAtoms.h"
#include "nsHtml5Atoms.h"
#include "nsIAtom.h"
#include "nsCSSPseudoElements.h"
#include "nsCSSAnonBoxes.h"
@ -7851,3 +7852,21 @@ nsLayoutUtils::HasApzAwareListeners(EventListenerManager* aElm)
aElm->HasListenersFor(nsGkAtoms::onDOMMouseScroll) ||
aElm->HasListenersFor(nsHtml5Atoms::onmousewheel);
}
/* static */ bool
nsLayoutUtils::HasDocumentLevelListenersForApzAwareEvents(nsIPresShell* aShell)
{
if (nsIDocument* doc = aShell->GetDocument()) {
WidgetEvent event(true, NS_EVENT_NULL);
nsTArray<EventTarget*> targets;
nsresult rv = EventDispatcher::Dispatch(doc, nullptr, &event, nullptr,
nullptr, nullptr, &targets);
NS_ENSURE_SUCCESS(rv, false);
for (size_t i = 0; i < targets.Length(); i++) {
if (HasApzAwareListeners(targets[i]->GetExistingListenerManager())) {
return true;
}
}
}
return false;
}

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

@ -2553,6 +2553,7 @@ public:
mozilla::WritingMode aFrameWM);
static bool HasApzAwareListeners(mozilla::EventListenerManager* aElm);
static bool HasDocumentLevelListenersForApzAwareEvents(nsIPresShell* aShell);
private:
static uint32_t sFontSizeInflationEmPerLine;

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

@ -615,6 +615,17 @@ RenderFrameParent::TakeFocusForClick()
} // namespace layout
} // namespace mozilla
nsDisplayRemote::nsDisplayRemote(nsDisplayListBuilder* aBuilder,
nsIFrame* aFrame,
RenderFrameParent* aRemoteFrame)
: nsDisplayItem(aBuilder, aFrame)
, mRemoteFrame(aRemoteFrame)
{
mForceDispatchToContentRegion =
aBuilder->IsBuildingLayerEventRegions() &&
nsLayoutUtils::HasDocumentLevelListenersForApzAwareEvents(aFrame->PresContext()->PresShell());
}
already_AddRefed<Layer>
nsDisplayRemote::BuildLayer(nsDisplayListBuilder* aBuilder,
LayerManager* aManager,
@ -624,6 +635,9 @@ nsDisplayRemote::BuildLayer(nsDisplayListBuilder* aBuilder,
nsIntRect visibleRect = GetVisibleRect().ToNearestPixels(appUnitsPerDevPixel);
visibleRect += aContainerParameters.mOffset;
nsRefPtr<Layer> layer = mRemoteFrame->BuildLayer(aBuilder, mFrame, aManager, visibleRect, this, aContainerParameters);
if (layer && layer->AsContainerLayer()) {
layer->AsContainerLayer()->SetForceDispatchToContentRegion(mForceDispatchToContentRegion);
}
return layer.forget();
}

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

@ -166,10 +166,7 @@ class nsDisplayRemote : public nsDisplayItem
public:
nsDisplayRemote(nsDisplayListBuilder* aBuilder, nsIFrame* aFrame,
RenderFrameParent* aRemoteFrame)
: nsDisplayItem(aBuilder, aFrame)
, mRemoteFrame(aRemoteFrame)
{}
RenderFrameParent* aRemoteFrame);
virtual LayerState GetLayerState(nsDisplayListBuilder* aBuilder,
LayerManager* aManager,
@ -187,6 +184,7 @@ public:
private:
RenderFrameParent* mRemoteFrame;
bool mForceDispatchToContentRegion;
};