| 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 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 #include "sky/engine/platform/transforms/TransformationMatrix.h" | 73 #include "sky/engine/platform/transforms/TransformationMatrix.h" |
| 74 #include "sky/engine/platform/transforms/TranslateTransformOperation.h" | 74 #include "sky/engine/platform/transforms/TranslateTransformOperation.h" |
| 75 #include "sky/engine/public/platform/Platform.h" | 75 #include "sky/engine/public/platform/Platform.h" |
| 76 #include "sky/engine/wtf/StdLibExtras.h" | 76 #include "sky/engine/wtf/StdLibExtras.h" |
| 77 #include "sky/engine/wtf/text/CString.h" | 77 #include "sky/engine/wtf/text/CString.h" |
| 78 | 78 |
| 79 namespace blink { | 79 namespace blink { |
| 80 | 80 |
| 81 RenderLayer::RenderLayer(RenderBox* renderer, LayerType type) | 81 RenderLayer::RenderLayer(RenderBox* renderer, LayerType type) |
| 82 : m_layerType(type) | 82 : m_layerType(type) |
| 83 , m_hasSelfPaintingLayerDescendant(false) | |
| 84 , m_hasSelfPaintingLayerDescendantDirty(false) | |
| 85 , m_isRootLayer(renderer->isRenderView()) | 83 , m_isRootLayer(renderer->isRenderView()) |
| 86 , m_3DTransformedDescendantStatusDirty(true) | 84 , m_3DTransformedDescendantStatusDirty(true) |
| 87 , m_has3DTransformedDescendant(false) | 85 , m_has3DTransformedDescendant(false) |
| 88 , m_hasFilterInfo(false) | 86 , m_hasFilterInfo(false) |
| 89 , m_renderer(renderer) | 87 , m_renderer(renderer) |
| 90 , m_parent(0) | 88 , m_parent(0) |
| 91 , m_previous(0) | 89 , m_previous(0) |
| 92 , m_next(0) | 90 , m_next(0) |
| 93 , m_first(0) | 91 , m_first(0) |
| 94 , m_last(0) | 92 , m_last(0) |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 133 m_subpixelAccumulation = size; | 131 m_subpixelAccumulation = size; |
| 134 } | 132 } |
| 135 | 133 |
| 136 void RenderLayer::updateLayerPositionsAfterLayout() | 134 void RenderLayer::updateLayerPositionsAfterLayout() |
| 137 { | 135 { |
| 138 TRACE_EVENT0("blink", "RenderLayer::updateLayerPositionsAfterLayout"); | 136 TRACE_EVENT0("blink", "RenderLayer::updateLayerPositionsAfterLayout"); |
| 139 | 137 |
| 140 m_clipper.clearClipRectsIncludingDescendants(); | 138 m_clipper.clearClipRectsIncludingDescendants(); |
| 141 } | 139 } |
| 142 | 140 |
| 143 void RenderLayer::updateHasSelfPaintingLayerDescendant() const | |
| 144 { | |
| 145 ASSERT(m_hasSelfPaintingLayerDescendantDirty); | |
| 146 | |
| 147 m_hasSelfPaintingLayerDescendant = false; | |
| 148 | |
| 149 for (RenderLayer* child = firstChild(); child; child = child->nextSibling())
{ | |
| 150 if (child->isSelfPaintingLayer() || child->hasSelfPaintingLayerDescendan
t()) { | |
| 151 m_hasSelfPaintingLayerDescendant = true; | |
| 152 break; | |
| 153 } | |
| 154 } | |
| 155 | |
| 156 m_hasSelfPaintingLayerDescendantDirty = false; | |
| 157 } | |
| 158 | |
| 159 void RenderLayer::dirtyAncestorChainHasSelfPaintingLayerDescendantStatus() | |
| 160 { | |
| 161 for (RenderLayer* layer = this; layer; layer = layer->parent()) { | |
| 162 layer->m_hasSelfPaintingLayerDescendantDirty = true; | |
| 163 // If we have reached a self-painting layer, we know our parent should h
ave a self-painting descendant | |
| 164 // in this case, there is no need to dirty our ancestors further. | |
| 165 if (layer->isSelfPaintingLayer()) { | |
| 166 ASSERT(!parent() || parent()->m_hasSelfPaintingLayerDescendantDirty
|| parent()->m_hasSelfPaintingLayerDescendant); | |
| 167 break; | |
| 168 } | |
| 169 } | |
| 170 } | |
| 171 | |
| 172 void RenderLayer::updateTransformationMatrix() | 141 void RenderLayer::updateTransformationMatrix() |
| 173 { | 142 { |
| 174 if (m_transform) { | 143 if (m_transform) { |
| 175 RenderBox* box = renderBox(); | 144 RenderBox* box = renderBox(); |
| 176 ASSERT(box); | 145 ASSERT(box); |
| 177 m_transform->makeIdentity(); | 146 m_transform->makeIdentity(); |
| 178 box->style()->applyTransform(*m_transform, box->pixelSnappedBorderBoxRec
t().size(), RenderStyle::IncludeTransformOrigin); | 147 box->style()->applyTransform(*m_transform, box->pixelSnappedBorderBoxRec
t().size(), RenderStyle::IncludeTransformOrigin); |
| 179 // FIXME(sky): We shouldn't need to do this once Skia has 4x4 matrix sup
port. | 148 // FIXME(sky): We shouldn't need to do this once Skia has 4x4 matrix sup
port. |
| 180 // Until then, 3d transforms don't work right. | 149 // Until then, 3d transforms don't work right. |
| 181 m_transform->makeAffine(); | 150 m_transform->makeAffine(); |
| (...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 420 | 389 |
| 421 if (child->stackingNode()->isNormalFlowOnly()) | 390 if (child->stackingNode()->isNormalFlowOnly()) |
| 422 m_stackingNode->dirtyNormalFlowList(); | 391 m_stackingNode->dirtyNormalFlowList(); |
| 423 | 392 |
| 424 if (!child->stackingNode()->isNormalFlowOnly() || child->firstChild()) { | 393 if (!child->stackingNode()->isNormalFlowOnly() || child->firstChild()) { |
| 425 // Dirty the z-order list in which we are contained. The ancestorStackin
gContextNode() can be null in the | 394 // Dirty the z-order list in which we are contained. The ancestorStackin
gContextNode() can be null in the |
| 426 // case where we're building up generated content layers. This is ok, si
nce the lists will start | 395 // case where we're building up generated content layers. This is ok, si
nce the lists will start |
| 427 // off dirty in that case anyway. | 396 // off dirty in that case anyway. |
| 428 child->stackingNode()->dirtyStackingContextZOrderLists(); | 397 child->stackingNode()->dirtyStackingContextZOrderLists(); |
| 429 } | 398 } |
| 430 | |
| 431 dirtyAncestorChainHasSelfPaintingLayerDescendantStatus(); | |
| 432 } | 399 } |
| 433 | 400 |
| 434 RenderLayer* RenderLayer::removeChild(RenderLayer* oldChild) | 401 RenderLayer* RenderLayer::removeChild(RenderLayer* oldChild) |
| 435 { | 402 { |
| 436 if (oldChild->previousSibling()) | 403 if (oldChild->previousSibling()) |
| 437 oldChild->previousSibling()->setNextSibling(oldChild->nextSibling()); | 404 oldChild->previousSibling()->setNextSibling(oldChild->nextSibling()); |
| 438 if (oldChild->nextSibling()) | 405 if (oldChild->nextSibling()) |
| 439 oldChild->nextSibling()->setPreviousSibling(oldChild->previousSibling())
; | 406 oldChild->nextSibling()->setPreviousSibling(oldChild->previousSibling())
; |
| 440 | 407 |
| 441 if (m_first == oldChild) | 408 if (m_first == oldChild) |
| 442 m_first = oldChild->nextSibling(); | 409 m_first = oldChild->nextSibling(); |
| 443 if (m_last == oldChild) | 410 if (m_last == oldChild) |
| 444 m_last = oldChild->previousSibling(); | 411 m_last = oldChild->previousSibling(); |
| 445 | 412 |
| 446 if (oldChild->stackingNode()->isNormalFlowOnly()) | 413 if (oldChild->stackingNode()->isNormalFlowOnly()) |
| 447 m_stackingNode->dirtyNormalFlowList(); | 414 m_stackingNode->dirtyNormalFlowList(); |
| 448 if (!oldChild->stackingNode()->isNormalFlowOnly() || oldChild->firstChild())
{ | 415 if (!oldChild->stackingNode()->isNormalFlowOnly() || oldChild->firstChild())
{ |
| 449 // Dirty the z-order list in which we are contained. When called via th
e | 416 // Dirty the z-order list in which we are contained. When called via th
e |
| 450 // reattachment process in removeOnlyThisLayer, the layer may already be
disconnected | 417 // reattachment process in removeOnlyThisLayer, the layer may already be
disconnected |
| 451 // from the main layer tree, so we need to null-check the | 418 // from the main layer tree, so we need to null-check the |
| 452 // |stackingContext| value. | 419 // |stackingContext| value. |
| 453 oldChild->stackingNode()->dirtyStackingContextZOrderLists(); | 420 oldChild->stackingNode()->dirtyStackingContextZOrderLists(); |
| 454 } | 421 } |
| 455 | 422 |
| 456 oldChild->setPreviousSibling(0); | 423 oldChild->setPreviousSibling(0); |
| 457 oldChild->setNextSibling(0); | 424 oldChild->setNextSibling(0); |
| 458 oldChild->m_parent = 0; | 425 oldChild->m_parent = 0; |
| 459 | 426 |
| 460 dirtyAncestorChainHasSelfPaintingLayerDescendantStatus(); | |
| 461 | |
| 462 return oldChild; | 427 return oldChild; |
| 463 } | 428 } |
| 464 | 429 |
| 465 void RenderLayer::removeOnlyThisLayer() | 430 void RenderLayer::removeOnlyThisLayer() |
| 466 { | 431 { |
| 467 if (!m_parent) | 432 if (!m_parent) |
| 468 return; | 433 return; |
| 469 | 434 |
| 470 m_clipper.clearClipRectsIncludingDescendants(); | 435 m_clipper.clearClipRectsIncludingDescendants(); |
| 471 | 436 |
| (...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 758 convertToLayerCoords(ancestorLayer, delta); | 723 convertToLayerCoords(ancestorLayer, delta); |
| 759 result.moveBy(delta); | 724 result.moveBy(delta); |
| 760 return result; | 725 return result; |
| 761 } | 726 } |
| 762 | 727 |
| 763 bool RenderLayer::shouldBeSelfPaintingLayer() const | 728 bool RenderLayer::shouldBeSelfPaintingLayer() const |
| 764 { | 729 { |
| 765 return m_layerType == NormalLayer; | 730 return m_layerType == NormalLayer; |
| 766 } | 731 } |
| 767 | 732 |
| 768 void RenderLayer::updateSelfPaintingLayer() | |
| 769 { | |
| 770 bool isSelfPaintingLayer = shouldBeSelfPaintingLayer(); | |
| 771 if (this->isSelfPaintingLayer() == isSelfPaintingLayer) | |
| 772 return; | |
| 773 | |
| 774 m_isSelfPaintingLayer = isSelfPaintingLayer; | |
| 775 | |
| 776 if (parent()) | |
| 777 parent()->dirtyAncestorChainHasSelfPaintingLayerDescendantStatus(); | |
| 778 } | |
| 779 | |
| 780 bool RenderLayer::hasNonEmptyChildRenderers() const | 733 bool RenderLayer::hasNonEmptyChildRenderers() const |
| 781 { | 734 { |
| 782 // Some HTML can cause whitespace text nodes to have renderers, like: | 735 // Some HTML can cause whitespace text nodes to have renderers, like: |
| 783 // <div> | 736 // <div> |
| 784 // <img src=...> | 737 // <img src=...> |
| 785 // </div> | 738 // </div> |
| 786 // so test for 0x0 RenderTexts here | 739 // so test for 0x0 RenderTexts here |
| 787 for (RenderObject* child = renderer()->slowFirstChild(); child; child = chil
d->nextSibling()) { | 740 for (RenderObject* child = renderer()->slowFirstChild(); child; child = chil
d->nextSibling()) { |
| 788 if (!child->hasLayer()) { | 741 if (!child->hasLayer()) { |
| 789 if (child->isRenderInline() || !child->isBox()) | 742 if (child->isRenderInline() || !child->isBox()) |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 829 updateOrRemoveFilterEffectRenderer(); | 782 updateOrRemoveFilterEffectRenderer(); |
| 830 } | 783 } |
| 831 | 784 |
| 832 void RenderLayer::styleChanged(StyleDifference diff, const RenderStyle* oldStyle
) | 785 void RenderLayer::styleChanged(StyleDifference diff, const RenderStyle* oldStyle
) |
| 833 { | 786 { |
| 834 m_stackingNode->updateIsNormalFlowOnly(); | 787 m_stackingNode->updateIsNormalFlowOnly(); |
| 835 m_stackingNode->updateStackingNodesAfterStyleChange(oldStyle); | 788 m_stackingNode->updateStackingNodesAfterStyleChange(oldStyle); |
| 836 | 789 |
| 837 // Overlay scrollbars can make this layer self-painting so we need | 790 // Overlay scrollbars can make this layer self-painting so we need |
| 838 // to recompute the bit once scrollbars have been updated. | 791 // to recompute the bit once scrollbars have been updated. |
| 839 updateSelfPaintingLayer(); | 792 m_isSelfPaintingLayer = shouldBeSelfPaintingLayer(); |
| 840 | 793 |
| 841 updateTransform(oldStyle, renderer()->style()); | 794 updateTransform(oldStyle, renderer()->style()); |
| 842 updateFilters(oldStyle, renderer()->style()); | 795 updateFilters(oldStyle, renderer()->style()); |
| 843 } | 796 } |
| 844 | 797 |
| 845 FilterOperations RenderLayer::computeFilterOperations(const RenderStyle* style) | 798 FilterOperations RenderLayer::computeFilterOperations(const RenderStyle* style) |
| 846 { | 799 { |
| 847 return style->filter(); | 800 return style->filter(); |
| 848 } | 801 } |
| 849 | 802 |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 883 renderer()->document().view()->setHasSoftwareFilters(true); | 836 renderer()->document().view()->setHasSoftwareFilters(true); |
| 884 } | 837 } |
| 885 | 838 |
| 886 // If the filter fails to build, remove it from the layer. It will still att
empt to | 839 // If the filter fails to build, remove it from the layer. It will still att
empt to |
| 887 // go through regular processing (e.g. compositing), but never apply anythin
g. | 840 // go through regular processing (e.g. compositing), but never apply anythin
g. |
| 888 if (!filterInfo->renderer()->build(renderer(), computeFilterOperations(rende
rer()->style()))) | 841 if (!filterInfo->renderer()->build(renderer(), computeFilterOperations(rende
rer()->style()))) |
| 889 filterInfo->setRenderer(nullptr); | 842 filterInfo->setRenderer(nullptr); |
| 890 } | 843 } |
| 891 | 844 |
| 892 } // namespace blink | 845 } // namespace blink |
| 893 | |
| 894 #ifndef NDEBUG | |
| 895 void showLayerTree(const blink::RenderLayer* layer) | |
| 896 { | |
| 897 if (!layer) | |
| 898 return; | |
| 899 | |
| 900 if (blink::LocalFrame* frame = layer->renderer()->frame()) { | |
| 901 WTF::String output = externalRepresentation(frame, blink::RenderAsTextSh
owAllLayers | blink::RenderAsTextShowLayerNesting | blink::RenderAsTextShowCompo
sitedLayers | blink::RenderAsTextShowAddresses | blink::RenderAsTextShowIDAndCla
ss | blink::RenderAsTextDontUpdateLayout | blink::RenderAsTextShowLayoutState); | |
| 902 fprintf(stderr, "%s\n", output.utf8().data()); | |
| 903 } | |
| 904 } | |
| 905 | |
| 906 void showLayerTree(const blink::RenderObject* renderer) | |
| 907 { | |
| 908 if (!renderer) | |
| 909 return; | |
| 910 showLayerTree(renderer->enclosingLayer()); | |
| 911 } | |
| 912 #endif | |
| OLD | NEW |