Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All rights reserved. | 2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Portions are Copyright (C) 1998 Netscape Communications Corporation. | 4 * Portions are Copyright (C) 1998 Netscape Communications Corporation. |
| 5 * | 5 * |
| 6 * Other contributors: | 6 * Other contributors: |
| 7 * Robert O'Callahan <roc+@cs.cmu.edu> | 7 * Robert O'Callahan <roc+@cs.cmu.edu> |
| 8 * David Baron <dbaron@fas.harvard.edu> | 8 * David Baron <dbaron@fas.harvard.edu> |
| 9 * Christian Biesinger <cbiesinger@web.de> | 9 * Christian Biesinger <cbiesinger@web.de> |
| 10 * Randall Jesup <rjesup@wgate.com> | 10 * Randall Jesup <rjesup@wgate.com> |
| (...skipping 397 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 408 return false; | 408 return false; |
| 409 | 409 |
| 410 // If the previous block is absolutely positioned, then we can't be paginate d by the columns block. | 410 // If the previous block is absolutely positioned, then we can't be paginate d by the columns block. |
| 411 if (prevBlock->isOutOfFlowPositioned()) | 411 if (prevBlock->isOutOfFlowPositioned()) |
| 412 return false; | 412 return false; |
| 413 | 413 |
| 414 // Otherwise we are paginated by the columns block. | 414 // Otherwise we are paginated by the columns block. |
| 415 return true; | 415 return true; |
| 416 } | 416 } |
| 417 | 417 |
| 418 // Convert a bounding box from flow thread coordinates, relative to |layer|, to visual coordinates, relative to |ancestorLayer|. | |
| 419 static void convertFromFlowThreadToVisualBoundingBoxInAncestor(const RenderLayer * layer, const RenderLayer* ancestorLayer, LayoutRect& rect) | |
| 420 { | |
| 421 RenderLayer* paginationLayer = layer->enclosingPaginationLayer(); | |
| 422 ASSERT(paginationLayer); | |
| 423 RenderFlowThread* flowThread = toRenderFlowThread(paginationLayer->renderer( )); | |
| 424 LayoutPoint offsetWithinPaginationLayer; | |
| 425 layer->convertToLayerCoords(paginationLayer, offsetWithinPaginationLayer); | |
| 426 | |
| 427 // First make the flow thread rectangle relative to the flow thread, not to |layer|. | |
|
Julien - ping for review
2014/10/15 14:36:40
It seems like this comment should encompass the 3
mstensho (USE GERRIT)
2014/10/15 16:45:22
Done.
| |
| 428 rect.moveBy(offsetWithinPaginationLayer); | |
| 429 | |
| 430 // Then make the rectangle visual, relative to the fragmentation context. Sp lit our box up into | |
| 431 // the actual fragment boxes that render in the columns/pages and unite thos e together to get | |
| 432 // our true bounding box. | |
| 433 rect = flowThread->fragmentsBoundingBox(rect); | |
| 434 | |
| 435 // Finally, make the visual rectangle relative to |ancestorLayer|. | |
| 436 // FIXME: nested fragmentation contexts (crbug.com/423076). For now just giv e up if there are | |
|
Julien - ping for review
2014/10/15 14:36:41
Let's make the FIXME actionable:
// FIXME: Handle
mstensho (USE GERRIT)
2014/10/15 16:45:22
Done.
| |
| 437 // different pagination layers involved. | |
| 438 if (!ancestorLayer->enclosingPaginationLayer() || ancestorLayer->enclosingPa ginationLayer() != paginationLayer) { | |
| 439 // The easy case. The ancestor layer is not within the pagination layer. | |
| 440 paginationLayer->convertToLayerCoords(ancestorLayer, rect); | |
| 441 return; | |
| 442 } | |
| 443 // The ancestor layer is also inside the pagination layer, so we need to sub tract the visual | |
| 444 // distance from the ancestor layer to the pagination layer. | |
| 445 LayoutPoint offsetFromPaginationLayerToAncestor; | |
| 446 ancestorLayer->convertToLayerCoords(paginationLayer, offsetFromPaginationLay erToAncestor); | |
| 447 offsetFromPaginationLayerToAncestor = flowThread->flowThreadPointToVisualPoi nt(offsetFromPaginationLayerToAncestor); | |
| 448 rect.moveBy(-offsetFromPaginationLayerToAncestor); | |
| 449 } | |
| 450 | |
| 418 bool RenderLayer::useRegionBasedColumns() const | 451 bool RenderLayer::useRegionBasedColumns() const |
| 419 { | 452 { |
| 420 return renderer()->document().regionBasedColumnsEnabled(); | 453 return renderer()->document().regionBasedColumnsEnabled(); |
| 421 } | 454 } |
| 422 | 455 |
| 423 void RenderLayer::updatePaginationRecursive(bool needsPaginationUpdate) | 456 void RenderLayer::updatePaginationRecursive(bool needsPaginationUpdate) |
| 424 { | 457 { |
| 425 m_isPaginated = false; | 458 m_isPaginated = false; |
| 426 m_enclosingPaginationLayer = 0; | 459 m_enclosingPaginationLayer = 0; |
| 427 | 460 |
| (...skipping 1807 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2235 convertToLayerCoords(ancestorLayer, result); | 2268 convertToLayerCoords(ancestorLayer, result); |
| 2236 return result; | 2269 return result; |
| 2237 } | 2270 } |
| 2238 | 2271 |
| 2239 LayoutRect RenderLayer::fragmentsBoundingBox(const RenderLayer* ancestorLayer) c onst | 2272 LayoutRect RenderLayer::fragmentsBoundingBox(const RenderLayer* ancestorLayer) c onst |
| 2240 { | 2273 { |
| 2241 if (!enclosingPaginationLayer()) | 2274 if (!enclosingPaginationLayer()) |
| 2242 return physicalBoundingBox(ancestorLayer); | 2275 return physicalBoundingBox(ancestorLayer); |
| 2243 | 2276 |
| 2244 LayoutRect result = flippedLogicalBoundingBox(); | 2277 LayoutRect result = flippedLogicalBoundingBox(); |
| 2245 | 2278 convertFromFlowThreadToVisualBoundingBoxInAncestor(this, ancestorLayer, resu lt); |
| 2246 // Split our box up into the actual fragment boxes that render in the column s/pages and unite those together to | |
| 2247 // get our true bounding box. | |
| 2248 LayoutPoint offsetWithinPaginationLayer; | |
| 2249 convertToLayerCoords(enclosingPaginationLayer(), offsetWithinPaginationLayer ); | |
| 2250 result.moveBy(offsetWithinPaginationLayer); | |
| 2251 | |
| 2252 RenderFlowThread* enclosingFlowThread = toRenderFlowThread(enclosingPaginati onLayer()->renderer()); | |
| 2253 result = enclosingFlowThread->fragmentsBoundingBox(result); | |
| 2254 enclosingPaginationLayer()->convertToLayerCoords(ancestorLayer, result); | |
| 2255 return result; | 2279 return result; |
| 2256 } | 2280 } |
| 2257 | 2281 |
| 2258 static void expandRectForReflectionAndStackingChildren(const RenderLayer* ancest orLayer, RenderLayer::CalculateBoundsOptions options, LayoutRect& result) | 2282 static void expandRectForReflectionAndStackingChildren(const RenderLayer* ancest orLayer, RenderLayer::CalculateBoundsOptions options, LayoutRect& result) |
| 2259 { | 2283 { |
| 2260 if (ancestorLayer->reflectionInfo() && !ancestorLayer->reflectionInfo()->ref lectionLayer()->hasCompositedLayerMapping()) | 2284 if (ancestorLayer->reflectionInfo() && !ancestorLayer->reflectionInfo()->ref lectionLayer()->hasCompositedLayerMapping()) |
| 2261 result.unite(ancestorLayer->reflectionInfo()->reflectionLayer()->boundin gBoxForCompositing(ancestorLayer)); | 2285 result.unite(ancestorLayer->reflectionInfo()->reflectionLayer()->boundin gBoxForCompositing(ancestorLayer)); |
| 2262 | 2286 |
| 2263 ASSERT(ancestorLayer->stackingNode()->isStackingContext() || !ancestorLayer- >stackingNode()->hasPositiveZOrderList()); | 2287 ASSERT(ancestorLayer->stackingNode()->isStackingContext() || !ancestorLayer- >stackingNode()->hasPositiveZOrderList()); |
| 2264 | 2288 |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2307 // The root layer is always just the size of the document. | 2331 // The root layer is always just the size of the document. |
| 2308 if (isRootLayer()) | 2332 if (isRootLayer()) |
| 2309 return m_renderer->view()->unscaledDocumentRect(); | 2333 return m_renderer->view()->unscaledDocumentRect(); |
| 2310 | 2334 |
| 2311 // The layer created for the RenderFlowThread is just a helper for painting and hit-testing, | 2335 // The layer created for the RenderFlowThread is just a helper for painting and hit-testing, |
| 2312 // and should not contribute to the bounding box. The RenderMultiColumnSets will contribute | 2336 // and should not contribute to the bounding box. The RenderMultiColumnSets will contribute |
| 2313 // the correct size for the rendered content of the multicol container. | 2337 // the correct size for the rendered content of the multicol container. |
| 2314 if (useRegionBasedColumns() && renderer()->isRenderFlowThread()) | 2338 if (useRegionBasedColumns() && renderer()->isRenderFlowThread()) |
| 2315 return LayoutRect(); | 2339 return LayoutRect(); |
| 2316 | 2340 |
| 2317 const bool shouldIncludeTransform = paintsWithTransform(PaintBehaviorNormal) || (options == ApplyBoundsChickenEggHacks && transform()); | 2341 LayoutRect result = clipper().localClipRect(); |
| 2342 if (result == PaintInfo::infiniteRect()) { | |
| 2343 LayoutPoint origin; | |
| 2344 result = physicalBoundingBox(ancestorLayer, &origin); | |
| 2318 | 2345 |
| 2319 LayoutRect localClipRect = clipper().localClipRect(); | 2346 const_cast<RenderLayer*>(this)->stackingNode()->updateLayerListsIfNeeded (); |
| 2320 if (localClipRect != PaintInfo::infiniteRect()) { | |
| 2321 if (shouldIncludeTransform) | |
| 2322 localClipRect = transform()->mapRect(localClipRect); | |
| 2323 | 2347 |
| 2324 LayoutPoint delta; | 2348 // Reflections are implemented with RenderLayers that hang off of the re flected layer. However, |
| 2325 convertToLayerCoords(ancestorLayer, delta); | 2349 // the reflection layer subtree does not include the subtree of the pare nt RenderLayer, so |
| 2326 localClipRect.moveBy(delta); | 2350 // a recursive computation of stacking children yields no results. This breaks cases when there are stacking |
| 2327 return localClipRect; | 2351 // children of the parent, that need to be included in reflected composi ted bounds. |
| 2352 // Fix this by including composited bounds of stacking children of the r eflected RenderLayer. | |
| 2353 if (hasCompositedLayerMapping() && parent() && parent()->reflectionInfo( ) && parent()->reflectionInfo()->reflectionLayer() == this) | |
| 2354 expandRectForReflectionAndStackingChildren(parent(), options, result ); | |
| 2355 else | |
| 2356 expandRectForReflectionAndStackingChildren(this, options, result); | |
| 2357 | |
| 2358 // FIXME: We can optimize the size of the composited layers, by not enla rging | |
| 2359 // filtered areas with the outsets if we know that the filter is going t o render in hardware. | |
| 2360 // https://bugs.webkit.org/show_bug.cgi?id=81239 | |
| 2361 m_renderer->style()->filterOutsets().expandRect(result); | |
| 2328 } | 2362 } |
| 2329 | 2363 |
| 2330 LayoutPoint origin; | 2364 if (paintsWithTransform(PaintBehaviorNormal) || (options == ApplyBoundsChick enEggHacks && transform())) |
| 2331 LayoutRect result = physicalBoundingBox(ancestorLayer, &origin); | |
| 2332 | |
| 2333 const_cast<RenderLayer*>(this)->stackingNode()->updateLayerListsIfNeeded(); | |
| 2334 | |
| 2335 // Reflections are implemented with RenderLayers that hang off of the reflec ted layer. However, | |
| 2336 // the reflection layer subtree does not include the subtree of the parent R enderLayer, so | |
| 2337 // a recursive computation of stacking children yields no results. This brea ks cases when there are stacking | |
| 2338 // children of the parent, that need to be included in reflected composited bounds. | |
| 2339 // Fix this by including composited bounds of stacking children of the refle cted RenderLayer. | |
| 2340 if (hasCompositedLayerMapping() && parent() && parent()->reflectionInfo() && parent()->reflectionInfo()->reflectionLayer() == this) | |
| 2341 expandRectForReflectionAndStackingChildren(parent(), options, result); | |
| 2342 else | |
| 2343 expandRectForReflectionAndStackingChildren(this, options, result); | |
| 2344 | |
| 2345 // FIXME: We can optimize the size of the composited layers, by not enlargin g | |
| 2346 // filtered areas with the outsets if we know that the filter is going to re nder in hardware. | |
| 2347 // https://bugs.webkit.org/show_bug.cgi?id=81239 | |
| 2348 m_renderer->style()->filterOutsets().expandRect(result); | |
| 2349 | |
| 2350 if (shouldIncludeTransform) | |
| 2351 result = transform()->mapRect(result); | 2365 result = transform()->mapRect(result); |
| 2352 | 2366 |
| 2367 if (enclosingPaginationLayer()) { | |
| 2368 convertFromFlowThreadToVisualBoundingBoxInAncestor(this, ancestorLayer, result); | |
| 2369 return result; | |
| 2370 } | |
| 2353 LayoutPoint delta; | 2371 LayoutPoint delta; |
| 2354 convertToLayerCoords(ancestorLayer, delta); | 2372 convertToLayerCoords(ancestorLayer, delta); |
| 2355 result.moveBy(delta); | 2373 result.moveBy(delta); |
| 2356 return result; | 2374 return result; |
| 2357 } | 2375 } |
| 2358 | 2376 |
| 2359 CompositingState RenderLayer::compositingState() const | 2377 CompositingState RenderLayer::compositingState() const |
| 2360 { | 2378 { |
| 2361 ASSERT(isAllowedToQueryCompositingState()); | 2379 ASSERT(isAllowedToQueryCompositingState()); |
| 2362 | 2380 |
| (...skipping 484 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2847 } | 2865 } |
| 2848 } | 2866 } |
| 2849 | 2867 |
| 2850 void showLayerTree(const blink::RenderObject* renderer) | 2868 void showLayerTree(const blink::RenderObject* renderer) |
| 2851 { | 2869 { |
| 2852 if (!renderer) | 2870 if (!renderer) |
| 2853 return; | 2871 return; |
| 2854 showLayerTree(renderer->enclosingLayer()); | 2872 showLayerTree(renderer->enclosingLayer()); |
| 2855 } | 2873 } |
| 2856 #endif | 2874 #endif |
| OLD | NEW |