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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 | 46 |
47 #include "core/CSSPropertyNames.h" | 47 #include "core/CSSPropertyNames.h" |
48 #include "core/HTMLNames.h" | 48 #include "core/HTMLNames.h" |
49 #include "core/css/PseudoStyleRequest.h" | 49 #include "core/css/PseudoStyleRequest.h" |
50 #include "core/dom/Document.h" | 50 #include "core/dom/Document.h" |
51 #include "core/dom/shadow/ShadowRoot.h" | 51 #include "core/dom/shadow/ShadowRoot.h" |
52 #include "core/frame/DeprecatedScheduleStyleRecalcDuringLayout.h" | 52 #include "core/frame/DeprecatedScheduleStyleRecalcDuringLayout.h" |
53 #include "core/frame/FrameView.h" | 53 #include "core/frame/FrameView.h" |
54 #include "core/frame/LocalFrame.h" | 54 #include "core/frame/LocalFrame.h" |
55 #include "core/html/HTMLFrameElement.h" | 55 #include "core/html/HTMLFrameElement.h" |
56 #include "core/layout/ColumnInfo.h" | |
57 #include "core/layout/HitTestRequest.h" | 56 #include "core/layout/HitTestRequest.h" |
58 #include "core/layout/HitTestResult.h" | 57 #include "core/layout/HitTestResult.h" |
59 #include "core/layout/HitTestingTransformState.h" | 58 #include "core/layout/HitTestingTransformState.h" |
60 #include "core/layout/LayoutFlowThread.h" | 59 #include "core/layout/LayoutFlowThread.h" |
61 #include "core/layout/LayoutGeometryMap.h" | 60 #include "core/layout/LayoutGeometryMap.h" |
62 #include "core/layout/LayoutInline.h" | 61 #include "core/layout/LayoutInline.h" |
63 #include "core/layout/LayoutPart.h" | 62 #include "core/layout/LayoutPart.h" |
64 #include "core/layout/LayoutReplica.h" | 63 #include "core/layout/LayoutReplica.h" |
65 #include "core/layout/LayoutScrollbar.h" | 64 #include "core/layout/LayoutScrollbar.h" |
66 #include "core/layout/LayoutScrollbarPart.h" | 65 #include "core/layout/LayoutScrollbarPart.h" |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
103 DeprecatedPaintLayer::DeprecatedPaintLayer(LayoutBoxModelObject* layoutObject, D
eprecatedPaintLayerType type) | 102 DeprecatedPaintLayer::DeprecatedPaintLayer(LayoutBoxModelObject* layoutObject, D
eprecatedPaintLayerType type) |
104 : m_layerType(type) | 103 : m_layerType(type) |
105 , m_hasSelfPaintingLayerDescendant(false) | 104 , m_hasSelfPaintingLayerDescendant(false) |
106 , m_hasSelfPaintingLayerDescendantDirty(false) | 105 , m_hasSelfPaintingLayerDescendantDirty(false) |
107 , m_isRootLayer(layoutObject->isLayoutView()) | 106 , m_isRootLayer(layoutObject->isLayoutView()) |
108 , m_visibleContentStatusDirty(true) | 107 , m_visibleContentStatusDirty(true) |
109 , m_hasVisibleContent(false) | 108 , m_hasVisibleContent(false) |
110 , m_visibleDescendantStatusDirty(false) | 109 , m_visibleDescendantStatusDirty(false) |
111 , m_hasVisibleDescendant(false) | 110 , m_hasVisibleDescendant(false) |
112 , m_hasVisibleNonLayerContent(false) | 111 , m_hasVisibleNonLayerContent(false) |
113 , m_isPaginated(false) | |
114 #if ENABLE(ASSERT) | 112 #if ENABLE(ASSERT) |
115 , m_needsPositionUpdate(true) | 113 , m_needsPositionUpdate(true) |
116 #endif | 114 #endif |
117 , m_3DTransformedDescendantStatusDirty(true) | 115 , m_3DTransformedDescendantStatusDirty(true) |
118 , m_has3DTransformedDescendant(false) | 116 , m_has3DTransformedDescendant(false) |
119 , m_containsDirtyOverlayScrollbars(false) | 117 , m_containsDirtyOverlayScrollbars(false) |
120 , m_hasFilterInfo(false) | 118 , m_hasFilterInfo(false) |
121 , m_needsAncestorDependentCompositingInputsUpdate(true) | 119 , m_needsAncestorDependentCompositingInputsUpdate(true) |
122 , m_needsDescendantDependentCompositingInputsUpdate(true) | 120 , m_needsDescendantDependentCompositingInputsUpdate(true) |
123 , m_childNeedsCompositingInputsUpdate(true) | 121 , m_childNeedsCompositingInputsUpdate(true) |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
237 { | 235 { |
238 TRACE_EVENT0("blink,benchmark", "DeprecatedPaintLayer::updateLayerPositionsA
fterLayout"); | 236 TRACE_EVENT0("blink,benchmark", "DeprecatedPaintLayer::updateLayerPositionsA
fterLayout"); |
239 | 237 |
240 m_clipper.clearClipRectsIncludingDescendants(); | 238 m_clipper.clearClipRectsIncludingDescendants(); |
241 updateLayerPositionRecursive(); | 239 updateLayerPositionRecursive(); |
242 | 240 |
243 { | 241 { |
244 // FIXME: Remove incremental compositing updates after fixing the chicke
n/egg issues | 242 // FIXME: Remove incremental compositing updates after fixing the chicke
n/egg issues |
245 // https://code.google.com/p/chromium/issues/detail?id=343756 | 243 // https://code.google.com/p/chromium/issues/detail?id=343756 |
246 DisableCompositingQueryAsserts disabler; | 244 DisableCompositingQueryAsserts disabler; |
247 bool needsPaginationUpdate = isPaginated() || enclosingPaginationLayer()
; | 245 updatePaginationRecursive(enclosingPaginationLayer()); |
248 updatePaginationRecursive(needsPaginationUpdate); | |
249 } | 246 } |
250 } | 247 } |
251 | 248 |
252 void DeprecatedPaintLayer::updateLayerPositionRecursive() | 249 void DeprecatedPaintLayer::updateLayerPositionRecursive() |
253 { | 250 { |
254 updateLayerPosition(); | 251 updateLayerPosition(); |
255 | 252 |
256 if (m_reflectionInfo) | 253 if (m_reflectionInfo) |
257 m_reflectionInfo->reflection()->layout(); | 254 m_reflectionInfo->reflection()->layout(); |
258 | 255 |
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
422 | 419 |
423 if (paintBehavior & PaintBehaviorFlattenCompositingLayers) { | 420 if (paintBehavior & PaintBehaviorFlattenCompositingLayers) { |
424 TransformationMatrix matrix = *m_transform; | 421 TransformationMatrix matrix = *m_transform; |
425 makeMatrixRenderable(matrix, false /* flatten 3d */); | 422 makeMatrixRenderable(matrix, false /* flatten 3d */); |
426 return matrix; | 423 return matrix; |
427 } | 424 } |
428 | 425 |
429 return *m_transform; | 426 return *m_transform; |
430 } | 427 } |
431 | 428 |
432 static bool checkContainingBlockChainForPagination(LayoutBoxModelObject* layoutO
bject, LayoutBox* ancestorColumnsLayoutObject) | |
433 { | |
434 LayoutView* view = layoutObject->view(); | |
435 LayoutBoxModelObject* prevBlock = layoutObject; | |
436 LayoutBlock* containingBlock; | |
437 for (containingBlock = layoutObject->containingBlock(); | |
438 containingBlock && containingBlock != view && containingBlock != ancesto
rColumnsLayoutObject; | |
439 containingBlock = containingBlock->containingBlock()) | |
440 prevBlock = containingBlock; | |
441 | |
442 // If the columns block wasn't in our containing block chain, then we aren't
paginated by it. | |
443 if (containingBlock != ancestorColumnsLayoutObject) | |
444 return false; | |
445 | |
446 // If the previous block is absolutely positioned, then we can't be paginate
d by the columns block. | |
447 if (prevBlock->isOutOfFlowPositioned()) | |
448 return false; | |
449 | |
450 // Otherwise we are paginated by the columns block. | |
451 return true; | |
452 } | |
453 | |
454 // Convert a bounding box from flow thread coordinates, relative to |layer|, to
visual coordinates, relative to |ancestorLayer|. | 429 // Convert a bounding box from flow thread coordinates, relative to |layer|, to
visual coordinates, relative to |ancestorLayer|. |
455 // See http://www.chromium.org/developers/design-documents/multi-column-layout f
or more info on these coordinate types. | 430 // See http://www.chromium.org/developers/design-documents/multi-column-layout f
or more info on these coordinate types. |
456 static void convertFromFlowThreadToVisualBoundingBoxInAncestor(const DeprecatedP
aintLayer* layer, const DeprecatedPaintLayer* ancestorLayer, LayoutRect& rect) | 431 static void convertFromFlowThreadToVisualBoundingBoxInAncestor(const DeprecatedP
aintLayer* layer, const DeprecatedPaintLayer* ancestorLayer, LayoutRect& rect) |
457 { | 432 { |
458 DeprecatedPaintLayer* paginationLayer = layer->enclosingPaginationLayer(); | 433 DeprecatedPaintLayer* paginationLayer = layer->enclosingPaginationLayer(); |
459 ASSERT(paginationLayer); | 434 ASSERT(paginationLayer); |
460 LayoutFlowThread* flowThread = toLayoutFlowThread(paginationLayer->layoutObj
ect()); | 435 LayoutFlowThread* flowThread = toLayoutFlowThread(paginationLayer->layoutObj
ect()); |
461 | 436 |
462 // First make the flow thread rectangle relative to the flow thread, not to
|layer|. | 437 // First make the flow thread rectangle relative to the flow thread, not to
|layer|. |
463 LayoutPoint offsetWithinPaginationLayer; | 438 LayoutPoint offsetWithinPaginationLayer; |
(...skipping 10 matching lines...) Expand all Loading... |
474 rect.moveBy(paginationLayer->visualOffsetFromAncestor(ancestorLayer)); | 449 rect.moveBy(paginationLayer->visualOffsetFromAncestor(ancestorLayer)); |
475 return; | 450 return; |
476 } | 451 } |
477 // The ancestor layer is inside the same pagination layer as |layer|, so we
need to subtract | 452 // The ancestor layer is inside the same pagination layer as |layer|, so we
need to subtract |
478 // the visual distance from the ancestor layer to the pagination layer. | 453 // the visual distance from the ancestor layer to the pagination layer. |
479 rect.moveBy(-ancestorLayer->visualOffsetFromAncestor(paginationLayer)); | 454 rect.moveBy(-ancestorLayer->visualOffsetFromAncestor(paginationLayer)); |
480 } | 455 } |
481 | 456 |
482 void DeprecatedPaintLayer::updatePaginationRecursive(bool needsPaginationUpdate) | 457 void DeprecatedPaintLayer::updatePaginationRecursive(bool needsPaginationUpdate) |
483 { | 458 { |
484 m_isPaginated = false; | |
485 m_enclosingPaginationLayer = 0; | 459 m_enclosingPaginationLayer = 0; |
486 | 460 |
487 if (RuntimeEnabledFeatures::regionBasedColumnsEnabled() && layoutObject()->i
sLayoutFlowThread()) | 461 if (layoutObject()->isLayoutFlowThread()) |
488 needsPaginationUpdate = true; | 462 needsPaginationUpdate = true; |
489 | 463 |
490 if (needsPaginationUpdate) | 464 if (needsPaginationUpdate) |
491 updatePagination(); | 465 updatePagination(); |
492 | 466 |
493 if (layoutObject()->hasColumns()) | |
494 needsPaginationUpdate = true; | |
495 | |
496 for (DeprecatedPaintLayer* child = firstChild(); child; child = child->nextS
ibling()) | 467 for (DeprecatedPaintLayer* child = firstChild(); child; child = child->nextS
ibling()) |
497 child->updatePaginationRecursive(needsPaginationUpdate); | 468 child->updatePaginationRecursive(needsPaginationUpdate); |
498 } | 469 } |
499 | 470 |
500 void DeprecatedPaintLayer::updatePagination() | 471 void DeprecatedPaintLayer::updatePagination() |
501 { | 472 { |
502 bool usesRegionBasedColumns = RuntimeEnabledFeatures::regionBasedColumnsEnab
led(); | 473 if (!parent()) |
503 if ((!usesRegionBasedColumns && compositingState() != NotComposited) || !par
ent()) | |
504 return; // FIXME: For now the LayoutView can't be paginated. Eventually
printing will move to a model where it is though. | 474 return; // FIXME: For now the LayoutView can't be paginated. Eventually
printing will move to a model where it is though. |
505 | 475 |
506 // The main difference between the paginated booleans for the old column cod
e and the new column code | 476 // Each paginated layer has to paint on its own. There is no recurring into
child layers. Each |
507 // is that each paginated layer has to paint on its own with the new code. T
here is no | 477 // layer has to be checked individually and genuinely know if it is going to
have to split |
508 // recurring into child layers. This means that the m_isPaginated bits for t
he new column code can't just be set on | 478 // itself up when painting only its contents (and not any other descendant l
ayers). We track an |
509 // "roots" that get split and paint all their descendants. Instead each laye
r has to be checked individually and | 479 // enclosingPaginationLayer instead of using a simple bit, since we want to
be able to get back |
510 // genuinely know if it is going to have to split itself up when painting on
ly its contents (and not any other descendant | |
511 // layers). We track an enclosingPaginationLayer instead of using a simple b
it, since we want to be able to get back | |
512 // to that layer easily. | 480 // to that layer easily. |
513 if (usesRegionBasedColumns && layoutObject()->isLayoutFlowThread()) { | 481 if (layoutObject()->isLayoutFlowThread()) { |
514 m_enclosingPaginationLayer = this; | 482 m_enclosingPaginationLayer = this; |
515 return; | 483 return; |
516 } | 484 } |
517 | 485 |
518 if (m_stackingNode->isNormalFlowOnly()) { | 486 if (m_stackingNode->isNormalFlowOnly()) { |
519 if (usesRegionBasedColumns) { | 487 // We cannot take the fast path for spanners, as they do not have their
nearest ancestor |
520 // We cannot take the fast path for spanners, as they do not have th
eir nearest ancestor | 488 // pagination layer (flow thread) in their containing block chain. |
521 // pagination layer (flow thread) in their containing block chain. | 489 if (!layoutObject()->isColumnSpanAll()) { |
522 if (!layoutObject()->isColumnSpanAll()) { | 490 // Content inside a transform is not considered to be paginated, sin
ce we simply |
523 // Content inside a transform is not considered to be paginated,
since we simply | 491 // paint the transform multiple times in each column, so we don't ha
ve to use |
524 // paint the transform multiple times in each column, so we don'
t have to use | 492 // fragments for the transformed content. |
525 // fragments for the transformed content. | 493 m_enclosingPaginationLayer = parent()->enclosingPaginationLayer(); |
526 m_enclosingPaginationLayer = parent()->enclosingPaginationLayer(
); | 494 if (m_enclosingPaginationLayer && m_enclosingPaginationLayer->hasTra
nsformRelatedProperty()) |
527 if (m_enclosingPaginationLayer && m_enclosingPaginationLayer->ha
sTransformRelatedProperty()) | 495 m_enclosingPaginationLayer = 0; |
528 m_enclosingPaginationLayer = 0; | |
529 return; | |
530 } | |
531 } else { | |
532 m_isPaginated = parent()->layoutObject()->hasColumns(); | |
533 return; | 496 return; |
534 } | 497 } |
535 } | 498 } |
536 | 499 |
537 // For the new columns code, we want to walk up our containing block chain l
ooking for an enclosing layer. Once | 500 // Walk up our containing block chain looking for an enclosing layer. Once w
e find one, then we |
538 // we find one, then we just check its pagination status. | 501 // just check its pagination status. |
539 if (usesRegionBasedColumns) { | 502 LayoutView* view = layoutObject()->view(); |
540 LayoutView* view = layoutObject()->view(); | 503 LayoutBlock* containingBlock; |
541 LayoutBlock* containingBlock; | 504 for (containingBlock = layoutObject()->containingBlock(); |
542 for (containingBlock = layoutObject()->containingBlock(); | 505 containingBlock && containingBlock != view; |
543 containingBlock && containingBlock != view; | 506 containingBlock = containingBlock->containingBlock()) { |
544 containingBlock = containingBlock->containingBlock()) { | 507 if (containingBlock->hasLayer()) { |
545 if (containingBlock->hasLayer()) { | 508 // Content inside a transform is not considered to be paginated, sin
ce we simply |
546 // Content inside a transform is not considered to be paginated,
since we simply | 509 // paint the transform multiple times in each column, so we don't ha
ve to use |
547 // paint the transform multiple times in each column, so we don'
t have to use | 510 // fragments for the transformed content. |
548 // fragments for the transformed content. | 511 m_enclosingPaginationLayer = containingBlock->layer()->enclosingPagi
nationLayer(); |
549 m_enclosingPaginationLayer = containingBlock->layer()->enclosing
PaginationLayer(); | 512 if (m_enclosingPaginationLayer && m_enclosingPaginationLayer->hasTra
nsformRelatedProperty()) |
550 if (m_enclosingPaginationLayer && m_enclosingPaginationLayer->ha
sTransformRelatedProperty()) | 513 m_enclosingPaginationLayer = 0; |
551 m_enclosingPaginationLayer = 0; | |
552 return; | |
553 } | |
554 } | |
555 return; | |
556 } | |
557 | |
558 // If we're not normal flow, then we need to look for a multi-column object
between us and our stacking container. | |
559 DeprecatedPaintLayerStackingNode* ancestorStackingContextNode = m_stackingNo
de->ancestorStackingContextNode(); | |
560 for (DeprecatedPaintLayer* curr = parent(); curr; curr = curr->parent()) { | |
561 if (curr->layoutObject()->hasColumns()) { | |
562 m_isPaginated = checkContainingBlockChainForPagination(layoutObject(
), curr->layoutBox()); | |
563 return; | 514 return; |
564 } | 515 } |
565 if (curr->stackingNode() == ancestorStackingContextNode) | |
566 return; | |
567 } | 516 } |
568 } | 517 } |
569 | 518 |
570 void DeprecatedPaintLayer::clearPaginationRecursive() | 519 void DeprecatedPaintLayer::clearPaginationRecursive() |
571 { | 520 { |
572 m_enclosingPaginationLayer = 0; | 521 m_enclosingPaginationLayer = 0; |
573 for (DeprecatedPaintLayer* child = firstChild(); child; child = child->nextS
ibling()) | 522 for (DeprecatedPaintLayer* child = firstChild(); child; child = child->nextS
ibling()) |
574 child->clearPaginationRecursive(); | 523 child->clearPaginationRecursive(); |
575 } | 524 } |
576 | 525 |
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
840 // For positioned layers, we subtract out the enclosing positioned layer
's scroll offset. | 789 // For positioned layers, we subtract out the enclosing positioned layer
's scroll offset. |
841 if (positionedParent->layoutObject()->hasOverflowClip()) { | 790 if (positionedParent->layoutObject()->hasOverflowClip()) { |
842 IntSize offset = positionedParent->layoutBox()->scrolledContentOffse
t(); | 791 IntSize offset = positionedParent->layoutBox()->scrolledContentOffse
t(); |
843 localPoint -= offset; | 792 localPoint -= offset; |
844 } | 793 } |
845 | 794 |
846 if (positionedParent->layoutObject()->isRelPositioned() && positionedPar
ent->layoutObject()->isLayoutInline()) { | 795 if (positionedParent->layoutObject()->isRelPositioned() && positionedPar
ent->layoutObject()->isLayoutInline()) { |
847 LayoutSize offset = toLayoutInline(positionedParent->layoutObject())
->offsetForInFlowPositionedInline(*toLayoutBox(layoutObject())); | 796 LayoutSize offset = toLayoutInline(positionedParent->layoutObject())
->offsetForInFlowPositionedInline(*toLayoutBox(layoutObject())); |
848 localPoint += offset; | 797 localPoint += offset; |
849 } | 798 } |
850 } else if (parent()) { | 799 } else if (parent() && parent()->layoutObject()->hasOverflowClip()) { |
851 // FIXME: This code is very wrong, but luckily only needed in the old/cu
rrent multicol | 800 IntSize scrollOffset = parent()->layoutBox()->scrolledContentOffset(); |
852 // implementation. The compositing system doesn't understand columns and
we're hacking | 801 localPoint -= scrollOffset; |
853 // around that fact by faking the position of the Layers when we think w
e'll end up | |
854 // being composited. | |
855 if (hasStyleDeterminedDirectCompositingReasons() && !RuntimeEnabledFeatu
res::regionBasedColumnsEnabled()) { | |
856 // FIXME: Composited layers ignore pagination, so about the best we
can do is make sure they're offset into the appropriate column. | |
857 // They won't split across columns properly. | |
858 if (!parent()->layoutObject()->hasColumns() && parent()->layoutObjec
t()->isDocumentElement() && layoutObject()->view()->hasColumns()) | |
859 localPoint += layoutObject()->view()->columnOffset(localPoint); | |
860 else | |
861 localPoint += parent()->layoutObject()->columnOffset(localPoint)
; | |
862 } | |
863 | |
864 if (parent()->layoutObject()->hasOverflowClip()) { | |
865 IntSize scrollOffset = parent()->layoutBox()->scrolledContentOffset(
); | |
866 localPoint -= scrollOffset; | |
867 } | |
868 } | 802 } |
869 | 803 |
870 bool positionOrOffsetChanged = false; | 804 bool positionOrOffsetChanged = false; |
871 if (layoutObject()->isRelPositioned()) { | 805 if (layoutObject()->isRelPositioned()) { |
872 LayoutSize newOffset = layoutObject()->offsetForInFlowPosition(); | 806 LayoutSize newOffset = layoutObject()->offsetForInFlowPosition(); |
873 positionOrOffsetChanged = newOffset != m_offsetForInFlowPosition; | 807 positionOrOffsetChanged = newOffset != m_offsetForInFlowPosition; |
874 m_offsetForInFlowPosition = newOffset; | 808 m_offsetForInFlowPosition = newOffset; |
875 localPoint.move(m_offsetForInFlowPosition); | 809 localPoint.move(m_offsetForInFlowPosition); |
876 } else { | 810 } else { |
877 m_offsetForInFlowPosition = LayoutSize(); | 811 m_offsetForInFlowPosition = LayoutSize(); |
(...skipping 1196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2074 { | 2008 { |
2075 if (!hasSelfPaintingLayerDescendant()) | 2009 if (!hasSelfPaintingLayerDescendant()) |
2076 return 0; | 2010 return 0; |
2077 | 2011 |
2078 DeprecatedPaintLayer* resultLayer = 0; | 2012 DeprecatedPaintLayer* resultLayer = 0; |
2079 DeprecatedPaintLayerStackingNodeReverseIterator iterator(*m_stackingNode, ch
ildrentoVisit); | 2013 DeprecatedPaintLayerStackingNodeReverseIterator iterator(*m_stackingNode, ch
ildrentoVisit); |
2080 while (DeprecatedPaintLayerStackingNode* child = iterator.next()) { | 2014 while (DeprecatedPaintLayerStackingNode* child = iterator.next()) { |
2081 DeprecatedPaintLayer* childLayer = child->layer(); | 2015 DeprecatedPaintLayer* childLayer = child->layer(); |
2082 DeprecatedPaintLayer* hitLayer = 0; | 2016 DeprecatedPaintLayer* hitLayer = 0; |
2083 HitTestResult tempResult(result.hitTestRequest(), result.hitTestLocation
()); | 2017 HitTestResult tempResult(result.hitTestRequest(), result.hitTestLocation
()); |
2084 if (childLayer->isPaginated()) | 2018 hitLayer = childLayer->hitTestLayer(rootLayer, this, tempResult, hitTest
Rect, hitTestLocation, false, transformState, zOffsetForDescendants); |
2085 hitLayer = hitTestPaginatedChildLayer(childLayer, rootLayer, tempRes
ult, hitTestRect, hitTestLocation, transformState, zOffsetForDescendants); | |
2086 else | |
2087 hitLayer = childLayer->hitTestLayer(rootLayer, this, tempResult, hit
TestRect, hitTestLocation, false, transformState, zOffsetForDescendants); | |
2088 | 2019 |
2089 // If it is a list-based test, we can safely append the temporary result
since it might had hit | 2020 // If it is a list-based test, we can safely append the temporary result
since it might had hit |
2090 // nodes but not necesserily had hitLayer set. | 2021 // nodes but not necesserily had hitLayer set. |
2091 ASSERT(!result.isRectBasedTest() || result.hitTestRequest().listBased())
; | 2022 ASSERT(!result.isRectBasedTest() || result.hitTestRequest().listBased())
; |
2092 if (result.hitTestRequest().listBased()) | 2023 if (result.hitTestRequest().listBased()) |
2093 result.append(tempResult); | 2024 result.append(tempResult); |
2094 | 2025 |
2095 if (isHitCandidate(hitLayer, depthSortDescendants, zOffset, unflattenedT
ransformState)) { | 2026 if (isHitCandidate(hitLayer, depthSortDescendants, zOffset, unflattenedT
ransformState)) { |
2096 resultLayer = hitLayer; | 2027 resultLayer = hitLayer; |
2097 if (!result.hitTestRequest().listBased()) | 2028 if (!result.hitTestRequest().listBased()) |
2098 result = tempResult; | 2029 result = tempResult; |
2099 if (!depthSortDescendants) | 2030 if (!depthSortDescendants) |
2100 break; | 2031 break; |
2101 } | 2032 } |
2102 } | 2033 } |
2103 | 2034 |
2104 return resultLayer; | 2035 return resultLayer; |
2105 } | 2036 } |
2106 | 2037 |
2107 DeprecatedPaintLayer* DeprecatedPaintLayer::hitTestPaginatedChildLayer(Deprecate
dPaintLayer* childLayer, DeprecatedPaintLayer* rootLayer, HitTestResult& result, | |
2108 const LayoutRect& hitTestRect, const HitTestLocation& hitTestLocation, const
HitTestingTransformState* transformState, double* zOffset) | |
2109 { | |
2110 Vector<DeprecatedPaintLayer*> columnLayers; | |
2111 DeprecatedPaintLayerStackingNode* ancestorNode = m_stackingNode->isNormalFlo
wOnly() ? parent()->stackingNode() : m_stackingNode->ancestorStackingContextNode
(); | |
2112 for (DeprecatedPaintLayer* curr = childLayer->parent(); curr; curr = curr->p
arent()) { | |
2113 if (curr->layoutObject()->hasColumns() && checkContainingBlockChainForPa
gination(childLayer->layoutObject(), curr->layoutBox())) | |
2114 columnLayers.append(curr); | |
2115 if (curr->stackingNode() == ancestorNode) | |
2116 break; | |
2117 } | |
2118 | |
2119 ASSERT(columnLayers.size()); | |
2120 return hitTestChildLayerColumns(childLayer, rootLayer, result, hitTestRect,
hitTestLocation, transformState, zOffset, | |
2121 columnLayers, columnLayers.size() - 1); | |
2122 } | |
2123 | |
2124 DeprecatedPaintLayer* DeprecatedPaintLayer::hitTestChildLayerColumns(DeprecatedP
aintLayer* childLayer, DeprecatedPaintLayer* rootLayer, HitTestResult& result, | |
2125 const LayoutRect& hitTestRect, const HitTestLocation& hitTestLocation, const
HitTestingTransformState* transformState, double* zOffset, | |
2126 const Vector<DeprecatedPaintLayer*>& columnLayers, size_t columnIndex) | |
2127 { | |
2128 LayoutBlock* columnBlock = toLayoutBlock(columnLayers[columnIndex]->layoutOb
ject()); | |
2129 | |
2130 ASSERT(columnBlock && columnBlock->hasColumns()); | |
2131 if (!columnBlock || !columnBlock->hasColumns()) | |
2132 return 0; | |
2133 | |
2134 LayoutPoint layerOffset; | |
2135 columnBlock->layer()->convertToLayerCoords(rootLayer, layerOffset); | |
2136 | |
2137 ColumnInfo* colInfo = columnBlock->columnInfo(); | |
2138 int colCount = columnBlock->columnCount(colInfo); | |
2139 | |
2140 // We have to go backwards from the last column to the first. | |
2141 bool isHorizontal = columnBlock->style()->isHorizontalWritingMode(); | |
2142 LayoutUnit logicalLeft = columnBlock->logicalLeftOffsetForContent(); | |
2143 LayoutUnit currLogicalTopOffset = 0; | |
2144 int i; | |
2145 for (i = 0; i < colCount; i++) { | |
2146 LayoutRect colRect = columnBlock->columnRectAt(colInfo, i); | |
2147 LayoutUnit blockDelta = (isHorizontal ? colRect.height() : colRect.widt
h()); | |
2148 if (columnBlock->style()->isFlippedBlocksWritingMode()) | |
2149 currLogicalTopOffset += blockDelta; | |
2150 else | |
2151 currLogicalTopOffset -= blockDelta; | |
2152 } | |
2153 for (i = colCount - 1; i >= 0; i--) { | |
2154 // For each rect, we clip to the rect, and then we adjust our coords. | |
2155 LayoutRect colRect = columnBlock->columnRectAt(colInfo, i); | |
2156 columnBlock->flipForWritingMode(colRect); | |
2157 LayoutUnit currLogicalLeftOffset = (isHorizontal ? colRect.x() : colRect
.y()) - logicalLeft; | |
2158 LayoutUnit blockDelta = (isHorizontal ? colRect.height() : colRect.widt
h()); | |
2159 if (columnBlock->style()->isFlippedBlocksWritingMode()) | |
2160 currLogicalTopOffset -= blockDelta; | |
2161 else | |
2162 currLogicalTopOffset += blockDelta; | |
2163 | |
2164 LayoutSize offset; | |
2165 if (isHorizontal) { | |
2166 if (colInfo->progressionAxis() == ColumnInfo::InlineAxis) | |
2167 offset = LayoutSize(currLogicalLeftOffset, currLogicalTopOffset)
; | |
2168 else | |
2169 offset = LayoutSize(0, colRect.y() + currLogicalTopOffset - colu
mnBlock->borderTop() - columnBlock->paddingTop()); | |
2170 } else { | |
2171 if (colInfo->progressionAxis() == ColumnInfo::InlineAxis) | |
2172 offset = LayoutSize(currLogicalTopOffset, currLogicalLeftOffset)
; | |
2173 else | |
2174 offset = LayoutSize(colRect.x() + currLogicalTopOffset - columnB
lock->borderLeft() - columnBlock->paddingLeft(), 0); | |
2175 } | |
2176 | |
2177 colRect.moveBy(layerOffset); | |
2178 | |
2179 LayoutRect localClipRect(hitTestRect); | |
2180 localClipRect.intersect(colRect); | |
2181 | |
2182 if (!localClipRect.isEmpty() && hitTestLocation.intersects(localClipRect
)) { | |
2183 DeprecatedPaintLayer* hitLayer = 0; | |
2184 if (!columnIndex) { | |
2185 // Apply a translation transform to change where the layer paint
s. | |
2186 TransformationMatrix oldTransform; | |
2187 bool oldHasTransform = childLayer->transform(); | |
2188 if (oldHasTransform) | |
2189 oldTransform = *childLayer->transform(); | |
2190 TransformationMatrix newTransform(oldTransform); | |
2191 newTransform.translateRight(offset.width(), offset.height()); | |
2192 | |
2193 childLayer->m_transform = adoptPtr(new TransformationMatrix(newT
ransform)); | |
2194 hitLayer = childLayer->hitTestLayer(rootLayer, columnLayers[0],
result, localClipRect, hitTestLocation, false, transformState, zOffset); | |
2195 if (oldHasTransform) | |
2196 childLayer->m_transform = adoptPtr(new TransformationMatrix(
oldTransform)); | |
2197 else | |
2198 childLayer->m_transform.clear(); | |
2199 } else { | |
2200 // Adjust the transform such that the layoutObjects's upper left
corner will be at (0,0) in user space. | |
2201 // This involves subtracting out the position of the layer in ou
r current coordinate space. | |
2202 DeprecatedPaintLayer* nextLayer = columnLayers[columnIndex - 1]; | |
2203 RefPtr<HitTestingTransformState> newTransformState = nextLayer->
createLocalTransformState(rootLayer, nextLayer, localClipRect, hitTestLocation,
transformState); | |
2204 newTransformState->translate(offset.width(), offset.height(), Hi
tTestingTransformState::AccumulateTransform); | |
2205 FloatPoint localPoint = newTransformState->mappedPoint(); | |
2206 FloatQuad localPointQuad = newTransformState->mappedQuad(); | |
2207 LayoutRect localHitTestRect(newTransformState->mappedArea().encl
osingBoundingBox()); | |
2208 HitTestLocation newHitTestLocation; | |
2209 if (hitTestLocation.isRectBasedTest()) | |
2210 newHitTestLocation = HitTestLocation(localPoint, localPointQ
uad); | |
2211 else | |
2212 newHitTestLocation = HitTestLocation(localPoint); | |
2213 newTransformState->flatten(); | |
2214 | |
2215 hitLayer = hitTestChildLayerColumns(childLayer, columnLayers[col
umnIndex - 1], result, localHitTestRect, newHitTestLocation, | |
2216 newTransformState.get(), zOffset, columnLayers, columnIndex
- 1); | |
2217 } | |
2218 | |
2219 if (hitLayer) | |
2220 return hitLayer; | |
2221 } | |
2222 } | |
2223 | |
2224 return 0; | |
2225 } | |
2226 | |
2227 void DeprecatedPaintLayer::blockSelectionGapsBoundsChanged() | 2038 void DeprecatedPaintLayer::blockSelectionGapsBoundsChanged() |
2228 { | 2039 { |
2229 setNeedsCompositingInputsUpdate(); | 2040 setNeedsCompositingInputsUpdate(); |
2230 } | 2041 } |
2231 | 2042 |
2232 void DeprecatedPaintLayer::addBlockSelectionGapsBounds(const LayoutRect& bounds) | 2043 void DeprecatedPaintLayer::addBlockSelectionGapsBounds(const LayoutRect& bounds) |
2233 { | 2044 { |
2234 m_blockSelectionGapsBounds.unite(enclosingIntRect(bounds)); | 2045 m_blockSelectionGapsBounds.unite(enclosingIntRect(bounds)); |
2235 blockSelectionGapsBoundsChanged(); | 2046 blockSelectionGapsBoundsChanged(); |
2236 } | 2047 } |
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2435 if (this != ancestorLayer && !hasVisibleContent() && !hasVisibleDescendant()
) | 2246 if (this != ancestorLayer && !hasVisibleContent() && !hasVisibleDescendant()
) |
2436 return LayoutRect(); | 2247 return LayoutRect(); |
2437 | 2248 |
2438 // The root layer is always just the size of the document. | 2249 // The root layer is always just the size of the document. |
2439 if (isRootLayer()) | 2250 if (isRootLayer()) |
2440 return LayoutRect(m_layoutObject->view()->unscaledDocumentRect()); | 2251 return LayoutRect(m_layoutObject->view()->unscaledDocumentRect()); |
2441 | 2252 |
2442 // The layer created for the LayoutFlowThread is just a helper for painting
and hit-testing, | 2253 // The layer created for the LayoutFlowThread is just a helper for painting
and hit-testing, |
2443 // and should not contribute to the bounding box. The LayoutMultiColumnSets
will contribute | 2254 // and should not contribute to the bounding box. The LayoutMultiColumnSets
will contribute |
2444 // the correct size for the layout content of the multicol container. | 2255 // the correct size for the layout content of the multicol container. |
2445 if (RuntimeEnabledFeatures::regionBasedColumnsEnabled() && layoutObject()->i
sLayoutFlowThread()) | 2256 if (layoutObject()->isLayoutFlowThread()) |
2446 return LayoutRect(); | 2257 return LayoutRect(); |
2447 | 2258 |
2448 LayoutRect result = clipper().localClipRect(); | 2259 LayoutRect result = clipper().localClipRect(); |
2449 if (result == LayoutRect::infiniteIntRect()) { | 2260 if (result == LayoutRect::infiniteIntRect()) { |
2450 LayoutPoint origin; | 2261 LayoutPoint origin; |
2451 result = physicalBoundingBox(ancestorLayer, &origin); | 2262 result = physicalBoundingBox(ancestorLayer, &origin); |
2452 | 2263 |
2453 const_cast<DeprecatedPaintLayer*>(this)->stackingNode()->updateLayerList
sIfNeeded(); | 2264 const_cast<DeprecatedPaintLayer*>(this)->stackingNode()->updateLayerList
sIfNeeded(); |
2454 | 2265 |
2455 // Reflections are implemented with Layers that hang off of the reflecte
d layer. However, | 2266 // Reflections are implemented with Layers that hang off of the reflecte
d layer. However, |
(...skipping 509 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2965 | 2776 |
2966 void showLayerTree(const blink::LayoutObject* layoutObject) | 2777 void showLayerTree(const blink::LayoutObject* layoutObject) |
2967 { | 2778 { |
2968 if (!layoutObject) { | 2779 if (!layoutObject) { |
2969 fprintf(stderr, "Cannot showLayerTree. Root is (nil)\n"); | 2780 fprintf(stderr, "Cannot showLayerTree. Root is (nil)\n"); |
2970 return; | 2781 return; |
2971 } | 2782 } |
2972 showLayerTree(layoutObject->enclosingLayer()); | 2783 showLayerTree(layoutObject->enclosingLayer()); |
2973 } | 2784 } |
2974 #endif | 2785 #endif |
OLD | NEW |