/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * * The contents of this file are subject to the Mozilla Public License Version * 1.1 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" basis, * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License * for the specific language governing rights and limitations under the * License. * * The Original Code is mozilla.org code. * * The Initial Developer of the Original Code is * Netscape Communications Corporation. * Portions created by the Initial Developer are Copyright (C) 1998 * the Initial Developer. All Rights Reserved. * * Contributor(s): * Travis Bogard * Håkan Waara * * Alternatively, the contents of this file may be used under the terms of * either of the GNU General Public License Version 2 or later (the "GPL"), * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), * in which case the provisions of the GPL or the LGPL are applicable instead * of those above. If you wish to allow use of your version of this file only * under the terms of either the GPL or the LGPL, and not to allow others to * use your version of this file under the terms of the MPL, indicate your * decision by deleting the provisions above and replace them with the notice * and other provisions required by the GPL or the LGPL. If you do not delete * the provisions above, a recipient may use your version of this file under * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ #include "nsCOMPtr.h" #include "nsLeafFrame.h" #include "nsGenericHTMLElement.h" #include "nsIDocShell.h" #include "nsIDocShellLoadInfo.h" #include "nsIDocShellTreeItem.h" #include "nsIDocShellTreeNode.h" #include "nsIDocShellTreeOwner.h" #include "nsIBaseWindow.h" #include "nsIContentViewer.h" #include "nsIMarkupDocumentViewer.h" #include "nsPresContext.h" #include "nsIPresShell.h" #include "nsIComponentManager.h" #include "nsFrameManager.h" #include "nsIStreamListener.h" #include "nsIURL.h" #include "nsNetUtil.h" #include "nsIDocument.h" #include "nsIView.h" #include "nsIViewManager.h" #include "nsWidgetsCID.h" #include "nsViewsCID.h" #include "nsHTMLAtoms.h" #include "nsIScrollableView.h" #include "nsStyleCoord.h" #include "nsStyleContext.h" #include "nsStyleConsts.h" #include "nsIDocumentLoader.h" #include "nsFrameSetFrame.h" #include "nsIDOMHTMLFrameElement.h" #include "nsIDOMHTMLIFrameElement.h" #include "nsIDOMXULElement.h" #include "nsIFrameLoader.h" #include "nsLayoutAtoms.h" #include "nsIScriptSecurityManager.h" #include "nsXPIDLString.h" #include "nsIScrollable.h" #include "nsINameSpaceManager.h" #include "nsIWidget.h" #include "nsIWebBrowserPrint.h" #include "nsWeakReference.h" #include "nsIDOMWindow.h" #include "nsIDOMDocument.h" #include "nsIRenderingContext.h" #include "nsIFrameFrame.h" #include "nsAutoPtr.h" #include "nsIDOMNSHTMLDocument.h" #include "nsUnicharUtils.h" // For Accessibility #ifdef ACCESSIBILITY #include "nsIAccessibilityService.h" #endif #include "nsIServiceManager.h" static NS_DEFINE_CID(kCChildCID, NS_CHILD_CID); /****************************************************************************** * nsSubDocumentFrame *****************************************************************************/ class nsSubDocumentFrame : public nsLeafFrame, public nsIFrameFrame { public: nsSubDocumentFrame(); #ifdef DEBUG NS_IMETHOD GetFrameName(nsAString& aResult) const; #endif // nsISupports NS_IMETHOD QueryInterface(REFNSIID aIID, void** aInstancePtr); NS_IMETHOD_(nsrefcnt) AddRef(void) { return 2; } NS_IMETHOD_(nsrefcnt) Release(void) { return 1; } virtual nsIAtom* GetType() const; NS_IMETHOD Init(nsPresContext* aPresContext, nsIContent* aContent, nsIFrame* aParent, nsStyleContext* aContext, nsIFrame* aPrevInFlow); NS_IMETHOD Destroy(nsPresContext* aPresContext); NS_IMETHOD Reflow(nsPresContext* aPresContext, nsHTMLReflowMetrics& aDesiredSize, const nsHTMLReflowState& aReflowState, nsReflowStatus& aStatus); NS_IMETHOD AttributeChanged(nsIContent* aChild, PRInt32 aNameSpaceID, nsIAtom* aAttribute, PRInt32 aModType); // if the content is "visibility:hidden", then just hide the view // and all our contents. We don't extend "visibility:hidden" to // the child content ourselves, since it belongs to a different // document and CSS doesn't inherit in there. virtual PRBool SupportsVisibilityHidden() { return PR_FALSE; } #ifdef ACCESSIBILITY NS_IMETHOD GetAccessible(nsIAccessible** aAccessible); #endif // nsIFrameFrame NS_IMETHOD GetDocShell(nsIDocShell **aDocShell); NS_IMETHOD VerifyTree() const; protected: nsSize GetMargin(); PRBool IsInline() { return mIsInline; } nsresult ReloadURL(); nsresult ShowDocShell(); nsresult CreateViewAndWidget(nsContentType aContentType); virtual void GetDesiredSize(nsPresContext* aPresContext, const nsHTMLReflowState& aReflowState, nsHTMLReflowMetrics& aDesiredSize); virtual PRIntn GetSkipSides() const; nsCOMPtr mFrameLoader; nsIView* mInnerView; PRPackedBool mDidCreateDoc; PRPackedBool mOwnsFrameLoader; PRPackedBool mIsInline; }; nsSubDocumentFrame::nsSubDocumentFrame() : nsLeafFrame(), mDidCreateDoc(PR_FALSE), mOwnsFrameLoader(PR_FALSE), mIsInline(PR_FALSE) { } #ifdef ACCESSIBILITY NS_IMETHODIMP nsSubDocumentFrame::GetAccessible(nsIAccessible** aAccessible) { nsCOMPtr accService = do_GetService("@mozilla.org/accessibilityService;1"); if (accService) { nsCOMPtr node = do_QueryInterface(mContent); return accService->CreateOuterDocAccessible(node, aAccessible); } return NS_ERROR_FAILURE; } #endif //-------------------------------------------------------------- // Frames are not refcounted, no need to AddRef NS_IMETHODIMP nsSubDocumentFrame::QueryInterface(const nsIID& aIID, void** aInstancePtr) { NS_PRECONDITION(0 != aInstancePtr, "null ptr"); if (NULL == aInstancePtr) { return NS_ERROR_NULL_POINTER; } if (aIID.Equals(NS_GET_IID(nsIFrameFrame))) { nsISupports *tmp = NS_STATIC_CAST(nsIFrameFrame *, this); *aInstancePtr = tmp; return NS_OK; } return nsLeafFrame::QueryInterface(aIID, aInstancePtr); } NS_IMETHODIMP nsSubDocumentFrame::Init(nsPresContext* aPresContext, nsIContent* aContent, nsIFrame* aParent, nsStyleContext* aContext, nsIFrame* aPrevInFlow) { // determine if we are a or