OLD | NEW |
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 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
183 AutoReset<size_t> positionChange(&m_insertionPosition, m_mapping.size()); | 183 AutoReset<size_t> positionChange(&m_insertionPosition, m_mapping.size()); |
184 do { | 184 do { |
185 layoutObject = | 185 layoutObject = |
186 layoutObject->pushMappingToContainer(ancestorLayoutObject, *this); | 186 layoutObject->pushMappingToContainer(ancestorLayoutObject, *this); |
187 } while (layoutObject && layoutObject != ancestorLayoutObject); | 187 } while (layoutObject && layoutObject != ancestorLayoutObject); |
188 | 188 |
189 ASSERT(m_mapping.isEmpty() || | 189 ASSERT(m_mapping.isEmpty() || |
190 isTopmostLayoutView(m_mapping[0].m_layoutObject)); | 190 isTopmostLayoutView(m_mapping[0].m_layoutObject)); |
191 } | 191 } |
192 | 192 |
193 static bool canMapBetweenLayoutObjects(const LayoutObject* layoutObject, | 193 static bool canMapBetweenLayoutObjects(const LayoutObject& layoutObject, |
194 const LayoutObject* ancestor) { | 194 const LayoutObject& ancestor) { |
195 for (const LayoutObject* current = layoutObject;; | 195 for (const LayoutObject* current = &layoutObject;; |
196 current = current->parent()) { | 196 current = current->parent()) { |
197 const ComputedStyle& style = current->styleRef(); | 197 const ComputedStyle& style = current->styleRef(); |
198 if (style.position() == EPosition::kFixed || | 198 if (style.position() == EPosition::kFixed || |
199 style.isFlippedBlocksWritingMode()) | 199 style.isFlippedBlocksWritingMode()) |
200 return false; | 200 return false; |
201 | 201 |
202 if (current->style()->canContainFixedPositionObjects() || | 202 if (current->style()->canContainFixedPositionObjects() || |
203 current->isLayoutFlowThread() || current->isSVGRoot()) | 203 current->isLayoutFlowThread() || current->isSVGRoot()) |
204 return false; | 204 return false; |
205 | 205 |
206 if (current == ancestor) | 206 if (current == &ancestor) |
207 break; | 207 break; |
208 | 208 |
209 if (current->isFloatingWithNonContainingBlockParent()) | 209 if (current->isFloatingWithNonContainingBlockParent()) |
210 return false; | 210 return false; |
211 } | 211 } |
212 | 212 |
213 return true; | 213 return true; |
214 } | 214 } |
215 | 215 |
216 void LayoutGeometryMap::pushMappingsToAncestor( | 216 void LayoutGeometryMap::pushMappingsToAncestor( |
217 const PaintLayer* layer, | 217 const PaintLayer* layer, |
218 const PaintLayer* ancestorLayer) { | 218 const PaintLayer* ancestorLayer) { |
219 const LayoutObject* layoutObject = layer->layoutObject(); | 219 const LayoutObject& layoutObject = layer->layoutObject(); |
220 | 220 |
221 bool crossDocument = | 221 bool crossDocument = |
222 ancestorLayer && | 222 ancestorLayer && |
223 layer->layoutObject()->frame() != ancestorLayer->layoutObject()->frame(); | 223 layoutObject.frame() != ancestorLayer->layoutObject().frame(); |
224 ASSERT(!crossDocument || m_mapCoordinatesFlags & TraverseDocumentBoundaries); | 224 ASSERT(!crossDocument || m_mapCoordinatesFlags & TraverseDocumentBoundaries); |
225 | 225 |
226 // We have to visit all the layoutObjects to detect flipped blocks. This might | 226 // We have to visit all the layoutObjects to detect flipped blocks. This might |
227 // defeat the gains from mapping via layers. | 227 // defeat the gains from mapping via layers. |
228 bool canConvertInLayerTree = | 228 bool canConvertInLayerTree = |
229 (ancestorLayer && !crossDocument) | 229 (ancestorLayer && !crossDocument) |
230 ? canMapBetweenLayoutObjects(layer->layoutObject(), | 230 ? canMapBetweenLayoutObjects(layoutObject, |
231 ancestorLayer->layoutObject()) | 231 ancestorLayer->layoutObject()) |
232 : false; | 232 : false; |
233 | 233 |
234 LAYOUT_GEOMETRY_MAP_LOG( | 234 LAYOUT_GEOMETRY_MAP_LOG( |
235 "LayoutGeometryMap::pushMappingsToAncestor from layer %p to layer %p, " | 235 "LayoutGeometryMap::pushMappingsToAncestor from layer %p to layer %p, " |
236 "canConvertInLayerTree=%d\n", | 236 "canConvertInLayerTree=%d\n", |
237 layer, ancestorLayer, canConvertInLayerTree); | 237 layer, ancestorLayer, canConvertInLayerTree); |
238 | 238 |
239 if (canConvertInLayerTree) { | 239 if (canConvertInLayerTree) { |
240 LayoutPoint layerOffset; | 240 LayoutPoint layerOffset; |
241 layer->convertToLayerCoords(ancestorLayer, layerOffset); | 241 layer->convertToLayerCoords(ancestorLayer, layerOffset); |
242 | 242 |
243 // The LayoutView must be pushed first. | 243 // The LayoutView must be pushed first. |
244 if (!m_mapping.size()) { | 244 if (!m_mapping.size()) { |
245 ASSERT(ancestorLayer->layoutObject()->isLayoutView()); | 245 DCHECK(ancestorLayer->layoutObject().isLayoutView()); |
246 pushMappingsToAncestor(ancestorLayer->layoutObject(), 0); | 246 pushMappingsToAncestor(&ancestorLayer->layoutObject(), 0); |
247 } | 247 } |
248 | 248 |
249 AutoReset<size_t> positionChange(&m_insertionPosition, m_mapping.size()); | 249 AutoReset<size_t> positionChange(&m_insertionPosition, m_mapping.size()); |
250 bool accumulatingTransform = | 250 bool accumulatingTransform = |
251 layer->layoutObject()->style()->preserves3D() || | 251 layoutObject.style()->preserves3D() || |
252 ancestorLayer->layoutObject()->style()->preserves3D(); | 252 ancestorLayer->layoutObject().style()->preserves3D(); |
253 push(layoutObject, toLayoutSize(layerOffset), | 253 push(&layoutObject, toLayoutSize(layerOffset), |
254 accumulatingTransform ? AccumulatingTransform : 0); | 254 accumulatingTransform ? AccumulatingTransform : 0); |
255 return; | 255 return; |
256 } | 256 } |
257 const LayoutBoxModelObject* ancestorLayoutObject = | 257 const LayoutBoxModelObject* ancestorLayoutObject = |
258 ancestorLayer ? ancestorLayer->layoutObject() : 0; | 258 ancestorLayer ? &ancestorLayer->layoutObject() : 0; |
259 pushMappingsToAncestor(layoutObject, ancestorLayoutObject); | 259 pushMappingsToAncestor(&layoutObject, ancestorLayoutObject); |
260 } | 260 } |
261 | 261 |
262 void LayoutGeometryMap::push(const LayoutObject* layoutObject, | 262 void LayoutGeometryMap::push(const LayoutObject* layoutObject, |
263 const LayoutSize& offsetFromContainer, | 263 const LayoutSize& offsetFromContainer, |
264 GeometryInfoFlags flags, | 264 GeometryInfoFlags flags, |
265 LayoutSize offsetForFixedPosition) { | 265 LayoutSize offsetForFixedPosition) { |
266 LAYOUT_GEOMETRY_MAP_LOG("LayoutGeometryMap::push %p %d,%d isNonUniform=%d\n", | 266 LAYOUT_GEOMETRY_MAP_LOG("LayoutGeometryMap::push %p %d,%d isNonUniform=%d\n", |
267 layoutObject, offsetFromContainer.width().toInt(), | 267 layoutObject, offsetFromContainer.width().toInt(), |
268 offsetFromContainer.height().toInt(), isNonUniform); | 268 offsetFromContainer.height().toInt(), isNonUniform); |
269 | 269 |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
321 } | 321 } |
322 if (UNLIKELY(mightBeSaturated)) { | 322 if (UNLIKELY(mightBeSaturated)) { |
323 m_accumulatedOffset = LayoutSize(); | 323 m_accumulatedOffset = LayoutSize(); |
324 for (const auto& step : m_mapping) | 324 for (const auto& step : m_mapping) |
325 m_accumulatedOffset += step.m_offset; | 325 m_accumulatedOffset += step.m_offset; |
326 } | 326 } |
327 } | 327 } |
328 | 328 |
329 void LayoutGeometryMap::popMappingsToAncestor(const PaintLayer* ancestorLayer) { | 329 void LayoutGeometryMap::popMappingsToAncestor(const PaintLayer* ancestorLayer) { |
330 const LayoutBoxModelObject* ancestorLayoutObject = | 330 const LayoutBoxModelObject* ancestorLayoutObject = |
331 ancestorLayer ? ancestorLayer->layoutObject() : 0; | 331 ancestorLayer ? &ancestorLayer->layoutObject() : 0; |
332 popMappingsToAncestor(ancestorLayoutObject); | 332 popMappingsToAncestor(ancestorLayoutObject); |
333 } | 333 } |
334 | 334 |
335 void LayoutGeometryMap::stepInserted(const LayoutGeometryMapStep& step) { | 335 void LayoutGeometryMap::stepInserted(const LayoutGeometryMapStep& step) { |
336 m_accumulatedOffset += step.m_offset; | 336 m_accumulatedOffset += step.m_offset; |
337 | 337 |
338 if (step.m_flags & IsNonUniform) | 338 if (step.m_flags & IsNonUniform) |
339 ++m_nonUniformStepsCount; | 339 ++m_nonUniformStepsCount; |
340 | 340 |
341 if (step.m_transform) | 341 if (step.m_transform) |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
373 // If we're not working with multiple LayoutViews, then any view is considered | 373 // If we're not working with multiple LayoutViews, then any view is considered |
374 // "topmost" (to preserve original behavior). | 374 // "topmost" (to preserve original behavior). |
375 if (!(m_mapCoordinatesFlags & TraverseDocumentBoundaries)) | 375 if (!(m_mapCoordinatesFlags & TraverseDocumentBoundaries)) |
376 return true; | 376 return true; |
377 | 377 |
378 return layoutObject->frame()->isMainFrame(); | 378 return layoutObject->frame()->isMainFrame(); |
379 } | 379 } |
380 #endif | 380 #endif |
381 | 381 |
382 } // namespace blink | 382 } // namespace blink |
OLD | NEW |