Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
1 /* -*- Mode: C++; tab-width: 2; 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 /* rendering object for HTML <frameset> elements */
8 #ifndef nsHTMLFrameset_h___
9 #define nsHTMLFrameset_h___
11 #include "mozilla/Attributes.h"
12 #include "nsContainerFrame.h"
13 #include "nsColor.h"
15 class nsIContent;
16 class nsPresContext;
17 struct nsRect;
18 struct nsHTMLReflowState;
19 struct nsSize;
20 class nsIAtom;
21 class nsHTMLFramesetBorderFrame;
22 class nsHTMLFramesetFrame;
24 #define NO_COLOR 0xFFFFFFFA
26 // defined at HTMLFrameSetElement.h
27 struct nsFramesetSpec;
29 struct nsBorderColor
30 {
31 nscolor mLeft;
32 nscolor mRight;
33 nscolor mTop;
34 nscolor mBottom;
36 nsBorderColor() { Set(NO_COLOR); }
37 ~nsBorderColor() {}
38 void Set(nscolor aColor) { mLeft = mRight = mTop = mBottom = aColor; }
39 };
41 enum nsFrameborder {
42 eFrameborder_Yes = 0,
43 eFrameborder_No,
44 eFrameborder_Notset
45 };
47 struct nsFramesetDrag {
48 nsHTMLFramesetFrame* mSource; // frameset whose border was dragged to cause the resize
49 int32_t mIndex; // index of left col or top row of effected area
50 int32_t mChange; // pos for left to right or top to bottom, neg otherwise
51 bool mVertical; // vertical if true, otherwise horizontal
53 nsFramesetDrag();
54 void Reset(bool aVertical,
55 int32_t aIndex,
56 int32_t aChange,
57 nsHTMLFramesetFrame* aSource);
58 void UnSet();
59 };
61 /*******************************************************************************
62 * nsHTMLFramesetFrame
63 ******************************************************************************/
64 class nsHTMLFramesetFrame : public nsContainerFrame
65 {
66 public:
67 NS_DECL_QUERYFRAME_TARGET(nsHTMLFramesetFrame)
68 NS_DECL_QUERYFRAME
69 NS_DECL_FRAMEARENA_HELPERS
71 nsHTMLFramesetFrame(nsStyleContext* aContext);
73 virtual ~nsHTMLFramesetFrame();
75 virtual void Init(nsIContent* aContent,
76 nsIFrame* aParent,
77 nsIFrame* aPrevInFlow) MOZ_OVERRIDE;
79 virtual nsresult SetInitialChildList(ChildListID aListID,
80 nsFrameList& aChildList) MOZ_OVERRIDE;
82 static bool gDragInProgress;
84 void GetSizeOfChild(nsIFrame* aChild, nsSize& aSize);
86 void GetSizeOfChildAt(int32_t aIndexInParent,
87 nsSize& aSize,
88 nsIntPoint& aCellIndex);
90 virtual nsresult HandleEvent(nsPresContext* aPresContext,
91 mozilla::WidgetGUIEvent* aEvent,
92 nsEventStatus* aEventStatus) MOZ_OVERRIDE;
94 virtual nsresult GetCursor(const nsPoint& aPoint,
95 nsIFrame::Cursor& aCursor) MOZ_OVERRIDE;
97 virtual void BuildDisplayList(nsDisplayListBuilder* aBuilder,
98 const nsRect& aDirtyRect,
99 const nsDisplayListSet& aLists) MOZ_OVERRIDE;
101 virtual nsresult Reflow(nsPresContext* aPresContext,
102 nsHTMLReflowMetrics& aDesiredSize,
103 const nsHTMLReflowState& aReflowState,
104 nsReflowStatus& aStatus) MOZ_OVERRIDE;
106 virtual nsIAtom* GetType() const MOZ_OVERRIDE;
107 #ifdef DEBUG_FRAME_DUMP
108 virtual nsresult GetFrameName(nsAString& aResult) const MOZ_OVERRIDE;
109 #endif
111 virtual bool IsLeaf() const MOZ_OVERRIDE;
113 void StartMouseDrag(nsPresContext* aPresContext,
114 nsHTMLFramesetBorderFrame* aBorder,
115 mozilla::WidgetGUIEvent* aEvent);
117 void MouseDrag(nsPresContext* aPresContext,
118 mozilla::WidgetGUIEvent* aEvent);
120 void EndMouseDrag(nsPresContext* aPresContext);
122 nsFrameborder GetParentFrameborder() { return mParentFrameborder; }
124 void SetParentFrameborder(nsFrameborder aValue) { mParentFrameborder = aValue; }
126 nsFramesetDrag& GetDrag() { return mDrag; }
128 void RecalculateBorderResize();
130 protected:
131 void Scale(nscoord aDesired,
132 int32_t aNumIndicies,
133 int32_t* aIndicies,
134 int32_t aNumItems,
135 int32_t* aItems);
137 void CalculateRowCol(nsPresContext* aPresContext,
138 nscoord aSize,
139 int32_t aNumSpecs,
140 const nsFramesetSpec* aSpecs,
141 nscoord* aValues);
143 void GenerateRowCol(nsPresContext* aPresContext,
144 nscoord aSize,
145 int32_t aNumSpecs,
146 const nsFramesetSpec* aSpecs,
147 nscoord* aValues,
148 nsString& aNewAttr);
150 virtual void GetDesiredSize(nsPresContext* aPresContext,
151 const nsHTMLReflowState& aReflowState,
152 nsHTMLReflowMetrics& aDesiredSize);
154 int32_t GetBorderWidth(nsPresContext* aPresContext,
155 bool aTakeForcingIntoAccount);
157 int32_t GetParentBorderWidth() { return mParentBorderWidth; }
159 void SetParentBorderWidth(int32_t aWidth) { mParentBorderWidth = aWidth; }
161 nscolor GetParentBorderColor() { return mParentBorderColor; }
163 void SetParentBorderColor(nscolor aColor) { mParentBorderColor = aColor; }
165 nsFrameborder GetFrameBorder();
167 nsFrameborder GetFrameBorder(nsIContent* aContent);
169 nscolor GetBorderColor();
171 nscolor GetBorderColor(nsIContent* aFrameContent);
173 bool GetNoResize(nsIFrame* aChildFrame);
175 void ReflowPlaceChild(nsIFrame* aChild,
176 nsPresContext* aPresContext,
177 const nsHTMLReflowState& aReflowState,
178 nsPoint& aOffset,
179 nsSize& aSize,
180 nsIntPoint* aCellIndex = 0);
182 bool CanResize(bool aVertical, bool aLeft);
184 bool CanChildResize(bool aVertical, bool aLeft, int32_t aChildX);
186 void SetBorderResize(nsHTMLFramesetBorderFrame* aBorderFrame);
188 static void FrameResizePrefCallback(const char* aPref, void* aClosure);
190 nsFramesetDrag mDrag;
191 nsBorderColor mEdgeColors;
192 nsHTMLFramesetBorderFrame* mDragger;
193 nsHTMLFramesetFrame* mTopLevelFrameset;
194 nsHTMLFramesetBorderFrame** mVerBorders; // vertical borders
195 nsHTMLFramesetBorderFrame** mHorBorders; // horizontal borders
196 nsFrameborder* mChildFrameborder; // the frameborder attr of children
197 nsBorderColor* mChildBorderColors;
198 nscoord* mRowSizes; // currently computed row sizes
199 nscoord* mColSizes; // currently computed col sizes
200 nsIntPoint mFirstDragPoint;
201 int32_t mNumRows;
202 int32_t mNumCols;
203 int32_t mNonBorderChildCount;
204 int32_t mNonBlankChildCount;
205 int32_t mEdgeVisibility;
206 nsFrameborder mParentFrameborder;
207 nscolor mParentBorderColor;
208 int32_t mParentBorderWidth;
209 int32_t mPrevNeighborOrigSize; // used during resize
210 int32_t mNextNeighborOrigSize;
211 int32_t mMinDrag;
212 int32_t mChildCount;
213 bool mForceFrameResizability;
214 };
216 #endif