1 /* 2 * Copyright (C) 2013 Google 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 are 6 * met: 7 * 8 * * Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer. 10 * * Redistributions in binary form must reproduce the above 11 * copyright notice, this list of conditions and the following disclaimer 12 * in the documentation and/or other materials provided with the 13 * distribution. 14 * * Neither the name of Google Inc. nor the names of its 15 * contributors may be used to endorse or promote products derived from 16 * this software without specific prior written permission. 17 * 18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 */ 30 31 #ifndef RenderLazyBlock_h 32 #define RenderLazyBlock_h 33 34 #include "core/rendering/RenderBlock.h" 35 36 namespace WebCore { 37 38 class RenderLazyBlock FINAL : public RenderBlock { 39 public: 40 RenderLazyBlock(Element*); 41 virtual ~RenderLazyBlock(); 42 43 bool isAttached() const { return m_attached; } 44 bool isNested() const; 45 46 void markForNestedLayout() 47 { 48 setNeedsLayout(); 49 m_isNestedLayout = true; 50 } 51 52 RenderLazyBlock* next() const { return m_next; } 53 RenderLazyBlock* previous() const { return m_previous; } 54 55 RenderBox* firstVisibleChildBox() const { return m_firstVisibleChildBox; } 56 RenderBox* lastVisibleChildBox() const { return m_lastVisibleChildBox; } 57 58 private: 59 virtual void paintChildren(PaintInfo&, const LayoutPoint&) OVERRIDE; 60 61 virtual bool isRenderLazyBlock() const OVERRIDE { return true; } 62 virtual void willBeDestroyed() OVERRIDE; 63 virtual void willBeRemovedFromTree() OVERRIDE; 64 virtual void layoutBlock(bool relayoutChildren, LayoutUnit pageLogicalHeight) OVERRIDE; 65 66 void layoutChildren(bool relayoutChildren); 67 68 void attachLazyBlock(); 69 void detachLazyBlock(); 70 71 RenderLazyBlock* m_next; 72 RenderLazyBlock* m_previous; 73 RenderBox* m_firstVisibleChildBox; 74 RenderBox* m_lastVisibleChildBox; 75 bool m_attached; 76 bool m_isNestedLayout; 77 LayoutRect m_intersectRect; 78 IntRect m_expandedViewportRect; 79 }; 80 81 inline RenderLazyBlock* toRenderLazyBlock(RenderObject* object) 82 { 83 ASSERT_WITH_SECURITY_IMPLICATION(!object || object->isRenderLazyBlock()); 84 return static_cast<RenderLazyBlock*>(object); 85 } 86 87 inline const RenderLazyBlock* toRenderLazyBlock(const RenderObject* object) 88 { 89 ASSERT_WITH_SECURITY_IMPLICATION(!object || object->isRenderLazyBlock()); 90 return static_cast<const RenderLazyBlock*>(object); 91 } 92 93 } // namespace WebCore 94 95 #endif // RenderLazyBlock_h 96