|
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/. */ |
|
5 |
|
6 #ifndef NSSUBDOCUMENTFRAME_H_ |
|
7 #define NSSUBDOCUMENTFRAME_H_ |
|
8 |
|
9 #include "mozilla/Attributes.h" |
|
10 #include "nsLeafFrame.h" |
|
11 #include "nsIReflowCallback.h" |
|
12 #include "nsFrameLoader.h" |
|
13 |
|
14 /****************************************************************************** |
|
15 * nsSubDocumentFrame |
|
16 *****************************************************************************/ |
|
17 class nsSubDocumentFrame : public nsLeafFrame, |
|
18 public nsIReflowCallback |
|
19 { |
|
20 public: |
|
21 NS_DECL_QUERYFRAME_TARGET(nsSubDocumentFrame) |
|
22 NS_DECL_FRAMEARENA_HELPERS |
|
23 |
|
24 nsSubDocumentFrame(nsStyleContext* aContext); |
|
25 |
|
26 #ifdef DEBUG_FRAME_DUMP |
|
27 void List(FILE* out = stderr, const char* aPrefix = "", uint32_t aFlags = 0) const MOZ_OVERRIDE; |
|
28 virtual nsresult GetFrameName(nsAString& aResult) const MOZ_OVERRIDE; |
|
29 #endif |
|
30 |
|
31 NS_DECL_QUERYFRAME |
|
32 |
|
33 virtual nsIAtom* GetType() const MOZ_OVERRIDE; |
|
34 |
|
35 virtual bool IsFrameOfType(uint32_t aFlags) const MOZ_OVERRIDE |
|
36 { |
|
37 // nsLeafFrame is already eReplacedContainsBlock, but that's somewhat bogus |
|
38 return nsLeafFrame::IsFrameOfType(aFlags & |
|
39 ~(nsIFrame::eReplaced | nsIFrame::eReplacedContainsBlock)); |
|
40 } |
|
41 |
|
42 virtual void Init(nsIContent* aContent, |
|
43 nsIFrame* aParent, |
|
44 nsIFrame* aPrevInFlow) MOZ_OVERRIDE; |
|
45 |
|
46 virtual void DestroyFrom(nsIFrame* aDestructRoot) MOZ_OVERRIDE; |
|
47 |
|
48 virtual nscoord GetMinWidth(nsRenderingContext *aRenderingContext) MOZ_OVERRIDE; |
|
49 virtual nscoord GetPrefWidth(nsRenderingContext *aRenderingContext) MOZ_OVERRIDE; |
|
50 |
|
51 virtual mozilla::IntrinsicSize GetIntrinsicSize() MOZ_OVERRIDE; |
|
52 virtual nsSize GetIntrinsicRatio() MOZ_OVERRIDE; |
|
53 |
|
54 virtual nsSize ComputeAutoSize(nsRenderingContext *aRenderingContext, |
|
55 nsSize aCBSize, nscoord aAvailableWidth, |
|
56 nsSize aMargin, nsSize aBorder, |
|
57 nsSize aPadding, bool aShrinkWrap) MOZ_OVERRIDE; |
|
58 |
|
59 virtual nsSize ComputeSize(nsRenderingContext *aRenderingContext, |
|
60 nsSize aCBSize, nscoord aAvailableWidth, |
|
61 nsSize aMargin, nsSize aBorder, nsSize aPadding, |
|
62 uint32_t aFlags) MOZ_OVERRIDE; |
|
63 |
|
64 virtual nsresult Reflow(nsPresContext* aPresContext, |
|
65 nsHTMLReflowMetrics& aDesiredSize, |
|
66 const nsHTMLReflowState& aReflowState, |
|
67 nsReflowStatus& aStatus) MOZ_OVERRIDE; |
|
68 |
|
69 virtual void BuildDisplayList(nsDisplayListBuilder* aBuilder, |
|
70 const nsRect& aDirtyRect, |
|
71 const nsDisplayListSet& aLists) MOZ_OVERRIDE; |
|
72 |
|
73 virtual nsresult AttributeChanged(int32_t aNameSpaceID, |
|
74 nsIAtom* aAttribute, |
|
75 int32_t aModType) MOZ_OVERRIDE; |
|
76 |
|
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; } |
|
82 |
|
83 #ifdef ACCESSIBILITY |
|
84 virtual mozilla::a11y::AccType AccessibleType() MOZ_OVERRIDE; |
|
85 #endif |
|
86 |
|
87 nsresult GetDocShell(nsIDocShell **aDocShell); |
|
88 nsresult BeginSwapDocShells(nsIFrame* aOther); |
|
89 void EndSwapDocShells(nsIFrame* aOther); |
|
90 nsView* EnsureInnerView(); |
|
91 nsIFrame* GetSubdocumentRootFrame(); |
|
92 nsIntSize GetSubdocumentSize(); |
|
93 |
|
94 // nsIReflowCallback |
|
95 virtual bool ReflowFinished() MOZ_OVERRIDE; |
|
96 virtual void ReflowCallbackCanceled() MOZ_OVERRIDE; |
|
97 |
|
98 bool ShouldClipSubdocument() |
|
99 { |
|
100 nsFrameLoader* frameLoader = FrameLoader(); |
|
101 return !frameLoader || frameLoader->ShouldClipSubdocument(); |
|
102 } |
|
103 |
|
104 bool ShouldClampScrollPosition() |
|
105 { |
|
106 nsFrameLoader* frameLoader = FrameLoader(); |
|
107 return !frameLoader || frameLoader->ShouldClampScrollPosition(); |
|
108 } |
|
109 |
|
110 /** |
|
111 * Return true if pointer event hit-testing should be allowed to target |
|
112 * content in the subdocument. |
|
113 */ |
|
114 bool PassPointerEventsToChildren(); |
|
115 |
|
116 protected: |
|
117 friend class AsyncFrameInit; |
|
118 |
|
119 // Helper method to look up the HTML marginwidth & marginheight attributes |
|
120 nsIntSize GetMarginAttributes(); |
|
121 |
|
122 nsFrameLoader* FrameLoader(); |
|
123 |
|
124 bool IsInline() { return mIsInline; } |
|
125 |
|
126 virtual nscoord GetIntrinsicWidth() MOZ_OVERRIDE; |
|
127 virtual nscoord GetIntrinsicHeight() MOZ_OVERRIDE; |
|
128 |
|
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 |
|
131 // being reframed. |
|
132 void ShowViewer(); |
|
133 |
|
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. |
|
138 * |
|
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. |
|
141 */ |
|
142 nsIFrame* ObtainIntrinsicSizeFrame(); |
|
143 |
|
144 nsRefPtr<nsFrameLoader> mFrameLoader; |
|
145 nsView* mInnerView; |
|
146 bool mIsInline; |
|
147 bool mPostedReflowCallback; |
|
148 bool mDidCreateDoc; |
|
149 bool mCallingShow; |
|
150 }; |
|
151 |
|
152 #endif /* NSSUBDOCUMENTFRAME_H_ */ |