2007-03-22 10:30:00 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 04:12:37 -07:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
#include "nsCOMPtr.h"
|
|
|
|
#include "nsIContainerBoxObject.h"
|
|
|
|
#include "nsIBrowserBoxObject.h"
|
|
|
|
#include "nsIEditorBoxObject.h"
|
|
|
|
#include "nsIIFrameBoxObject.h"
|
|
|
|
#include "nsBoxObject.h"
|
|
|
|
#include "nsIDocShell.h"
|
|
|
|
#include "nsIContent.h"
|
|
|
|
#include "nsIDocument.h"
|
|
|
|
#include "nsIFrame.h"
|
2010-08-30 17:49:07 -07:00
|
|
|
#include "nsSubDocumentFrame.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* nsContainerBoxObject implements deprecated nsIBrowserBoxObject,
|
|
|
|
* nsIEditorBoxObject and nsIIFrameBoxObject interfaces only because of the
|
|
|
|
* backward compatibility.
|
|
|
|
*/
|
|
|
|
|
|
|
|
class nsContainerBoxObject : public nsBoxObject,
|
|
|
|
public nsIBrowserBoxObject,
|
|
|
|
public nsIEditorBoxObject,
|
|
|
|
public nsIIFrameBoxObject
|
|
|
|
{
|
2014-07-08 14:23:18 -07:00
|
|
|
protected:
|
|
|
|
virtual ~nsContainerBoxObject() {}
|
2007-03-22 10:30:00 -07:00
|
|
|
public:
|
|
|
|
NS_DECL_ISUPPORTS_INHERITED
|
|
|
|
NS_DECL_NSICONTAINERBOXOBJECT
|
|
|
|
NS_DECL_NSIBROWSERBOXOBJECT
|
|
|
|
NS_DECL_NSIEDITORBOXOBJECT
|
|
|
|
NS_DECL_NSIIFRAMEBOXOBJECT
|
|
|
|
};
|
|
|
|
|
|
|
|
NS_INTERFACE_MAP_BEGIN(nsContainerBoxObject)
|
|
|
|
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsIContainerBoxObject, nsIBrowserBoxObject)
|
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIBrowserBoxObject)
|
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIEditorBoxObject)
|
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIIFrameBoxObject)
|
|
|
|
NS_INTERFACE_MAP_END_INHERITING(nsBoxObject)
|
|
|
|
|
|
|
|
NS_IMPL_ADDREF_INHERITED(nsContainerBoxObject, nsBoxObject)
|
|
|
|
NS_IMPL_RELEASE_INHERITED(nsContainerBoxObject, nsBoxObject)
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsContainerBoxObject::GetDocShell(nsIDocShell** aResult)
|
|
|
|
{
|
2012-07-30 07:20:58 -07:00
|
|
|
*aResult = nullptr;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2014-03-25 08:36:49 -07:00
|
|
|
nsSubDocumentFrame *subDocFrame = do_QueryFrame(GetFrame(false));
|
|
|
|
if (subDocFrame) {
|
|
|
|
// Ok, the frame for mContent is an nsSubDocumentFrame, it knows how
|
|
|
|
// to reach the docshell, so ask it...
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2014-03-25 08:36:49 -07:00
|
|
|
return subDocFrame->GetDocShell(aResult);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!mContent) {
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2010-08-30 17:49:07 -07:00
|
|
|
// No nsSubDocumentFrame available for mContent, try if there's a mapping
|
2007-03-22 10:30:00 -07:00
|
|
|
// between mContent's document to mContent's subdocument.
|
|
|
|
|
2014-08-20 17:38:01 -07:00
|
|
|
nsIDocument *doc = mContent->GetComposedDoc();
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
if (!doc) {
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsIDocument *sub_doc = doc->GetSubDocumentFor(mContent);
|
|
|
|
|
|
|
|
if (!sub_doc) {
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2013-11-15 08:32:12 -08:00
|
|
|
NS_IF_ADDREF(*aResult = sub_doc->GetDocShell());
|
|
|
|
return NS_OK;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
NS_NewContainerBoxObject(nsIBoxObject** aResult)
|
|
|
|
{
|
|
|
|
*aResult = new nsContainerBoxObject();
|
|
|
|
if (!*aResult)
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
NS_ADDREF(*aResult);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|