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

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: Rebase master 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
« no previous file with comments | « Source/core/style/ComputedStyle.h ('k') | Source/core/style/StyleTransformData.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 24 matching lines...) Expand all
35 #include "core/style/QuotesData.h" 35 #include "core/style/QuotesData.h"
36 #include "core/style/ShadowList.h" 36 #include "core/style/ShadowList.h"
37 #include "core/style/StyleImage.h" 37 #include "core/style/StyleImage.h"
38 #include "core/style/StyleInheritedData.h" 38 #include "core/style/StyleInheritedData.h"
39 #include "platform/LengthFunctions.h" 39 #include "platform/LengthFunctions.h"
40 #include "platform/RuntimeEnabledFeatures.h" 40 #include "platform/RuntimeEnabledFeatures.h"
41 #include "platform/fonts/Font.h" 41 #include "platform/fonts/Font.h"
42 #include "platform/fonts/FontSelector.h" 42 #include "platform/fonts/FontSelector.h"
43 #include "platform/geometry/FloatRoundedRect.h" 43 #include "platform/geometry/FloatRoundedRect.h"
44 #include "platform/graphics/GraphicsContext.h" 44 #include "platform/graphics/GraphicsContext.h"
45 #include "platform/transforms/RotateTransformOperation.h"
46 #include "platform/transforms/ScaleTransformOperation.h"
47 #include "platform/transforms/TranslateTransformOperation.h"
45 #include "wtf/MathExtras.h" 48 #include "wtf/MathExtras.h"
46 49
47 #include <algorithm> 50 #include <algorithm>
48 51
49 namespace blink { 52 namespace blink {
50 53
51 struct SameSizeAsBorderValue { 54 struct SameSizeAsBorderValue {
52 RGBA32 m_color; 55 RGBA32 m_color;
53 unsigned m_width; 56 unsigned m_width;
54 }; 57 };
(...skipping 821 matching lines...) Expand 10 before | Expand all | Expand 10 after
876 case CSSPropertyBottom: 879 case CSSPropertyBottom:
877 case CSSPropertyRight: 880 case CSSPropertyRight:
878 return true; 881 return true;
879 default: 882 default:
880 break; 883 break;
881 } 884 }
882 } 885 }
883 return false; 886 return false;
884 } 887 }
885 888
886 inline bool requireTransformOrigin(const Vector<RefPtr<TransformOperation>>& tra nsformOperations, ComputedStyle::ApplyTransformOrigin applyOrigin, ComputedStyle ::ApplyMotionPath applyMotionPath) 889 bool ComputedStyle::requireTransformOrigin(ApplyTransformOrigin applyOrigin, App lyMotionPath applyMotionPath) const
887 { 890 {
891 const Vector<RefPtr<TransformOperation>>& transformOperations = transform(). operations();
892
888 // transform-origin brackets the transform with translate operations. 893 // 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 894 // Optimize for the case where the only transform is a translation, since th e transform-origin is irrelevant
890 // in that case. 895 // in that case.
891 if (applyOrigin != ComputedStyle::IncludeTransformOrigin) 896 if (applyOrigin != IncludeTransformOrigin)
892 return false; 897 return false;
893 898
894 if (applyMotionPath == ComputedStyle::IncludeMotionPath) 899 if (applyMotionPath == IncludeMotionPath)
895 return true; 900 return true;
896 901
897 unsigned size = transformOperations.size(); 902 unsigned size = transformOperations.size();
898 for (unsigned i = 0; i < size; ++i) { 903 for (unsigned i = 0; i < size; ++i) {
899 TransformOperation::OperationType type = transformOperations[i]->type(); 904 TransformOperation::OperationType type = transformOperations[i]->type();
900 if (type != TransformOperation::TranslateX 905 if (type != TransformOperation::TranslateX
901 && type != TransformOperation::TranslateY 906 && type != TransformOperation::TranslateY
902 && type != TransformOperation::Translate 907 && type != TransformOperation::Translate
903 && type != TransformOperation::TranslateZ 908 && type != TransformOperation::TranslateZ
904 && type != TransformOperation::Translate3D) 909 && type != TransformOperation::Translate3D)
905 return true; 910 return true;
906 } 911 }
907 912
908 return false; 913 return scale() || rotate();
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& result, const LayoutSiz e& borderBoxSize, ApplyTransformOrigin applyOrigin, ApplyMotionPath applyMotionP ath, ApplyIndependentTransformProperties applyIndependentTransformProperties) co nst
912 { 917 {
913 applyTransform(transform, FloatRect(FloatPoint(), FloatSize(borderBoxSize)), applyOrigin, applyMotionPath); 918 applyTransform(result, FloatRect(FloatPoint(), FloatSize(borderBoxSize)), ap plyOrigin, applyMotionPath, applyIndependentTransformProperties);
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& result, const FloatRect & boundingBox, ApplyTransformOrigin applyOrigin, ApplyMotionPath applyMotionPath , ApplyIndependentTransformProperties applyIndependentTransformProperties) 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 bool applyTransformOrigin = requireTransformOrigin(applyOrigin, applyMotionP ath);
921 bool applyTransformOrigin = requireTransformOrigin(transformOperations, appl yOrigin, applyMotionPath);
922 926
923 float offsetX = transformOriginX().type() == Percent ? boundingBox.x() : 0; 927 float offsetX = transformOriginX().type() == Percent ? boundingBox.x() : 0;
924 float offsetY = transformOriginY().type() == Percent ? boundingBox.y() : 0; 928 float offsetY = transformOriginY().type() == Percent ? boundingBox.y() : 0;
925 929
926 if (applyTransformOrigin) { 930 if (applyTransformOrigin) {
927 transform.translate3d(floatValueForLength(transformOriginX(), boundingBo x.width()) + offsetX, 931 result.translate3d(floatValueForLength(transformOriginX(), boundingBox.w idth()) + offsetX,
928 floatValueForLength(transformOriginY(), boundingBox.height()) + offs etY, 932 floatValueForLength(transformOriginY(), boundingBox.height()) + offs etY,
929 transformOriginZ()); 933 transformOriginZ());
930 } 934 }
931 935
936 if (applyIndependentTransformProperties == IncludeIndependentTransformProper ties) {
937 if (translate())
938 translate()->apply(result, boundingBox.size());
939
940 if (rotate())
941 rotate()->apply(result, boundingBox.size());
942
943 if (scale())
944 scale()->apply(result, boundingBox.size());
945 }
946
932 if (applyMotionPath == ComputedStyle::IncludeMotionPath) 947 if (applyMotionPath == ComputedStyle::IncludeMotionPath)
933 applyMotionPathTransform(transform); 948 applyMotionPathTransform(result);
934 949
950 const Vector<RefPtr<TransformOperation>>& transformOperations = transform(). operations();
935 unsigned size = transformOperations.size(); 951 unsigned size = transformOperations.size();
936 for (unsigned i = 0; i < size; ++i) 952 for (unsigned i = 0; i < size; ++i)
937 transformOperations[i]->apply(transform, boundingBox.size()); 953 transformOperations[i]->apply(result, boundingBox.size());
938 954
939 if (applyTransformOrigin) { 955 if (applyTransformOrigin) {
940 transform.translate3d(-floatValueForLength(transformOriginX(), boundingB ox.width()) - offsetX, 956 result.translate3d(-floatValueForLength(transformOriginX(), boundingBox. width()) - offsetX,
941 -floatValueForLength(transformOriginY(), boundingBox.height()) - off setY, 957 -floatValueForLength(transformOriginY(), boundingBox.height()) - off setY,
942 -transformOriginZ()); 958 -transformOriginZ());
943 } 959 }
944 } 960 }
945 961
946 void ComputedStyle::applyMotionPathTransform(TransformationMatrix& transform) co nst 962 void ComputedStyle::applyMotionPathTransform(TransformationMatrix& transform) co nst
947 { 963 {
948 const StyleMotionData& motionData = rareNonInheritedData->m_transform->m_mot ion; 964 const StyleMotionData& motionData = rareNonInheritedData->m_transform->m_mot ion;
949 ASSERT(motionData.m_path && motionData.m_path->isPathStyleMotionPath()); 965 ASSERT(motionData.m_path && motionData.m_path->isPathStyleMotionPath());
950 const PathStyleMotionPath& motionPath = toPathStyleMotionPath(*motionData.m_ path); 966 const PathStyleMotionPath& motionPath = toPathStyleMotionPath(*motionData.m_ path);
(...skipping 793 matching lines...) Expand 10 before | Expand all | Expand 10 after
1744 } 1760 }
1745 1761
1746 void ComputedStyle::copyChildDependentFlagsFrom(const ComputedStyle& other) 1762 void ComputedStyle::copyChildDependentFlagsFrom(const ComputedStyle& other)
1747 { 1763 {
1748 setEmptyState(other.emptyState()); 1764 setEmptyState(other.emptyState());
1749 if (other.hasExplicitlyInheritedProperties()) 1765 if (other.hasExplicitlyInheritedProperties())
1750 setHasExplicitlyInheritedProperties(); 1766 setHasExplicitlyInheritedProperties();
1751 } 1767 }
1752 1768
1753 } // namespace blink 1769 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/style/ComputedStyle.h ('k') | Source/core/style/StyleTransformData.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698