1/*
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 *           (C) 1999 Antti Koivisto (koivisto@kde.org)
4 *           (C) 2001 Dirk Mueller (mueller@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 "NodeRenderingTraversal.h"
30
31#include <wtf/Noncopyable.h>
32#include <wtf/RefPtr.h>
33#include <wtf/text/AtomicString.h>
34
35namespace WebCore {
36
37class ContainerNode;
38class Document;
39class InsertionPoint;
40class Node;
41class RenderNamedFlowThread;
42class RenderObject;
43class RenderStyle;
44class ElementShadow;
45
46class NodeRenderingContext {
47public:
48    explicit NodeRenderingContext(Node*);
49    NodeRenderingContext(Node*, RenderStyle*);
50    NodeRenderingContext(Node*, const Node::AttachContext&);
51    ~NodeRenderingContext();
52
53    void createRendererForTextIfNeeded();
54    void createRendererForElementIfNeeded();
55
56    Node* node() const;
57    ContainerNode* parentNodeForRenderingAndStyle() const;
58    bool resetStyleInheritance() const;
59    RenderObject* parentRenderer() const;
60    RenderObject* nextRenderer() const;
61    RenderObject* previousRenderer() const;
62    InsertionPoint* insertionPoint() const;
63
64    const RenderStyle* style() const;
65
66    bool isOnUpperEncapsulationBoundary() const;
67    bool isOnEncapsulationBoundary() const;
68
69private:
70    bool shouldCreateRenderer() const;
71    void moveToFlowThreadIfNeeded();
72    bool elementInsideRegionNeedsRenderer();
73
74    Node* m_node;
75    ContainerNode* m_renderingParent;
76    NodeRenderingTraversal::ParentDetails m_parentDetails;
77    RefPtr<RenderStyle> m_style;
78    RenderNamedFlowThread* m_parentFlowRenderer;
79};
80
81inline Node* NodeRenderingContext::node() const
82{
83    return m_node;
84}
85
86inline ContainerNode* NodeRenderingContext::parentNodeForRenderingAndStyle() const
87{
88    return m_renderingParent;
89}
90
91inline bool NodeRenderingContext::resetStyleInheritance() const
92{
93    return m_parentDetails.resetStyleInheritance();
94}
95
96inline const RenderStyle* NodeRenderingContext::style() const
97{
98    return m_style.get();
99}
100
101inline InsertionPoint* NodeRenderingContext::insertionPoint() const
102{
103    return m_parentDetails.insertionPoint();
104}
105
106} // namespace WebCore
107
108#endif
109