bug 947022 - type nsIPresShell::mForwardingContainer and nsPresContext::mContainer r=bz

This commit is contained in:
Trevor Saunders 2013-11-20 14:18:25 -05:00
parent ca597b70d4
commit 1e02452a1d
26 changed files with 166 additions and 208 deletions

View File

@ -6581,8 +6581,7 @@ nsContentUtils::GetSelectionInTextControl(Selection* aSelection,
nsIEditor*
nsContentUtils::GetHTMLEditor(nsPresContext* aPresContext)
{
nsCOMPtr<nsISupports> container = aPresContext->GetContainer();
nsCOMPtr<nsIDocShell> docShell(do_QueryInterface(container));
nsCOMPtr<nsIDocShell> docShell(aPresContext->GetDocShell());
bool isEditable;
if (!docShell ||
NS_FAILED(docShell->GetEditable(&isEditable)) || !isEditable)

View File

@ -6183,7 +6183,8 @@ nsDocument::DoNotifyPossibleTitleChange()
nsCOMPtr<nsIPresShell> shell = GetShell();
if (shell) {
nsCOMPtr<nsISupports> container = shell->GetPresContext()->GetContainer();
nsCOMPtr<nsISupports> container =
shell->GetPresContext()->GetContainerWeak();
if (container) {
nsCOMPtr<nsIBaseWindow> docShellWin = do_QueryInterface(container);
if (docShellWin) {

View File

@ -63,7 +63,7 @@ nsDOMUIEvent::nsDOMUIEvent(mozilla::dom::EventTarget* aOwner,
mView = nullptr;
if (mPresContext)
{
nsCOMPtr<nsISupports> container = mPresContext->GetContainer();
nsISupports* container = mPresContext->GetContainerWeak();
if (container)
{
nsCOMPtr<nsIDOMWindow> window = do_GetInterface(container);

View File

@ -1455,7 +1455,7 @@ nsEventStateManager::GetAccessKeyLabelPrefix(nsAString& aPrefix)
nsAutoString separator, modifierText;
nsContentUtils::GetModifierSeparatorText(separator);
nsCOMPtr<nsISupports> container = mPresContext->GetContainer();
nsCOMPtr<nsISupports> container = mPresContext->GetContainerWeak();
int32_t modifierMask = GetAccessModifierMaskFor(container);
if (modifierMask & NS_MODIFIER_CONTROL) {
@ -1489,7 +1489,7 @@ nsEventStateManager::HandleAccessKey(nsPresContext* aPresContext,
ProcessingAccessKeyState aAccessKeyState,
int32_t aModifierMask)
{
nsCOMPtr<nsISupports> pcContainer = aPresContext->GetContainer();
nsCOMPtr<nsISupports> pcContainer = aPresContext->GetContainerWeak();
// Alt or other accesskey modifier is down, we may need to do an accesskey
if (mAccessKeys.Count() > 0 &&
@ -2204,7 +2204,7 @@ nsEventStateManager::DetermineDragTarget(nsPresContext* aPresContext,
{
*aTargetNode = nullptr;
nsCOMPtr<nsISupports> container = aPresContext->GetContainer();
nsCOMPtr<nsISupports> container = aPresContext->GetContainerWeak();
nsCOMPtr<nsPIDOMWindow> window = do_GetInterface(container);
if (!window)
return;
@ -2423,10 +2423,7 @@ nsEventStateManager::GetMarkupDocumentViewer(nsIMarkupDocumentViewer** aMv)
nsPresContext *presContext = presShell->GetPresContext();
if(!presContext) return NS_ERROR_FAILURE;
nsCOMPtr<nsISupports> pcContainer = presContext->GetContainer();
if(!pcContainer) return NS_ERROR_FAILURE;
nsCOMPtr<nsIDocShell> docshell(do_QueryInterface(pcContainer));
nsCOMPtr<nsIDocShell> docshell(presContext->GetDocShell());
if(!docshell) return NS_ERROR_FAILURE;
nsCOMPtr<nsIContentViewer> cv;
@ -2487,7 +2484,7 @@ nsEventStateManager::ChangeFullZoom(int32_t change)
void
nsEventStateManager::DoScrollHistory(int32_t direction)
{
nsCOMPtr<nsISupports> pcContainer(mPresContext->GetContainer());
nsCOMPtr<nsISupports> pcContainer(mPresContext->GetContainerWeak());
if (pcContainer) {
nsCOMPtr<nsIWebNavigation> webNav(do_QueryInterface(pcContainer));
if (webNav) {
@ -3787,8 +3784,7 @@ nsEventStateManager::UpdateCursor(nsPresContext* aPresContext,
if (Preferences::GetBool("ui.use_activity_cursor", false)) {
// Check whether or not to show the busy cursor
nsCOMPtr<nsISupports> pcContainer = aPresContext->GetContainer();
nsCOMPtr<nsIDocShell> docShell(do_QueryInterface(pcContainer));
nsCOMPtr<nsIDocShell> docShell(aPresContext->GetDocShell());
if (!docShell) return;
uint32_t busyFlags = nsIDocShell::BUSY_FLAGS_NONE;
docShell->GetBusyFlags(&busyFlags);

View File

@ -130,44 +130,41 @@ BodyRule::MapRuleInfoInto(nsRuleData* aData)
// if marginwidth or marginheight is set in the <frame> and not set in the <body>
// reflect them as margin in the <body>
if (bodyMarginWidth == -1 || bodyMarginHeight == -1) {
nsCOMPtr<nsISupports> container = aData->mPresContext->GetContainer();
if (container) {
nsCOMPtr<nsIDocShell> docShell(do_QueryInterface(container));
if (docShell) {
nscoord frameMarginWidth=-1; // default value
nscoord frameMarginHeight=-1; // default value
docShell->GetMarginWidth(&frameMarginWidth); // -1 indicates not set
docShell->GetMarginHeight(&frameMarginHeight);
if ((frameMarginWidth >= 0) && (bodyMarginWidth == -1)) { // set in <frame> & not in <body>
if (eCompatibility_NavQuirks == mode) {
if ((bodyMarginHeight == -1) && (0 > frameMarginHeight)) // nav quirk
frameMarginHeight = 0;
}
nsCOMPtr<nsIDocShell> docShell(aData->mPresContext->GetDocShell());
if (docShell) {
nscoord frameMarginWidth=-1; // default value
nscoord frameMarginHeight=-1; // default value
docShell->GetMarginWidth(&frameMarginWidth); // -1 indicates not set
docShell->GetMarginHeight(&frameMarginHeight);
if ((frameMarginWidth >= 0) && (bodyMarginWidth == -1)) { // set in <frame> & not in <body>
if (eCompatibility_NavQuirks == mode) {
if ((bodyMarginHeight == -1) && (0 > frameMarginHeight)) // nav quirk
frameMarginHeight = 0;
}
if ((frameMarginHeight >= 0) && (bodyMarginHeight == -1)) { // set in <frame> & not in <body>
if (eCompatibility_NavQuirks == mode) {
if ((bodyMarginWidth == -1) && (0 > frameMarginWidth)) // nav quirk
frameMarginWidth = 0;
}
}
if ((frameMarginHeight >= 0) && (bodyMarginHeight == -1)) { // set in <frame> & not in <body>
if (eCompatibility_NavQuirks == mode) {
if ((bodyMarginWidth == -1) && (0 > frameMarginWidth)) // nav quirk
frameMarginWidth = 0;
}
}
if ((bodyMarginWidth == -1) && (frameMarginWidth >= 0)) {
nsCSSValue* marginLeft = aData->ValueForMarginLeftValue();
if (marginLeft->GetUnit() == eCSSUnit_Null)
marginLeft->SetFloatValue((float)frameMarginWidth, eCSSUnit_Pixel);
nsCSSValue* marginRight = aData->ValueForMarginRightValue();
if (marginRight->GetUnit() == eCSSUnit_Null)
marginRight->SetFloatValue((float)frameMarginWidth, eCSSUnit_Pixel);
}
if ((bodyMarginWidth == -1) && (frameMarginWidth >= 0)) {
nsCSSValue* marginLeft = aData->ValueForMarginLeftValue();
if (marginLeft->GetUnit() == eCSSUnit_Null)
marginLeft->SetFloatValue((float)frameMarginWidth, eCSSUnit_Pixel);
nsCSSValue* marginRight = aData->ValueForMarginRightValue();
if (marginRight->GetUnit() == eCSSUnit_Null)
marginRight->SetFloatValue((float)frameMarginWidth, eCSSUnit_Pixel);
}
if ((bodyMarginHeight == -1) && (frameMarginHeight >= 0)) {
nsCSSValue* marginTop = aData->ValueForMarginTop();
if (marginTop->GetUnit() == eCSSUnit_Null)
marginTop->SetFloatValue((float)frameMarginHeight, eCSSUnit_Pixel);
nsCSSValue* marginBottom = aData->ValueForMarginBottom();
if (marginBottom->GetUnit() == eCSSUnit_Null)
marginBottom->SetFloatValue((float)frameMarginHeight, eCSSUnit_Pixel);
}
if ((bodyMarginHeight == -1) && (frameMarginHeight >= 0)) {
nsCSSValue* marginTop = aData->ValueForMarginTop();
if (marginTop->GetUnit() == eCSSUnit_Null)
marginTop->SetFloatValue((float)frameMarginHeight, eCSSUnit_Pixel);
nsCSSValue* marginBottom = aData->ValueForMarginBottom();
if (marginBottom->GetUnit() == eCSSUnit_Null)
marginBottom->SetFloatValue((float)frameMarginHeight, eCSSUnit_Pixel);
}
}
}
@ -462,8 +459,7 @@ HTMLBodyElement::GetAssociatedEditor()
return nullptr;
}
nsCOMPtr<nsISupports> container = presContext->GetContainer();
nsCOMPtr<nsIDocShell> docShell = do_QueryInterface(container);
nsCOMPtr<nsIDocShell> docShell = presContext->GetDocShell();
if (!docShell) {
return nullptr;
}

View File

@ -33,7 +33,7 @@ nsDOMTimeEvent::nsDOMTimeEvent(mozilla::dom::EventTarget* aOwner,
mEvent->mFlags.mCancelable = false;
if (mPresContext) {
nsCOMPtr<nsISupports> container = mPresContext->GetContainer();
nsISupports* container = mPresContext->GetContainerWeak();
if (container) {
nsCOMPtr<nsIDOMWindow> window = do_GetInterface(container);
if (window) {

View File

@ -2042,12 +2042,7 @@ XULDocument::StartLayout(void)
if (! cx)
return NS_ERROR_UNEXPECTED;
nsCOMPtr<nsISupports> container = cx->GetContainer();
NS_ASSERTION(container != nullptr, "pres context has no container");
if (! container)
return NS_ERROR_UNEXPECTED;
nsCOMPtr<nsIDocShell> docShell(do_QueryInterface(container));
nsCOMPtr<nsIDocShell> docShell = cx->GetDocShell();
NS_ASSERTION(docShell != nullptr, "container is not a docshell");
if (! docShell)
return NS_ERROR_UNEXPECTED;

View File

@ -325,8 +325,7 @@ MaybeReflowForInflationScreenWidthChange(nsPresContext *aPresContext)
changed = changed ||
(fontInflationWasEnabled != presShell->FontSizeInflationEnabled());
if (changed) {
nsCOMPtr<nsISupports> container = aPresContext->GetContainer();
nsCOMPtr<nsIDocShell> docShell = do_QueryInterface(container);
nsCOMPtr<nsIDocShell> docShell = aPresContext->GetDocShell();
if (docShell) {
nsCOMPtr<nsIContentViewer> cv;
docShell->GetContentViewer(getter_AddRefs(cv));

View File

@ -498,7 +498,7 @@ NS_IMETHODIMP nsPluginInstanceOwner::GetURL(const char *aURL,
}
// the container of the pres context will give us the link handler
nsCOMPtr<nsISupports> container = presContext->GetContainer();
nsCOMPtr<nsISupports> container = presContext->GetContainerWeak();
NS_ENSURE_TRUE(container,NS_ERROR_FAILURE);
nsCOMPtr<nsILinkHandler> lh = do_QueryInterface(container);
NS_ENSURE_TRUE(lh, NS_ERROR_FAILURE);
@ -554,12 +554,7 @@ NS_IMETHODIMP nsPluginInstanceOwner::ShowStatus(const PRUnichar *aStatusMsg)
if (!mObjectFrame) {
return rv;
}
nsCOMPtr<nsISupports> cont = mObjectFrame->PresContext()->GetContainer();
if (!cont) {
return NS_OK;
}
nsCOMPtr<nsIDocShellTreeItem> docShellItem(do_QueryInterface(cont, &rv));
nsCOMPtr<nsIDocShellTreeItem> docShellItem = mObjectFrame->PresContext()->GetDocShell();
if (NS_FAILED(rv) || !docShellItem) {
return rv;
}

View File

@ -105,11 +105,7 @@ nsSetDocumentOptionsCommand::DoCommandParams(const char *aCommandName,
rv = aParams->GetBooleanValue("plugins", &allowPlugins);
if (NS_SUCCEEDED(rv))
{
nsCOMPtr<nsISupports> container = presContext->GetContainer();
NS_ENSURE_TRUE(container, NS_ERROR_FAILURE);
nsCOMPtr<nsIDocShell> docShell(do_QueryInterface(container, &rv));
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIDocShell> docShell(presContext->GetDocShell());
NS_ENSURE_TRUE(docShell, NS_ERROR_FAILURE);
rv = docShell->SetAllowPlugins(allowPlugins);
@ -158,11 +154,7 @@ nsSetDocumentOptionsCommand::GetCommandStateParams(const char *aCommandName,
rv = aParams->GetBooleanValue("plugins", &allowPlugins);
if (NS_SUCCEEDED(rv))
{
nsCOMPtr<nsISupports> container = presContext->GetContainer();
NS_ENSURE_TRUE(container, NS_ERROR_FAILURE);
nsCOMPtr<nsIDocShell> docShell(do_QueryInterface(container, &rv));
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIDocShell> docShell(presContext->GetDocShell());
NS_ENSURE_TRUE(docShell, NS_ERROR_FAILURE);
allowPlugins = docShell->PluginsAllowedInCurrentDoc();

View File

@ -49,7 +49,7 @@
#include "nsContentUtils.h"
#include "nsIScriptError.h"
#ifdef XP_MACOSX
#include "nsIDocShellTreeItem.h"
#include "nsIDocShell.h"
#endif
#include "ChildIterator.h"
#include "nsError.h"
@ -4094,22 +4094,19 @@ const nsCSSFrameConstructor::FrameConstructionData*
nsCSSFrameConstructor::FindXULMenubarData(Element* aElement,
nsStyleContext* aStyleContext)
{
nsCOMPtr<nsISupports> container =
aStyleContext->PresContext()->GetContainer();
if (container) {
nsCOMPtr<nsIDocShellTreeItem> treeItem(do_QueryInterface(container));
if (treeItem) {
int32_t type;
treeItem->GetItemType(&type);
if (nsIDocShellTreeItem::typeChrome == type) {
nsCOMPtr<nsIDocShellTreeItem> parent;
treeItem->GetParent(getter_AddRefs(parent));
if (!parent) {
// This is the root. Suppress the menubar, since on Mac
// window menus are not attached to the window.
static const FrameConstructionData sSuppressData = SUPPRESS_FCDATA();
return &sSuppressData;
}
nsCOMPtr<nsIDocShell> treeItem =
aStyleContext->PresContext()->GetDocShell();
if (treeItem) {
int32_t type;
treeItem->GetItemType(&type);
if (nsIDocShellTreeItem::typeChrome == type) {
nsCOMPtr<nsIDocShellTreeItem> parent;
treeItem->GetParent(getter_AddRefs(parent));
if (!parent) {
// This is the root. Suppress the menubar, since on Mac
// window menus are not attached to the window.
static const FrameConstructionData sSuppressData = SUPPRESS_FCDATA();
return &sSuppressData;
}
}
}

View File

@ -617,7 +617,7 @@ nsDocumentViewer::SetContainer(nsIDocShell* aContainer)
{
mContainer = static_cast<nsDocShell*>(aContainer)->asWeakPtr();
if (mPresContext) {
mPresContext->SetContainer(aContainer);
mPresContext->SetContainer(mContainer);
}
// We're loading a new document into the window where this document
@ -887,7 +887,7 @@ nsDocumentViewer::InitInternal(nsIWidget* aParentWidget,
requestor->GetInterface(NS_GET_IID(nsILinkHandler),
getter_AddRefs(linkHandler));
mPresContext->SetContainer(requestor);
mPresContext->SetContainer(mContainer);
mPresContext->SetLinkHandler(linkHandler);
}
@ -1309,13 +1309,13 @@ AttachContainerRecurse(nsIDocShell* aShell)
nsRefPtr<nsPresContext> pc;
viewer->GetPresContext(getter_AddRefs(pc));
if (pc) {
pc->SetContainer(aShell);
pc->SetContainer(static_cast<nsDocShell*>(aShell));
pc->SetLinkHandler(nsCOMPtr<nsILinkHandler>(do_QueryInterface(aShell)));
}
nsCOMPtr<nsIPresShell> presShell;
viewer->GetPresShell(getter_AddRefs(presShell));
if (presShell) {
presShell->SetForwardingContainer(nullptr);
presShell->SetForwardingContainer(WeakPtr<nsDocShell>());
}
}
@ -1343,7 +1343,7 @@ nsDocumentViewer::Open(nsISupports *aState, nsISHEntry *aSHEntry)
mHidden = false;
if (mPresShell)
mPresShell->SetForwardingContainer(nullptr);
mPresShell->SetForwardingContainer(WeakPtr<nsDocShell>());
// Rehook the child presentations. The child shells are still in
// session history, so get them from there.
@ -1469,7 +1469,8 @@ DetachContainerRecurse(nsIDocShell *aShell)
nsCOMPtr<nsIPresShell> presShell;
viewer->GetPresShell(getter_AddRefs(presShell));
if (presShell) {
presShell->SetForwardingContainer(nsWeakPtr(do_GetWeakReference(aShell)));
auto weakShell = static_cast<nsDocShell*>(aShell)->asWeakPtr();
presShell->SetForwardingContainer(weakShell);
}
}
@ -1590,9 +1591,7 @@ nsDocumentViewer::Destroy()
mPresContext->SetContainer(nullptr);
}
if (mPresShell) {
nsWeakPtr container =
do_GetWeakReference(static_cast<nsIDocShell*>(mContainer));
mPresShell->SetForwardingContainer(container);
mPresShell->SetForwardingContainer(mContainer);
}
// Do the same for our children. Note that we need to get the child
@ -1993,7 +1992,7 @@ nsDocumentViewer::Show(void)
mPresContext->SetLinkHandler(linkHandler);
}
mPresContext->SetContainer(base_win);
mPresContext->SetContainer(mContainer);
}
if (mPresContext) {

View File

@ -22,6 +22,7 @@
#include "mozilla/EventForwards.h"
#include "mozilla/MemoryReporting.h"
#include "mozilla/WeakPtr.h"
#include "gfxPoint.h"
#include "nsTHashtable.h"
#include "nsHashKeys.h"
@ -42,6 +43,7 @@
#include "nsMargin.h"
class nsIContent;
class nsDocShell;
class nsIDocument;
class nsIFrame;
class nsPresContext;
@ -956,7 +958,7 @@ public:
* user events at the docshell's parent. This pointer allows us to do that.
* It should not be used for any other purpose.
*/
void SetForwardingContainer(nsWeakPtr aContainer)
void SetForwardingContainer(const mozilla::WeakPtr<nsDocShell> &aContainer)
{
mForwardingContainer = aContainer;
}
@ -1508,7 +1510,7 @@ protected:
// Pointer into mFrameConstructor - this is purely so that FrameManager() and
// GetRootFrame() can be inlined:
nsFrameManagerBase* mFrameManager;
nsWeakPtr mForwardingContainer;
mozilla::WeakPtr<nsDocShell> mForwardingContainer;
nsRefreshDriver* mHiddenInvalidationObserverRefreshDriver;
#ifdef ACCESSIBILITY
mozilla::a11y::DocAccessible* mDocAccessible;

View File

@ -12,7 +12,7 @@
#include "nsCOMPtr.h"
#include "nsPresContext.h"
#include "nsIPresShell.h"
#include "nsIDocShell.h"
#include "nsDocShell.h"
#include "nsIContentViewer.h"
#include "nsPIDOMWindow.h"
#include "nsStyleSet.h"
@ -621,7 +621,7 @@ nsPresContext::GetDocumentColorPreferences()
{
int32_t useAccessibilityTheme = 0;
bool usePrefColors = true;
nsCOMPtr<nsIDocShellTreeItem> docShell(do_QueryReferent(mContainer));
nsCOMPtr<nsIDocShellTreeItem> docShell(mContainer);
if (docShell) {
int32_t docShellType;
docShell->GetItemType(&docShellType);
@ -894,7 +894,7 @@ nsPresContext::UpdateAfterPreferencesChanged()
{
mPrefChangedTimer = nullptr;
nsCOMPtr<nsIDocShellTreeItem> docShell(do_QueryReferent(mContainer));
nsCOMPtr<nsIDocShellTreeItem> docShell(mContainer);
if (docShell) {
int32_t docShellType;
docShell->GetItemType(&docShellType);
@ -1479,26 +1479,35 @@ nsPresContext::ScreenWidthInchesForFontInflation(bool* aChanged)
}
void
nsPresContext::SetContainer(nsISupports* aHandler)
nsPresContext::SetContainer(nsIDocShell* aDocShell)
{
mContainer = do_GetWeakReference(aHandler);
if (aDocShell) {
mContainer = static_cast<nsDocShell*>(aDocShell)->asWeakPtr();
} else {
mContainer = WeakPtr<nsDocShell>();
}
InvalidateIsChromeCache();
if (mContainer) {
GetDocumentColorPreferences();
}
}
already_AddRefed<nsISupports>
nsPresContext::GetContainerInternal() const
nsISupports*
nsPresContext::GetContainerWeakInternal() const
{
nsCOMPtr<nsISupports> result = do_QueryReferent(mContainer);
return result.forget();
return static_cast<nsIDocShell*>(mContainer);
}
already_AddRefed<nsISupports>
nsPresContext::GetContainerExternal() const
nsISupports*
nsPresContext::GetContainerWeakExternal() const
{
return GetContainerInternal();
return GetContainerWeakInternal();
}
nsIDocShell*
nsPresContext::GetDocShell() const
{
return mContainer;
}
bool
@ -1596,7 +1605,7 @@ nsPresContext::GetBidi() const
bool
nsPresContext::IsTopLevelWindowInactive()
{
nsCOMPtr<nsIDocShellTreeItem> treeItem(do_QueryReferent(mContainer));
nsCOMPtr<nsIDocShellTreeItem> treeItem(mContainer);
if (!treeItem)
return false;
@ -1919,7 +1928,7 @@ nsPresContext::SetPrintSettings(nsIPrintSettings *aPrintSettings)
bool
nsPresContext::EnsureVisible()
{
nsCOMPtr<nsIDocShell> docShell(do_QueryReferent(mContainer));
nsCOMPtr<nsIDocShell> docShell(mContainer);
if (docShell) {
nsCOMPtr<nsIContentViewer> cv;
docShell->GetContentViewer(getter_AddRefs(cv));
@ -1953,16 +1962,12 @@ bool
nsPresContext::IsChromeSlow() const
{
bool isChrome = false;
nsCOMPtr<nsISupports> container = GetContainer();
if (container) {
nsresult result;
nsCOMPtr<nsIDocShellTreeItem> docShell(do_QueryInterface(container, &result));
if (NS_SUCCEEDED(result) && docShell) {
int32_t docShellType;
result = docShell->GetItemType(&docShellType);
if (NS_SUCCEEDED(result)) {
isChrome = nsIDocShellTreeItem::typeChrome == docShellType;
}
nsCOMPtr<nsIDocShellTreeItem> docShell(mContainer);
if (docShell) {
int32_t docShellType;
nsresult result = docShell->GetItemType(&docShellType);
if (NS_SUCCEEDED(result)) {
isChrome = nsIDocShellTreeItem::typeChrome == docShellType;
}
}
mIsChrome = isChrome;
@ -2697,7 +2702,7 @@ bool
nsPresContext::IsDeviceSizePageSize()
{
bool isDeviceSizePageSize = false;
nsCOMPtr<nsIDocShell> docShell(do_QueryReferent(mContainer));
nsCOMPtr<nsIDocShell> docShell(mContainer);
if (docShell) {
isDeviceSizePageSize = docShell->GetDeviceSizeIsPageSize();
}

View File

@ -9,6 +9,7 @@
#define nsPresContext_h___
#include "mozilla/Attributes.h"
#include "mozilla/WeakPtr.h"
#include "nsColor.h"
#include "nsCoord.h"
#include "nsCOMPtr.h"
@ -42,6 +43,8 @@ class nsBidiPresUtils;
class nsAString;
class nsIPrintSettings;
class nsDocShell;
class nsIDocShell;
class nsIDocument;
class nsILanguageAtomService;
class nsITheme;
@ -410,18 +413,20 @@ public:
bool GetFocusRingOnAnything() const { return mFocusRingOnAnything; }
uint8_t GetFocusRingStyle() const { return mFocusRingStyle; }
NS_HIDDEN_(void) SetContainer(nsISupports* aContainer);
NS_HIDDEN_(void) SetContainer(nsIDocShell* aContainer);
virtual NS_HIDDEN_(already_AddRefed<nsISupports>) GetContainerExternal() const;
NS_HIDDEN_(already_AddRefed<nsISupports>) GetContainerInternal() const;
virtual nsISupports* GetContainerWeakExternal() const;
nsISupports* GetContainerWeakInternal() const;
#ifdef MOZILLA_INTERNAL_API
already_AddRefed<nsISupports> GetContainer() const
{ return GetContainerInternal(); }
nsISupports* GetContainerWeak() const
{ return GetContainerWeakInternal(); }
#else
already_AddRefed<nsISupports> GetContainer() const
{ return GetContainerExternal(); }
nsISupports* GetContainerWeak() const
{ return GetContainerWeakExternal(); }
#endif
nsIDocShell* GetDocShell() const;
// XXX this are going to be replaced with set/get container
void SetLinkHandler(nsILinkHandler* aHandler) { mLinkHandler = aHandler; }
nsILinkHandler* GetLinkHandler() { return mLinkHandler; }
@ -1171,7 +1176,7 @@ public:
protected:
nsWeakPtr mContainer;
mozilla::WeakPtr<nsDocShell> mContainer;
PRCList mDOMMediaQueryLists;

View File

@ -80,7 +80,7 @@
#include "pldhash.h"
#include "mozilla/dom/Touch.h"
#include "nsIObserverService.h"
#include "nsIDocShell.h" // for reflow observation
#include "nsDocShell.h" // for reflow observation
#include "nsIBaseWindow.h"
#include "nsError.h"
#include "nsLayoutUtils.h"
@ -1369,8 +1369,7 @@ nsresult PresShell::SetPrefNoFramesRule(void)
NS_ASSERTION(mPrefStyleSheet, "prefstylesheet should not be null");
bool allowSubframes = true;
nsCOMPtr<nsISupports> container = mPresContext->GetContainer();
nsCOMPtr<nsIDocShell> docShell(do_QueryInterface(container));
nsCOMPtr<nsIDocShell> docShell(mPresContext->GetDocShell());
if (docShell) {
docShell->GetAllowSubframes(&allowSubframes);
}
@ -3645,11 +3644,7 @@ PresShell::CaptureHistoryState(nsILayoutHistoryState** aState)
// content viewer's Hide() method... by that point the docshell's
// state could be wrong. We should sort out a better ownership
// model for the layout history state.
nsCOMPtr<nsISupports> container = mPresContext->GetContainer();
if (!container)
return NS_ERROR_FAILURE;
nsCOMPtr<nsIDocShell> docShell(do_QueryInterface(container));
nsCOMPtr<nsIDocShell> docShell(mPresContext->GetDocShell());
if (!docShell)
return NS_ERROR_FAILURE;
@ -5081,8 +5076,7 @@ PresShell::AddCanvasBackgroundColorItem(nsDisplayListBuilder& aBuilder,
static bool IsTransparentContainerElement(nsPresContext* aPresContext)
{
nsCOMPtr<nsISupports> container = aPresContext->GetContainerInternal();
nsCOMPtr<nsIDocShellTreeItem> docShellItem = do_QueryInterface(container);
nsCOMPtr<nsIDocShellTreeItem> docShellItem = aPresContext->GetDocShell();
nsCOMPtr<nsPIDOMWindow> pwin(do_GetInterface(docShellItem));
if (!pwin)
return false;
@ -5567,8 +5561,7 @@ PresShell::AssumeAllImagesVisible()
if (!sImageVisibilityEnabled &&
sImageVisibilityEnabledForBrowserElementsOnly) {
nsCOMPtr<nsISupports> container = mPresContext->GetContainer();
nsCOMPtr<nsIDocShell> docshell(do_QueryInterface(container));
nsCOMPtr<nsIDocShell> docshell(mPresContext->GetDocShell());
if (!docshell || !docshell->GetIsInBrowserElement()) {
return true;
}
@ -6006,13 +5999,13 @@ already_AddRefed<nsIPresShell>
PresShell::GetParentPresShell()
{
NS_ENSURE_TRUE(mPresContext, nullptr);
nsCOMPtr<nsISupports> container = mPresContext->GetContainer();
if (!container) {
container = do_QueryReferent(mForwardingContainer);
}
// Now, find the parent pres shell and send the event there
nsCOMPtr<nsIDocShellTreeItem> treeItem = do_QueryInterface(container);
nsCOMPtr<nsIDocShellTreeItem> treeItem = mPresContext->GetDocShell();
if (!treeItem) {
treeItem = mForwardingContainer.get();
}
// Might have gone away, or never been around to start with
NS_ENSURE_TRUE(treeItem, nullptr);
@ -6327,8 +6320,8 @@ PresShell::HandleEvent(nsIFrame* aFrame,
// would occur if the mouse button is held down while a tab change occurs.
// If the docshell is visible, look for a scrolling container.
bool vis;
nsCOMPtr<nsISupports> supports = mPresContext->GetContainer();
nsCOMPtr<nsIBaseWindow> baseWin(do_QueryInterface(supports));
nsCOMPtr<nsIBaseWindow> baseWin =
do_QueryInterface(mPresContext->GetContainerWeak());
if (baseWin && NS_SUCCEEDED(baseWin->GetVisibility(&vis)) && vis) {
captureRetarget = gCaptureInfo.mRetargetToElement;
if (!captureRetarget) {
@ -6702,8 +6695,7 @@ PresShell::GetTouchEventTargetDocument()
return nullptr;
}
nsCOMPtr<nsISupports> container = context->GetContainer();
nsCOMPtr<nsIDocShellTreeItem> shellAsTreeItem = do_QueryInterface(container);
nsCOMPtr<nsIDocShellTreeItem> shellAsTreeItem = context->GetDocShell();
if (!shellAsTreeItem) {
return nullptr;
}
@ -7183,7 +7175,7 @@ PresShell::HandleDOMEventWithTarget(nsIContent* aTargetContent,
// and the js context is out of date. This check detects the case
// that caused a crash in bug 41013, but there may be a better way
// to handle this situation!
nsCOMPtr<nsISupports> container = mPresContext->GetContainer();
nsCOMPtr<nsISupports> container = mPresContext->GetContainerWeak();
if (container) {
// Dispatch event to content
@ -7204,7 +7196,7 @@ PresShell::HandleDOMEventWithTarget(nsIContent* aTargetContent,
nsresult rv = NS_OK;
PushCurrentEventInfo(nullptr, aTargetContent);
nsCOMPtr<nsISupports> container = mPresContext->GetContainer();
nsCOMPtr<nsISupports> container = mPresContext->GetContainerWeak();
if (container) {
rv = nsEventDispatcher::DispatchDOMEvent(aTargetContent, nullptr, aEvent,
mPresContext, aStatus);
@ -7877,13 +7869,10 @@ PresShell::DidDoReflow(bool aInterruptible, bool aWasInterrupted)
HandlePostedReflowCallbacks(aInterruptible);
nsCOMPtr<nsISupports> container = mPresContext->GetContainer();
if (container) {
nsCOMPtr<nsIDocShell> docShell = do_QueryInterface(container);
if (docShell) {
DOMHighResTimeStamp now = GetPerformanceNow();
docShell->NotifyReflowObservers(aInterruptible, mLastReflowStart, now);
}
nsCOMPtr<nsIDocShell> docShell = mPresContext->GetDocShell();
if (docShell) {
DOMHighResTimeStamp now = GetPerformanceNow();
docShell->NotifyReflowObservers(aInterruptible, mLastReflowStart, now);
}
if (sSynthMouseMove) {
@ -9628,7 +9617,7 @@ void nsIPresShell::ReleaseStatics()
// Asks our docshell whether we're active.
void PresShell::QueryIsActive()
{
nsCOMPtr<nsISupports> container = mPresContext->GetContainer();
nsCOMPtr<nsISupports> container = mPresContext->GetContainerWeak();
if (mDocument) {
nsIDocument* displayDoc = mDocument->GetDisplayDocument();
if (displayDoc) {
@ -9641,7 +9630,7 @@ void PresShell::QueryIsActive()
nsIPresShell* displayPresShell = displayDoc->GetShell();
if (displayPresShell) {
container = displayPresShell->GetPresContext()->GetContainer();
container = displayPresShell->GetPresContext()->GetContainerWeak();
}
}
}

View File

@ -2491,7 +2491,7 @@ ScrollFrameHelper::GetScrollbarStylesFromFrame() const
}
ScrollbarStyles result = presContext->GetViewportOverflowOverride();
nsCOMPtr<nsISupports> container = presContext->GetContainer();
nsCOMPtr<nsISupports> container = presContext->GetContainerWeak();
nsCOMPtr<nsIScrollable> scrollable = do_QueryInterface(container);
if (scrollable) {
HandleScrollPref(scrollable, nsIScrollable::ScrollOrientation_X,

View File

@ -8,7 +8,7 @@
#include "nsPresContext.h"
#include "nsINameSpaceManager.h"
#include "prprf.h" // For PR_snprintf()
#include "nsIDocShellTreeItem.h"
#include "nsIDocShell.h"
#include "nsIDocShellTreeOwner.h"
#include "nsIWebBrowserChrome.h"
#include "nsIInterfaceRequestorUtils.h"
@ -246,17 +246,14 @@ NS_IMPL_ISUPPORTS1(nsMathMLmactionFrame::MouseListener,
void
ShowStatus(nsPresContext* aPresContext, nsString& aStatusMsg)
{
nsCOMPtr<nsISupports> cont = aPresContext->GetContainer();
if (cont) {
nsCOMPtr<nsIDocShellTreeItem> docShellItem(do_QueryInterface(cont));
if (docShellItem) {
nsCOMPtr<nsIDocShellTreeOwner> treeOwner;
docShellItem->GetTreeOwner(getter_AddRefs(treeOwner));
if (treeOwner) {
nsCOMPtr<nsIWebBrowserChrome> browserChrome(do_GetInterface(treeOwner));
if (browserChrome) {
browserChrome->SetStatus(nsIWebBrowserChrome::STATUS_LINK, aStatusMsg.get());
}
nsCOMPtr<nsIDocShellTreeItem> docShellItem(aPresContext->GetDocShell());
if (docShellItem) {
nsCOMPtr<nsIDocShellTreeOwner> treeOwner;
docShellItem->GetTreeOwner(getter_AddRefs(treeOwner));
if (treeOwner) {
nsCOMPtr<nsIWebBrowserChrome> browserChrome(do_GetInterface(treeOwner));
if (browserChrome) {
browserChrome->SetStatus(nsIWebBrowserChrome::STATUS_LINK, aStatusMsg.get());
}
}
}

View File

@ -2214,8 +2214,7 @@ nsPrintEngine::ReflowPrintObject(nsPrintObject * aPO)
// This docshell stuff is weird; will go away when we stop having multiple
// presentations per document
nsCOMPtr<nsISupports> supps(do_QueryInterface(aPO->mDocShell));
aPO->mPresContext->SetContainer(supps);
aPO->mPresContext->SetContainer(aPO->mDocShell);
aPO->mPresShell->BeginObservingDocument();

View File

@ -915,7 +915,7 @@ nsSVGOuterSVGFrame::IsRootOfReplacedElementSubDoc(nsIFrame **aEmbeddingFrame)
{
if (!mContent->GetParent()) {
// Our content is the document element
nsCOMPtr<nsISupports> container = PresContext()->GetContainer();
nsCOMPtr<nsISupports> container = PresContext()->GetContainerWeak();
nsCOMPtr<nsIDOMWindow> window = do_GetInterface(container);
if (window) {
nsCOMPtr<nsIDOMElement> frameElement;

View File

@ -29,7 +29,7 @@
#include "nsBoxLayoutState.h"
#include "nsIScrollableFrame.h"
#include "nsIRootBox.h"
#include "nsIDocShellTreeItem.h"
#include "nsIDocShell.h"
#include "nsReadableUtils.h"
#include "nsUnicharUtils.h"
#include "nsLayoutUtils.h"
@ -147,8 +147,7 @@ nsMenuPopupFrame::Init(nsIContent* aContent,
mIsDragPopup = true;
}
nsCOMPtr<nsISupports> cont = PresContext()->GetContainer();
nsCOMPtr<nsIDocShellTreeItem> dsti = do_QueryInterface(cont);
nsCOMPtr<nsIDocShellTreeItem> dsti = PresContext()->GetDocShell();
int32_t type = -1;
if (dsti && NS_SUCCEEDED(dsti->GetItemType(&type)) &&
type == nsIDocShellTreeItem::typeChrome)
@ -280,8 +279,7 @@ nsMenuPopupFrame::CreateWidgetForView(nsView* aView)
// should be in front of it.
nsCOMPtr<nsIWidget> parentWidget;
if (widgetData.mPopupLevel != ePopupLevelTop) {
nsCOMPtr<nsISupports> cont = PresContext()->GetContainer();
nsCOMPtr<nsIDocShellTreeItem> dsti = do_QueryInterface(cont);
nsCOMPtr<nsIDocShellTreeItem> dsti = PresContext()->GetDocShell();
if (!dsti)
return NS_ERROR_FAILURE;

View File

@ -338,8 +338,7 @@ nsResizerFrame::GetContentToResize(nsIPresShell* aPresShell, nsIBaseWindow** aWi
// don't allow resizing windows in content shells
bool isChromeShell = false;
nsCOMPtr<nsISupports> cont = aPresShell->GetPresContext()->GetContainer();
nsCOMPtr<nsIDocShellTreeItem> dsti = do_QueryInterface(cont);
nsCOMPtr<nsIDocShellTreeItem> dsti = aPresShell->GetPresContext()->GetDocShell();
if (dsti) {
int32_t type = -1;
isChromeShell = (NS_SUCCEEDED(dsti->GetItemType(&type)) &&

View File

@ -12,7 +12,7 @@
#include "nsIWidget.h"
#include "nsMenuPopupFrame.h"
#include "nsPresContext.h"
#include "nsIDocShellTreeItem.h"
#include "nsIDocShell.h"
#include "nsPIDOMWindow.h"
#include "nsEventDispatcher.h"
#include "nsDisplayList.h"
@ -72,8 +72,7 @@ nsTitleBarFrame::HandleEvent(nsPresContext* aPresContext,
case NS_MOUSE_BUTTON_DOWN: {
if (aEvent->AsMouseEvent()->button == WidgetMouseEvent::eLeftButton) {
// titlebar has no effect in non-chrome shells
nsCOMPtr<nsISupports> cont = aPresContext->GetContainer();
nsCOMPtr<nsIDocShellTreeItem> dsti = do_QueryInterface(cont);
nsCOMPtr<nsIDocShellTreeItem> dsti = aPresContext->GetDocShell();
if (dsti) {
int32_t type = -1;
if (NS_SUCCEEDED(dsti->GetItemType(&type)) &&

View File

@ -1466,8 +1466,7 @@ nsXULPopupManager::MayShowPopup(nsMenuPopupFrame* aPopup)
if (widget && widget->GetLastRollup() == aPopup->GetContent())
return false;
nsCOMPtr<nsISupports> cont = aPopup->PresContext()->GetContainer();
nsCOMPtr<nsIDocShellTreeItem> dsti = do_QueryInterface(cont);
nsCOMPtr<nsIDocShellTreeItem> dsti = aPopup->PresContext()->GetDocShell();
nsCOMPtr<nsIBaseWindow> baseWin = do_QueryInterface(dsti);
if (!baseWin)
return false;

View File

@ -311,17 +311,15 @@ nsTypeAheadFind::FindItNow(nsIPresShell *aPresShell, bool aIsLinksOnly,
nsISelectionController::SELECTION_NORMAL, getter_AddRefs(selection));
}
nsCOMPtr<nsISupports> startingContainer = presContext->GetContainer();
nsCOMPtr<nsIDocShellTreeItem> treeItem(do_QueryInterface(startingContainer));
NS_ASSERTION(treeItem, "Bug 175321 Crashes with Type Ahead Find [@ nsTypeAheadFind::FindItNow]");
if (!treeItem)
nsCOMPtr<nsIDocShell> startingDocShell(presContext->GetDocShell());
NS_ASSERTION(startingDocShell, "Bug 175321 Crashes with Type Ahead Find [@ nsTypeAheadFind::FindItNow]");
if (!startingDocShell)
return NS_ERROR_FAILURE;
nsCOMPtr<nsIDocShellTreeItem> rootContentTreeItem;
nsCOMPtr<nsIDocShell> currentDocShell;
nsCOMPtr<nsIDocShell> startingDocShell(do_QueryInterface(startingContainer));
treeItem->GetSameTypeRootTreeItem(getter_AddRefs(rootContentTreeItem));
startingDocShell->GetSameTypeRootTreeItem(getter_AddRefs(rootContentTreeItem));
nsCOMPtr<nsIDocShell> rootContentDocShell =
do_QueryInterface(rootContentTreeItem);
@ -334,7 +332,7 @@ nsTypeAheadFind::FindItNow(nsIPresShell *aPresShell, bool aIsLinksOnly,
getter_AddRefs(docShellEnumerator));
// Default: can start at the current document
nsCOMPtr<nsISupports> currentContainer = startingContainer =
nsCOMPtr<nsISupports> currentContainer =
do_QueryInterface(rootContentDocShell);
// Iterate up to current shell, if there's more than 1 that we're
@ -1224,7 +1222,7 @@ nsTypeAheadFind::GetPresShell()
nsCOMPtr<nsIPresShell> shell = do_QueryReferent(mPresShell);
if (shell) {
nsPresContext *pc = shell->GetPresContext();
if (!pc || !nsCOMPtr<nsISupports>(pc->GetContainer())) {
if (!pc || !pc->GetContainerWeak()) {
return nullptr;
}
}

View File

@ -1513,8 +1513,7 @@ nsBaseWidget::GetRootAccessible()
// If container is null then the presshell is not active. This often happens
// when a preshell is being held onto for fastback.
nsPresContext* presContext = presShell->GetPresContext();
nsCOMPtr<nsISupports> container = presContext->GetContainer();
NS_ENSURE_TRUE(container, nullptr);
NS_ENSURE_TRUE(presContext->GetContainerWeak(), nullptr);
// Accessible creation might be not safe so use IsSafeToRunScript to
// make sure it's not created at unsafe times.