Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(112)

Side by Side Diff: Source/core/dom/NodeRenderingContext.cpp

Issue 14373010: Make abspos <dialog>'s containing block be the ICB. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: review comments Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 NodeRenderingContext::~NodeRenderingContext() 72 NodeRenderingContext::~NodeRenderingContext()
73 { 73 {
74 } 74 }
75 75
76 static bool isRendererReparented(const RenderObject* renderer) 76 static bool isRendererReparented(const RenderObject* renderer)
77 { 77 {
78 if (!renderer->node()->isElementNode()) 78 if (!renderer->node()->isElementNode())
79 return false; 79 return false;
80 if (renderer->style() && !renderer->style()->flowThread().isEmpty()) 80 if (renderer->style() && !renderer->style()->flowThread().isEmpty())
81 return true; 81 return true;
82 if (toElement(renderer->node())->isInTopLayer()) 82 if (toElement(renderer->node())->shouldBeReparentedUnderRenderView(renderer- >style()))
83 return true; 83 return true;
84 return false; 84 return false;
85 } 85 }
86 86
87 RenderObject* NodeRenderingContext::nextRenderer() const 87 RenderObject* NodeRenderingContext::nextRenderer() const
88 { 88 {
89 if (RenderObject* renderer = m_node->renderer()) 89 if (RenderObject* renderer = m_node->renderer())
90 return renderer->nextSibling(); 90 return renderer->nextSibling();
91 91
92 Element* element = m_node->isElementNode() ? toElement(m_node) : 0; 92 Element* element = m_node->isElementNode() ? toElement(m_node) : 0;
93 if (element && element->isInTopLayer()) { 93 if (element && element->shouldBeReparentedUnderRenderView(m_style.get())) {
94 // FIXME: Reparented renderers not in the top layer should probably be
95 // ordered in DOM tree order. We don't have a good way to do that yet,
96 // since NodeRenderingTraversal isn't aware of reparenting. It's safe to
97 // just append for now; it doesn't disrupt the top layer rendering as
98 // the layer collection in RenderLayer only requires that top layer
99 // renderers are orderered correctly relative to each other.
100 if (!element->isInTopLayer())
101 return 0;
102
94 const Vector<RefPtr<Element> >& topLayerElements = element->document()-> topLayerElements(); 103 const Vector<RefPtr<Element> >& topLayerElements = element->document()-> topLayerElements();
95 size_t position = topLayerElements.find(element); 104 size_t position = topLayerElements.find(element);
96 ASSERT(position != notFound); 105 ASSERT(position != notFound);
97 for (size_t i = position + 1; i < topLayerElements.size(); ++i) { 106 for (size_t i = position + 1; i < topLayerElements.size(); ++i) {
98 if (RenderObject* renderer = topLayerElements[i]->renderer()) 107 if (RenderObject* renderer = topLayerElements[i]->renderer())
99 return renderer; 108 return renderer;
100 } 109 }
101 return 0; 110 return 0;
102 } 111 }
103 112
(...skipping 12 matching lines...) Expand all
116 } 125 }
117 126
118 return 0; 127 return 0;
119 } 128 }
120 129
121 RenderObject* NodeRenderingContext::previousRenderer() const 130 RenderObject* NodeRenderingContext::previousRenderer() const
122 { 131 {
123 if (RenderObject* renderer = m_node->renderer()) 132 if (RenderObject* renderer = m_node->renderer())
124 return renderer->previousSibling(); 133 return renderer->previousSibling();
125 134
126 // FIXME: This doesn't work correctly for things in the top layer that are 135 // FIXME: This doesn't work correctly for reparented elements that are
127 // display: none. We'd need to duplicate the logic in nextRenderer, but sinc e 136 // display: none. We'd need to duplicate the logic in nextRenderer, but sinc e
128 // nothing needs that yet just assert. 137 // nothing needs that yet just assert.
129 ASSERT(!m_node->isElementNode() || !toElement(m_node)->isInTopLayer()); 138 ASSERT(!m_node->isElementNode() || !toElement(m_node)->shouldBeReparentedUnd erRenderView(m_style.get()));
130 139
131 if (m_parentFlowRenderer) 140 if (m_parentFlowRenderer)
132 return m_parentFlowRenderer->previousRendererForNode(m_node); 141 return m_parentFlowRenderer->previousRendererForNode(m_node);
133 142
134 // FIXME: We should have the same O(N^2) avoidance as nextRenderer does 143 // FIXME: We should have the same O(N^2) avoidance as nextRenderer does
135 // however, when I tried adding it, several tests failed. 144 // however, when I tried adding it, several tests failed.
136 for (Node* sibling = NodeRenderingTraversal::previousSibling(m_node); siblin g; sibling = NodeRenderingTraversal::previousSibling(sibling)) { 145 for (Node* sibling = NodeRenderingTraversal::previousSibling(m_node); siblin g; sibling = NodeRenderingTraversal::previousSibling(sibling)) {
137 RenderObject* renderer = sibling->renderer(); 146 RenderObject* renderer = sibling->renderer();
138 if (renderer && !isRendererReparented(renderer)) 147 if (renderer && !isRendererReparented(renderer))
139 return renderer; 148 return renderer;
140 } 149 }
141 150
142 return 0; 151 return 0;
143 } 152 }
144 153
145 RenderObject* NodeRenderingContext::parentRenderer() const 154 RenderObject* NodeRenderingContext::parentRenderer() const
146 { 155 {
147 if (RenderObject* renderer = m_node->renderer()) 156 if (RenderObject* renderer = m_node->renderer())
148 return renderer->parent(); 157 return renderer->parent();
149 158
150 if (m_node->isElementNode() && toElement(m_node)->isInTopLayer()) { 159 if (m_node->isElementNode() && toElement(m_node)->shouldBeReparentedUnderRen derView(m_style.get())) {
151 // The parent renderer of top layer elements is the RenderView, but only 160 // The parent renderer of reparented elements is the RenderView, but onl y
152 // if the normal parent would have had a renderer. 161 // if the normal parent would have had a renderer.
153 // FIXME: This behavior isn't quite right as the spec for top layer 162 // FIXME: This behavior isn't quite right as the spec for top layer
154 // only talks about display: none ancestors so putting a <dialog> inside 163 // only talks about display: none ancestors so putting a <dialog> inside
155 // an <optgroup> seems like it should still work even though this check 164 // an <optgroup> seems like it should still work even though this check
156 // will prevent it. 165 // will prevent it.
157 if (!m_renderingParent || !m_renderingParent->renderer()) 166 if (!m_renderingParent || !m_renderingParent->renderer())
158 return 0; 167 return 0;
159 return m_node->document()->renderView(); 168 return m_node->document()->renderView();
160 } 169 }
161 170
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
306 newRenderer->setFlowThreadState(parentRenderer->flowThreadState()); 315 newRenderer->setFlowThreadState(parentRenderer->flowThreadState());
307 316
308 RenderObject* nextRenderer = this->nextRenderer(); 317 RenderObject* nextRenderer = this->nextRenderer();
309 textNode->setRenderer(newRenderer); 318 textNode->setRenderer(newRenderer);
310 // Parent takes care of the animations, no need to call setAnimatableStyle. 319 // Parent takes care of the animations, no need to call setAnimatableStyle.
311 newRenderer->setStyle(m_style.release()); 320 newRenderer->setStyle(m_style.release());
312 parentRenderer->addChild(newRenderer, nextRenderer); 321 parentRenderer->addChild(newRenderer, nextRenderer);
313 } 322 }
314 323
315 } 324 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698