 Chromium Code Reviews
 Chromium Code Reviews Issue 1158603003:
  CSS Independent Transform Properties  (Closed) 
  Base URL: https://chromium.googlesource.com/chromium/blink.git@master
    
  
    Issue 1158603003:
  CSS Independent Transform Properties  (Closed) 
  Base URL: https://chromium.googlesource.com/chromium/blink.git@master| 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 = rareNonInher itedData->m_transform->m_operations.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 | 
| 910 if (hasScaleProperty() || hasRotateProperty()) | |
| 911 return true; | |
| 912 | |
| 908 return false; | 913 return false; | 
| 909 } | 914 } | 
| 910 | 915 | 
| 911 void ComputedStyle::applyTransform(TransformationMatrix& transform, const Layout Size& borderBoxSize, ApplyTransformOrigin applyOrigin, ApplyMotionPath applyMoti onPath) const | 916 void ComputedStyle::applyTransform(TransformationMatrix& transform, const Layout Size& borderBoxSize, ApplyTransformOrigin applyOrigin, ApplyMotionPath applyMoti onPath, ApplyTransformProperty applyTransformProperty) const | 
| 912 { | 917 { | 
| 913 applyTransform(transform, FloatRect(FloatPoint(), FloatSize(borderBoxSize)), applyOrigin, applyMotionPath); | 918 applyTransform(transform, FloatRect(FloatPoint(), FloatSize(borderBoxSize)), applyOrigin, applyMotionPath, applyTransformProperty); | 
| 914 } | 919 } | 
| 915 | 920 | 
| 916 void ComputedStyle::applyTransform(TransformationMatrix& transform, const FloatR ect& boundingBox, ApplyTransformOrigin applyOrigin, ApplyMotionPath applyMotionP ath) const | 921 void ComputedStyle::applyTransform(TransformationMatrix& transform, const FloatR ect& boundingBox, ApplyTransformOrigin applyOrigin, ApplyMotionPath applyMotionP ath, ApplyTransformProperty applyTransformProperty) const | 
| 917 { | 922 { | 
| 918 if (!hasMotionPath()) | 923 if (!hasMotionPath()) | 
| 919 applyMotionPath = ExcludeMotionPath; | 924 applyMotionPath = ExcludeMotionPath; | 
| 920 const Vector<RefPtr<TransformOperation>>& transformOperations = rareNonInher itedData->m_transform->m_operations.operations(); | 925 const Vector<RefPtr<TransformOperation>>& transformOperations = rareNonInher itedData->m_transform->m_operations.operations(); | 
| 921 bool applyTransformOrigin = requireTransformOrigin(transformOperations, appl yOrigin, applyMotionPath); | 926 bool applyTransformOrigin = requireTransformOrigin(applyOrigin, applyMotionP ath); | 
| 922 | 927 | 
| 923 float offsetX = transformOriginX().type() == Percent ? boundingBox.x() : 0; | 928 float offsetX = transformOriginX().type() == Percent ? boundingBox.x() : 0; | 
| 924 float offsetY = transformOriginY().type() == Percent ? boundingBox.y() : 0; | 929 float offsetY = transformOriginY().type() == Percent ? boundingBox.y() : 0; | 
| 925 | 930 | 
| 926 if (applyTransformOrigin) { | 931 if (applyTransformOrigin) { | 
| 927 transform.translate3d(floatValueForLength(transformOriginX(), boundingBo x.width()) + offsetX, | 932 transform.translate3d(floatValueForLength(transformOriginX(), boundingBo x.width()) + offsetX, | 
| 928 floatValueForLength(transformOriginY(), boundingBox.height()) + offs etY, | 933 floatValueForLength(transformOriginY(), boundingBox.height()) + offs etY, | 
| 929 transformOriginZ()); | 934 transformOriginZ()); | 
| 930 } | 935 } | 
| 931 | 936 | 
| 937 if (applyTransformProperty == IncludeTransformProperty) { | |
| 
dstockwell
2015/06/12 00:17:58
It's confusing that IncludeTransformProperty doesn
 
soonm
2015/06/12 01:54:12
Change to IncludeTransformL2
 | |
| 938 if (hasTranslateProperty()) { | |
| 939 RefPtr<TransformOperation> translateOp = translate(); | |
| 940 translateOp->apply(transform, boundingBox.size()); | |
| 941 } | |
| 942 | |
| 943 if (hasRotateProperty()) { | |
| 944 RefPtr<TransformOperation> rotateOp = rotate(); | |
| 945 rotateOp->apply(transform, boundingBox.size()); | |
| 946 } | |
| 947 | |
| 948 if (hasScaleProperty()) { | |
| 949 RefPtr<TransformOperation> scaleOp = scale(); | |
| 950 scaleOp->apply(transform, boundingBox.size()); | |
| 951 } | |
| 952 } | |
| 953 | |
| 932 if (applyMotionPath == ComputedStyle::IncludeMotionPath) | 954 if (applyMotionPath == ComputedStyle::IncludeMotionPath) | 
| 933 applyMotionPathTransform(transform); | 955 applyMotionPathTransform(transform); | 
| 934 | 956 | 
| 935 unsigned size = transformOperations.size(); | 957 unsigned size = transformOperations.size(); | 
| 936 for (unsigned i = 0; i < size; ++i) | 958 for (unsigned i = 0; i < size; ++i) | 
| 937 transformOperations[i]->apply(transform, boundingBox.size()); | 959 transformOperations[i]->apply(transform, boundingBox.size()); | 
| 938 | 960 | 
| 939 if (applyTransformOrigin) { | 961 if (applyTransformOrigin) { | 
| 940 transform.translate3d(-floatValueForLength(transformOriginX(), boundingB ox.width()) - offsetX, | 962 transform.translate3d(-floatValueForLength(transformOriginX(), boundingB ox.width()) - offsetX, | 
| 941 -floatValueForLength(transformOriginY(), boundingBox.height()) - off setY, | 963 -floatValueForLength(transformOriginY(), boundingBox.height()) - off setY, | 
| (...skipping 802 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1744 } | 1766 } | 
| 1745 | 1767 | 
| 1746 void ComputedStyle::copyChildDependentFlagsFrom(const ComputedStyle& other) | 1768 void ComputedStyle::copyChildDependentFlagsFrom(const ComputedStyle& other) | 
| 1747 { | 1769 { | 
| 1748 setEmptyState(other.emptyState()); | 1770 setEmptyState(other.emptyState()); | 
| 1749 if (other.hasExplicitlyInheritedProperties()) | 1771 if (other.hasExplicitlyInheritedProperties()) | 
| 1750 setHasExplicitlyInheritedProperties(); | 1772 setHasExplicitlyInheritedProperties(); | 
| 1751 } | 1773 } | 
| 1752 | 1774 | 
| 1753 } // namespace blink | 1775 } // namespace blink | 
| OLD | NEW |