~ubuntu-branches/ubuntu/raring/qtwebkit-source/raring-proposed

« back to all changes in this revision

Viewing changes to Source/WebCore/rendering/RenderFrameSet.h

  • Committer: Package Import Robot
  • Author(s): Jonathan Riddell
  • Date: 2013-02-18 14:24:18 UTC
  • Revision ID: package-import@ubuntu.com-20130218142418-eon0jmjg3nj438uy
Tags: upstream-2.3
ImportĀ upstreamĀ versionĀ 2.3

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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 "RenderBox.h"
 
27
 
 
28
namespace WebCore {
 
29
 
 
30
class HTMLFrameSetElement;
 
31
class MouseEvent;
 
32
class RenderFrame;
 
33
 
 
34
enum FrameEdge { LeftFrameEdge, RightFrameEdge, TopFrameEdge, BottomFrameEdge };
 
35
 
 
36
struct FrameEdgeInfo {
 
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 RenderBox {
 
57
public:
 
58
    RenderFrameSet(HTMLFrameSetElement*);
 
59
    virtual ~RenderFrameSet();
 
60
 
 
61
    RenderObject* firstChild() const { ASSERT(children() == virtualChildren()); return children()->firstChild(); }
 
62
    RenderObject* lastChild() const { ASSERT(children() == virtualChildren()); return children()->lastChild(); }
 
63
 
 
64
    const RenderObjectChildList* children() const { return &m_children; }
 
65
    RenderObjectChildList* children() { return &m_children; }
 
66
 
 
67
    FrameEdgeInfo edgeInfo() const;
 
68
 
 
69
    bool userResize(MouseEvent*);
 
70
 
 
71
    bool isResizingRow() const;
 
72
    bool isResizingColumn() const;
 
73
 
 
74
    bool canResizeRow(const IntPoint&) const;
 
75
    bool canResizeColumn(const IntPoint&) const;
 
76
 
 
77
    void notifyFrameEdgeInfoChanged();
 
78
 
 
79
private:
 
80
    static const int noSplit = -1;
 
81
 
 
82
    class GridAxis {
 
83
        WTF_MAKE_NONCOPYABLE(GridAxis);
 
84
    public:
 
85
        GridAxis();
 
86
        void resize(int);
 
87
        Vector<int> m_sizes;
 
88
        Vector<int> m_deltas;
 
89
        Vector<bool> m_preventResize;
 
90
        Vector<bool> m_allowBorder;
 
91
        int m_splitBeingResized;
 
92
        int m_splitResizeOffset;
 
93
    };
 
94
 
 
95
    virtual RenderObjectChildList* virtualChildren() { return children(); }
 
96
    virtual const RenderObjectChildList* virtualChildren() const { return children(); }
 
97
 
 
98
    virtual const char* renderName() const { return "RenderFrameSet"; }
 
99
    virtual bool isFrameSet() const { return true; }
 
100
 
 
101
    virtual void layout();
 
102
    virtual bool nodeAtPoint(const HitTestRequest&, HitTestResult&, const HitTestLocation& locationInContainer, const LayoutPoint& accumulatedOffset, HitTestAction) OVERRIDE;
 
103
    virtual void paint(PaintInfo&, const LayoutPoint&);
 
104
    virtual bool isChildAllowed(RenderObject*, RenderStyle*) const;
 
105
    virtual CursorDirective getCursor(const LayoutPoint&, Cursor&) const;
 
106
 
 
107
    inline HTMLFrameSetElement* frameSet() const;
 
108
 
 
109
    bool flattenFrameSet() const;
 
110
 
 
111
    void setIsResizing(bool);
 
112
 
 
113
    void layOutAxis(GridAxis&, const Length*, int availableSpace);
 
114
    void computeEdgeInfo();
 
115
    void fillFromEdgeInfo(const FrameEdgeInfo& edgeInfo, int r, int c);
 
116
    void positionFrames();
 
117
    void positionFramesWithFlattening();
 
118
 
 
119
    int splitPosition(const GridAxis&, int split) const;
 
120
    int hitTestSplit(const GridAxis&, int position) const;
 
121
 
 
122
    void startResizing(GridAxis&, int position);
 
123
    void continueResizing(GridAxis&, int position);
 
124
 
 
125
    void paintRowBorder(const PaintInfo&, const IntRect&);
 
126
    void paintColumnBorder(const PaintInfo&, const IntRect&);
 
127
 
 
128
    RenderObjectChildList m_children;
 
129
 
 
130
    GridAxis m_rows;
 
131
    GridAxis m_cols;
 
132
 
 
133
    bool m_isResizing;
 
134
    bool m_isChildResizing;
 
135
};
 
136
 
 
137
 
 
138
inline RenderFrameSet* toRenderFrameSet(RenderObject* object)
 
139
{
 
140
    ASSERT(!object || object->isFrameSet());
 
141
    return static_cast<RenderFrameSet*>(object);
 
142
}
 
143
 
 
144
// This will catch anyone doing an unnecessary cast.
 
145
void toRenderFrameSet(const RenderFrameSet*);
 
146
 
 
147
} // namespace WebCore
 
148
 
 
149
#endif // RenderFrameSet_h