Wed, 31 Dec 2014 06:55:50 +0100
Added tag UPSTREAM_283F7C6 for changeset ca08bd8f51b2
michael@0 | 1 | /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
michael@0 | 2 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 5 | |
michael@0 | 6 | #include "nsCOMPtr.h" |
michael@0 | 7 | #include "nsIContainerBoxObject.h" |
michael@0 | 8 | #include "nsIBrowserBoxObject.h" |
michael@0 | 9 | #include "nsIEditorBoxObject.h" |
michael@0 | 10 | #include "nsIIFrameBoxObject.h" |
michael@0 | 11 | #include "nsBoxObject.h" |
michael@0 | 12 | #include "nsIDocShell.h" |
michael@0 | 13 | #include "nsIContent.h" |
michael@0 | 14 | #include "nsIDocument.h" |
michael@0 | 15 | #include "nsIFrame.h" |
michael@0 | 16 | #include "nsSubDocumentFrame.h" |
michael@0 | 17 | |
michael@0 | 18 | /** |
michael@0 | 19 | * nsContainerBoxObject implements deprecated nsIBrowserBoxObject, |
michael@0 | 20 | * nsIEditorBoxObject and nsIIFrameBoxObject interfaces only because of the |
michael@0 | 21 | * backward compatibility. |
michael@0 | 22 | */ |
michael@0 | 23 | |
michael@0 | 24 | class nsContainerBoxObject : public nsBoxObject, |
michael@0 | 25 | public nsIBrowserBoxObject, |
michael@0 | 26 | public nsIEditorBoxObject, |
michael@0 | 27 | public nsIIFrameBoxObject |
michael@0 | 28 | { |
michael@0 | 29 | public: |
michael@0 | 30 | NS_DECL_ISUPPORTS_INHERITED |
michael@0 | 31 | NS_DECL_NSICONTAINERBOXOBJECT |
michael@0 | 32 | NS_DECL_NSIBROWSERBOXOBJECT |
michael@0 | 33 | NS_DECL_NSIEDITORBOXOBJECT |
michael@0 | 34 | NS_DECL_NSIIFRAMEBOXOBJECT |
michael@0 | 35 | }; |
michael@0 | 36 | |
michael@0 | 37 | NS_INTERFACE_MAP_BEGIN(nsContainerBoxObject) |
michael@0 | 38 | NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsIContainerBoxObject, nsIBrowserBoxObject) |
michael@0 | 39 | NS_INTERFACE_MAP_ENTRY(nsIBrowserBoxObject) |
michael@0 | 40 | NS_INTERFACE_MAP_ENTRY(nsIEditorBoxObject) |
michael@0 | 41 | NS_INTERFACE_MAP_ENTRY(nsIIFrameBoxObject) |
michael@0 | 42 | NS_INTERFACE_MAP_END_INHERITING(nsBoxObject) |
michael@0 | 43 | |
michael@0 | 44 | NS_IMPL_ADDREF_INHERITED(nsContainerBoxObject, nsBoxObject) |
michael@0 | 45 | NS_IMPL_RELEASE_INHERITED(nsContainerBoxObject, nsBoxObject) |
michael@0 | 46 | |
michael@0 | 47 | NS_IMETHODIMP nsContainerBoxObject::GetDocShell(nsIDocShell** aResult) |
michael@0 | 48 | { |
michael@0 | 49 | *aResult = nullptr; |
michael@0 | 50 | |
michael@0 | 51 | nsSubDocumentFrame *subDocFrame = do_QueryFrame(GetFrame(false)); |
michael@0 | 52 | if (subDocFrame) { |
michael@0 | 53 | // Ok, the frame for mContent is an nsSubDocumentFrame, it knows how |
michael@0 | 54 | // to reach the docshell, so ask it... |
michael@0 | 55 | |
michael@0 | 56 | return subDocFrame->GetDocShell(aResult); |
michael@0 | 57 | } |
michael@0 | 58 | |
michael@0 | 59 | if (!mContent) { |
michael@0 | 60 | return NS_OK; |
michael@0 | 61 | } |
michael@0 | 62 | |
michael@0 | 63 | // No nsSubDocumentFrame available for mContent, try if there's a mapping |
michael@0 | 64 | // between mContent's document to mContent's subdocument. |
michael@0 | 65 | |
michael@0 | 66 | // XXXbz sXBL/XBL2 issue -- ownerDocument or currentDocument? |
michael@0 | 67 | nsIDocument *doc = mContent->GetDocument(); |
michael@0 | 68 | |
michael@0 | 69 | if (!doc) { |
michael@0 | 70 | return NS_OK; |
michael@0 | 71 | } |
michael@0 | 72 | |
michael@0 | 73 | nsIDocument *sub_doc = doc->GetSubDocumentFor(mContent); |
michael@0 | 74 | |
michael@0 | 75 | if (!sub_doc) { |
michael@0 | 76 | return NS_OK; |
michael@0 | 77 | } |
michael@0 | 78 | |
michael@0 | 79 | NS_IF_ADDREF(*aResult = sub_doc->GetDocShell()); |
michael@0 | 80 | return NS_OK; |
michael@0 | 81 | } |
michael@0 | 82 | |
michael@0 | 83 | nsresult |
michael@0 | 84 | NS_NewContainerBoxObject(nsIBoxObject** aResult) |
michael@0 | 85 | { |
michael@0 | 86 | *aResult = new nsContainerBoxObject(); |
michael@0 | 87 | if (!*aResult) |
michael@0 | 88 | return NS_ERROR_OUT_OF_MEMORY; |
michael@0 | 89 | NS_ADDREF(*aResult); |
michael@0 | 90 | return NS_OK; |
michael@0 | 91 | } |
michael@0 | 92 |