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 417 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
428 return false; | 428 return false; |
429 | 429 |
430 // If the previous block is absolutely positioned, then we can't be paginate d by the columns block. | 430 // If the previous block is absolutely positioned, then we can't be paginate d by the columns block. |
431 if (prevBlock->isOutOfFlowPositioned()) | 431 if (prevBlock->isOutOfFlowPositioned()) |
432 return false; | 432 return false; |
433 | 433 |
434 // Otherwise we are paginated by the columns block. | 434 // Otherwise we are paginated by the columns block. |
435 return true; | 435 return true; |
436 } | 436 } |
437 | 437 |
438 // Convert a bounding box from flow thread coordinates, relative to |layer|, to visual coordinates, relative to |ancestorLayer|. | 438 // Convert a bounding box from flow thread coordinates, relative to |layer|, to visual coordinates, relative to |ancestorLayer|. |
chrishtr
2015/01/09 17:24:23
Add a link to the design doc page here.
mstensho (USE GERRIT)
2015/01/09 18:26:40
Done.
| |
439 static void convertFromFlowThreadToVisualBoundingBoxInAncestor(const RenderLayer * layer, const RenderLayer* ancestorLayer, LayoutRect& rect) | 439 static void convertFromFlowThreadToVisualBoundingBoxInAncestor(const RenderLayer * layer, const RenderLayer* ancestorLayer, LayoutRect& rect) |
440 { | 440 { |
441 RenderLayer* paginationLayer = layer->enclosingPaginationLayer(); | 441 RenderLayer* paginationLayer = layer->enclosingPaginationLayer(); |
442 ASSERT(paginationLayer); | 442 ASSERT(paginationLayer); |
443 RenderFlowThread* flowThread = toRenderFlowThread(paginationLayer->renderer( )); | 443 RenderFlowThread* flowThread = toRenderFlowThread(paginationLayer->renderer( )); |
444 | 444 |
445 // First make the flow thread rectangle relative to the flow thread, not to |layer|. | 445 // First make the flow thread rectangle relative to the flow thread, not to |layer|. |
446 LayoutPoint offsetWithinPaginationLayer; | 446 LayoutPoint offsetWithinPaginationLayer; |
447 layer->convertToLayerCoords(paginationLayer, offsetWithinPaginationLayer); | 447 layer->convertToLayerCoords(paginationLayer, offsetWithinPaginationLayer); |
448 rect.moveBy(offsetWithinPaginationLayer); | 448 rect.moveBy(offsetWithinPaginationLayer); |
449 | 449 |
450 // Then make the rectangle visual, relative to the fragmentation context. Sp lit our box up into | 450 // Then make the rectangle visual, relative to the fragmentation context. Sp lit our box up into |
451 // the actual fragment boxes that render in the columns/pages and unite thos e together to get | 451 // the actual fragment boxes that render in the columns/pages and unite thos e together to get |
452 // our true bounding box. | 452 // our true bounding box. |
453 rect = flowThread->fragmentsBoundingBox(rect); | 453 rect = flowThread->fragmentsBoundingBox(rect); |
454 | 454 |
455 // Finally, make the visual rectangle relative to |ancestorLayer|. | 455 // Finally, make the visual rectangle relative to |ancestorLayer|. |
456 // FIXME: Handle nested fragmentation contexts (crbug.com/423076). For now j ust give up if there | 456 if (ancestorLayer->enclosingPaginationLayer() != paginationLayer) { |
457 // are different pagination layers involved. | 457 rect.moveBy(paginationLayer->visualOffsetFromAncestor(ancestorLayer)); |
458 if (!ancestorLayer->enclosingPaginationLayer() || ancestorLayer->enclosingPa ginationLayer() != paginationLayer) { | |
459 // The easy case. The ancestor layer is not within the pagination layer. | |
460 paginationLayer->convertToLayerCoords(ancestorLayer, rect); | |
461 return; | 458 return; |
462 } | 459 } |
463 // The ancestor layer is also inside the pagination layer, so we need to sub tract the visual | 460 // The ancestor layer is inside the same pagination layer as |layer|, so we need to subtract |
464 // distance from the ancestor layer to the pagination layer. | 461 // the visual distance from the ancestor layer to the pagination layer. |
465 rect.moveBy(-ancestorLayer->visualOffsetFromAncestor(paginationLayer)); | 462 rect.moveBy(-ancestorLayer->visualOffsetFromAncestor(paginationLayer)); |
466 } | 463 } |
467 | 464 |
468 bool RenderLayer::useRegionBasedColumns() const | 465 bool RenderLayer::useRegionBasedColumns() const |
469 { | 466 { |
470 return renderer()->document().regionBasedColumnsEnabled(); | 467 return renderer()->document().regionBasedColumnsEnabled(); |
471 } | 468 } |
472 | 469 |
473 void RenderLayer::updatePaginationRecursive(bool needsPaginationUpdate) | 470 void RenderLayer::updatePaginationRecursive(bool needsPaginationUpdate) |
474 { | 471 { |
(...skipping 971 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1446 | 1443 |
1447 void RenderLayer::convertToLayerCoords(const RenderLayer* ancestorLayer, LayoutR ect& rect) const | 1444 void RenderLayer::convertToLayerCoords(const RenderLayer* ancestorLayer, LayoutR ect& rect) const |
1448 { | 1445 { |
1449 LayoutPoint delta; | 1446 LayoutPoint delta; |
1450 convertToLayerCoords(ancestorLayer, delta); | 1447 convertToLayerCoords(ancestorLayer, delta); |
1451 rect.moveBy(delta); | 1448 rect.moveBy(delta); |
1452 } | 1449 } |
1453 | 1450 |
1454 LayoutPoint RenderLayer::visualOffsetFromAncestor(const RenderLayer* ancestorLay er) const | 1451 LayoutPoint RenderLayer::visualOffsetFromAncestor(const RenderLayer* ancestorLay er) const |
1455 { | 1452 { |
1453 LayoutPoint offset; | |
1454 if (ancestorLayer == this) | |
1455 return offset; | |
1456 RenderLayer* paginationLayer = enclosingPaginationLayer(); | 1456 RenderLayer* paginationLayer = enclosingPaginationLayer(); |
1457 LayoutPoint offset; | 1457 if (paginationLayer == this) |
1458 if (!paginationLayer || paginationLayer == this) { | 1458 paginationLayer = parent()->enclosingPaginationLayer(); |
1459 if (!paginationLayer) { | |
1459 convertToLayerCoords(ancestorLayer, offset); | 1460 convertToLayerCoords(ancestorLayer, offset); |
1460 return offset; | 1461 return offset; |
1461 } | 1462 } |
1462 | 1463 |
1463 RenderFlowThread* flowThread = toRenderFlowThread(paginationLayer->renderer( )); | 1464 RenderFlowThread* flowThread = toRenderFlowThread(paginationLayer->renderer( )); |
1464 convertToLayerCoords(paginationLayer, offset); | 1465 convertToLayerCoords(paginationLayer, offset); |
1465 offset = flowThread->flowThreadPointToVisualPoint(offset); | 1466 offset = flowThread->flowThreadPointToVisualPoint(offset); |
1466 if (ancestorLayer == paginationLayer) | 1467 if (ancestorLayer == paginationLayer) |
1467 return offset; | 1468 return offset; |
1468 | 1469 |
1469 // FIXME: Handle nested fragmentation contexts (crbug.com/423076). For now j ust give up if there | 1470 if (ancestorLayer->enclosingPaginationLayer() != paginationLayer) { |
1470 // are different pagination layers involved. | |
1471 if (!ancestorLayer->enclosingPaginationLayer() || ancestorLayer->enclosingPa ginationLayer() != paginationLayer) { | |
1472 // The easy case. The ancestor layer is not within the pagination layer. | |
1473 offset.moveBy(paginationLayer->visualOffsetFromAncestor(ancestorLayer)); | 1471 offset.moveBy(paginationLayer->visualOffsetFromAncestor(ancestorLayer)); |
1474 } else { | 1472 } else { |
1475 // The ancestor layer is also inside the pagination layer, so we need to subtract the visual | 1473 // The ancestor layer is also inside the pagination layer, so we need to subtract the visual |
1476 // distance from the ancestor layer to the pagination layer. | 1474 // distance from the ancestor layer to the pagination layer. |
1477 offset.moveBy(-ancestorLayer->visualOffsetFromAncestor(paginationLayer)) ; | 1475 offset.moveBy(-ancestorLayer->visualOffsetFromAncestor(paginationLayer)) ; |
1478 } | 1476 } |
1479 return offset; | 1477 return offset; |
1480 } | 1478 } |
1481 | 1479 |
1482 void RenderLayer::didUpdateNeedsCompositedScrolling() | 1480 void RenderLayer::didUpdateNeedsCompositedScrolling() |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1548 ClipRect outlineRectInFlowThread; | 1546 ClipRect outlineRectInFlowThread; |
1549 clipper().calculateRects(paginationClipRectsContext, LayoutRect::infiniteInt Rect(), layerBoundsInFlowThread, backgroundRectInFlowThread, foregroundRectInFlo wThread, | 1547 clipper().calculateRects(paginationClipRectsContext, LayoutRect::infiniteInt Rect(), layerBoundsInFlowThread, backgroundRectInFlowThread, foregroundRectInFlo wThread, |
1550 outlineRectInFlowThread, &offsetWithinPaginatedLayer); | 1548 outlineRectInFlowThread, &offsetWithinPaginatedLayer); |
1551 | 1549 |
1552 // Take our bounding box within the flow thread and clip it. | 1550 // Take our bounding box within the flow thread and clip it. |
1553 LayoutRect layerBoundingBoxInFlowThread = layerBoundingBox ? *layerBoundingB ox : physicalBoundingBox(enclosingPaginationLayer(), &offsetWithinPaginatedLayer ); | 1551 LayoutRect layerBoundingBoxInFlowThread = layerBoundingBox ? *layerBoundingB ox : physicalBoundingBox(enclosingPaginationLayer(), &offsetWithinPaginatedLayer ); |
1554 layerBoundingBoxInFlowThread.intersect(backgroundRectInFlowThread.rect()); | 1552 layerBoundingBoxInFlowThread.intersect(backgroundRectInFlowThread.rect()); |
1555 | 1553 |
1556 // Make the dirty rect relative to the fragmentation context (multicol conta iner, etc.). | 1554 // Make the dirty rect relative to the fragmentation context (multicol conta iner, etc.). |
1557 RenderFlowThread* enclosingFlowThread = toRenderFlowThread(enclosingPaginati onLayer()->renderer()); | 1555 RenderFlowThread* enclosingFlowThread = toRenderFlowThread(enclosingPaginati onLayer()->renderer()); |
1558 LayoutPoint offsetOfPaginationLayerFromRoot; | 1556 LayoutPoint offsetOfPaginationLayerFromRoot; // Visual offset from the root layer to the nearest fragmentation context. |
1559 // FIXME: more work needed if there are nested pagination layers. | 1557 if (rootLayer->enclosingPaginationLayer() == enclosingPaginationLayer()) { |
1560 if (rootLayer != enclosingPaginationLayer() && rootLayer->enclosingPaginatio nLayer() == enclosingPaginationLayer()) { | 1558 // The root layer is in the same fragmentation context as this layer, so we need to look |
1561 // The root layer is inside the fragmentation context. So we need to loo k inside it and find | 1559 // inside it and subtract the offset between the fragmentation context a nd the root layer. |
1562 // the visual offset from the fragmentation context. | 1560 offsetOfPaginationLayerFromRoot = -rootLayer->visualOffsetFromAncestor(e nclosingPaginationLayer()); |
1563 LayoutPoint flowThreadOffset; | |
1564 rootLayer->convertToLayerCoords(enclosingPaginationLayer(), flowThreadOf fset); | |
1565 offsetOfPaginationLayerFromRoot = -enclosingFlowThread->flowThreadPointT oVisualPoint(flowThreadOffset); | |
1566 } else { | 1561 } else { |
1567 enclosingPaginationLayer()->convertToLayerCoords(rootLayer, offsetOfPagi nationLayerFromRoot); | 1562 offsetOfPaginationLayerFromRoot = enclosingPaginationLayer()->visualOffs etFromAncestor(rootLayer); |
1568 } | 1563 } |
1569 LayoutRect dirtyRectInFlowThread(dirtyRect); | 1564 LayoutRect dirtyRectInFlowThread(dirtyRect); |
1570 dirtyRectInFlowThread.moveBy(-offsetOfPaginationLayerFromRoot); | 1565 dirtyRectInFlowThread.moveBy(-offsetOfPaginationLayerFromRoot); |
1571 | 1566 |
1572 // Tell the flow thread to collect the fragments. We pass enough information to create a minimal number of fragments based off the pages/columns | 1567 // Tell the flow thread to collect the fragments. We pass enough information to create a minimal number of fragments based off the pages/columns |
1573 // that intersect the actual dirtyRect as well as the pages/columns that int ersect our layer's bounding box. | 1568 // that intersect the actual dirtyRect as well as the pages/columns that int ersect our layer's bounding box. |
1574 enclosingFlowThread->collectLayerFragments(fragments, layerBoundingBoxInFlow Thread, dirtyRectInFlowThread); | 1569 enclosingFlowThread->collectLayerFragments(fragments, layerBoundingBoxInFlow Thread, dirtyRectInFlowThread); |
1575 | 1570 |
1576 if (fragments.isEmpty()) | 1571 if (fragments.isEmpty()) |
1577 return; | 1572 return; |
(...skipping 1322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2900 } | 2895 } |
2901 } | 2896 } |
2902 | 2897 |
2903 void showLayerTree(const blink::RenderObject* renderer) | 2898 void showLayerTree(const blink::RenderObject* renderer) |
2904 { | 2899 { |
2905 if (!renderer) | 2900 if (!renderer) |
2906 return; | 2901 return; |
2907 showLayerTree(renderer->enclosingLayer()); | 2902 showLayerTree(renderer->enclosingLayer()); |
2908 } | 2903 } |
2909 #endif | 2904 #endif |
OLD | NEW |