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 RenderTreeBuilder_h 27 #define RenderTreeBuilder_h 28 29 #include "core/dom/Document.h" 30 #include "core/dom/Node.h" 31 #include "core/dom/NodeRenderingTraversal.h" 32 #include "wtf/RefPtr.h" 33 34 namespace blink { 35 36 class ContainerNode; 37 class RenderObject; 38 class RenderStyle; 39 40 class RenderTreeBuilder { 41 STACK_ALLOCATED(); 42 public: 43 RenderTreeBuilder(Node* node, RenderStyle* style) 44 : m_node(node) 45 , m_renderingParent(nullptr) 46 , m_style(style) 47 { 48 ASSERT(!node->renderer()); 49 ASSERT(node->needsAttach()); 50 ASSERT(node->document().inStyleRecalc()); 51 52 // FIXME: We should be able to ASSERT(node->inActiveDocument()) but childrenChanged is called 53 // before ChildNodeInsertionNotifier in ContainerNode's methods and some implementations 54 // will trigger a layout inside childrenChanged. 55 // Mainly HTMLTextAreaElement::childrenChanged calls HTMLTextFormControlElement::setSelectionRange 56 // which does an updateLayoutIgnorePendingStylesheets. 57 58 m_renderingParent = NodeRenderingTraversal::parent(node, &m_parentDetails); 59 } 60 61 void createRendererForTextIfNeeded(); 62 void createRendererForElementIfNeeded(); 63 64 private: 65 RenderObject* parentRenderer() const; 66 RenderObject* nextRenderer() const; 67 bool shouldCreateRenderer() const; 68 RenderStyle& style() const; 69 70 RawPtrWillBeMember<Node> m_node; 71 RawPtrWillBeMember<ContainerNode> m_renderingParent; 72 NodeRenderingTraversal::ParentDetails m_parentDetails; 73 mutable RefPtr<RenderStyle> m_style; 74 }; 75 76 } // namespace blink 77 78 #endif 79