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 LayoutFrameSet_h
24 #define LayoutFrameSet_h
26 #include "core/layout/LayoutBox.h"
31 class HTMLFrameSetElement
;
34 enum FrameEdge
{ LeftFrameEdge
, RightFrameEdge
, TopFrameEdge
, BottomFrameEdge
};
36 struct FrameEdgeInfo
{
38 FrameEdgeInfo(bool preventResize
= false, bool allowBorder
= true)
42 m_preventResize
.fill(preventResize
);
43 m_allowBorder
.fill(allowBorder
);
46 bool preventResize(FrameEdge edge
) const { return m_preventResize
[edge
]; }
47 bool allowBorder(FrameEdge edge
) const { return m_allowBorder
[edge
]; }
49 void setPreventResize(FrameEdge edge
, bool preventResize
) { m_preventResize
[edge
] = preventResize
; }
50 void setAllowBorder(FrameEdge edge
, bool allowBorder
) { m_allowBorder
[edge
] = allowBorder
; }
53 Vector
<bool> m_preventResize
;
54 Vector
<bool> m_allowBorder
;
57 class LayoutFrameSet final
: public LayoutBox
{
59 LayoutFrameSet(HTMLFrameSetElement
*);
60 ~LayoutFrameSet() override
;
62 LayoutObject
* firstChild() const { ASSERT(children() == virtualChildren()); return children()->firstChild(); }
63 LayoutObject
* lastChild() const { ASSERT(children() == virtualChildren()); return children()->lastChild(); }
65 // If you have a LayoutFrameSet, use firstChild or lastChild instead.
66 void slowFirstChild() const = delete;
67 void slowLastChild() const = delete;
69 const LayoutObjectChildList
* children() const { return &m_children
; }
70 LayoutObjectChildList
* 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();
80 HTMLFrameSetElement
* frameSet() const;
83 DISALLOW_ALLOCATION();
84 WTF_MAKE_NONCOPYABLE(GridAxis
);
91 Vector
<bool> m_preventResize
;
92 Vector
<bool> m_allowBorder
;
93 int m_splitBeingResized
;
94 int m_splitResizeOffset
;
97 const GridAxis
& rows() { return m_rows
; }
98 const GridAxis
& columns() { return m_cols
; }
100 const char* name() const override
{ return "LayoutFrameSet"; }
103 static const int noSplit
= -1;
105 LayoutObjectChildList
* virtualChildren() override
{ return children(); }
106 const LayoutObjectChildList
* virtualChildren() const override
{ return children(); }
108 bool isOfType(LayoutObjectType type
) const override
{ return type
== LayoutObjectFrameSet
|| LayoutBox::isOfType(type
); }
110 void layout() override
;
111 void paint(const PaintInfo
&, const LayoutPoint
&) override
;
112 void computePreferredLogicalWidths() override
;
113 bool isChildAllowed(LayoutObject
*, const ComputedStyle
&) const override
;
114 CursorDirective
getCursor(const LayoutPoint
&, Cursor
&) const override
;
116 void setIsResizing(bool);
118 void layOutAxis(GridAxis
&, const Vector
<HTMLDimension
>&, int availableSpace
);
119 void computeEdgeInfo();
120 void fillFromEdgeInfo(const FrameEdgeInfo
&, int r
, int c
);
121 void positionFrames();
123 int splitPosition(const GridAxis
&, int split
) const;
124 int hitTestSplit(const GridAxis
&, int position
) const;
126 void startResizing(GridAxis
&, int position
);
127 void continueResizing(GridAxis
&, int position
);
129 LayoutObjectChildList m_children
;
135 bool m_isChildResizing
;
138 DEFINE_LAYOUT_OBJECT_TYPE_CASTS(LayoutFrameSet
, isFrameSet());
142 #endif // LayoutFrameSet_h