Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(151)

Side by Side Diff: Source/core/style/ComputedStyle.cpp

Issue 1158603003: CSS Independent Transform Properties (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Correct equality operators and remove dependencies on size() in parser Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 864 matching lines...) Expand 10 before | Expand all | Expand 10 after
875 case CSSPropertyBottom: 875 case CSSPropertyBottom:
876 case CSSPropertyRight: 876 case CSSPropertyRight:
877 return true; 877 return true;
878 default: 878 default:
879 break; 879 break;
880 } 880 }
881 } 881 }
882 return false; 882 return false;
883 } 883 }
884 884
885 inline bool requireTransformOrigin(const Vector<RefPtr<TransformOperation>>& tra nsformOperations, ComputedStyle::ApplyTransformOrigin applyOrigin, ComputedStyle ::ApplyMotionPath applyMotionPath) 885 bool ComputedStyle::requireTransformOrigin(ApplyTransformOrigin applyOrigin, App lyMotionPath applyMotionPath) const
886 { 886 {
887 const Vector<RefPtr<TransformOperation>>& transformOperations = rareNonInher itedData->m_transform->m_operations.operations();
888
887 // transform-origin brackets the transform with translate operations. 889 // transform-origin brackets the transform with translate operations.
888 // Optimize for the case where the only transform is a translation, since th e transform-origin is irrelevant 890 // Optimize for the case where the only transform is a translation, since th e transform-origin is irrelevant
889 // in that case. 891 // in that case.
890 if (applyOrigin != ComputedStyle::IncludeTransformOrigin) 892 if (applyOrigin != IncludeTransformOrigin)
891 return false; 893 return false;
892 894
893 if (applyMotionPath == ComputedStyle::IncludeMotionPath) 895 if (applyMotionPath == IncludeMotionPath)
894 return true; 896 return true;
895 897
896 unsigned size = transformOperations.size(); 898 unsigned size = transformOperations.size();
897 for (unsigned i = 0; i < size; ++i) { 899 for (unsigned i = 0; i < size; ++i) {
898 TransformOperation::OperationType type = transformOperations[i]->type(); 900 TransformOperation::OperationType type = transformOperations[i]->type();
899 if (type != TransformOperation::TranslateX 901 if (type != TransformOperation::TranslateX
900 && type != TransformOperation::TranslateY 902 && type != TransformOperation::TranslateY
901 && type != TransformOperation::Translate 903 && type != TransformOperation::Translate
902 && type != TransformOperation::TranslateZ 904 && type != TransformOperation::TranslateZ
903 && type != TransformOperation::Translate3D) 905 && type != TransformOperation::Translate3D)
904 return true; 906 return true;
905 } 907 }
906 908
909 if (hasScaleProperty() || hasRotateProperty())
910 return true;
911
907 return false; 912 return false;
908 } 913 }
909 914
910 void ComputedStyle::applyTransform(TransformationMatrix& transform, const Layout Size& borderBoxSize, ApplyTransformOrigin applyOrigin, ApplyMotionPath applyMoti onPath) const 915 void ComputedStyle::applyTransform(TransformationMatrix& transform, const Layout Size& borderBoxSize, ApplyTransformOrigin applyOrigin, ApplyMotionPath applyMoti onPath, ApplyTransformProperty applyTransformProperty) const
911 { 916 {
912 applyTransform(transform, FloatRect(FloatPoint(), FloatSize(borderBoxSize)), applyOrigin, applyMotionPath); 917 applyTransform(transform, FloatRect(FloatPoint(), FloatSize(borderBoxSize)), applyOrigin, applyMotionPath, applyTransformProperty);
913 } 918 }
914 919
915 void ComputedStyle::applyTransform(TransformationMatrix& transform, const FloatR ect& boundingBox, ApplyTransformOrigin applyOrigin, ApplyMotionPath applyMotionP ath) const 920 void ComputedStyle::applyTransform(TransformationMatrix& transform, const FloatR ect& boundingBox, ApplyTransformOrigin applyOrigin, ApplyMotionPath applyMotionP ath, ApplyTransformProperty applyTransformProperty) const
916 { 921 {
917 if (!hasMotionPath()) 922 if (!hasMotionPath())
918 applyMotionPath = ExcludeMotionPath; 923 applyMotionPath = ExcludeMotionPath;
919 const Vector<RefPtr<TransformOperation>>& transformOperations = rareNonInher itedData->m_transform->m_operations.operations(); 924 const Vector<RefPtr<TransformOperation>>& transformOperations = rareNonInher itedData->m_transform->m_operations.operations();
920 bool applyTransformOrigin = requireTransformOrigin(transformOperations, appl yOrigin, applyMotionPath); 925 bool applyTransformOrigin = requireTransformOrigin(applyOrigin, applyMotionP ath);
921 926
922 float offsetX = transformOriginX().type() == Percent ? boundingBox.x() : 0; 927 float offsetX = transformOriginX().type() == Percent ? boundingBox.x() : 0;
923 float offsetY = transformOriginY().type() == Percent ? boundingBox.y() : 0; 928 float offsetY = transformOriginY().type() == Percent ? boundingBox.y() : 0;
924 929
925 if (applyTransformOrigin) { 930 if (applyTransformOrigin) {
926 transform.translate3d(floatValueForLength(transformOriginX(), boundingBo x.width()) + offsetX, 931 transform.translate3d(floatValueForLength(transformOriginX(), boundingBo x.width()) + offsetX,
927 floatValueForLength(transformOriginY(), boundingBox.height()) + offs etY, 932 floatValueForLength(transformOriginY(), boundingBox.height()) + offs etY,
928 transformOriginZ()); 933 transformOriginZ());
929 } 934 }
930 935
936 if (applyTransformProperty == IncludeTransformProperty) {
937 if (hasTranslateProperty()) {
938 RefPtr<TransformOperation> translateOp = translate();
939 translateOp->apply(transform, boundingBox.size());
940 }
941
942 if (hasRotateProperty()) {
943 RefPtr<TransformOperation> rotateOp = rotate();
944 rotateOp->apply(transform, boundingBox.size());
945 }
946
947 if (hasScaleProperty()) {
948 RefPtr<TransformOperation> scaleOp = scale();
949 scaleOp->apply(transform, boundingBox.size());
950 }
951 }
952
931 if (applyMotionPath == ComputedStyle::IncludeMotionPath) 953 if (applyMotionPath == ComputedStyle::IncludeMotionPath)
932 applyMotionPathTransform(transform); 954 applyMotionPathTransform(transform);
933 955
934 unsigned size = transformOperations.size(); 956 unsigned size = transformOperations.size();
935 for (unsigned i = 0; i < size; ++i) 957 for (unsigned i = 0; i < size; ++i)
936 transformOperations[i]->apply(transform, boundingBox.size()); 958 transformOperations[i]->apply(transform, boundingBox.size());
937 959
938 if (applyTransformOrigin) { 960 if (applyTransformOrigin) {
939 transform.translate3d(-floatValueForLength(transformOriginX(), boundingB ox.width()) - offsetX, 961 transform.translate3d(-floatValueForLength(transformOriginX(), boundingB ox.width()) - offsetX,
940 -floatValueForLength(transformOriginY(), boundingBox.height()) - off setY, 962 -floatValueForLength(transformOriginY(), boundingBox.height()) - off setY,
(...skipping 797 matching lines...) Expand 10 before | Expand all | Expand 10 after
1738 } 1760 }
1739 1761
1740 void ComputedStyle::copyChildDependentFlagsFrom(const ComputedStyle& other) 1762 void ComputedStyle::copyChildDependentFlagsFrom(const ComputedStyle& other)
1741 { 1763 {
1742 setEmptyState(other.emptyState()); 1764 setEmptyState(other.emptyState());
1743 if (other.hasExplicitlyInheritedProperties()) 1765 if (other.hasExplicitlyInheritedProperties())
1744 setHasExplicitlyInheritedProperties(); 1766 setHasExplicitlyInheritedProperties();
1745 } 1767 }
1746 1768
1747 } // namespace blink 1769 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698