OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) | 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) |
4 * (C) 2001 Dirk Mueller (mueller@kde.org) | 4 * (C) 2001 Dirk Mueller (mueller@kde.org) |
5 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All r ights reserved. | 5 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All r ights reserved. |
6 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t orchmobile.com/) | 6 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t orchmobile.com/) |
7 * Copyright (C) 2011 Google Inc. All rights reserved. | 7 * Copyright (C) 2011 Google Inc. All rights reserved. |
8 * | 8 * |
9 * This library is free software; you can redistribute it and/or | 9 * This library is free software; you can redistribute it and/or |
10 * modify it under the terms of the GNU Library General Public | 10 * modify it under the terms of the GNU Library General Public |
11 * License as published by the Free Software Foundation; either | 11 * License as published by the Free Software Foundation; either |
12 * version 2 of the License, or (at your option) any later version. | 12 * version 2 of the License, or (at your option) any later version. |
13 * | 13 * |
14 * This library is distributed in the hope that it will be useful, | 14 * This library is distributed in the hope that it will be useful, |
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
17 * Library General Public License for more details. | 17 * Library General Public License for more details. |
18 * | 18 * |
19 * You should have received a copy of the GNU Library General Public License | 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 | 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, | 21 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
22 * Boston, MA 02110-1301, USA. | 22 * Boston, MA 02110-1301, USA. |
23 * | 23 * |
24 */ | 24 */ |
25 | 25 |
26 #ifndef RenderTreeBuilder_h | 26 #ifndef RenderTreeBuilder_h |
27 #define RenderTreeBuilder_h | 27 #define RenderTreeBuilder_h |
28 | 28 |
29 #include "core/dom/Document.h" | 29 #include "core/dom/Document.h" |
30 #include "core/dom/FirstLetterPseudoElement.h" | |
30 #include "core/dom/Node.h" | 31 #include "core/dom/Node.h" |
31 #include "core/dom/NodeRenderingTraversal.h" | 32 #include "core/dom/NodeRenderingTraversal.h" |
33 #include "core/rendering/RenderObject.h" | |
32 #include "wtf/RefPtr.h" | 34 #include "wtf/RefPtr.h" |
33 | 35 |
34 namespace blink { | 36 namespace blink { |
35 | 37 |
36 class ContainerNode; | 38 class ContainerNode; |
37 class RenderObject; | |
38 class RenderStyle; | 39 class RenderStyle; |
39 | 40 |
40 class RenderTreeBuilder { | 41 class RenderTreeBuilder { |
41 STACK_ALLOCATED(); | 42 STACK_ALLOCATED(); |
42 public: | 43 public: |
43 RenderTreeBuilder(Node* node, RenderStyle* style) | 44 RenderTreeBuilder(Node* node, RenderStyle* style) |
44 : m_node(node) | 45 : m_node(node) |
45 , m_renderingParent(nullptr) | 46 , m_renderingParent(nullptr) |
46 , m_style(style) | 47 , m_style(style) |
47 { | 48 { |
48 ASSERT(!node->renderer()); | 49 ASSERT(!node->renderer()); |
49 ASSERT(node->needsAttach()); | 50 ASSERT(node->needsAttach()); |
50 ASSERT(node->document().inStyleRecalc()); | 51 ASSERT(node->document().inStyleRecalc()); |
51 | 52 |
52 // FIXME: We should be able to ASSERT(node->inActiveDocument()) but chil drenChanged is called | 53 // FIXME: We should be able to ASSERT(node->inActiveDocument()) but chil drenChanged is called |
53 // before ChildNodeInsertionNotifier in ContainerNode's methods and some implementations | 54 // before ChildNodeInsertionNotifier in ContainerNode's methods and some implementations |
54 // will trigger a layout inside childrenChanged. | 55 // will trigger a layout inside childrenChanged. |
55 // Mainly HTMLTextAreaElement::childrenChanged calls HTMLTextFormControl Element::setSelectionRange | 56 // Mainly HTMLTextAreaElement::childrenChanged calls HTMLTextFormControl Element::setSelectionRange |
56 // which does an updateLayoutIgnorePendingStylesheets. | 57 // which does an updateLayoutIgnorePendingStylesheets. |
57 | 58 |
58 m_renderingParent = NodeRenderingTraversal::parent(node, &m_parentDetail s); | 59 Element* element = node->isElementNode() ? toElement(node) : 0; |
60 if (element && element->isFirstLetterPseudoElement()) { | |
61 RenderObject* nextRenderer = FirstLetterPseudoElement::firstLetterTe xtRenderer(*element); | |
62 if (nextRenderer && nextRenderer->parent()) | |
esprehn
2014/10/11 04:46:20
This should not be inline, this is way too much co
dsinclair
2014/10/14 14:31:27
Done.
| |
63 m_renderingParent = nextRenderer->parent(); | |
esprehn
2014/10/11 04:46:20
m_renderingParent is nullptr either way, so you ca
dsinclair
2014/10/14 14:31:27
Done.
| |
64 | |
65 } else { | |
66 ContainerNode* containerNode = NodeRenderingTraversal::parent(node, &m_parentDetails); | |
esprehn
2014/10/11 04:46:20
else if (ContainerNode* ...)
dsinclair
2014/10/14 14:31:27
Done.
| |
67 if (containerNode) | |
68 m_renderingParent = containerNode->renderer(); | |
69 } | |
59 } | 70 } |
60 | 71 |
61 void createRendererForTextIfNeeded(); | 72 void createRendererForTextIfNeeded(); |
62 void createRendererForElementIfNeeded(); | 73 void createRendererForElementIfNeeded(); |
63 | 74 |
64 private: | 75 private: |
65 RenderObject* parentRenderer() const; | 76 RenderObject* parentRenderer() const; |
66 RenderObject* nextRenderer() const; | 77 RenderObject* nextRenderer() const; |
67 bool shouldCreateRenderer() const; | 78 bool shouldCreateRenderer() const; |
68 RenderStyle& style() const; | 79 RenderStyle& style() const; |
69 | 80 |
70 RawPtrWillBeMember<Node> m_node; | 81 RawPtrWillBeMember<Node> m_node; |
71 RawPtrWillBeMember<ContainerNode> m_renderingParent; | 82 RawPtrWillBeMember<RenderObject> m_renderingParent; |
Julien - ping for review
2014/10/10 22:47:23
I would have liked this change to be in a separate
esprehn
2014/10/11 04:46:20
Hmm, this seems bad. The parent is always supposed
dsinclair
2014/10/14 14:31:27
Acknowledged.
dsinclair
2014/10/14 14:31:27
So, the problem I have specifically, is if you hav
| |
72 NodeRenderingTraversal::ParentDetails m_parentDetails; | 83 NodeRenderingTraversal::ParentDetails m_parentDetails; |
73 mutable RefPtr<RenderStyle> m_style; | 84 mutable RefPtr<RenderStyle> m_style; |
74 }; | 85 }; |
75 | 86 |
76 } // namespace blink | 87 } // namespace blink |
77 | 88 |
78 #endif | 89 #endif |
OLD | NEW |