1 /* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2 * This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 #ifndef NSSUBDOCUMENTFRAME_H_
7 #define NSSUBDOCUMENTFRAME_H_
9 #include "mozilla/Attributes.h"
10 #include "nsLeafFrame.h"
11 #include "nsIReflowCallback.h"
12 #include "nsFrameLoader.h"
14 /******************************************************************************
16 *****************************************************************************/
17 class nsSubDocumentFrame
: public nsLeafFrame
,
18 public nsIReflowCallback
21 NS_DECL_QUERYFRAME_TARGET(nsSubDocumentFrame
)
22 NS_DECL_FRAMEARENA_HELPERS
24 nsSubDocumentFrame(nsStyleContext
* aContext
);
27 void List(FILE* out
, int32_t aIndent
, uint32_t aFlags
= 0) const MOZ_OVERRIDE
;
28 NS_IMETHOD
GetFrameName(nsAString
& aResult
) const MOZ_OVERRIDE
;
33 virtual nsIAtom
* GetType() const MOZ_OVERRIDE
;
35 virtual bool IsFrameOfType(uint32_t aFlags
) const MOZ_OVERRIDE
37 // nsLeafFrame is already eReplacedContainsBlock, but that's somewhat bogus
38 return nsLeafFrame::IsFrameOfType(aFlags
&
39 ~(nsIFrame::eReplaced
| nsIFrame::eReplacedContainsBlock
));
42 virtual void Init(nsIContent
* aContent
,
44 nsIFrame
* aPrevInFlow
) MOZ_OVERRIDE
;
46 virtual void DestroyFrom(nsIFrame
* aDestructRoot
) MOZ_OVERRIDE
;
48 virtual nscoord
GetMinWidth(nsRenderingContext
*aRenderingContext
) MOZ_OVERRIDE
;
49 virtual nscoord
GetPrefWidth(nsRenderingContext
*aRenderingContext
) MOZ_OVERRIDE
;
51 virtual mozilla::IntrinsicSize
GetIntrinsicSize() MOZ_OVERRIDE
;
52 virtual nsSize
GetIntrinsicRatio() MOZ_OVERRIDE
;
54 virtual nsSize
ComputeAutoSize(nsRenderingContext
*aRenderingContext
,
55 nsSize aCBSize
, nscoord aAvailableWidth
,
56 nsSize aMargin
, nsSize aBorder
,
57 nsSize aPadding
, bool aShrinkWrap
) MOZ_OVERRIDE
;
59 virtual nsSize
ComputeSize(nsRenderingContext
*aRenderingContext
,
60 nsSize aCBSize
, nscoord aAvailableWidth
,
61 nsSize aMargin
, nsSize aBorder
, nsSize aPadding
,
62 uint32_t aFlags
) MOZ_OVERRIDE
;
64 NS_IMETHOD
Reflow(nsPresContext
* aPresContext
,
65 nsHTMLReflowMetrics
& aDesiredSize
,
66 const nsHTMLReflowState
& aReflowState
,
67 nsReflowStatus
& aStatus
) MOZ_OVERRIDE
;
69 virtual void BuildDisplayList(nsDisplayListBuilder
* aBuilder
,
70 const nsRect
& aDirtyRect
,
71 const nsDisplayListSet
& aLists
) MOZ_OVERRIDE
;
73 NS_IMETHOD
AttributeChanged(int32_t aNameSpaceID
,
75 int32_t aModType
) MOZ_OVERRIDE
;
77 // if the content is "visibility:hidden", then just hide the view
78 // and all our contents. We don't extend "visibility:hidden" to
79 // the child content ourselves, since it belongs to a different
80 // document and CSS doesn't inherit in there.
81 virtual bool SupportsVisibilityHidden() MOZ_OVERRIDE
{ return false; }
84 virtual mozilla::a11y::AccType
AccessibleType() MOZ_OVERRIDE
;
87 nsresult
GetDocShell(nsIDocShell
**aDocShell
);
88 nsresult
BeginSwapDocShells(nsIFrame
* aOther
);
89 void EndSwapDocShells(nsIFrame
* aOther
);
90 nsView
* EnsureInnerView();
91 nsIFrame
* GetSubdocumentRootFrame();
92 nsIntSize
GetSubdocumentSize();
95 virtual bool ReflowFinished() MOZ_OVERRIDE
;
96 virtual void ReflowCallbackCanceled() MOZ_OVERRIDE
;
98 bool ShouldClipSubdocument()
100 nsFrameLoader
* frameLoader
= FrameLoader();
101 return !frameLoader
|| frameLoader
->ShouldClipSubdocument();
104 bool ShouldClampScrollPosition()
106 nsFrameLoader
* frameLoader
= FrameLoader();
107 return !frameLoader
|| frameLoader
->ShouldClampScrollPosition();
111 * Return true if pointer event hit-testing should be allowed to target
112 * content in the subdocument.
114 bool PassPointerEventsToChildren();
117 friend class AsyncFrameInit
;
119 // Helper method to look up the HTML marginwidth & marginheight attributes
120 nsIntSize
GetMarginAttributes();
122 nsFrameLoader
* FrameLoader();
124 bool IsInline() { return mIsInline
; }
126 virtual nscoord
GetIntrinsicWidth() MOZ_OVERRIDE
;
127 virtual nscoord
GetIntrinsicHeight() MOZ_OVERRIDE
;
129 // Show our document viewer. The document viewer is hidden via a script
130 // runner, so that we can save and restore the presentation if we're
134 /* Obtains the frame we should use for intrinsic size information if we are
135 * an HTML <object>, <embed> or <applet> (a replaced element - not <iframe>)
136 * and our sub-document has an intrinsic size. The frame returned is the
137 * frame for the document element of the document we're embedding.
139 * Called "Obtain*" and not "Get*" because of comment on GetDocShell that
140 * says it should be called ObtainDocShell because of it's side effects.
142 nsIFrame
* ObtainIntrinsicSizeFrame();
144 nsRefPtr
<nsFrameLoader
> mFrameLoader
;
147 bool mPostedReflowCallback
;
152 #endif /* NSSUBDOCUMENTFRAME_H_ */