1 /* 2 * Copyright (C) 1999 Lars Knoll (knoll (at) kde.org) 3 * (C) 1999 Antti Koivisto (koivisto (at) kde.org) 4 * (C) 2001 Dirk Mueller (mueller (at) kde.org) 5 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserved. 6 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmobile.com/) 7 * Copyright (C) 2011 Google Inc. All rights reserved. 8 * 9 * This library is free software; you can redistribute it and/or 10 * modify it under the terms of the GNU Library General Public 11 * License as published by the Free Software Foundation; either 12 * version 2 of the License, or (at your option) any later version. 13 * 14 * This library is distributed in the hope that it will be useful, 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 * Library General Public License for more details. 18 * 19 * You should have received a copy of the GNU Library General Public License 20 * along with this library; see the file COPYING.LIB. If not, write to 21 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 22 * Boston, MA 02110-1301, USA. 23 * 24 */ 25 26 #ifndef NodeRenderingContext_h 27 #define NodeRenderingContext_h 28 29 #include "core/dom/NodeRenderingTraversal.h" 30 31 #include "wtf/RefPtr.h" 32 33 namespace WebCore { 34 35 class ContainerNode; 36 class Node; 37 class RenderNamedFlowThread; 38 class RenderObject; 39 class RenderStyle; 40 41 class NodeRenderingContext { 42 public: 43 explicit NodeRenderingContext(Node* node, RenderStyle* style = 0) 44 : m_node(node) 45 , m_renderingParent(0) 46 , m_style(style) 47 , m_parentFlowRenderer(0) 48 { 49 m_renderingParent = NodeRenderingTraversal::parent(node, &m_parentDetails); 50 } 51 52 void createRendererForTextIfNeeded(); 53 void createRendererForElementIfNeeded(); 54 55 Node* node() const { return m_node; } 56 RenderObject* parentRenderer() const; 57 RenderObject* nextRenderer() const; 58 RenderObject* previousRenderer() const; 59 60 const RenderStyle* style() const { return m_style.get(); } 61 62 private: 63 bool shouldCreateRenderer() const; 64 void moveToFlowThreadIfNeeded(); 65 bool elementInsideRegionNeedsRenderer(); 66 67 Node* m_node; 68 ContainerNode* m_renderingParent; 69 NodeRenderingTraversal::ParentDetails m_parentDetails; 70 RefPtr<RenderStyle> m_style; 71 RenderNamedFlowThread* m_parentFlowRenderer; 72 }; 73 74 } // namespace WebCore 75 76 #endif 77