| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 1999 Antti Koivisto (koivisto@kde.org) | 2 * Copyright (C) 1999 Antti Koivisto (koivisto@kde.org) |
| 3 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights
reserved. | 3 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights
reserved. |
| 4 * Copyright (C) 2011 Adobe Systems Incorporated. All rights reserved. | 4 * Copyright (C) 2011 Adobe Systems Incorporated. All rights reserved. |
| 5 * | 5 * |
| 6 * This library is free software; you can redistribute it and/or | 6 * This library is free software; you can redistribute it and/or |
| 7 * modify it under the terms of the GNU Library General Public | 7 * modify it under the terms of the GNU Library General Public |
| 8 * License as published by the Free Software Foundation; either | 8 * License as published by the Free Software Foundation; either |
| 9 * version 2 of the License, or (at your option) any later version. | 9 * version 2 of the License, or (at your option) any later version. |
| 10 * | 10 * |
| (...skipping 865 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 876 case CSSPropertyBottom: | 876 case CSSPropertyBottom: |
| 877 case CSSPropertyRight: | 877 case CSSPropertyRight: |
| 878 return true; | 878 return true; |
| 879 default: | 879 default: |
| 880 break; | 880 break; |
| 881 } | 881 } |
| 882 } | 882 } |
| 883 return false; | 883 return false; |
| 884 } | 884 } |
| 885 | 885 |
| 886 inline bool requireTransformOrigin(const Vector<RefPtr<TransformOperation>>& tra
nsformOperations, ComputedStyle::ApplyTransformOrigin applyOrigin, ComputedStyle
::ApplyMotionPath applyMotionPath) | 886 bool ComputedStyle::requireTransformOrigin(ApplyTransformOrigin applyOrigin, App
lyMotionPath applyMotionPath) const |
| 887 { | 887 { |
| 888 const Vector<RefPtr<TransformOperation>>& transformOperations = transform().
operations(); |
| 889 |
| 888 // transform-origin brackets the transform with translate operations. | 890 // transform-origin brackets the transform with translate operations. |
| 889 // Optimize for the case where the only transform is a translation, since th
e transform-origin is irrelevant | 891 // Optimize for the case where the only transform is a translation, since th
e transform-origin is irrelevant |
| 890 // in that case. | 892 // in that case. |
| 891 if (applyOrigin != ComputedStyle::IncludeTransformOrigin) | 893 if (applyOrigin != IncludeTransformOrigin) |
| 892 return false; | 894 return false; |
| 893 | 895 |
| 894 if (applyMotionPath == ComputedStyle::IncludeMotionPath) | 896 if (applyMotionPath == IncludeMotionPath) |
| 895 return true; | 897 return true; |
| 896 | 898 |
| 897 unsigned size = transformOperations.size(); | 899 unsigned size = transformOperations.size(); |
| 898 for (unsigned i = 0; i < size; ++i) { | 900 for (unsigned i = 0; i < size; ++i) { |
| 899 TransformOperation::OperationType type = transformOperations[i]->type(); | 901 TransformOperation::OperationType type = transformOperations[i]->type(); |
| 900 if (type != TransformOperation::TranslateX | 902 if (type != TransformOperation::TranslateX |
| 901 && type != TransformOperation::TranslateY | 903 && type != TransformOperation::TranslateY |
| 902 && type != TransformOperation::Translate | 904 && type != TransformOperation::Translate |
| 903 && type != TransformOperation::TranslateZ | 905 && type != TransformOperation::TranslateZ |
| 904 && type != TransformOperation::Translate3D) | 906 && type != TransformOperation::Translate3D) |
| 905 return true; | 907 return true; |
| 906 } | 908 } |
| 907 | 909 |
| 908 return false; | 910 return scale() || rotate(); |
| 909 } | 911 } |
| 910 | 912 |
| 911 void ComputedStyle::applyTransform(TransformationMatrix& transform, const Layout
Size& borderBoxSize, ApplyTransformOrigin applyOrigin, ApplyMotionPath applyMoti
onPath) const | 913 void ComputedStyle::applyTransform(TransformationMatrix& result, const LayoutSiz
e& borderBoxSize, ApplyTransformOrigin applyOrigin, ApplyMotionPath applyMotionP
ath, ApplyIndependentTransformProperties applyIndependentTransformProperties) co
nst |
| 912 { | 914 { |
| 913 applyTransform(transform, FloatRect(FloatPoint(), FloatSize(borderBoxSize)),
applyOrigin, applyMotionPath); | 915 applyTransform(result, FloatRect(FloatPoint(), FloatSize(borderBoxSize)), ap
plyOrigin, applyMotionPath, applyIndependentTransformProperties); |
| 914 } | 916 } |
| 915 | 917 |
| 916 void ComputedStyle::applyTransform(TransformationMatrix& transform, const FloatR
ect& boundingBox, ApplyTransformOrigin applyOrigin, ApplyMotionPath applyMotionP
ath) const | 918 void ComputedStyle::applyTransform(TransformationMatrix& result, const FloatRect
& boundingBox, ApplyTransformOrigin applyOrigin, ApplyMotionPath applyMotionPath
, ApplyIndependentTransformProperties applyIndependentTransformProperties) const |
| 917 { | 919 { |
| 918 if (!hasMotionPath()) | 920 if (!hasMotionPath()) |
| 919 applyMotionPath = ExcludeMotionPath; | 921 applyMotionPath = ExcludeMotionPath; |
| 920 const Vector<RefPtr<TransformOperation>>& transformOperations = rareNonInher
itedData->m_transform->m_operations.operations(); | 922 bool applyTransformOrigin = requireTransformOrigin(applyOrigin, applyMotionP
ath); |
| 921 bool applyTransformOrigin = requireTransformOrigin(transformOperations, appl
yOrigin, applyMotionPath); | |
| 922 | 923 |
| 923 float offsetX = transformOriginX().type() == Percent ? boundingBox.x() : 0; | 924 float offsetX = transformOriginX().type() == Percent ? boundingBox.x() : 0; |
| 924 float offsetY = transformOriginY().type() == Percent ? boundingBox.y() : 0; | 925 float offsetY = transformOriginY().type() == Percent ? boundingBox.y() : 0; |
| 925 | 926 |
| 926 if (applyTransformOrigin) { | 927 if (applyTransformOrigin) { |
| 927 transform.translate3d(floatValueForLength(transformOriginX(), boundingBo
x.width()) + offsetX, | 928 result.translate3d(floatValueForLength(transformOriginX(), boundingBox.w
idth()) + offsetX, |
| 928 floatValueForLength(transformOriginY(), boundingBox.height()) + offs
etY, | 929 floatValueForLength(transformOriginY(), boundingBox.height()) + offs
etY, |
| 929 transformOriginZ()); | 930 transformOriginZ()); |
| 930 } | 931 } |
| 931 | 932 |
| 933 if (applyIndependentTransformProperties == IncludeIndependentTransformProper
ties) { |
| 934 if (translate()) |
| 935 translate()->apply(result, boundingBox.size()); |
| 936 |
| 937 if (rotate()) |
| 938 rotate()->apply(result, boundingBox.size()); |
| 939 |
| 940 if (scale()) |
| 941 scale()->apply(result, boundingBox.size()); |
| 942 } |
| 943 |
| 932 if (applyMotionPath == ComputedStyle::IncludeMotionPath) | 944 if (applyMotionPath == ComputedStyle::IncludeMotionPath) |
| 933 applyMotionPathTransform(transform); | 945 applyMotionPathTransform(result); |
| 934 | 946 |
| 947 const Vector<RefPtr<TransformOperation>>& transformOperations = transform().
operations(); |
| 935 unsigned size = transformOperations.size(); | 948 unsigned size = transformOperations.size(); |
| 936 for (unsigned i = 0; i < size; ++i) | 949 for (unsigned i = 0; i < size; ++i) |
| 937 transformOperations[i]->apply(transform, boundingBox.size()); | 950 transformOperations[i]->apply(result, boundingBox.size()); |
| 938 | 951 |
| 939 if (applyTransformOrigin) { | 952 if (applyTransformOrigin) { |
| 940 transform.translate3d(-floatValueForLength(transformOriginX(), boundingB
ox.width()) - offsetX, | 953 result.translate3d(-floatValueForLength(transformOriginX(), boundingBox.
width()) - offsetX, |
| 941 -floatValueForLength(transformOriginY(), boundingBox.height()) - off
setY, | 954 -floatValueForLength(transformOriginY(), boundingBox.height()) - off
setY, |
| 942 -transformOriginZ()); | 955 -transformOriginZ()); |
| 943 } | 956 } |
| 944 } | 957 } |
| 945 | 958 |
| 946 void ComputedStyle::applyMotionPathTransform(TransformationMatrix& transform) co
nst | 959 void ComputedStyle::applyMotionPathTransform(TransformationMatrix& transform) co
nst |
| 947 { | 960 { |
| 948 const StyleMotionData& motionData = rareNonInheritedData->m_transform->m_mot
ion; | 961 const StyleMotionData& motionData = rareNonInheritedData->m_transform->m_mot
ion; |
| 949 ASSERT(motionData.m_path && motionData.m_path->isPathStyleMotionPath()); | 962 ASSERT(motionData.m_path && motionData.m_path->isPathStyleMotionPath()); |
| 950 const PathStyleMotionPath& motionPath = toPathStyleMotionPath(*motionData.m_
path); | 963 const PathStyleMotionPath& motionPath = toPathStyleMotionPath(*motionData.m_
path); |
| (...skipping 793 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1744 } | 1757 } |
| 1745 | 1758 |
| 1746 void ComputedStyle::copyChildDependentFlagsFrom(const ComputedStyle& other) | 1759 void ComputedStyle::copyChildDependentFlagsFrom(const ComputedStyle& other) |
| 1747 { | 1760 { |
| 1748 setEmptyState(other.emptyState()); | 1761 setEmptyState(other.emptyState()); |
| 1749 if (other.hasExplicitlyInheritedProperties()) | 1762 if (other.hasExplicitlyInheritedProperties()) |
| 1750 setHasExplicitlyInheritedProperties(); | 1763 setHasExplicitlyInheritedProperties(); |
| 1751 } | 1764 } |
| 1752 | 1765 |
| 1753 } // namespace blink | 1766 } // namespace blink |
| OLD | NEW |