1 : /* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2 : * ***** BEGIN LICENSE BLOCK *****
3 : * Version: MPL 1.1/GPL 2.0/LGPL 2.1
4 : *
5 : * The contents of this file are subject to the Mozilla Public License Version
6 : * 1.1 (the "License"); you may not use this file except in compliance with
7 : * the License. You may obtain a copy of the License at
8 : * http://www.mozilla.org/MPL/
9 : *
10 : * Software distributed under the License is distributed on an "AS IS" basis,
11 : * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 : * for the specific language governing rights and limitations under the
13 : * License.
14 : *
15 : * The Original Code is Mozilla Corporation code.
16 : *
17 : * The Initial Developer of the Original Code is Mozilla Foundation.
18 : * Portions created by the Initial Developer are Copyright (C) 2010
19 : * the Initial Developer. All Rights Reserved.
20 : *
21 : * Contributor(s):
22 : * Robert O'Callahan <robert@ocallahan.org>
23 : *
24 : * Alternatively, the contents of this file may be used under the terms of
25 : * either the GNU General Public License Version 2 or later (the "GPL"), or
26 : * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
27 : * in which case the provisions of the GPL or the LGPL are applicable instead
28 : * of those above. If you wish to allow use of your version of this file only
29 : * under the terms of either the GPL or the LGPL, and not to allow others to
30 : * use your version of this file under the terms of the MPL, indicate your
31 : * decision by deleting the provisions above and replace them with the notice
32 : * and other provisions required by the GPL or the LGPL. If you do not delete
33 : * the provisions above, a recipient may use your version of this file under
34 : * the terms of any one of the MPL, the GPL or the LGPL.
35 : *
36 : * ***** END LICENSE BLOCK ***** */
37 :
38 : #ifndef NSSUBDOCUMENTFRAME_H_
39 : #define NSSUBDOCUMENTFRAME_H_
40 :
41 : #include "nsLeafFrame.h"
42 : #include "nsIReflowCallback.h"
43 : #include "nsFrameLoader.h"
44 :
45 : /******************************************************************************
46 : * nsSubDocumentFrame
47 : *****************************************************************************/
48 : class nsSubDocumentFrame : public nsLeafFrame,
49 : public nsIReflowCallback
50 0 : {
51 : public:
52 : NS_DECL_QUERYFRAME_TARGET(nsSubDocumentFrame)
53 : NS_DECL_FRAMEARENA_HELPERS
54 :
55 : nsSubDocumentFrame(nsStyleContext* aContext);
56 :
57 : #ifdef DEBUG
58 : NS_IMETHOD GetFrameName(nsAString& aResult) const;
59 : #endif
60 :
61 : NS_DECL_QUERYFRAME
62 :
63 : virtual nsIAtom* GetType() const;
64 :
65 0 : virtual bool IsFrameOfType(PRUint32 aFlags) const
66 : {
67 : // nsLeafFrame is already eReplacedContainsBlock, but that's somewhat bogus
68 : return nsLeafFrame::IsFrameOfType(aFlags &
69 0 : ~(nsIFrame::eReplaced | nsIFrame::eReplacedContainsBlock));
70 : }
71 :
72 : NS_IMETHOD Init(nsIContent* aContent,
73 : nsIFrame* aParent,
74 : nsIFrame* aPrevInFlow);
75 :
76 : virtual void DestroyFrom(nsIFrame* aDestructRoot);
77 :
78 : virtual nscoord GetMinWidth(nsRenderingContext *aRenderingContext);
79 : virtual nscoord GetPrefWidth(nsRenderingContext *aRenderingContext);
80 :
81 : virtual IntrinsicSize GetIntrinsicSize();
82 : virtual nsSize GetIntrinsicRatio();
83 :
84 : virtual nsSize ComputeAutoSize(nsRenderingContext *aRenderingContext,
85 : nsSize aCBSize, nscoord aAvailableWidth,
86 : nsSize aMargin, nsSize aBorder,
87 : nsSize aPadding, bool aShrinkWrap);
88 :
89 : virtual nsSize ComputeSize(nsRenderingContext *aRenderingContext,
90 : nsSize aCBSize, nscoord aAvailableWidth,
91 : nsSize aMargin, nsSize aBorder, nsSize aPadding,
92 : bool aShrinkWrap);
93 :
94 : NS_IMETHOD Reflow(nsPresContext* aPresContext,
95 : nsHTMLReflowMetrics& aDesiredSize,
96 : const nsHTMLReflowState& aReflowState,
97 : nsReflowStatus& aStatus);
98 :
99 : NS_IMETHOD BuildDisplayList(nsDisplayListBuilder* aBuilder,
100 : const nsRect& aDirtyRect,
101 : const nsDisplayListSet& aLists);
102 :
103 : NS_IMETHOD AttributeChanged(PRInt32 aNameSpaceID,
104 : nsIAtom* aAttribute,
105 : PRInt32 aModType);
106 :
107 : // if the content is "visibility:hidden", then just hide the view
108 : // and all our contents. We don't extend "visibility:hidden" to
109 : // the child content ourselves, since it belongs to a different
110 : // document and CSS doesn't inherit in there.
111 0 : virtual bool SupportsVisibilityHidden() { return false; }
112 :
113 : #ifdef ACCESSIBILITY
114 : virtual already_AddRefed<nsAccessible> CreateAccessible();
115 : #endif
116 :
117 : nsresult GetDocShell(nsIDocShell **aDocShell);
118 : nsresult BeginSwapDocShells(nsIFrame* aOther);
119 : void EndSwapDocShells(nsIFrame* aOther);
120 : nsIView* EnsureInnerView();
121 : nsIFrame* GetSubdocumentRootFrame();
122 :
123 : // nsIReflowCallback
124 : virtual bool ReflowFinished();
125 : virtual void ReflowCallbackCanceled();
126 :
127 0 : bool ShouldClipSubdocument()
128 : {
129 0 : nsFrameLoader* frameLoader = FrameLoader();
130 0 : return !frameLoader || frameLoader->ShouldClipSubdocument();
131 : }
132 :
133 0 : bool ShouldClampScrollPosition()
134 : {
135 0 : nsFrameLoader* frameLoader = FrameLoader();
136 0 : return !frameLoader || frameLoader->ShouldClampScrollPosition();
137 : }
138 :
139 : protected:
140 : friend class AsyncFrameInit;
141 :
142 : // Helper method to look up the HTML marginwidth & marginheight attributes
143 : nsIntSize GetMarginAttributes();
144 :
145 : nsFrameLoader* FrameLoader();
146 :
147 0 : bool IsInline() { return mIsInline; }
148 :
149 : virtual nscoord GetIntrinsicWidth();
150 : virtual nscoord GetIntrinsicHeight();
151 :
152 : virtual PRIntn GetSkipSides() const;
153 :
154 : // Hide or show our document viewer
155 : void HideViewer();
156 : void ShowViewer();
157 :
158 : /* Obtains the frame we should use for intrinsic size information if we are
159 : * an HTML <object>, <embed> or <applet> (a replaced element - not <iframe>)
160 : * and our sub-document has an intrinsic size. The frame returned is the
161 : * frame for the document element of the document we're embedding.
162 : *
163 : * Called "Obtain*" and not "Get*" because of comment on GetDocShell that
164 : * says it should be called ObtainDocShell because of it's side effects.
165 : */
166 : nsIFrame* ObtainIntrinsicSizeFrame();
167 :
168 : nsRefPtr<nsFrameLoader> mFrameLoader;
169 : nsIView* mInnerView;
170 : bool mIsInline;
171 : bool mPostedReflowCallback;
172 : bool mDidCreateDoc;
173 : bool mCallingShow;
174 : };
175 :
176 : #endif /* NSSUBDOCUMENTFRAME_H_ */
|