1 /* 2 * Copyright (C) 1999 Lars Knoll (knoll (at) kde.org) 3 * (C) 2000 Simon Hausmann <hausmann (at) 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 "core/rendering/RenderBox.h" 27 28 namespace WebCore { 29 30 class HTMLDimension; 31 class HTMLFrameSetElement; 32 class MouseEvent; 33 class RenderFrame; 34 35 enum FrameEdge { LeftFrameEdge, RightFrameEdge, TopFrameEdge, BottomFrameEdge }; 36 37 struct FrameEdgeInfo { 38 FrameEdgeInfo(bool preventResize = false, bool allowBorder = true) 39 : m_preventResize(4) 40 , m_allowBorder(4) 41 { 42 m_preventResize.fill(preventResize); 43 m_allowBorder.fill(allowBorder); 44 } 45 46 bool preventResize(FrameEdge edge) const { return m_preventResize[edge]; } 47 bool allowBorder(FrameEdge edge) const { return m_allowBorder[edge]; } 48 49 void setPreventResize(FrameEdge edge, bool preventResize) { m_preventResize[edge] = preventResize; } 50 void setAllowBorder(FrameEdge edge, bool allowBorder) { m_allowBorder[edge] = allowBorder; } 51 52 private: 53 Vector<bool> m_preventResize; 54 Vector<bool> m_allowBorder; 55 }; 56 57 class RenderFrameSet FINAL : public RenderBox { 58 public: 59 RenderFrameSet(HTMLFrameSetElement*); 60 virtual ~RenderFrameSet(); 61 62 RenderObject* firstChild() const { ASSERT(children() == virtualChildren()); return children()->firstChild(); } 63 RenderObject* lastChild() const { ASSERT(children() == virtualChildren()); return children()->lastChild(); } 64 65 const RenderObjectChildList* children() const { return &m_children; } 66 RenderObjectChildList* children() { return &m_children; } 67 68 FrameEdgeInfo edgeInfo() const; 69 70 bool userResize(MouseEvent*); 71 72 bool isResizingRow() const; 73 bool isResizingColumn() const; 74 75 bool canResizeRow(const IntPoint&) const; 76 bool canResizeColumn(const IntPoint&) const; 77 78 void notifyFrameEdgeInfoChanged(); 79 80 private: 81 static const int noSplit = -1; 82 83 class GridAxis { 84 WTF_MAKE_NONCOPYABLE(GridAxis); 85 public: 86 GridAxis(); 87 void resize(int); 88 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 virtual RenderObjectChildList* virtualChildren() { return children(); } 98 virtual const RenderObjectChildList* virtualChildren() const { return children(); } 99 100 virtual const char* renderName() const { return "RenderFrameSet"; } 101 virtual bool isFrameSet() const { return true; } 102 103 virtual void layout(); 104 virtual void paint(PaintInfo&, const LayoutPoint&); 105 virtual bool isChildAllowed(RenderObject*, RenderStyle*) const; 106 virtual CursorDirective getCursor(const LayoutPoint&, Cursor&) const; 107 108 inline HTMLFrameSetElement* frameSet() const; 109 110 void setIsResizing(bool); 111 112 void layOutAxis(GridAxis&, const Vector<HTMLDimension>&, int availableSpace); 113 void computeEdgeInfo(); 114 void fillFromEdgeInfo(const FrameEdgeInfo& edgeInfo, int r, int c); 115 void positionFrames(); 116 117 int splitPosition(const GridAxis&, int split) const; 118 int hitTestSplit(const GridAxis&, int position) const; 119 120 void startResizing(GridAxis&, int position); 121 void continueResizing(GridAxis&, int position); 122 123 void paintRowBorder(const PaintInfo&, const IntRect&); 124 void paintColumnBorder(const PaintInfo&, const IntRect&); 125 126 RenderObjectChildList m_children; 127 128 GridAxis m_rows; 129 GridAxis m_cols; 130 131 bool m_isResizing; 132 bool m_isChildResizing; 133 }; 134 135 DEFINE_RENDER_OBJECT_TYPE_CASTS(RenderFrameSet, isFrameSet()); 136 137 } // namespace WebCore 138 139 #endif // RenderFrameSet_h 140