Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

backing out bug 347743 due to major crasher in 386332

  • Loading branch information...
commit 424ea449be75344d2b87e9aadc19d0a35412fdaa 1 parent 37abdd2
mconnor@steelgryphon.com authored
View
224 layout/generic/nsObjectFrame.cpp
@@ -122,8 +122,6 @@
#include "nsPIPluginHost.h"
#include "nsIPluginDocument.h"
-#include "nsThreadUtils.h"
-
#ifdef MOZ_CAIRO_GFX
#include "gfxContext.h"
#endif
@@ -334,8 +332,6 @@ class nsPluginInstanceOwner : public nsIPluginInstanceOwner,
nsresult Destroy();
- void PrepareToStop(PRBool aDelayedStop);
-
//nsIEventListener interface
nsEventStatus ProcessEvent(const nsGUIEvent & anEvent);
@@ -367,11 +363,6 @@ class nsPluginInstanceOwner : public nsIPluginInstanceOwner,
void GUItoMacEvent(const nsGUIEvent& anEvent, EventRecord* origEvent, EventRecord& aMacEvent);
#endif
- void SetOwner(nsObjectFrame *aOwner)
- {
- mOwner = aOwner;
- }
-
private:
void FixUpURLS(const nsString &name, nsAString &value);
@@ -386,10 +377,6 @@ class nsPluginInstanceOwner : public nsIPluginInstanceOwner,
nsCOMPtr<nsIPluginHost> mPluginHost;
PRPackedBool mContentFocused;
PRPackedBool mWidgetVisible; // used on Mac to store our widget's visible state
-
- // If true, destroy the widget on destruction. Used when plugin stop
- // is being delayed to a safer point in time.
- PRPackedBool mDestroyWidget;
PRUint16 mNumCachedAttrs;
PRUint16 mNumCachedParams;
char **mCachedAttrParamNames;
@@ -512,7 +499,7 @@ nsObjectFrame::Destroy()
// we need to finish with the plugin before native window is destroyed
// doing this in the destructor is too late.
- StopPluginInternal(PR_TRUE);
+ StopPlugin();
nsObjectFrameSuper::Destroy();
}
@@ -1301,7 +1288,7 @@ nsresult
nsObjectFrame::PrepareInstanceOwner()
{
// First, have to stop any possibly running plugins.
- StopPluginInternal(PR_FALSE);
+ StopPlugin();
NS_ASSERTION(!mInstanceOwner, "Must not have an instance owner here");
@@ -1371,49 +1358,47 @@ nsObjectFrame::Instantiate(const char* aMimeType, nsIURI* aURI)
return rv;
}
-class nsStopPluginRunnable : public nsRunnable
-{
-public:
- nsStopPluginRunnable(nsPluginInstanceOwner *aInstanceOwner)
- : mInstanceOwner(aInstanceOwner)
- {
- }
-
- NS_IMETHOD Run();
-
-private:
- nsRefPtr<nsPluginInstanceOwner> mInstanceOwner;
-};
-
-static void
-DoStopPlugin(nsPluginInstanceOwner *aInstanceOwner)
+void
+nsObjectFrame::StopPlugin()
{
- nsCOMPtr<nsIPluginInstance> inst;
- aInstanceOwner->GetInstance(*getter_AddRefs(inst));
- if (inst) {
- nsPluginWindow *win;
- aInstanceOwner->GetWindow(win);
- nsPluginNativeWindow *window = (nsPluginNativeWindow *)win;
- nsCOMPtr<nsIPluginInstance> nullinst;
-
- PRBool doCache = PR_TRUE;
- PRBool doCallSetWindowAfterDestroy = PR_FALSE;
-
- // first, determine if the plugin wants to be cached
- inst->GetValue(nsPluginInstanceVariable_DoCacheBool, (void *)&doCache);
- if (!doCache) {
- // then determine if the plugin wants Destroy to be called after
- // Set Window. This is for bug 50547.
- inst->GetValue(nsPluginInstanceVariable_CallSetWindowAfterDestroyBool,
- (void *)&doCallSetWindowAfterDestroy);
- if (doCallSetWindowAfterDestroy) {
- inst->Stop();
- inst->Destroy();
-
- if (window)
- window->CallSetWindow(nullinst);
- else
- inst->SetWindow(nsnull);
+ if (mInstanceOwner != nsnull) {
+ nsCOMPtr<nsIPluginInstance> inst;
+ mInstanceOwner->GetInstance(*getter_AddRefs(inst));
+ if (inst) {
+ nsPluginWindow *win;
+ mInstanceOwner->GetWindow(win);
+ nsPluginNativeWindow *window = (nsPluginNativeWindow *)win;
+ nsCOMPtr<nsIPluginInstance> nullinst;
+
+ PRBool doCache = PR_TRUE;
+ PRBool doCallSetWindowAfterDestroy = PR_FALSE;
+
+ // first, determine if the plugin wants to be cached
+ inst->GetValue(nsPluginInstanceVariable_DoCacheBool,
+ (void *) &doCache);
+ if (!doCache) {
+ // then determine if the plugin wants Destroy to be called after
+ // Set Window. This is for bug 50547.
+ inst->GetValue(nsPluginInstanceVariable_CallSetWindowAfterDestroyBool,
+ (void *) &doCallSetWindowAfterDestroy);
+ if (doCallSetWindowAfterDestroy) {
+ inst->Stop();
+ inst->Destroy();
+
+ if (window)
+ window->CallSetWindow(nullinst);
+ else
+ inst->SetWindow(nsnull);
+ }
+ else {
+ if (window)
+ window->CallSetWindow(nullinst);
+ else
+ inst->SetWindow(nsnull);
+
+ inst->Stop();
+ inst->Destroy();
+ }
}
else {
if (window)
@@ -1422,82 +1407,21 @@ DoStopPlugin(nsPluginInstanceOwner *aInstanceOwner)
inst->SetWindow(nsnull);
inst->Stop();
- inst->Destroy();
}
- }
- else {
- if (window)
- window->CallSetWindow(nullinst);
- else
- inst->SetWindow(nsnull);
-
- inst->Stop();
- }
- nsCOMPtr<nsIPluginHost> pluginHost = do_GetService(kCPluginManagerCID);
- if (pluginHost)
- pluginHost->StopPluginInstance(inst);
-
- // the frame is going away along with its widget so tell the
- // window to forget its widget too
- if (window)
- window->SetPluginWidget(nsnull);
- }
-
- aInstanceOwner->Destroy();
-}
-
-NS_IMETHODIMP
-nsStopPluginRunnable::Run()
-{
- DoStopPlugin(mInstanceOwner);
-
- return NS_OK;
-}
+ nsCOMPtr<nsIPluginHost> pluginHost = do_GetService(kCPluginManagerCID);
+ if (pluginHost)
+ pluginHost->StopPluginInstance(inst);
-void
-nsObjectFrame::StopPlugin()
-{
- StopPluginInternal(PR_FALSE);
-}
-
-void
-nsObjectFrame::StopPluginInternal(PRBool aDelayedStop)
-{
- if (mInstanceOwner == nsnull) {
- return;
- }
-
- mInstanceOwner->PrepareToStop(aDelayedStop);
-
-#ifdef XP_WIN
- // We only deal with delayed stopping of plugins on Win32 for now,
- // as that's the only platform where we need to (AFAIK) and it's
- // unclear how safe widget parenting is on other platforms.
- if (aDelayedStop) {
- // nsStopPluginRunnable will hold a strong reference to
- // mInstanceOwner, and thus keep it alive as long as it needs it.
- nsCOMPtr<nsIRunnable> evt = new nsStopPluginRunnable(mInstanceOwner);
- NS_DispatchToCurrentThread(evt);
-
- // If we're asked to do a delayed stop it means we're stopping the
- // plugin because we're destroying the frame. In that case, tell
- // the view to disown the widget (i.e. leave it up to us to
- // destroy it).
- nsIView *view = GetView();
- if (view) {
- view->DisownWidget();
+ // the frame is going away along with its widget
+ // so tell the window to forget its widget too
+ if (window)
+ window->SetPluginWidget(nsnull);
}
- } else
-#endif
- {
- DoStopPlugin(mInstanceOwner);
- }
-
- // Break relationship between frame and plugin instance owner
- mInstanceOwner->SetOwner(nsnull);
- NS_RELEASE(mInstanceOwner);
+ mInstanceOwner->Destroy();
+ NS_RELEASE(mInstanceOwner);
+ }
}
void
@@ -1649,7 +1573,6 @@ nsPluginInstanceOwner::nsPluginInstanceOwner()
mNumCachedParams = 0;
mCachedAttrParamNames = nsnull;
mCachedAttrParamValues = nsnull;
- mDestroyWidget = PR_FALSE;
}
nsPluginInstanceOwner::~nsPluginInstanceOwner()
@@ -3208,45 +3131,6 @@ nsPluginInstanceOwner::Destroy()
target->RemoveEventListener(NS_LITERAL_STRING("draggesture"), listener, PR_TRUE);
}
- if (mDestroyWidget && mWidget) {
- mWidget->Destroy();
- }
-
- return NS_OK;
-}
-
-/*
- * Prepare to stop
- */
-void
-nsPluginInstanceOwner::PrepareToStop(PRBool aDelayedStop)
-{
- if (!mWidget) {
- return;
- }
-
-#ifdef XP_WIN
- if (aDelayedStop) {
- // To delay stopping a plugin we need to reparent the plugin to
- // the top-level Gecko widget so that we can safely tear down the
- // plugin after its frame (and view) is gone.
-
- nsIWidget *appTopWidget = mWidget->GetTopLevelWindow();
-
- // Also hide and disable the widget to avoid it from appearing in
- // odd places after reparenting it, but before it gets destroyed.
- mWidget->Show(PR_FALSE);
- mWidget->Enable(PR_FALSE);
-
- // Reparent the plugins native window. This relies on the widget
- // and plugin et al not holding any other references to its
- // parent.
- mWidget->SetParent(appTopWidget);
-
- mDestroyWidget = PR_TRUE;
- }
-#endif
-
// Unregister scroll position listener
nsIFrame* parentWithView = mOwner->GetAncestorWithView();
nsIView* curView = parentWithView ? parentWithView->GetView() : nsnull;
@@ -3257,6 +3141,10 @@ nsPluginInstanceOwner::PrepareToStop(PRBool aDelayedStop)
curView = curView->GetParent();
}
+
+ mOwner = nsnull; // break relationship between frame and plugin instance owner
+
+ return NS_OK;
}
// Paints are handled differently, so we just simulate an update event.
View
8 layout/generic/nsObjectFrame.h
@@ -112,14 +112,6 @@ class nsObjectFrame : public nsObjectFrameSuper, public nsIObjectFrame {
virtual nsresult Instantiate(const char* aMimeType, nsIURI* aURI);
virtual void StopPlugin();
- /*
- * Stop a plugin instance. If aDelayedStop is true, the plugin will
- * be stopped at a later point when it's safe to do so (i.e. not
- * while destroying the frame tree). Delayed stopping is only
- * implemented on Win32 for now.
- */
- void StopPluginInternal(PRBool aDelayedStop);
-
/* fail on any requests to get a cursor from us because plugins set their own! see bug 118877 */
NS_IMETHOD GetCursor(const nsPoint& aPoint, nsIFrame::Cursor& aCursor)
View
9 view/public/nsIView.h
@@ -299,14 +299,6 @@ class nsIView
*/
PRBool HasWidget() const { return mWindow != nsnull; }
- /**
- * If called, will make the view disown the widget and leave it up
- * to other code to destroy it.
- */
- void DisownWidget() {
- mWidgetDisowned = PR_TRUE;
- }
-
#ifdef DEBUG
/**
* Output debug info to FILE
@@ -337,7 +329,6 @@ class nsIView
nsRect mDimBounds; // relative to parent
float mOpacity;
PRUint32 mVFlags;
- PRBool mWidgetDisowned;
virtual ~nsIView() {}
};
View
5 view/src/nsView.cpp
@@ -183,7 +183,6 @@ nsView::nsView(nsViewManager* aViewManager, nsViewVisibility aVisibility)
mVFlags = 0;
mViewManager = aViewManager;
mDirtyRegion = nsnull;
- mWidgetDisowned = PR_FALSE;
}
void nsView::DropMouseGrabbing() {
@@ -251,9 +250,7 @@ nsView::~nsView()
NS_IF_RELEASE(wrapper);
mWindow->SetClientData(nsnull);
- if (!mWidgetDisowned) {
- mWindow->Destroy();
- }
+ mWindow->Destroy();
NS_RELEASE(mWindow);
}
delete mDirtyRegion;
View
30 widget/src/windows/nsWindow.cpp
@@ -7374,7 +7374,7 @@ nsWindow::ResolveIMECaretPos(nsWindow* aClient,
nsRect& aResult)
{
// RootView coordinates -> Screen coordinates
- GetTopLevelWindowInternal()->WidgetToScreen(aEventResult, aResult);
+ GetTopLevelWindow()->WidgetToScreen(aEventResult, aResult);
// if aClient is nsnull, returns screen coordinates
if (!aClient)
return;
@@ -7766,26 +7766,6 @@ nsWindow::GetLastInputEventTime(PRUint32& aTime)
return NS_OK;
}
-nsIWidget* nsWindow::GetTopLevelWindow(void)
-{
- HWND hWnd = (HWND)GetNativeData(NS_NATIVE_WINDOW);
- HWND rootWnd = hWnd;
- nsIWidget *topWidget = nsnull;
-
- while (1) {
- HWND parent = ::GetParent(rootWnd);
-
- if (!parent || GetNSWindowPtr(parent) == nsnull) {
- break;
- }
-
- rootWnd = parent;
- }
-
- return GetNSWindowPtr(rootWnd);
-}
-
-
//-------------------------------------------------------------------------
//-------------------------------------------------------------------------
//-- NOTE!!! These hook functions can be removed when we migrate to
@@ -8204,7 +8184,7 @@ STDMETHODIMP_(LRESULT) nsWindow::LresultFromObject(REFIID riid, WPARAM wParam, L
#ifdef MOZ_XUL
-nsWindow* nsWindow::GetTopLevelWindowInternal()
+nsWindow* nsWindow::GetTopLevelWindow()
{
nsWindow* curWindow = this;
@@ -8323,21 +8303,21 @@ void nsWindow::ResizeTranslucentWindow(PRInt32 aNewWidth, PRInt32 aNewHeight, PR
NS_IMETHODIMP nsWindow::GetWindowTranslucency(PRBool& aTranslucent)
{
- aTranslucent = GetTopLevelWindowInternal()->GetWindowTranslucencyInner();
+ aTranslucent = GetTopLevelWindow()->GetWindowTranslucencyInner();
return NS_OK;
}
NS_IMETHODIMP nsWindow::SetWindowTranslucency(PRBool aTranslucent)
{
- nsresult rv = GetTopLevelWindowInternal()->SetWindowTranslucencyInner(aTranslucent);
+ nsresult rv = GetTopLevelWindow()->SetWindowTranslucencyInner(aTranslucent);
return rv;
}
NS_IMETHODIMP nsWindow::UpdateTranslucentWindowAlpha(const nsRect& aRect, PRUint8* aAlphas)
{
- GetTopLevelWindowInternal()->UpdateTranslucentWindowAlphaInner(aRect, aAlphas);
+ GetTopLevelWindow()->UpdateTranslucentWindowAlphaInner(aRect, aAlphas);
return NS_OK;
}
View
4 widget/src/windows/nsWindow.h
@@ -204,9 +204,7 @@ class nsWindow : public nsSwitchToUIThread,
NS_IMETHOD GetAttention(PRInt32 aCycleCount);
NS_IMETHOD GetLastInputEventTime(PRUint32& aTime);
- virtual nsIWidget* GetTopLevelWindow(void);
-
- nsWindow* GetTopLevelWindowInternal();
+ nsWindow* GetTopLevelWindow();
#ifdef MOZ_CAIRO_GFX
gfxASurface *GetThebesSurface();
View
7 widget/src/xpwidgets/nsBaseWidget.cpp
@@ -856,13 +856,6 @@ nsBaseWidget::GetAnimatedResize(PRUint16* aAnimation)
return NS_ERROR_NOT_IMPLEMENTED;
}
-nsIWidget* nsBaseWidget::GetTopLevelWindow(void)
-{
- NS_WARNING("Not implemented");
-
- return nsnull;
-}
-
/**
* Modifies aFile to point at an icon file with the given name and suffix. The
* suffix may correspond to a file extension with leading '.' if appropriate.
View
1  widget/src/xpwidgets/nsBaseWidget.h
@@ -133,7 +133,6 @@ class nsBaseWidget : public nsIWidget
NS_IMETHOD SetIcon(const nsAString &anIconSpec);
NS_IMETHOD SetAnimatedResize(PRUint16 aAnimation);
NS_IMETHOD GetAnimatedResize(PRUint16* aAnimation);
- virtual nsIWidget* GetTopLevelWindow();
virtual void ConvertToDeviceCoordinates(nscoord &aX,nscoord &aY) {}
virtual void FreeNativeData(void * data, PRUint32 aDataType) {}//~~~
Please sign in to comment.
Something went wrong with that request. Please try again.