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

Side by Side Diff: Source/core/rendering/RenderGeometryMap.cpp

Issue 899163003: Move rendering/RenderObject to layout/LayoutObject. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 10 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) 2012 Apple Inc. All rights reserved. 2 * Copyright (C) 2012 Apple Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 if (!hasFixedPositionStep() && !hasTransformStep() && !hasNonUniformStep() & & (!container || (m_mapping.size() && container == m_mapping[0].m_renderer))) 111 if (!hasFixedPositionStep() && !hasTransformStep() && !hasNonUniformStep() & & (!container || (m_mapping.size() && container == m_mapping[0].m_renderer)))
112 result = p + m_accumulatedOffset; 112 result = p + m_accumulatedOffset;
113 else { 113 else {
114 TransformState transformState(TransformState::ApplyTransformDirection, p ); 114 TransformState transformState(TransformState::ApplyTransformDirection, p );
115 mapToContainer(transformState, container); 115 mapToContainer(transformState, container);
116 result = transformState.lastPlanarPoint(); 116 result = transformState.lastPlanarPoint();
117 } 117 }
118 118
119 #if ENABLE(ASSERT) 119 #if ENABLE(ASSERT)
120 if (m_mapping.size() > 0) { 120 if (m_mapping.size() > 0) {
121 const RenderObject* lastRenderer = m_mapping.last().m_renderer; 121 const LayoutObject* lastRenderer = m_mapping.last().m_renderer;
122 const Layer* layer = lastRenderer->enclosingLayer(); 122 const Layer* layer = lastRenderer->enclosingLayer();
123 123
124 // Bounds for invisible layers are intentionally not calculated, and are 124 // Bounds for invisible layers are intentionally not calculated, and are
125 // therefore not necessarily expected to be correct here. This is ok, 125 // therefore not necessarily expected to be correct here. This is ok,
126 // because they will be recomputed if the layer becomes visible. 126 // because they will be recomputed if the layer becomes visible.
127 if (!layer || !layer->subtreeIsInvisible()) { 127 if (!layer || !layer->subtreeIsInvisible()) {
128 FloatPoint rendererMappedResult = lastRenderer->localToContainerPoin t(p, container, m_mapCoordinatesFlags); 128 FloatPoint rendererMappedResult = lastRenderer->localToContainerPoin t(p, container, m_mapCoordinatesFlags);
129 129
130 ASSERT(roundedIntPoint(rendererMappedResult) == roundedIntPoint(resu lt)); 130 ASSERT(roundedIntPoint(rendererMappedResult) == roundedIntPoint(resu lt));
131 } 131 }
(...skipping 25 matching lines...) Expand all
157 result = rect; 157 result = rect;
158 result.move(m_accumulatedOffset); 158 result.move(m_accumulatedOffset);
159 } else { 159 } else {
160 TransformState transformState(TransformState::ApplyTransformDirection, r ect.center(), rect); 160 TransformState transformState(TransformState::ApplyTransformDirection, r ect.center(), rect);
161 mapToContainer(transformState, container); 161 mapToContainer(transformState, container);
162 result = transformState.lastPlanarQuad(); 162 result = transformState.lastPlanarQuad();
163 } 163 }
164 164
165 #if ENABLE(ASSERT) 165 #if ENABLE(ASSERT)
166 if (m_mapping.size() > 0) { 166 if (m_mapping.size() > 0) {
167 const RenderObject* lastRenderer = m_mapping.last().m_renderer; 167 const LayoutObject* lastRenderer = m_mapping.last().m_renderer;
168 const Layer* layer = lastRenderer->enclosingLayer(); 168 const Layer* layer = lastRenderer->enclosingLayer();
169 169
170 // Bounds for invisible layers are intentionally not calculated, and are 170 // Bounds for invisible layers are intentionally not calculated, and are
171 // therefore not necessarily expected to be correct here. This is ok, 171 // therefore not necessarily expected to be correct here. This is ok,
172 // because they will be recomputed if the layer becomes visible. 172 // because they will be recomputed if the layer becomes visible.
173 if (!layer->subtreeIsInvisible() && lastRenderer->style()->visibility() == VISIBLE) { 173 if (!layer->subtreeIsInvisible() && lastRenderer->style()->visibility() == VISIBLE) {
174 FloatRect rendererMappedResult = lastRenderer->localToContainerQuad( rect, container, m_mapCoordinatesFlags).boundingBox(); 174 FloatRect rendererMappedResult = lastRenderer->localToContainerQuad( rect, container, m_mapCoordinatesFlags).boundingBox();
175 175
176 // Inspector creates renderers with negative width <https://bugs.web kit.org/show_bug.cgi?id=87194>. 176 // Inspector creates renderers with negative width <https://bugs.web kit.org/show_bug.cgi?id=87194>.
177 // Taking FloatQuad bounds avoids spurious assertions because of tha t. 177 // Taking FloatQuad bounds avoids spurious assertions because of tha t.
178 ASSERT(enclosingIntRect(rendererMappedResult) == enclosingIntRect(re sult.boundingBox())); 178 ASSERT(enclosingIntRect(rendererMappedResult) == enclosingIntRect(re sult.boundingBox()));
179 } 179 }
180 } 180 }
181 #endif 181 #endif
182 182
183 return result; 183 return result;
184 } 184 }
185 185
186 void RenderGeometryMap::pushMappingsToAncestor(const RenderObject* renderer, con st LayoutLayerModelObject* ancestorRenderer) 186 void RenderGeometryMap::pushMappingsToAncestor(const LayoutObject* renderer, con st LayoutLayerModelObject* ancestorRenderer)
187 { 187 {
188 // We need to push mappings in reverse order here, so do insertions rather t han appends. 188 // We need to push mappings in reverse order here, so do insertions rather t han appends.
189 TemporaryChange<size_t> positionChange(m_insertionPosition, m_mapping.size() ); 189 TemporaryChange<size_t> positionChange(m_insertionPosition, m_mapping.size() );
190 do { 190 do {
191 renderer = renderer->pushMappingToContainer(ancestorRenderer, *this); 191 renderer = renderer->pushMappingToContainer(ancestorRenderer, *this);
192 } while (renderer && renderer != ancestorRenderer); 192 } while (renderer && renderer != ancestorRenderer);
193 193
194 ASSERT(m_mapping.isEmpty() || isTopmostRenderView(m_mapping[0].m_renderer)); 194 ASSERT(m_mapping.isEmpty() || isTopmostRenderView(m_mapping[0].m_renderer));
195 } 195 }
196 196
197 static bool canMapBetweenRenderers(const RenderObject* renderer, const RenderObj ect* ancestor) 197 static bool canMapBetweenRenderers(const LayoutObject* renderer, const LayoutObj ect* ancestor)
198 { 198 {
199 for (const RenderObject* current = renderer; ; current = current->parent()) { 199 for (const LayoutObject* current = renderer; ; current = current->parent()) {
200 const RenderStyle* style = current->style(); 200 const RenderStyle* style = current->style();
201 if (style->position() == FixedPosition || style->isFlippedBlocksWritingM ode()) 201 if (style->position() == FixedPosition || style->isFlippedBlocksWritingM ode())
202 return false; 202 return false;
203 203
204 if (current->hasColumns() || current->hasTransformRelatedProperty() || c urrent->isRenderFlowThread() || current->isSVGRoot()) 204 if (current->hasColumns() || current->hasTransformRelatedProperty() || c urrent->isRenderFlowThread() || current->isSVGRoot())
205 return false; 205 return false;
206 206
207 if (current == ancestor) 207 if (current == ancestor)
208 break; 208 break;
209 } 209 }
210 210
211 return true; 211 return true;
212 } 212 }
213 213
214 void RenderGeometryMap::pushMappingsToAncestor(const Layer* layer, const Layer* ancestorLayer) 214 void RenderGeometryMap::pushMappingsToAncestor(const Layer* layer, const Layer* ancestorLayer)
215 { 215 {
216 const RenderObject* renderer = layer->renderer(); 216 const LayoutObject* renderer = layer->renderer();
217 217
218 bool crossDocument = ancestorLayer && layer->renderer()->frame() != ancestor Layer->renderer()->frame(); 218 bool crossDocument = ancestorLayer && layer->renderer()->frame() != ancestor Layer->renderer()->frame();
219 ASSERT(!crossDocument || m_mapCoordinatesFlags & TraverseDocumentBoundaries) ; 219 ASSERT(!crossDocument || m_mapCoordinatesFlags & TraverseDocumentBoundaries) ;
220 220
221 // We have to visit all the renderers to detect flipped blocks. This might d efeat the gains 221 // We have to visit all the renderers to detect flipped blocks. This might d efeat the gains
222 // from mapping via layers. 222 // from mapping via layers.
223 bool canConvertInLayerTree = (ancestorLayer && !crossDocument) ? canMapBetwe enRenderers(layer->renderer(), ancestorLayer->renderer()) : false; 223 bool canConvertInLayerTree = (ancestorLayer && !crossDocument) ? canMapBetwe enRenderers(layer->renderer(), ancestorLayer->renderer()) : false;
224 224
225 // fprintf(stderr, "RenderGeometryMap::pushMappingsToAncestor from layer %p t o layer %p, canConvertInLayerTree=%d\n", layer, ancestorLayer, canConvertInLayer Tree); 225 // fprintf(stderr, "RenderGeometryMap::pushMappingsToAncestor from layer %p t o layer %p, canConvertInLayerTree=%d\n", layer, ancestorLayer, canConvertInLayer Tree);
226 226
227 if (canConvertInLayerTree) { 227 if (canConvertInLayerTree) {
228 LayoutPoint layerOffset; 228 LayoutPoint layerOffset;
229 layer->convertToLayerCoords(ancestorLayer, layerOffset); 229 layer->convertToLayerCoords(ancestorLayer, layerOffset);
230 230
231 // The RenderView must be pushed first. 231 // The RenderView must be pushed first.
232 if (!m_mapping.size()) { 232 if (!m_mapping.size()) {
233 ASSERT(ancestorLayer->renderer()->isRenderView()); 233 ASSERT(ancestorLayer->renderer()->isRenderView());
234 pushMappingsToAncestor(ancestorLayer->renderer(), 0); 234 pushMappingsToAncestor(ancestorLayer->renderer(), 0);
235 } 235 }
236 236
237 TemporaryChange<size_t> positionChange(m_insertionPosition, m_mapping.si ze()); 237 TemporaryChange<size_t> positionChange(m_insertionPosition, m_mapping.si ze());
238 bool accumulatingTransform = layer->renderer()->style()->preserves3D() | | ancestorLayer->renderer()->style()->preserves3D(); 238 bool accumulatingTransform = layer->renderer()->style()->preserves3D() | | ancestorLayer->renderer()->style()->preserves3D();
239 push(renderer, toLayoutSize(layerOffset), accumulatingTransform, /*isNon Uniform*/ false, /*isFixedPosition*/ false, /*hasTransform*/ false); 239 push(renderer, toLayoutSize(layerOffset), accumulatingTransform, /*isNon Uniform*/ false, /*isFixedPosition*/ false, /*hasTransform*/ false);
240 return; 240 return;
241 } 241 }
242 const LayoutLayerModelObject* ancestorRenderer = ancestorLayer ? ancestorLay er->renderer() : 0; 242 const LayoutLayerModelObject* ancestorRenderer = ancestorLayer ? ancestorLay er->renderer() : 0;
243 pushMappingsToAncestor(renderer, ancestorRenderer); 243 pushMappingsToAncestor(renderer, ancestorRenderer);
244 } 244 }
245 245
246 void RenderGeometryMap::push(const RenderObject* renderer, const LayoutSize& off setFromContainer, bool accumulatingTransform, bool isNonUniform, bool isFixedPos ition, bool hasTransform, LayoutSize offsetForFixedPosition) 246 void RenderGeometryMap::push(const LayoutObject* renderer, const LayoutSize& off setFromContainer, bool accumulatingTransform, bool isNonUniform, bool isFixedPos ition, bool hasTransform, LayoutSize offsetForFixedPosition)
247 { 247 {
248 // fprintf(stderr, "RenderGeometryMap::push %p %d,%d isNonUniform=%d\n", rend erer, offsetFromContainer.width().toInt(), offsetFromContainer.height().toInt(), isNonUniform); 248 // fprintf(stderr, "RenderGeometryMap::push %p %d,%d isNonUniform=%d\n", rend erer, offsetFromContainer.width().toInt(), offsetFromContainer.height().toInt(), isNonUniform);
249 249
250 ASSERT(m_insertionPosition != kNotFound); 250 ASSERT(m_insertionPosition != kNotFound);
251 ASSERT(!renderer->isRenderView() || !m_insertionPosition || m_mapCoordinates Flags & TraverseDocumentBoundaries); 251 ASSERT(!renderer->isRenderView() || !m_insertionPosition || m_mapCoordinates Flags & TraverseDocumentBoundaries);
252 ASSERT(offsetForFixedPosition.isZero() || renderer->isRenderView()); 252 ASSERT(offsetForFixedPosition.isZero() || renderer->isRenderView());
253 253
254 m_mapping.insert(m_insertionPosition, RenderGeometryMapStep(renderer, accumu latingTransform, isNonUniform, isFixedPosition, hasTransform)); 254 m_mapping.insert(m_insertionPosition, RenderGeometryMapStep(renderer, accumu latingTransform, isNonUniform, isFixedPosition, hasTransform));
255 255
256 RenderGeometryMapStep& step = m_mapping[m_insertionPosition]; 256 RenderGeometryMapStep& step = m_mapping[m_insertionPosition];
257 step.m_offset = offsetFromContainer; 257 step.m_offset = offsetFromContainer;
258 step.m_offsetForFixedPosition = offsetForFixedPosition; 258 step.m_offsetForFixedPosition = offsetForFixedPosition;
259 259
260 stepInserted(step); 260 stepInserted(step);
261 } 261 }
262 262
263 void RenderGeometryMap::push(const RenderObject* renderer, const TransformationM atrix& t, bool accumulatingTransform, bool isNonUniform, bool isFixedPosition, b ool hasTransform, LayoutSize offsetForFixedPosition) 263 void RenderGeometryMap::push(const LayoutObject* renderer, const TransformationM atrix& t, bool accumulatingTransform, bool isNonUniform, bool isFixedPosition, b ool hasTransform, LayoutSize offsetForFixedPosition)
264 { 264 {
265 ASSERT(m_insertionPosition != kNotFound); 265 ASSERT(m_insertionPosition != kNotFound);
266 ASSERT(!renderer->isRenderView() || !m_insertionPosition || m_mapCoordinates Flags & TraverseDocumentBoundaries); 266 ASSERT(!renderer->isRenderView() || !m_insertionPosition || m_mapCoordinates Flags & TraverseDocumentBoundaries);
267 ASSERT(offsetForFixedPosition.isZero() || renderer->isRenderView()); 267 ASSERT(offsetForFixedPosition.isZero() || renderer->isRenderView());
268 268
269 m_mapping.insert(m_insertionPosition, RenderGeometryMapStep(renderer, accumu latingTransform, isNonUniform, isFixedPosition, hasTransform)); 269 m_mapping.insert(m_insertionPosition, RenderGeometryMapStep(renderer, accumu latingTransform, isNonUniform, isFixedPosition, hasTransform));
270 270
271 RenderGeometryMapStep& step = m_mapping[m_insertionPosition]; 271 RenderGeometryMapStep& step = m_mapping[m_insertionPosition];
272 step.m_offsetForFixedPosition = offsetForFixedPosition; 272 step.m_offsetForFixedPosition = offsetForFixedPosition;
273 273
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
323 --m_transformedStepsCount; 323 --m_transformedStepsCount;
324 } 324 }
325 325
326 if (step.m_isFixedPosition) { 326 if (step.m_isFixedPosition) {
327 ASSERT(m_fixedStepsCount); 327 ASSERT(m_fixedStepsCount);
328 --m_fixedStepsCount; 328 --m_fixedStepsCount;
329 } 329 }
330 } 330 }
331 331
332 #if ENABLE(ASSERT) 332 #if ENABLE(ASSERT)
333 bool RenderGeometryMap::isTopmostRenderView(const RenderObject* renderer) const 333 bool RenderGeometryMap::isTopmostRenderView(const LayoutObject* renderer) const
334 { 334 {
335 if (!renderer->isRenderView()) 335 if (!renderer->isRenderView())
336 return false; 336 return false;
337 337
338 // If we're not working with multiple RenderViews, then any view is consider ed 338 // If we're not working with multiple RenderViews, then any view is consider ed
339 // "topmost" (to preserve original behavior). 339 // "topmost" (to preserve original behavior).
340 if (!(m_mapCoordinatesFlags & TraverseDocumentBoundaries)) 340 if (!(m_mapCoordinatesFlags & TraverseDocumentBoundaries))
341 return true; 341 return true;
342 342
343 return renderer->frame()->isMainFrame(); 343 return renderer->frame()->isMainFrame();
344 } 344 }
345 #endif 345 #endif
346 346
347 } // namespace blink 347 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/rendering/RenderGeometryMap.h ('k') | Source/core/rendering/RenderGeometryMapStep.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698