| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "platform/graphics/paint/TransformPaintPropertyNode.h" | 5 #include "platform/graphics/paint/TransformPaintPropertyNode.h" |
| 6 | 6 |
| 7 #include "platform/graphics/paint/PropertyTreeState.h" | 7 #include "platform/graphics/paint/PropertyTreeState.h" |
| 8 | 8 |
| 9 namespace blink { | 9 namespace blink { |
| 10 | 10 |
| 11 // The root of the transform tree. The root transform node references the root | 11 // The root of the transform tree. The root transform node references the root |
| 12 // scroll node. | 12 // scroll node. |
| 13 TransformPaintPropertyNode* TransformPaintPropertyNode::root() { | 13 TransformPaintPropertyNode* TransformPaintPropertyNode::root() { |
| 14 DEFINE_STATIC_REF(TransformPaintPropertyNode, root, | 14 DEFINE_STATIC_REF(TransformPaintPropertyNode, root, |
| 15 adoptRef(new TransformPaintPropertyNode( | 15 adoptRef(new TransformPaintPropertyNode( |
| 16 nullptr, TransformationMatrix(), FloatPoint3D(), false, | 16 nullptr, TransformationMatrix(), FloatPoint3D(), false, |
| 17 0, CompositingReasonNone, CompositorElementId(), | 17 0, CompositingReasonNone, CompositorElementId(), |
| 18 ScrollPaintPropertyNode::root()))); | 18 ScrollPaintPropertyNode::root()))); |
| 19 return root; | 19 return root; |
| 20 } | 20 } |
| 21 | 21 |
| 22 const ScrollPaintPropertyNode* |
| 23 TransformPaintPropertyNode::findEnclosingScrollNode() const { |
| 24 if (m_scroll) |
| 25 return m_scroll.get(); |
| 26 |
| 27 for (const auto* ancestor = parent(); ancestor; |
| 28 ancestor = ancestor->parent()) { |
| 29 if (const auto* scrollNode = ancestor->scrollNode()) |
| 30 return scrollNode; |
| 31 } |
| 32 // The root transform node references the root scroll node so a scroll node |
| 33 // should always exist. |
| 34 NOTREACHED(); |
| 35 return nullptr; |
| 36 } |
| 37 |
| 22 String TransformPaintPropertyNode::toString() const { | 38 String TransformPaintPropertyNode::toString() const { |
| 23 auto transform = String::format( | 39 auto transform = String::format( |
| 24 "parent=%p transform=%s origin=%s flattensInheritedTransform=%s " | 40 "parent=%p transform=%s origin=%s flattensInheritedTransform=%s " |
| 25 "renderingContextId=%x directCompositingReasons=%s " | 41 "renderingContextId=%x directCompositingReasons=%s " |
| 26 "compositorElementId=(%d, %d)", | 42 "compositorElementId=(%d, %d)", |
| 27 m_parent.get(), m_matrix.toString().ascii().data(), | 43 m_parent.get(), m_matrix.toString().ascii().data(), |
| 28 m_origin.toString().ascii().data(), | 44 m_origin.toString().ascii().data(), |
| 29 m_flattensInheritedTransform ? "yes" : "no", m_renderingContextId, | 45 m_flattensInheritedTransform ? "yes" : "no", m_renderingContextId, |
| 30 compositingReasonsAsString(m_directCompositingReasons).ascii().data(), | 46 compositingReasonsAsString(m_directCompositingReasons).ascii().data(), |
| 31 m_compositorElementId.primaryId, m_compositorElementId.secondaryId); | 47 m_compositorElementId.primaryId, m_compositorElementId.secondaryId); |
| 32 if (m_scroll) | 48 if (m_scroll) |
| 33 return transform + " scroll=" + m_scroll->toString(); | 49 return transform + " scroll=" + m_scroll->toString(); |
| 34 return transform; | 50 return transform; |
| 35 } | 51 } |
| 36 | 52 |
| 37 #if DCHECK_IS_ON() | 53 #if DCHECK_IS_ON() |
| 38 | 54 |
| 39 String TransformPaintPropertyNode::toTreeString() const { | 55 String TransformPaintPropertyNode::toTreeString() const { |
| 40 return blink::PropertyTreeStatePrinter<blink::TransformPaintPropertyNode>() | 56 return blink::PropertyTreeStatePrinter<blink::TransformPaintPropertyNode>() |
| 41 .pathAsString(this); | 57 .pathAsString(this); |
| 42 } | 58 } |
| 43 | 59 |
| 44 #endif | 60 #endif |
| 45 | 61 |
| 46 } // namespace blink | 62 } // namespace blink |
| OLD | NEW |