Bug 1252877 Part 4: Remove notification of plugins about scrolling from child. r=jimm

MozReview-Commit-ID: 2tHtOxx7jKa
This commit is contained in:
Bob Owen
2016-07-18 09:54:02 +01:00
parent c9184bab91
commit 4d92ace334
15 changed files with 3 additions and 145 deletions

View File

@@ -327,11 +327,6 @@ PluginPRLibrary::GetScrollCaptureContainer(NPP aInstance, ImageContainer** aCont
{ {
return NS_ERROR_NOT_IMPLEMENTED; return NS_ERROR_NOT_IMPLEMENTED;
} }
nsresult
PluginPRLibrary::UpdateScrollState(NPP aInstance, bool aIsScrolling)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
#endif #endif
nsresult nsresult

View File

@@ -127,7 +127,6 @@ public:
virtual void SetHasLocalInstance() override { } virtual void SetHasLocalInstance() override { }
#if defined(XP_WIN) #if defined(XP_WIN)
virtual nsresult GetScrollCaptureContainer(NPP aInstance, mozilla::layers::ImageContainer** aContainer) override; virtual nsresult GetScrollCaptureContainer(NPP aInstance, mozilla::layers::ImageContainer** aContainer) override;
virtual nsresult UpdateScrollState(NPP aInstance, bool aIsScrolling) override;
#endif #endif
virtual nsresult HandledWindowedPluginKeyEvent( virtual nsresult HandledWindowedPluginKeyEvent(
NPP aInstance, NPP aInstance,

View File

@@ -1161,15 +1161,6 @@ nsNPAPIPluginInstance::GetScrollCaptureContainer(ImageContainer**aContainer)
AutoPluginLibraryCall library(this); AutoPluginLibraryCall library(this);
return !library ? NS_ERROR_FAILURE : library->GetScrollCaptureContainer(&mNPP, aContainer); return !library ? NS_ERROR_FAILURE : library->GetScrollCaptureContainer(&mNPP, aContainer);
} }
nsresult
nsNPAPIPluginInstance::UpdateScrollState(bool aIsScrolling)
{
if (RUNNING != mRunning)
return NS_OK;
AutoPluginLibraryCall library(this);
return !library ? NS_ERROR_FAILURE : library->UpdateScrollState(&mNPP, aIsScrolling);
}
#endif #endif
nsresult nsresult

View File

@@ -122,7 +122,6 @@ public:
nsresult GetMIMEType(const char* *result); nsresult GetMIMEType(const char* *result);
#if defined(XP_WIN) #if defined(XP_WIN)
nsresult GetScrollCaptureContainer(mozilla::layers::ImageContainer **aContainer); nsresult GetScrollCaptureContainer(mozilla::layers::ImageContainer **aContainer);
nsresult UpdateScrollState(bool aIsScrolling);
#endif #endif
nsresult HandledWindowedPluginKeyEvent( nsresult HandledWindowedPluginKeyEvent(
const mozilla::NativeEventData& aKeyEventData, const mozilla::NativeEventData& aKeyEventData,

View File

@@ -322,21 +322,6 @@ nsPluginInstanceOwner::GetCurrentImageSize()
return size; return size;
} }
bool
nsPluginInstanceOwner::UpdateScrollState(bool aIsScrolling)
{
#if defined(XP_WIN)
if (!mInstance) {
return false;
}
mScrollState = aIsScrolling;
nsresult rv = mInstance->UpdateScrollState(aIsScrolling);
return NS_SUCCEEDED(rv);
#else
return false;
#endif
}
nsPluginInstanceOwner::nsPluginInstanceOwner() nsPluginInstanceOwner::nsPluginInstanceOwner()
: mPluginWindow(nullptr) : mPluginWindow(nullptr)
{ {
@@ -384,7 +369,6 @@ nsPluginInstanceOwner::nsPluginInstanceOwner()
mGotCompositionData = false; mGotCompositionData = false;
mSentStartComposition = false; mSentStartComposition = false;
mPluginDidNotHandleIMEComposition = false; mPluginDidNotHandleIMEComposition = false;
mScrollState = false;
#endif #endif
} }

View File

@@ -229,8 +229,6 @@ public:
// Returns true if this is windowed plugin that can return static captures // Returns true if this is windowed plugin that can return static captures
// for scroll operations. // for scroll operations.
bool NeedsScrollImageLayer(); bool NeedsScrollImageLayer();
// Notification we receive from nsPluginFrame about scroll state.
bool UpdateScrollState(bool aIsScrolling);
void DidComposite(); void DidComposite();
@@ -411,9 +409,6 @@ private:
#endif #endif
bool mWaitingForPaint; bool mWaitingForPaint;
#if defined(XP_WIN)
bool mScrollState;
#endif
}; };
#endif // nsPluginInstanceOwner_h_ #endif // nsPluginInstanceOwner_h_

View File

@@ -1209,12 +1209,6 @@ PluginInstanceParent::GetScrollCaptureContainer(ImageContainer** aContainer)
return NS_OK; return NS_OK;
} }
nsresult
PluginInstanceParent::UpdateScrollState(bool aIsScrolling)
{
return NS_OK;
}
#endif // XP_WIN #endif // XP_WIN
PluginAsyncSurrogate* PluginAsyncSurrogate*

View File

@@ -333,7 +333,6 @@ public:
#if defined(XP_WIN) #if defined(XP_WIN)
nsresult SetScrollCaptureId(uint64_t aScrollCaptureId); nsresult SetScrollCaptureId(uint64_t aScrollCaptureId);
nsresult GetScrollCaptureContainer(mozilla::layers::ImageContainer** aContainer); nsresult GetScrollCaptureContainer(mozilla::layers::ImageContainer** aContainer);
nsresult UpdateScrollState(bool aIsScrolling);
#endif #endif
void DidComposite(); void DidComposite();

View File

@@ -89,7 +89,6 @@ public:
#endif #endif
#if defined(XP_WIN) #if defined(XP_WIN)
virtual nsresult GetScrollCaptureContainer(NPP aInstance, mozilla::layers::ImageContainer** aContainer) = 0; virtual nsresult GetScrollCaptureContainer(NPP aInstance, mozilla::layers::ImageContainer** aContainer) = 0;
virtual nsresult UpdateScrollState(NPP aInstance, bool aIsScrolling) = 0;
#endif #endif
virtual nsresult HandledWindowedPluginKeyEvent( virtual nsresult HandledWindowedPluginKeyEvent(
NPP aInstance, NPP aInstance,

View File

@@ -2033,12 +2033,6 @@ PluginModuleParent::GetScrollCaptureContainer(NPP aInstance,
PluginInstanceParent* inst = PluginInstanceParent::Cast(aInstance); PluginInstanceParent* inst = PluginInstanceParent::Cast(aInstance);
return !inst ? NS_ERROR_FAILURE : inst->GetScrollCaptureContainer(aContainer); return !inst ? NS_ERROR_FAILURE : inst->GetScrollCaptureContainer(aContainer);
} }
nsresult
PluginModuleParent::UpdateScrollState(NPP aInstance, bool aIsScrolling)
{
PluginInstanceParent* inst = PluginInstanceParent::Cast(aInstance);
return !inst ? NS_ERROR_FAILURE : inst->UpdateScrollState(aIsScrolling);
}
#endif #endif
nsresult nsresult

View File

@@ -263,7 +263,6 @@ protected:
#if defined(XP_WIN) #if defined(XP_WIN)
virtual nsresult GetScrollCaptureContainer(NPP aInstance, mozilla::layers::ImageContainer** aContainer) override; virtual nsresult GetScrollCaptureContainer(NPP aInstance, mozilla::layers::ImageContainer** aContainer) override;
virtual nsresult UpdateScrollState(NPP aInstance, bool aIsScrolling);
#endif #endif
virtual nsresult HandledWindowedPluginKeyEvent( virtual nsresult HandledWindowedPluginKeyEvent(

View File

@@ -1893,7 +1893,6 @@ ScrollFrameHelper::ScrollFrameHelper(nsContainerFrame* aOuter,
, mZoomableByAPZ(false) , mZoomableByAPZ(false)
, mScrollsClipOnUnscrolledOutOfFlow(false) , mScrollsClipOnUnscrolledOutOfFlow(false)
, mVelocityQueue(aOuter->PresContext()) , mVelocityQueue(aOuter->PresContext())
, mAsyncScrollEvent(END_DOM)
{ {
if (LookAndFeel::GetInt(LookAndFeel::eIntID_UseOverlayScrollbars) != 0) { if (LookAndFeel::GetInt(LookAndFeel::eIntID_UseOverlayScrollbars) != 0) {
mScrollbarActivity = new ScrollbarActivity(do_QueryFrame(aOuter)); mScrollbarActivity = new ScrollbarActivity(do_QueryFrame(aOuter));
@@ -2006,8 +2005,6 @@ ScrollFrameHelper::AsyncScrollCallback(ScrollFrameHelper* aInstance,
void void
ScrollFrameHelper::CompleteAsyncScroll(const nsRect &aRange, nsIAtom* aOrigin) ScrollFrameHelper::CompleteAsyncScroll(const nsRect &aRange, nsIAtom* aOrigin)
{ {
NotifyPluginFrames(END_DOM);
// Apply desired destination range since this is the last step of scrolling. // Apply desired destination range since this is the last step of scrolling.
mAsyncSmoothMSDScroll = nullptr; mAsyncSmoothMSDScroll = nullptr;
mAsyncScroll = nullptr; mAsyncScroll = nullptr;
@@ -2023,11 +2020,6 @@ ScrollFrameHelper::CompleteAsyncScroll(const nsRect &aRange, nsIAtom* aOrigin)
#if defined(XP_WIN) || defined(MOZ_WIDGET_GTK) #if defined(XP_WIN) || defined(MOZ_WIDGET_GTK)
struct PluginSearchCtx { struct PluginSearchCtx {
enum PluginAction {
UPDATE, // Update the scroll visibility of any plugin frames using |value|
QUERY // Set |value| to true if plugin frames were found
};
PluginAction action;
nsIFrame* outer; nsIFrame* outer;
bool value; bool value;
}; };
@@ -2044,11 +2036,7 @@ NotifyPluginFramesCallback(nsISupports* aSupports, void* aCtx)
// Check to be sure this plugin is contained within a subframe of // Check to be sure this plugin is contained within a subframe of
// the nsGfxScrollFrame that initiated this callback. // the nsGfxScrollFrame that initiated this callback.
if (nsLayoutUtils::IsAncestorFrameCrossDoc(pCtx->outer, plugin, nullptr)) { if (nsLayoutUtils::IsAncestorFrameCrossDoc(pCtx->outer, plugin, nullptr)) {
if (pCtx->action == PluginSearchCtx::UPDATE) { pCtx->value = true;
plugin->SetScrollVisibility(pCtx->value);
} else if (pCtx->action == PluginSearchCtx::QUERY) {
pCtx->value = true;
}
} }
} }
} }
@@ -2064,39 +2052,13 @@ NotifyPluginSubframesCallback(nsIDocument* aDocument, void* aCtx)
} }
#endif #endif
void
ScrollFrameHelper::NotifyPluginFrames(AsyncScrollEventType aEvent)
{
#if defined(XP_WIN) || defined(MOZ_WIDGET_GTK)
if (!gfxPrefs::HidePluginsForScroll()) {
return;
}
if (XRE_IsContentProcess()) {
// Ignore 'inner' dom events triggered by apz transformations
if (mAsyncScrollEvent == BEGIN_APZ && aEvent != END_APZ) {
return;
}
if (aEvent != mAsyncScrollEvent) {
nsPresContext* presContext = mOuter->PresContext();
PluginSearchCtx ctx = { PluginSearchCtx::UPDATE, mOuter, (aEvent == BEGIN_APZ || aEvent == BEGIN_DOM) };
presContext->Document()->EnumerateActivityObservers(NotifyPluginFramesCallback,
(void*)&ctx);
presContext->Document()->EnumerateSubDocuments(NotifyPluginSubframesCallback,
(void*)&ctx);
mAsyncScrollEvent = aEvent;
}
}
#endif
}
bool bool
ScrollFrameHelper::HasPluginFrames() ScrollFrameHelper::HasPluginFrames()
{ {
#if defined(XP_WIN) || defined(MOZ_WIDGET_GTK) #if defined(XP_WIN) || defined(MOZ_WIDGET_GTK)
if (XRE_IsContentProcess()) { if (XRE_IsContentProcess()) {
nsPresContext* presContext = mOuter->PresContext(); nsPresContext* presContext = mOuter->PresContext();
PluginSearchCtx ctx = { PluginSearchCtx::QUERY, mOuter, false }; PluginSearchCtx ctx = { mOuter, false };
presContext->Document()->EnumerateActivityObservers(NotifyPluginFramesCallback, presContext->Document()->EnumerateActivityObservers(NotifyPluginFramesCallback,
(void*)&ctx); (void*)&ctx);
if (ctx.value) { if (ctx.value) {
@@ -2322,7 +2284,6 @@ ScrollFrameHelper::ScrollToWithOrigin(nsPoint aScrollPosition,
mAsyncScroll->mIsSmoothScroll = isSmoothScroll; mAsyncScroll->mIsSmoothScroll = isSmoothScroll;
if (isSmoothScroll) { if (isSmoothScroll) {
NotifyPluginFrames(BEGIN_DOM);
mAsyncScroll->InitSmoothScroll(now, mDestination, aOrigin, range, currentVelocity); mAsyncScroll->InitSmoothScroll(now, mDestination, aOrigin, range, currentVelocity);
} else { } else {
mAsyncScroll->Init(range); mAsyncScroll->Init(range);

View File

@@ -379,7 +379,6 @@ public:
// because we have special behaviour for it when APZ scrolling is active. // because we have special behaviour for it when APZ scrolling is active.
mOuter->SchedulePaint(); mOuter->SchedulePaint();
} }
NotifyPluginFrames(aTransforming ? BEGIN_APZ : END_APZ);
} }
bool IsTransformingByAPZ() const { bool IsTransformingByAPZ() const {
return mTransformingByAPZ; return mTransformingByAPZ;
@@ -620,13 +619,6 @@ protected:
void CompleteAsyncScroll(const nsRect &aRange, nsIAtom* aOrigin = nullptr); void CompleteAsyncScroll(const nsRect &aRange, nsIAtom* aOrigin = nullptr);
/*
* Helper that notifies plugins about async smooth scroll operations managed
* by nsGfxScrollFrame.
*/
enum AsyncScrollEventType { BEGIN_DOM, BEGIN_APZ, END_DOM, END_APZ };
void NotifyPluginFrames(AsyncScrollEventType aEvent);
AsyncScrollEventType mAsyncScrollEvent;
bool HasPluginFrames(); bool HasPluginFrames();
bool HasPerspective() const; bool HasPerspective() const;
bool HasBgAttachmentLocal() const; bool HasBgAttachmentLocal() const;

View File

@@ -153,7 +153,6 @@ nsPluginFrame::nsPluginFrame(nsStyleContext* aContext)
: nsFrame(aContext) : nsFrame(aContext)
, mInstanceOwner(nullptr) , mInstanceOwner(nullptr)
, mReflowCallbackPosted(false) , mReflowCallbackPosted(false)
, mIsHiddenDueToScroll(false)
{ {
MOZ_LOG(sPluginFrameLog, LogLevel::Debug, MOZ_LOG(sPluginFrameLog, LogLevel::Debug,
("Created new nsPluginFrame %p\n", this)); ("Created new nsPluginFrame %p\n", this));
@@ -418,7 +417,7 @@ nsPluginFrame::GetWidgetConfiguration(nsTArray<nsIWidget::Configuration>* aConfi
#if defined(XP_WIN) || defined(MOZ_WIDGET_GTK) #if defined(XP_WIN) || defined(MOZ_WIDGET_GTK)
if (XRE_IsContentProcess()) { if (XRE_IsContentProcess()) {
configuration->mWindowID = (uintptr_t)mWidget->GetNativeData(NS_NATIVE_PLUGIN_PORT); configuration->mWindowID = (uintptr_t)mWidget->GetNativeData(NS_NATIVE_PLUGIN_PORT);
configuration->mVisible = !mIsHiddenDueToScroll && mWidget->IsVisible(); configuration->mVisible = mWidget->IsVisible();
} }
#endif // defined(XP_WIN) || defined(MOZ_WIDGET_GTK) #endif // defined(XP_WIN) || defined(MOZ_WIDGET_GTK)
@@ -772,24 +771,6 @@ nsPluginFrame::IsHidden(bool aCheckVisibilityStyle) const
return false; return false;
} }
// Clips windowed plugin frames during remote content scroll operations managed
// by nsGfxScrollFrame.
void
nsPluginFrame::SetScrollVisibility(bool aState)
{
// Limit this setting to windowed plugins by checking if we have a widget
if (mWidget) {
bool changed = mIsHiddenDueToScroll != aState;
mIsHiddenDueToScroll = aState;
// Force a paint so plugin window visibility gets flushed via
// the compositor.
if (changed && mInstanceOwner) {
mInstanceOwner->UpdateScrollState(mIsHiddenDueToScroll);
SchedulePaint();
}
}
}
mozilla::LayoutDeviceIntPoint mozilla::LayoutDeviceIntPoint
nsPluginFrame::GetRemoteTabChromeOffset() nsPluginFrame::GetRemoteTabChromeOffset()
{ {
@@ -1138,13 +1119,6 @@ nsPluginFrame::DidSetWidgetGeometry()
bool bool
nsPluginFrame::IsOpaque() const nsPluginFrame::IsOpaque() const
{ {
#if defined(MOZ_WIDGET_GTK)
// Insure underlying content gets painted when we clip windowed plugins
// during remote content scroll operations managed by nsGfxScrollFrame.
if (mIsHiddenDueToScroll) {
return false;
}
#endif
#if defined(XP_MACOSX) #if defined(XP_MACOSX)
return false; return false;
#elif defined(MOZ_WIDGET_ANDROID) #elif defined(MOZ_WIDGET_ANDROID)
@@ -1194,14 +1168,6 @@ nsPluginFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
const nsRect& aDirtyRect, const nsRect& aDirtyRect,
const nsDisplayListSet& aLists) const nsDisplayListSet& aLists)
{ {
#if defined(MOZ_WIDGET_GTK)
// Clip windowed plugin frames from the list during remote content scroll
// operations managed by nsGfxScrollFrame.
if (mIsHiddenDueToScroll) {
return;
}
#endif
// XXX why are we painting collapsed object frames? // XXX why are we painting collapsed object frames?
if (!IsVisibleOrCollapsedForPainting(aBuilder)) if (!IsVisibleOrCollapsedForPainting(aBuilder))
return; return;

View File

@@ -213,11 +213,6 @@ public:
void SetInstanceOwner(nsPluginInstanceOwner* aOwner); void SetInstanceOwner(nsPluginInstanceOwner* aOwner);
/**
* Helper for hiding windowed plugins during async scroll operations.
*/
void SetScrollVisibility(bool aState);
/** /**
* HandleWheelEventAsDefaultAction() handles eWheel event as default action. * HandleWheelEventAsDefaultAction() handles eWheel event as default action.
* This should be called only when WantsToHandleWheelEventAsDefaultAction() * This should be called only when WantsToHandleWheelEventAsDefaultAction()
@@ -337,10 +332,6 @@ private:
RefPtr<nsRootPresContext> mRootPresContextRegisteredWith; RefPtr<nsRootPresContext> mRootPresContextRegisteredWith;
mozilla::UniquePtr<PluginFrameDidCompositeObserver> mDidCompositeObserver; mozilla::UniquePtr<PluginFrameDidCompositeObserver> mDidCompositeObserver;
// Tracks windowed plugin visibility during scroll operations. See
// SetScrollVisibility.
bool mIsHiddenDueToScroll;
}; };
class nsDisplayPlugin : public nsDisplayItem { class nsDisplayPlugin : public nsDisplayItem {