]> git.saurik.com Git - iphone-api.git/blob - WebCore/RenderFrameSet.h
Add support for new WinterBoard Settings features.
[iphone-api.git] / WebCore / RenderFrameSet.h
1 /*
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 2000 Simon Hausmann <hausmann@kde.org>
4 * Copyright (C) 2006, 2008 Apple Inc. All rights reserved.
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details.
15 *
16 * You should have received a copy of the GNU Library General Public License
17 * along with this library; see the file COPYING.LIB. If not, write to
18 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 * Boston, MA 02110-1301, USA.
20 *
21 */
22
23 #ifndef RenderFrameSet_h
24 #define RenderFrameSet_h
25
26 #include "RenderContainer.h"
27
28 namespace WebCore {
29
30 class HTMLFrameSetElement;
31 class MouseEvent;
32
33 enum FrameEdge { LeftFrameEdge, RightFrameEdge, TopFrameEdge, BottomFrameEdge };
34
35 struct FrameEdgeInfo
36 {
37 FrameEdgeInfo(bool preventResize = false, bool allowBorder = true)
38 : m_preventResize(4)
39 , m_allowBorder(4)
40 {
41 m_preventResize.fill(preventResize);
42 m_allowBorder.fill(allowBorder);
43 }
44
45 bool preventResize(FrameEdge edge) const { return m_preventResize[edge]; }
46 bool allowBorder(FrameEdge edge) const { return m_allowBorder[edge]; }
47
48 void setPreventResize(FrameEdge edge, bool preventResize) { m_preventResize[edge] = preventResize; }
49 void setAllowBorder(FrameEdge edge, bool allowBorder) { m_allowBorder[edge] = allowBorder; }
50
51 private:
52 Vector<bool> m_preventResize;
53 Vector<bool> m_allowBorder;
54 };
55
56 class RenderFrameSet : public RenderContainer {
57 public:
58 RenderFrameSet(HTMLFrameSetElement*);
59 virtual ~RenderFrameSet();
60
61 virtual const char* renderName() const { return "RenderFrameSet"; }
62 virtual bool isFrameSet() const { return true; }
63
64 virtual void layout();
65 virtual void calcPrefWidths();
66 virtual bool nodeAtPoint(const HitTestRequest&, HitTestResult&, int x, int y, int tx, int ty, HitTestAction);
67 virtual void paint(PaintInfo& paintInfo, int tx, int ty);
68 virtual bool isChildAllowed(RenderObject*, RenderStyle*) const;
69
70 FrameEdgeInfo edgeInfo() const;
71
72 bool userResize(MouseEvent*);
73
74 bool isResizingRow() const;
75 bool isResizingColumn() const;
76
77 bool canResizeRow(const IntPoint&) const;
78 bool canResizeColumn(const IntPoint&) const;
79
80 bool flattenFrameset() const;
81
82 private:
83 static const int noSplit = -1;
84
85 class GridAxis : Noncopyable {
86 public:
87 GridAxis();
88 void resize(int);
89 Vector<int> m_sizes;
90 Vector<int> m_deltas;
91 Vector<bool> m_preventResize;
92 Vector<bool> m_allowBorder;
93 int m_splitBeingResized;
94 int m_splitResizeOffset;
95 };
96
97 inline HTMLFrameSetElement* frameSet() const;
98
99 bool canResize(const IntPoint&) const;
100 void setIsResizing(bool);
101
102 void layOutAxis(GridAxis&, const Length*, int availableSpace);
103 void computeEdgeInfo();
104 void fillFromEdgeInfo(const FrameEdgeInfo& edgeInfo, int r, int c);
105 void positionFrames();
106 void positionFramesWithFlattening();
107
108 int splitPosition(const GridAxis&, int split) const;
109 int hitTestSplit(const GridAxis&, int position) const;
110
111 void startResizing(GridAxis&, int position);
112 void continueResizing(GridAxis&, int position);
113
114 void paintRowBorder(const PaintInfo& paintInfo, const IntRect& rect);
115 void paintColumnBorder(const PaintInfo& paintInfo, const IntRect& rect);
116
117 GridAxis m_rows;
118 GridAxis m_cols;
119
120 bool m_isResizing;
121 bool m_isChildResizing;
122 };
123
124 } // namespace WebCore
125
126 #endif // RenderFrameSet_h