WebCore/rendering/RenderFrameSet.h
changeset 0 4f2f89ce4247
equal deleted inserted replaced
-1:000000000000 0:4f2f89ce4247
       
     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 
       
    33 enum FrameEdge { LeftFrameEdge, RightFrameEdge, TopFrameEdge, BottomFrameEdge };
       
    34 
       
    35 struct FrameEdgeInfo {
       
    36     FrameEdgeInfo(bool preventResize = false, bool allowBorder = true)
       
    37         : m_preventResize(4)
       
    38         , m_allowBorder(4)
       
    39     {
       
    40         m_preventResize.fill(preventResize);
       
    41         m_allowBorder.fill(allowBorder);
       
    42     }
       
    43 
       
    44     bool preventResize(FrameEdge edge) const { return m_preventResize[edge]; }
       
    45     bool allowBorder(FrameEdge edge) const { return m_allowBorder[edge]; }
       
    46 
       
    47     void setPreventResize(FrameEdge edge, bool preventResize) { m_preventResize[edge] = preventResize; }
       
    48     void setAllowBorder(FrameEdge edge, bool allowBorder) { m_allowBorder[edge] = allowBorder; }
       
    49 
       
    50 private:
       
    51     Vector<bool> m_preventResize;
       
    52     Vector<bool> m_allowBorder;
       
    53 };
       
    54 
       
    55 class RenderFrameSet : public RenderBox {
       
    56 public:
       
    57     RenderFrameSet(HTMLFrameSetElement*);
       
    58     virtual ~RenderFrameSet();
       
    59 
       
    60     const RenderObjectChildList* children() const { return &m_children; }
       
    61     RenderObjectChildList* children() { return &m_children; }
       
    62 
       
    63     FrameEdgeInfo edgeInfo() const;
       
    64 
       
    65     bool userResize(MouseEvent*);
       
    66 
       
    67     bool isResizingRow() const;
       
    68     bool isResizingColumn() const;
       
    69 
       
    70     bool canResizeRow(const IntPoint&) const;
       
    71     bool canResizeColumn(const IntPoint&) const;
       
    72 
       
    73 private:
       
    74     static const int noSplit = -1;
       
    75 
       
    76     class GridAxis : public Noncopyable {
       
    77     public:
       
    78         GridAxis();
       
    79         void resize(int);
       
    80         Vector<int> m_sizes;
       
    81         Vector<int> m_deltas;
       
    82         Vector<bool> m_preventResize;
       
    83         Vector<bool> m_allowBorder;
       
    84         int m_splitBeingResized;
       
    85         int m_splitResizeOffset;
       
    86     };
       
    87 
       
    88     virtual RenderObjectChildList* virtualChildren() { return children(); }
       
    89     virtual const RenderObjectChildList* virtualChildren() const { return children(); }
       
    90 
       
    91     virtual const char* renderName() const { return "RenderFrameSet"; }
       
    92     virtual bool isFrameSet() const { return true; }
       
    93 
       
    94     virtual void layout();
       
    95     virtual bool nodeAtPoint(const HitTestRequest&, HitTestResult&, int x, int y, int tx, int ty, HitTestAction);
       
    96     virtual void paint(PaintInfo&, int tx, int ty);
       
    97     virtual bool isChildAllowed(RenderObject*, RenderStyle*) const;
       
    98 
       
    99     inline HTMLFrameSetElement* frameSet() const;
       
   100 
       
   101     bool flattenFrameSet() const;
       
   102 
       
   103     void setIsResizing(bool);
       
   104 
       
   105     void layOutAxis(GridAxis&, const Length*, int availableSpace);
       
   106     void computeEdgeInfo();
       
   107     void fillFromEdgeInfo(const FrameEdgeInfo& edgeInfo, int r, int c);
       
   108     void positionFrames();
       
   109     void positionFramesWithFlattening();
       
   110 
       
   111     int splitPosition(const GridAxis&, int split) const;
       
   112     int hitTestSplit(const GridAxis&, int position) const;
       
   113 
       
   114     void startResizing(GridAxis&, int position);
       
   115     void continueResizing(GridAxis&, int position);
       
   116 
       
   117     void paintRowBorder(const PaintInfo&, const IntRect&);
       
   118     void paintColumnBorder(const PaintInfo&, const IntRect&);
       
   119 
       
   120     RenderObjectChildList m_children;
       
   121 
       
   122     GridAxis m_rows;
       
   123     GridAxis m_cols;
       
   124 
       
   125     bool m_isResizing;
       
   126     bool m_isChildResizing;
       
   127 };
       
   128 
       
   129 
       
   130 inline RenderFrameSet* toRenderFrameSet(RenderObject* object)
       
   131 {
       
   132     ASSERT(!object || object->isFrameSet());
       
   133     return static_cast<RenderFrameSet*>(object);
       
   134 }
       
   135 
       
   136 // This will catch anyone doing an unnecessary cast.
       
   137 void toRenderFrameSet(const RenderFrameSet*);
       
   138 
       
   139 } // namespace WebCore
       
   140 
       
   141 #endif // RenderFrameSet_h