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.
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.
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.
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.
23 #ifndef RenderFrameSet_h
24 #define RenderFrameSet_h
26 #include "core/rendering/RenderBox.h"
31 class HTMLFrameSetElement;
34 enum FrameEdge { LeftFrameEdge, RightFrameEdge, TopFrameEdge, BottomFrameEdge };
36 struct FrameEdgeInfo {
37 FrameEdgeInfo(bool preventResize = false, bool allowBorder = true)
41 m_preventResize.fill(preventResize);
42 m_allowBorder.fill(allowBorder);
45 bool preventResize(FrameEdge edge) const { return m_preventResize[edge]; }
46 bool allowBorder(FrameEdge edge) const { return m_allowBorder[edge]; }
48 void setPreventResize(FrameEdge edge, bool preventResize) { m_preventResize[edge] = preventResize; }
49 void setAllowBorder(FrameEdge edge, bool allowBorder) { m_allowBorder[edge] = allowBorder; }
52 Vector<bool> m_preventResize;
53 Vector<bool> m_allowBorder;
56 class RenderFrameSet final : public RenderBox {
58 RenderFrameSet(HTMLFrameSetElement*);
59 virtual ~RenderFrameSet();
60 virtual void trace(Visitor*) override;
62 RenderObject* firstChild() const { ASSERT(children() == virtualChildren()); return children()->firstChild(); }
63 RenderObject* lastChild() const { ASSERT(children() == virtualChildren()); return children()->lastChild(); }
65 // If you have a RenderFrameSet, use firstChild or lastChild instead.
66 void slowFirstChild() const WTF_DELETED_FUNCTION;
67 void slowLastChild() const WTF_DELETED_FUNCTION;
69 const RenderObjectChildList* children() const { return &m_children; }
70 RenderObjectChildList* children() { return &m_children; }
72 FrameEdgeInfo edgeInfo() const;
74 bool userResize(MouseEvent*);
76 bool canResizeRow(const IntPoint&) const;
77 bool canResizeColumn(const IntPoint&) const;
79 void notifyFrameEdgeInfoChanged();
82 static const int noSplit = -1;
85 WTF_MAKE_NONCOPYABLE(GridAxis);
92 Vector<bool> m_preventResize;
93 Vector<bool> m_allowBorder;
94 int m_splitBeingResized;
95 int m_splitResizeOffset;
98 virtual RenderObjectChildList* virtualChildren() override { return children(); }
99 virtual const RenderObjectChildList* virtualChildren() const override { return children(); }
101 virtual const char* renderName() const override { return "RenderFrameSet"; }
102 virtual bool isOfType(RenderObjectType type) const override { return type == RenderObjectFrameSet || RenderBox::isOfType(type); }
104 virtual void layout() override;
105 virtual void paint(PaintInfo&, const LayoutPoint&) override;
106 virtual void computePreferredLogicalWidths() override;
107 virtual bool isChildAllowed(RenderObject*, RenderStyle*) const override;
108 virtual CursorDirective getCursor(const LayoutPoint&, Cursor&) const override;
110 inline HTMLFrameSetElement* frameSet() const;
112 void setIsResizing(bool);
114 void layOutAxis(GridAxis&, const Vector<HTMLDimension>&, int availableSpace);
115 void computeEdgeInfo();
116 void fillFromEdgeInfo(const FrameEdgeInfo& edgeInfo, int r, int c);
117 void positionFrames();
119 int splitPosition(const GridAxis&, int split) const;
120 int hitTestSplit(const GridAxis&, int position) const;
122 void startResizing(GridAxis&, int position);
123 void continueResizing(GridAxis&, int position);
125 void paintRowBorder(const PaintInfo&, const IntRect&);
126 void paintColumnBorder(const PaintInfo&, const IntRect&);
128 RenderObjectChildList m_children;
134 bool m_isChildResizing;
137 DEFINE_RENDER_OBJECT_TYPE_CASTS(RenderFrameSet, isFrameSet());
141 #endif // RenderFrameSet_h