Home | History | Annotate | Download | only in rendering
      1 /*
      2  * Copyright (C) 2007 Apple Inc.  All rights reserved.
      3  *
      4  * Redistribution and use in source and binary forms, with or without
      5  * modification, are permitted provided that the following conditions
      6  * are met:
      7  * 1. Redistributions of source code must retain the above copyright
      8  *    notice, this list of conditions and the following disclaimer.
      9  * 2. Redistributions in binary form must reproduce the above copyright
     10  *    notice, this list of conditions and the following disclaimer in the
     11  *    documentation and/or other materials provided with the distribution.
     12  *
     13  * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
     14  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     15  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     16  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
     17  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
     18  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
     19  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
     20  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
     21  * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     22  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
     23  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     24  */
     25 
     26 #ifndef LayoutState_h
     27 #define LayoutState_h
     28 
     29 #include "IntRect.h"
     30 #include "IntSize.h"
     31 #include <wtf/Noncopyable.h>
     32 
     33 namespace WebCore {
     34 
     35 class ColumnInfo;
     36 class RenderArena;
     37 class RenderBox;
     38 class RenderObject;
     39 
     40 class LayoutState {
     41     WTF_MAKE_NONCOPYABLE(LayoutState);
     42 public:
     43     LayoutState()
     44         : m_clipped(false)
     45         , m_pageLogicalHeight(0)
     46         , m_pageLogicalHeightChanged(false)
     47         , m_columnInfo(0)
     48         , m_next(0)
     49 #ifndef NDEBUG
     50         , m_renderer(0)
     51 #endif
     52     {
     53     }
     54 
     55     LayoutState(LayoutState*, RenderBox*, const IntSize& offset, int pageHeight, bool pageHeightChanged, ColumnInfo*);
     56     LayoutState(RenderObject*);
     57 
     58     void destroy(RenderArena*);
     59 
     60     // Overloaded new operator.
     61     void* operator new(size_t, RenderArena*) throw();
     62 
     63     // Overridden to prevent the normal delete from being called.
     64     void operator delete(void*, size_t);
     65 
     66     void clearPaginationInformation();
     67     bool isPaginatingColumns() const { return m_columnInfo; }
     68     bool isPaginated() const { return m_pageLogicalHeight || m_columnInfo; }
     69 
     70     // The page logical offset is the object's offset from the top of the page in the page progression
     71     // direction (so an x-offset in vertical text and a y-offset for horizontal text).
     72     int pageLogicalOffset(int childLogicalOffset) const;
     73 
     74     void addForcedColumnBreak(int childLogicalOffset);
     75 
     76     bool pageLogicalHeight() const { return m_pageLogicalHeight; }
     77     bool pageLogicalHeightChanged() const { return m_pageLogicalHeightChanged; }
     78 
     79 private:
     80     // The normal operator new is disallowed.
     81     void* operator new(size_t) throw();
     82 
     83 public:
     84     bool m_clipped;
     85     IntRect m_clipRect;
     86     IntSize m_paintOffset; // x/y offset from container.  Includes relative positioning and scroll offsets.
     87     IntSize m_layoutOffset; // x/y offset from container.  Does not include relative positioning or scroll offsets.
     88     IntSize m_layoutDelta; // Transient offset from the final position of the object
     89                            // used to ensure that repaints happen in the correct place.
     90                            // This is a total delta accumulated from the root.
     91 
     92     int m_pageLogicalHeight; // The current page height for the pagination model that encloses us.
     93     bool m_pageLogicalHeightChanged; // If our page height has changed, this will force all blocks to relayout.
     94     IntSize m_pageOffset; // The offset of the start of the first page in the nearest enclosing pagination model.
     95     ColumnInfo* m_columnInfo; // If the enclosing pagination model is a column model, then this will store column information for easy retrieval/manipulation.
     96 
     97     LayoutState* m_next;
     98 #ifndef NDEBUG
     99     RenderObject* m_renderer;
    100 #endif
    101 };
    102 
    103 } // namespace WebCore
    104 
    105 #endif // LayoutState_h
    106