| 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 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 | 95 |
| 96 RenderLayer::~RenderLayer() | 96 RenderLayer::~RenderLayer() |
| 97 { | 97 { |
| 98 } | 98 } |
| 99 | 99 |
| 100 void RenderLayer::updateLayerPositionsAfterLayout() | 100 void RenderLayer::updateLayerPositionsAfterLayout() |
| 101 { | 101 { |
| 102 m_clipper.clearClipRectsIncludingDescendants(); | 102 m_clipper.clearClipRectsIncludingDescendants(); |
| 103 } | 103 } |
| 104 | 104 |
| 105 void RenderLayer::updateTransformationMatrix() | |
| 106 { | |
| 107 if (m_transform) { | |
| 108 RenderBox* box = renderer(); | |
| 109 m_transform->makeIdentity(); | |
| 110 box->style()->applyTransform(*m_transform, box->pixelSnappedBorderBoxRec
t().size(), RenderStyle::IncludeTransformOrigin); | |
| 111 // FIXME(sky): We shouldn't need to do this once Skia has 4x4 matrix sup
port. | |
| 112 // Until then, 3d transforms don't work right. | |
| 113 m_transform->makeAffine(); | |
| 114 } | |
| 115 } | |
| 116 | |
| 117 void RenderLayer::updateTransform(const RenderStyle* oldStyle, RenderStyle* newS
tyle) | |
| 118 { | |
| 119 if (oldStyle && newStyle->transformDataEquivalent(*oldStyle)) | |
| 120 return; | |
| 121 | |
| 122 // hasTransform() on the renderer is also true when there is transform-style
: preserve-3d or perspective set, | |
| 123 // so check style too. | |
| 124 bool hasTransform = renderer()->hasTransform() && newStyle->hasTransform(); | |
| 125 bool had3DTransform = has3DTransform(); | |
| 126 | |
| 127 bool hadTransform = m_transform; | |
| 128 if (hasTransform != hadTransform) { | |
| 129 if (hasTransform) | |
| 130 m_transform = adoptPtr(new TransformationMatrix); | |
| 131 else | |
| 132 m_transform.clear(); | |
| 133 | |
| 134 // Layers with transforms act as clip rects roots, so clear the cached c
lip rects here. | |
| 135 m_clipper.clearClipRectsIncludingDescendants(); | |
| 136 } else if (hasTransform) { | |
| 137 m_clipper.clearClipRectsIncludingDescendants(AbsoluteClipRects); | |
| 138 } | |
| 139 | |
| 140 updateTransformationMatrix(); | |
| 141 | |
| 142 if (had3DTransform != has3DTransform()) | |
| 143 dirty3DTransformedDescendantStatus(); | |
| 144 } | |
| 145 | 105 |
| 146 void RenderLayer::dirty3DTransformedDescendantStatus() | 106 void RenderLayer::dirty3DTransformedDescendantStatus() |
| 147 { | 107 { |
| 148 RenderLayerStackingNode* stackingNode = m_stackingNode->ancestorStackingCont
extNode(); | 108 RenderLayerStackingNode* stackingNode = m_stackingNode->ancestorStackingCont
extNode(); |
| 149 if (!stackingNode) | 109 if (!stackingNode) |
| 150 return; | 110 return; |
| 151 | 111 |
| 152 stackingNode->layer()->m_3DTransformedDescendantStatusDirty = true; | 112 stackingNode->layer()->m_3DTransformedDescendantStatusDirty = true; |
| 153 | 113 |
| 154 // This propagates up through preserve-3d hierarchies to the enclosing flatt
ening layer. | 114 // This propagates up through preserve-3d hierarchies to the enclosing flatt
ening layer. |
| 155 // Note that preserves3D() creates stacking context, so we can just run up t
he stacking containers. | 115 // Note that preserves3D() creates stacking context, so we can just run up t
he stacking containers. |
| 156 while (stackingNode && stackingNode->layer()->preserves3D()) { | 116 while (stackingNode && stackingNode->layer()->renderer()->style()->preserves
3D()) { |
| 157 stackingNode->layer()->m_3DTransformedDescendantStatusDirty = true; | 117 stackingNode->layer()->m_3DTransformedDescendantStatusDirty = true; |
| 158 stackingNode = stackingNode->ancestorStackingContextNode(); | 118 stackingNode = stackingNode->ancestorStackingContextNode(); |
| 159 } | 119 } |
| 160 } | 120 } |
| 161 | 121 |
| 162 // Return true if this layer or any preserve-3d descendants have 3d. | 122 // Return true if this layer or any preserve-3d descendants have 3d. |
| 163 bool RenderLayer::update3DTransformedDescendantStatus() | 123 bool RenderLayer::update3DTransformedDescendantStatus() |
| 164 { | 124 { |
| 165 if (m_3DTransformedDescendantStatusDirty) { | 125 if (m_3DTransformedDescendantStatusDirty) { |
| 166 m_has3DTransformedDescendant = false; | 126 m_has3DTransformedDescendant = false; |
| 167 | 127 |
| 168 m_stackingNode->updateZOrderLists(); | 128 m_stackingNode->updateZOrderLists(); |
| 169 | 129 |
| 170 // Transformed or preserve-3d descendants can only be in the z-order lis
ts, not | 130 // Transformed or preserve-3d descendants can only be in the z-order lis
ts, not |
| 171 // in the normal flow list, so we only need to check those. | 131 // in the normal flow list, so we only need to check those. |
| 172 RenderLayerStackingNodeIterator iterator(*m_stackingNode.get(), Positive
ZOrderChildren); | 132 RenderLayerStackingNodeIterator iterator(*m_stackingNode.get(), Positive
ZOrderChildren); |
| 173 while (RenderLayerStackingNode* node = iterator.next()) | 133 while (RenderLayerStackingNode* node = iterator.next()) |
| 174 m_has3DTransformedDescendant |= node->layer()->update3DTransformedDe
scendantStatus(); | 134 m_has3DTransformedDescendant |= node->layer()->update3DTransformedDe
scendantStatus(); |
| 175 | 135 |
| 176 m_3DTransformedDescendantStatusDirty = false; | 136 m_3DTransformedDescendantStatusDirty = false; |
| 177 } | 137 } |
| 178 | 138 |
| 179 // If we live in a 3d hierarchy, then the layer at the root of that hierarch
y needs | 139 // If we live in a 3d hierarchy, then the layer at the root of that hierarch
y needs |
| 180 // the m_has3DTransformedDescendant set. | 140 // the m_has3DTransformedDescendant set. |
| 181 if (preserves3D()) | 141 if (renderer()->style()->preserves3D()) |
| 182 return has3DTransform() || m_has3DTransformedDescendant; | 142 return renderer()->has3DTransform() || m_has3DTransformedDescendant; |
| 183 | 143 |
| 184 return has3DTransform(); | 144 return renderer()->has3DTransform(); |
| 185 } | 145 } |
| 186 | 146 |
| 187 IntSize RenderLayer::size() const | 147 IntSize RenderLayer::size() const |
| 188 { | 148 { |
| 189 // FIXME: Is snapping the size really needed here? | 149 // FIXME: Is snapping the size really needed here? |
| 190 RenderBox* box = renderer(); | 150 RenderBox* box = renderer(); |
| 191 return pixelSnappedIntSize(box->size(), box->location()); | 151 return pixelSnappedIntSize(box->size(), box->location()); |
| 192 } | 152 } |
| 193 | 153 |
| 194 LayoutPoint RenderLayer::location() const | 154 LayoutPoint RenderLayer::location() const |
| (...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 564 | 524 |
| 565 if (!ancestorLayer) | 525 if (!ancestorLayer) |
| 566 ancestorLayer = this; | 526 ancestorLayer = this; |
| 567 | 527 |
| 568 // The root layer is always just the size of the document. | 528 // The root layer is always just the size of the document. |
| 569 if (isRootLayer()) | 529 if (isRootLayer()) |
| 570 return m_renderer->view()->unscaledDocumentRect(); | 530 return m_renderer->view()->unscaledDocumentRect(); |
| 571 | 531 |
| 572 LayoutRect localClipRect = clipper().localClipRect(); | 532 LayoutRect localClipRect = clipper().localClipRect(); |
| 573 if (localClipRect != PaintInfo::infiniteRect()) { | 533 if (localClipRect != PaintInfo::infiniteRect()) { |
| 574 if (transform()) | 534 if (renderer()->transform()) |
| 575 localClipRect = transform()->mapRect(localClipRect); | 535 localClipRect = renderer()->transform()->mapRect(localClipRect); |
| 576 | 536 |
| 577 LayoutPoint delta; | 537 LayoutPoint delta; |
| 578 convertToLayerCoords(ancestorLayer, delta); | 538 convertToLayerCoords(ancestorLayer, delta); |
| 579 localClipRect.moveBy(delta); | 539 localClipRect.moveBy(delta); |
| 580 return localClipRect; | 540 return localClipRect; |
| 581 } | 541 } |
| 582 | 542 |
| 583 LayoutPoint origin; | 543 LayoutPoint origin; |
| 584 LayoutRect result = physicalBoundingBox(ancestorLayer, &origin); | 544 LayoutRect result = physicalBoundingBox(ancestorLayer, &origin); |
| 585 | 545 |
| 586 const_cast<RenderLayer*>(this)->stackingNode()->updateLayerListsIfNeeded(); | 546 const_cast<RenderLayer*>(this)->stackingNode()->updateLayerListsIfNeeded(); |
| 587 | 547 |
| 588 expandRectForReflectionAndStackingChildren(this, result); | 548 expandRectForReflectionAndStackingChildren(this, result); |
| 589 | 549 |
| 590 // FIXME: We can optimize the size of the composited layers, by not enlargin
g | 550 // FIXME: We can optimize the size of the composited layers, by not enlargin
g |
| 591 // filtered areas with the outsets if we know that the filter is going to re
nder in hardware. | 551 // filtered areas with the outsets if we know that the filter is going to re
nder in hardware. |
| 592 // https://bugs.webkit.org/show_bug.cgi?id=81239 | 552 // https://bugs.webkit.org/show_bug.cgi?id=81239 |
| 593 m_renderer->style()->filterOutsets().expandRect(result); | 553 m_renderer->style()->filterOutsets().expandRect(result); |
| 594 | 554 |
| 595 if (transform()) | 555 if (renderer()->transform()) |
| 596 result = transform()->mapRect(result); | 556 result = renderer()->transform()->mapRect(result); |
| 597 | 557 |
| 598 LayoutPoint delta; | 558 LayoutPoint delta; |
| 599 convertToLayerCoords(ancestorLayer, delta); | 559 convertToLayerCoords(ancestorLayer, delta); |
| 600 result.moveBy(delta); | 560 result.moveBy(delta); |
| 601 return result; | 561 return result; |
| 602 } | 562 } |
| 603 | 563 |
| 604 bool RenderLayer::shouldBeSelfPaintingLayer() const | 564 bool RenderLayer::shouldBeSelfPaintingLayer() const |
| 605 { | 565 { |
| 606 return m_layerType == NormalLayer; | 566 return m_layerType == NormalLayer; |
| 607 } | 567 } |
| 608 | 568 |
| 609 void RenderLayer::styleChanged(StyleDifference diff, const RenderStyle* oldStyle
) | 569 void RenderLayer::styleChanged(StyleDifference diff, const RenderStyle* oldStyle
) |
| 610 { | 570 { |
| 611 m_stackingNode->updateIsNormalFlowOnly(); | 571 m_stackingNode->updateIsNormalFlowOnly(); |
| 612 m_stackingNode->updateStackingNodesAfterStyleChange(oldStyle); | 572 m_stackingNode->updateStackingNodesAfterStyleChange(oldStyle); |
| 613 | 573 |
| 614 // Overlay scrollbars can make this layer self-painting so we need | 574 // Overlay scrollbars can make this layer self-painting so we need |
| 615 // to recompute the bit once scrollbars have been updated. | 575 // to recompute the bit once scrollbars have been updated. |
| 616 m_isSelfPaintingLayer = shouldBeSelfPaintingLayer(); | 576 m_isSelfPaintingLayer = shouldBeSelfPaintingLayer(); |
| 617 | |
| 618 updateTransform(oldStyle, renderer()->style()); | |
| 619 } | 577 } |
| 620 | 578 |
| 621 } // namespace blink | 579 } // namespace blink |
| OLD | NEW |