| 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 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 | 80 |
| 81 RenderLayer::RenderLayer(RenderLayerModelObject* renderer, LayerType type) | 81 RenderLayer::RenderLayer(RenderLayerModelObject* renderer, LayerType type) |
| 82 : m_layerType(type) | 82 : m_layerType(type) |
| 83 , m_hasSelfPaintingLayerDescendant(false) | 83 , m_hasSelfPaintingLayerDescendant(false) |
| 84 , m_hasSelfPaintingLayerDescendantDirty(false) | 84 , m_hasSelfPaintingLayerDescendantDirty(false) |
| 85 , m_isRootLayer(renderer->isRenderView()) | 85 , m_isRootLayer(renderer->isRenderView()) |
| 86 , m_usedTransparency(false) | 86 , m_usedTransparency(false) |
| 87 , m_3DTransformedDescendantStatusDirty(true) | 87 , m_3DTransformedDescendantStatusDirty(true) |
| 88 , m_has3DTransformedDescendant(false) | 88 , m_has3DTransformedDescendant(false) |
| 89 , m_hasFilterInfo(false) | 89 , m_hasFilterInfo(false) |
| 90 , m_needsAncestorDependentCompositingInputsUpdate(true) | |
| 91 , m_needsDescendantDependentCompositingInputsUpdate(true) | |
| 92 , m_childNeedsCompositingInputsUpdate(true) | |
| 93 , m_hasCompositingDescendant(false) | |
| 94 , m_lostGroupedMapping(false) | 90 , m_lostGroupedMapping(false) |
| 95 , m_renderer(renderer) | 91 , m_renderer(renderer) |
| 96 , m_parent(0) | 92 , m_parent(0) |
| 97 , m_previous(0) | 93 , m_previous(0) |
| 98 , m_next(0) | 94 , m_next(0) |
| 99 , m_first(0) | 95 , m_first(0) |
| 100 , m_last(0) | 96 , m_last(0) |
| 101 , m_staticInlinePosition(0) | 97 , m_staticInlinePosition(0) |
| 102 , m_staticBlockPosition(0) | 98 , m_staticBlockPosition(0) |
| 103 , m_clipper(*renderer) | 99 , m_clipper(*renderer) |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 172 // in this case, there is no need to dirty our ancestors further. | 168 // in this case, there is no need to dirty our ancestors further. |
| 173 if (layer->isSelfPaintingLayer()) { | 169 if (layer->isSelfPaintingLayer()) { |
| 174 ASSERT(!parent() || parent()->m_hasSelfPaintingLayerDescendantDirty
|| parent()->m_hasSelfPaintingLayerDescendant); | 170 ASSERT(!parent() || parent()->m_hasSelfPaintingLayerDescendantDirty
|| parent()->m_hasSelfPaintingLayerDescendant); |
| 175 break; | 171 break; |
| 176 } | 172 } |
| 177 } | 173 } |
| 178 } | 174 } |
| 179 | 175 |
| 180 bool RenderLayer::scrollsWithRespectTo(const RenderLayer* other) const | 176 bool RenderLayer::scrollsWithRespectTo(const RenderLayer* other) const |
| 181 { | 177 { |
| 182 return ancestorScrollingLayer() != other->ancestorScrollingLayer(); | 178 return false; |
| 183 } | 179 } |
| 184 | 180 |
| 185 void RenderLayer::updateTransformationMatrix() | 181 void RenderLayer::updateTransformationMatrix() |
| 186 { | 182 { |
| 187 if (m_transform) { | 183 if (m_transform) { |
| 188 RenderBox* box = renderBox(); | 184 RenderBox* box = renderBox(); |
| 189 ASSERT(box); | 185 ASSERT(box); |
| 190 m_transform->makeIdentity(); | 186 m_transform->makeIdentity(); |
| 191 box->style()->applyTransform(*m_transform, box->pixelSnappedBorderBoxRec
t().size(), RenderStyle::IncludeTransformOrigin); | 187 box->style()->applyTransform(*m_transform, box->pixelSnappedBorderBoxRec
t().size(), RenderStyle::IncludeTransformOrigin); |
| 192 makeMatrixRenderable(*m_transform); | 188 makeMatrixRenderable(*m_transform); |
| (...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 434 | 430 |
| 435 RenderLayer* RenderLayer::enclosingPositionedAncestor() const | 431 RenderLayer* RenderLayer::enclosingPositionedAncestor() const |
| 436 { | 432 { |
| 437 RenderLayer* curr = parent(); | 433 RenderLayer* curr = parent(); |
| 438 while (curr && !curr->isPositionedContainer()) | 434 while (curr && !curr->isPositionedContainer()) |
| 439 curr = curr->parent(); | 435 curr = curr->parent(); |
| 440 | 436 |
| 441 return curr; | 437 return curr; |
| 442 } | 438 } |
| 443 | 439 |
| 444 RenderLayer* RenderLayer::enclosingTransformedAncestor() const | |
| 445 { | |
| 446 RenderLayer* curr = parent(); | |
| 447 while (curr && !curr->isRootLayer() && !curr->renderer()->hasTransform()) | |
| 448 curr = curr->parent(); | |
| 449 | |
| 450 return curr; | |
| 451 } | |
| 452 | |
| 453 LayoutPoint RenderLayer::computeOffsetFromTransformedAncestor() const | |
| 454 { | |
| 455 const AncestorDependentCompositingInputs& properties = ancestorDependentComp
ositingInputs(); | |
| 456 | |
| 457 TransformState transformState(TransformState::ApplyTransformDirection, Float
Point()); | |
| 458 // FIXME: add a test that checks flipped writing mode and ApplyContainerFlip
are correct. | |
| 459 renderer()->mapLocalToContainer(properties.transformAncestor ? properties.tr
ansformAncestor->renderer() : 0, transformState, ApplyContainerFlip); | |
| 460 transformState.flatten(); | |
| 461 return LayoutPoint(transformState.lastPlanarPoint()); | |
| 462 } | |
| 463 | |
| 464 const RenderLayer* RenderLayer::compositingContainer() const | 440 const RenderLayer* RenderLayer::compositingContainer() const |
| 465 { | 441 { |
| 466 if (stackingNode()->isNormalFlowOnly()) | 442 if (stackingNode()->isNormalFlowOnly()) |
| 467 return parent(); | 443 return parent(); |
| 468 if (RenderLayerStackingNode* ancestorStackingNode = stackingNode()->ancestor
StackingContextNode()) | 444 if (RenderLayerStackingNode* ancestorStackingNode = stackingNode()->ancestor
StackingContextNode()) |
| 469 return ancestorStackingNode->layer(); | 445 return ancestorStackingNode->layer(); |
| 470 return 0; | 446 return 0; |
| 471 } | 447 } |
| 472 | 448 |
| 473 RenderLayer* RenderLayer::enclosingFilterLayer(IncludeSelfOrNot includeSelf) con
st | 449 RenderLayer* RenderLayer::enclosingFilterLayer(IncludeSelfOrNot includeSelf) con
st |
| 474 { | 450 { |
| 475 const RenderLayer* curr = (includeSelf == IncludeSelf) ? this : parent(); | 451 const RenderLayer* curr = (includeSelf == IncludeSelf) ? this : parent(); |
| 476 for (; curr; curr = curr->parent()) { | 452 for (; curr; curr = curr->parent()) { |
| 477 if (curr->requiresFullLayerImageForFilters()) | 453 if (curr->requiresFullLayerImageForFilters()) |
| 478 return const_cast<RenderLayer*>(curr); | 454 return const_cast<RenderLayer*>(curr); |
| 479 } | 455 } |
| 480 | 456 |
| 481 return 0; | 457 return 0; |
| 482 } | 458 } |
| 483 | 459 |
| 484 void RenderLayer::updateAncestorDependentCompositingInputs(const AncestorDepende
ntCompositingInputs& compositingInputs) | |
| 485 { | |
| 486 m_ancestorDependentCompositingInputs = compositingInputs; | |
| 487 m_needsAncestorDependentCompositingInputsUpdate = false; | |
| 488 } | |
| 489 | |
| 490 void RenderLayer::updateDescendantDependentCompositingInputs(const DescendantDep
endentCompositingInputs& compositingInputs) | |
| 491 { | |
| 492 m_descendantDependentCompositingInputs = compositingInputs; | |
| 493 m_needsDescendantDependentCompositingInputsUpdate = false; | |
| 494 } | |
| 495 | |
| 496 void RenderLayer::setHasCompositingDescendant(bool hasCompositingDescendant) | |
| 497 { | |
| 498 // FIXME(sky): Remove | |
| 499 m_hasCompositingDescendant = hasCompositingDescendant; | |
| 500 } | |
| 501 | |
| 502 | |
| 503 bool RenderLayer::hasAncestorWithFilterOutsets() const | 460 bool RenderLayer::hasAncestorWithFilterOutsets() const |
| 504 { | 461 { |
| 505 for (const RenderLayer* curr = this; curr; curr = curr->parent()) { | 462 for (const RenderLayer* curr = this; curr; curr = curr->parent()) { |
| 506 RenderLayerModelObject* renderer = curr->renderer(); | 463 RenderLayerModelObject* renderer = curr->renderer(); |
| 507 if (renderer->style()->hasFilterOutsets()) | 464 if (renderer->style()->hasFilterOutsets()) |
| 508 return true; | 465 return true; |
| 509 } | 466 } |
| 510 return false; | 467 return false; |
| 511 } | 468 } |
| 512 | 469 |
| (...skipping 1041 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1554 if (offsetFromRoot) | 1511 if (offsetFromRoot) |
| 1555 delta = *offsetFromRoot; | 1512 delta = *offsetFromRoot; |
| 1556 else | 1513 else |
| 1557 convertToLayerCoords(ancestorLayer, delta); | 1514 convertToLayerCoords(ancestorLayer, delta); |
| 1558 | 1515 |
| 1559 LayoutRect result = logicalBoundingBox(); | 1516 LayoutRect result = logicalBoundingBox(); |
| 1560 result.moveBy(delta); | 1517 result.moveBy(delta); |
| 1561 return result; | 1518 return result; |
| 1562 } | 1519 } |
| 1563 | 1520 |
| 1564 static void expandRectForReflectionAndStackingChildren(const RenderLayer* ancest
orLayer, RenderLayer::CalculateBoundsOptions options, LayoutRect& result) | 1521 static void expandRectForReflectionAndStackingChildren(const RenderLayer* ancest
orLayer, LayoutRect& result) |
| 1565 { | 1522 { |
| 1566 ASSERT(ancestorLayer->stackingNode()->isStackingContext() || !ancestorLayer-
>stackingNode()->hasPositiveZOrderList()); | 1523 ASSERT(ancestorLayer->stackingNode()->isStackingContext() || !ancestorLayer-
>stackingNode()->hasPositiveZOrderList()); |
| 1567 | 1524 |
| 1568 #if ENABLE(ASSERT) | 1525 #if ENABLE(ASSERT) |
| 1569 LayerListMutationDetector mutationChecker(const_cast<RenderLayer*>(ancestorL
ayer)->stackingNode()); | 1526 LayerListMutationDetector mutationChecker(const_cast<RenderLayer*>(ancestorL
ayer)->stackingNode()); |
| 1570 #endif | 1527 #endif |
| 1571 | 1528 |
| 1572 RenderLayerStackingNodeIterator iterator(*ancestorLayer->stackingNode(), All
Children); | 1529 RenderLayerStackingNodeIterator iterator(*ancestorLayer->stackingNode(), All
Children); |
| 1573 while (RenderLayerStackingNode* node = iterator.next()) { | 1530 while (RenderLayerStackingNode* node = iterator.next()) { |
| 1574 result.unite(node->layer()->boundingBoxForCompositing(ancestorLayer, opt
ions)); | 1531 result.unite(node->layer()->boundingBoxForCompositing(ancestorLayer)); |
| 1575 } | 1532 } |
| 1576 } | 1533 } |
| 1577 | 1534 |
| 1578 LayoutRect RenderLayer::physicalBoundingBoxIncludingReflectionAndStackingChildre
n(const RenderLayer* ancestorLayer, const LayoutPoint& offsetFromRoot) const | 1535 LayoutRect RenderLayer::physicalBoundingBoxIncludingReflectionAndStackingChildre
n(const RenderLayer* ancestorLayer, const LayoutPoint& offsetFromRoot) const |
| 1579 { | 1536 { |
| 1580 LayoutPoint origin; | 1537 LayoutPoint origin; |
| 1581 LayoutRect result = physicalBoundingBox(ancestorLayer, &origin); | 1538 LayoutRect result = physicalBoundingBox(ancestorLayer, &origin); |
| 1582 | 1539 |
| 1583 const_cast<RenderLayer*>(this)->stackingNode()->updateLayerListsIfNeeded(); | 1540 const_cast<RenderLayer*>(this)->stackingNode()->updateLayerListsIfNeeded(); |
| 1584 | 1541 |
| 1585 expandRectForReflectionAndStackingChildren(this, DoNotApplyBoundsChickenEggH
acks, result); | 1542 expandRectForReflectionAndStackingChildren(this, result); |
| 1586 | 1543 |
| 1587 result.moveBy(offsetFromRoot); | 1544 result.moveBy(offsetFromRoot); |
| 1588 return result; | 1545 return result; |
| 1589 } | 1546 } |
| 1590 | 1547 |
| 1591 LayoutRect RenderLayer::boundingBoxForCompositing(const RenderLayer* ancestorLay
er, CalculateBoundsOptions options) const | 1548 LayoutRect RenderLayer::boundingBoxForCompositing(const RenderLayer* ancestorLay
er) const |
| 1592 { | 1549 { |
| 1593 if (!isSelfPaintingLayer()) | 1550 if (!isSelfPaintingLayer()) |
| 1594 return LayoutRect(); | 1551 return LayoutRect(); |
| 1595 | 1552 |
| 1596 if (!ancestorLayer) | 1553 if (!ancestorLayer) |
| 1597 ancestorLayer = this; | 1554 ancestorLayer = this; |
| 1598 | 1555 |
| 1599 // The root layer is always just the size of the document. | 1556 // The root layer is always just the size of the document. |
| 1600 if (isRootLayer()) | 1557 if (isRootLayer()) |
| 1601 return m_renderer->view()->unscaledDocumentRect(); | 1558 return m_renderer->view()->unscaledDocumentRect(); |
| 1602 | 1559 |
| 1603 const bool shouldIncludeTransform = paintsWithTransform() || (options == App
lyBoundsChickenEggHacks && transform()); | 1560 const bool shouldIncludeTransform = paintsWithTransform(); |
| 1604 | 1561 |
| 1605 LayoutRect localClipRect = clipper().localClipRect(); | 1562 LayoutRect localClipRect = clipper().localClipRect(); |
| 1606 if (localClipRect != PaintInfo::infiniteRect()) { | 1563 if (localClipRect != PaintInfo::infiniteRect()) { |
| 1607 if (shouldIncludeTransform) | 1564 if (shouldIncludeTransform) |
| 1608 localClipRect = transform()->mapRect(localClipRect); | 1565 localClipRect = transform()->mapRect(localClipRect); |
| 1609 | 1566 |
| 1610 LayoutPoint delta; | 1567 LayoutPoint delta; |
| 1611 convertToLayerCoords(ancestorLayer, delta); | 1568 convertToLayerCoords(ancestorLayer, delta); |
| 1612 localClipRect.moveBy(delta); | 1569 localClipRect.moveBy(delta); |
| 1613 return localClipRect; | 1570 return localClipRect; |
| 1614 } | 1571 } |
| 1615 | 1572 |
| 1616 LayoutPoint origin; | 1573 LayoutPoint origin; |
| 1617 LayoutRect result = physicalBoundingBox(ancestorLayer, &origin); | 1574 LayoutRect result = physicalBoundingBox(ancestorLayer, &origin); |
| 1618 | 1575 |
| 1619 const_cast<RenderLayer*>(this)->stackingNode()->updateLayerListsIfNeeded(); | 1576 const_cast<RenderLayer*>(this)->stackingNode()->updateLayerListsIfNeeded(); |
| 1620 | 1577 |
| 1621 expandRectForReflectionAndStackingChildren(this, options, result); | 1578 expandRectForReflectionAndStackingChildren(this, result); |
| 1622 | 1579 |
| 1623 // FIXME: We can optimize the size of the composited layers, by not enlargin
g | 1580 // FIXME: We can optimize the size of the composited layers, by not enlargin
g |
| 1624 // filtered areas with the outsets if we know that the filter is going to re
nder in hardware. | 1581 // filtered areas with the outsets if we know that the filter is going to re
nder in hardware. |
| 1625 // https://bugs.webkit.org/show_bug.cgi?id=81239 | 1582 // https://bugs.webkit.org/show_bug.cgi?id=81239 |
| 1626 m_renderer->style()->filterOutsets().expandRect(result); | 1583 m_renderer->style()->filterOutsets().expandRect(result); |
| 1627 | 1584 |
| 1628 if (shouldIncludeTransform) | 1585 if (shouldIncludeTransform) |
| 1629 result = transform()->mapRect(result); | 1586 result = transform()->mapRect(result); |
| 1630 | 1587 |
| 1631 LayoutPoint delta; | 1588 LayoutPoint delta; |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1783 } | 1740 } |
| 1784 } | 1741 } |
| 1785 | 1742 |
| 1786 void showLayerTree(const blink::RenderObject* renderer) | 1743 void showLayerTree(const blink::RenderObject* renderer) |
| 1787 { | 1744 { |
| 1788 if (!renderer) | 1745 if (!renderer) |
| 1789 return; | 1746 return; |
| 1790 showLayerTree(renderer->enclosingLayer()); | 1747 showLayerTree(renderer->enclosingLayer()); |
| 1791 } | 1748 } |
| 1792 #endif | 1749 #endif |
| OLD | NEW |