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

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

Issue 2247773004: [WIP] CSS Motion Path: offset-anchor and offset-position Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: offsetAnchor Created 4 years, 3 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 970 matching lines...) Expand 10 before | Expand all | Expand 10 after
981 case CSSPropertyWebkitMaskBoxImage: 981 case CSSPropertyWebkitMaskBoxImage:
982 case CSSPropertyWebkitClipPath: 982 case CSSPropertyWebkitClipPath:
983 case CSSPropertyWebkitBoxReflect: 983 case CSSPropertyWebkitBoxReflect:
984 case CSSPropertyFilter: 984 case CSSPropertyFilter:
985 case CSSPropertyAliasWebkitFilter: 985 case CSSPropertyAliasWebkitFilter:
986 case CSSPropertyBackdropFilter: 986 case CSSPropertyBackdropFilter:
987 case CSSPropertyZIndex: 987 case CSSPropertyZIndex:
988 case CSSPropertyPosition: 988 case CSSPropertyPosition:
989 case CSSPropertyMixBlendMode: 989 case CSSPropertyMixBlendMode:
990 case CSSPropertyIsolation: 990 case CSSPropertyIsolation:
991 case CSSPropertyOffsetPath:
991 return true; 992 return true;
992 default: 993 default:
993 break; 994 break;
994 } 995 }
995 } 996 }
996 return false; 997 return false;
997 } 998 }
998 999
999 void ComputedStyle::updateIsStackingContext(bool isDocumentElement, bool isInTop Layer) 1000 void ComputedStyle::updateIsStackingContext(bool isDocumentElement, bool isInTop Layer)
1000 { 1001 {
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
1090 return scale() || rotate(); 1091 return scale() || rotate();
1091 } 1092 }
1092 1093
1093 void ComputedStyle::applyTransform(TransformationMatrix& result, const LayoutSiz e& borderBoxSize, ApplyTransformOrigin applyOrigin, ApplyMotionPath applyMotionP ath, ApplyIndependentTransformProperties applyIndependentTransformProperties) co nst 1094 void ComputedStyle::applyTransform(TransformationMatrix& result, const LayoutSiz e& borderBoxSize, ApplyTransformOrigin applyOrigin, ApplyMotionPath applyMotionP ath, ApplyIndependentTransformProperties applyIndependentTransformProperties) co nst
1094 { 1095 {
1095 applyTransform(result, FloatRect(FloatPoint(), FloatSize(borderBoxSize)), ap plyOrigin, applyMotionPath, applyIndependentTransformProperties); 1096 applyTransform(result, FloatRect(FloatPoint(), FloatSize(borderBoxSize)), ap plyOrigin, applyMotionPath, applyIndependentTransformProperties);
1096 } 1097 }
1097 1098
1098 void ComputedStyle::applyTransform(TransformationMatrix& result, const FloatRect & boundingBox, ApplyTransformOrigin applyOrigin, ApplyMotionPath applyMotionPath , ApplyIndependentTransformProperties applyIndependentTransformProperties) const 1099 void ComputedStyle::applyTransform(TransformationMatrix& result, const FloatRect & boundingBox, ApplyTransformOrigin applyOrigin, ApplyMotionPath applyMotionPath , ApplyIndependentTransformProperties applyIndependentTransformProperties) const
1099 { 1100 {
1100 if (!hasMotionPath()) 1101 if (!hasOffsetPath())
1101 applyMotionPath = ExcludeMotionPath; 1102 applyMotionPath = ExcludeMotionPath;
1102 bool applyTransformOrigin = requireTransformOrigin(applyOrigin, applyMotionP ath); 1103 bool applyTransformOrigin = requireTransformOrigin(applyOrigin, applyMotionP ath);
1103 1104
1104 float offsetX = transformOriginX().type() == Percent ? boundingBox.x() : 0; 1105 float offsetX = transformOriginX().type() == Percent ? boundingBox.x() : 0;
1105 float offsetY = transformOriginY().type() == Percent ? boundingBox.y() : 0; 1106 float offsetY = transformOriginY().type() == Percent ? boundingBox.y() : 0;
1106 1107
1107 float originX = 0; 1108 float originX = 0;
1108 float originY = 0; 1109 float originY = 0;
1109 float originZ = 0; 1110 float originZ = 0;
1110 1111
1111 if (applyTransformOrigin) { 1112 if (applyTransformOrigin) {
1112 originX = floatValueForLength(transformOriginX(), boundingBox.width()) + offsetX; 1113 originX = floatValueForLength(transformOriginX(), boundingBox.width()) + offsetX;
1113 originY = floatValueForLength(transformOriginY(), boundingBox.height()) + offsetY; 1114 originY = floatValueForLength(transformOriginY(), boundingBox.height()) + offsetY;
1114 originZ = transformOriginZ(); 1115 originZ = transformOriginZ();
1115 result.translate3d(originX, originY, originZ); 1116 result.translate3d(originX, originY, originZ);
1116 } 1117 }
1117 1118
1118 if (applyIndependentTransformProperties == IncludeIndependentTransformProper ties) { 1119 if (applyIndependentTransformProperties == IncludeIndependentTransformProper ties) {
1119 if (translate()) 1120 if (translate())
1120 translate()->apply(result, boundingBox.size()); 1121 translate()->apply(result, boundingBox.size());
1121 1122
1122 if (rotate()) 1123 if (rotate())
1123 rotate()->apply(result, boundingBox.size()); 1124 rotate()->apply(result, boundingBox.size());
1124 1125
1125 if (scale()) 1126 if (scale())
1126 scale()->apply(result, boundingBox.size()); 1127 scale()->apply(result, boundingBox.size());
1127 } 1128 }
1128 1129
1129 if (applyMotionPath == ComputedStyle::IncludeMotionPath) 1130 if (applyMotionPath == ComputedStyle::IncludeMotionPath)
1130 applyMotionPathTransform(originX, originY, result); 1131 applyMotionPathTransform(originX, originY, boundingBox, result);
1131 1132
1132 const Vector<RefPtr<TransformOperation>>& transformOperations = transform(). operations(); 1133 const Vector<RefPtr<TransformOperation>>& transformOperations = transform(). operations();
1133 unsigned size = transformOperations.size(); 1134 unsigned size = transformOperations.size();
1134 for (unsigned i = 0; i < size; ++i) 1135 for (unsigned i = 0; i < size; ++i)
1135 transformOperations[i]->apply(result, boundingBox.size()); 1136 transformOperations[i]->apply(result, boundingBox.size());
1136 1137
1137 if (applyTransformOrigin) { 1138 if (applyTransformOrigin) {
1138 result.translate3d(-originX, -originY, -originZ); 1139 result.translate3d(-originX, -originY, -originZ);
1139 } 1140 }
1140 } 1141 }
1141 1142
1142 void ComputedStyle::applyMotionPathTransform(float originX, float originY, Trans formationMatrix& transform) const 1143 void ComputedStyle::applyMotionPathTransform(float originX, float originY, const FloatRect& boundingBox, TransformationMatrix& transform) const
1143 { 1144 {
1144 const StyleMotionData& motionData = m_rareNonInheritedData->m_transform->m_m otion; 1145 const StyleMotionData& motionData = m_rareNonInheritedData->m_transform->m_m otion;
1145 ASSERT(motionData.m_path); 1146 ASSERT(motionData.m_path);
1146 const StylePath& motionPath = *motionData.m_path; 1147 const StylePath& motionPath = *motionData.m_path;
1147 float pathLength = motionPath.length(); 1148 float pathLength = motionPath.length();
1148 float distance = floatValueForLength(motionData.m_offset, pathLength); 1149 float distance = floatValueForLength(motionData.m_distance, pathLength);
1149 float computedDistance; 1150 float computedDistance;
1150 if (motionPath.isClosed() && pathLength > 0) { 1151 if (motionPath.isClosed() && pathLength > 0) {
1151 computedDistance = fmod(distance, pathLength); 1152 computedDistance = fmod(distance, pathLength);
1152 if (computedDistance < 0) 1153 if (computedDistance < 0)
1153 computedDistance += pathLength; 1154 computedDistance += pathLength;
1154 } else { 1155 } else {
1155 computedDistance = clampTo<float>(distance, 0, pathLength); 1156 computedDistance = clampTo<float>(distance, 0, pathLength);
1156 } 1157 }
1157 1158
1158 FloatPoint point; 1159 FloatPoint point;
1159 float angle; 1160 float angle;
1160 motionPath.path().pointAndNormalAtLength(computedDistance, point, angle); 1161 motionPath.path().pointAndNormalAtLength(computedDistance, point, angle);
1161 1162
1162 if (motionData.m_rotation.type == MotionRotationFixed) 1163 if (motionData.m_rotation.type == OffsetRotationFixed)
1163 angle = 0; 1164 angle = 0;
1164 1165
1165 transform.translate(point.x() - originX, point.y() - originY); 1166 float translateX = point.x();
1167 float translateY = point.y();
1168 const LengthPoint& position = offsetPosition();
1169 if (position.x() == Auto) {
1170 translateX -= originX;
1171 translateY -= originY;
1172 } else {
1173 translateX += floatValueForLength(position.x(), boundingBox.width()) - f loatValueForLength(left(), boundingBox.width());
1174 translateY += floatValueForLength(position.y(), boundingBox.height()) - floatValueForLength(top(), boundingBox.height());
1175 }
1176
1177 const LengthPoint& anchor = offsetAnchor();
1178 // TODO(ericwilligers): Consider interaction between position, anchor, rotat ion
1179 if (anchor.x() != Auto) {
1180 translateX += floatValueForLength(left(), boundingBox.width()) - boundin gBox.x() - floatValueForLength(anchor.x(), boundingBox.width());
1181 translateY += floatValueForLength(top(), boundingBox.height()) - boundin gBox.y() - floatValueForLength(anchor.y(), boundingBox.height());
1182 }
1183 transform.translate(translateX, translateY);
1166 transform.rotate(angle + motionData.m_rotation.angle); 1184 transform.rotate(angle + motionData.m_rotation.angle);
1167 } 1185 }
1168 1186
1169 void ComputedStyle::setTextShadow(PassRefPtr<ShadowList> s) 1187 void ComputedStyle::setTextShadow(PassRefPtr<ShadowList> s)
1170 { 1188 {
1171 m_rareInheritedData.access()->textShadow = s; 1189 m_rareInheritedData.access()->textShadow = s;
1172 } 1190 }
1173 1191
1174 void ComputedStyle::setBoxShadow(PassRefPtr<ShadowList> s) 1192 void ComputedStyle::setBoxShadow(PassRefPtr<ShadowList> s)
1175 { 1193 {
(...skipping 660 matching lines...) Expand 10 before | Expand all | Expand 10 after
1836 else 1854 else
1837 setMarginLeft(margin); 1855 setMarginLeft(margin);
1838 } else { 1856 } else {
1839 if (isLeftToRightDirection()) 1857 if (isLeftToRightDirection())
1840 setMarginBottom(margin); 1858 setMarginBottom(margin);
1841 else 1859 else
1842 setMarginTop(margin); 1860 setMarginTop(margin);
1843 } 1861 }
1844 } 1862 }
1845 1863
1846 void ComputedStyle::setMotionPath(PassRefPtr<StylePath> path) 1864 void ComputedStyle::setOffsetPath(PassRefPtr<StylePath> path)
1847 { 1865 {
1848 m_rareNonInheritedData.access()->m_transform.access()->m_motion.m_path = pat h; 1866 m_rareNonInheritedData.access()->m_transform.access()->m_motion.m_path = pat h;
1849 } 1867 }
1850 1868
1851 int ComputedStyle::outlineOutsetExtent() const 1869 int ComputedStyle::outlineOutsetExtent() const
1852 { 1870 {
1853 if (!hasOutline()) 1871 if (!hasOutline())
1854 return 0; 1872 return 0;
1855 if (outlineStyleIsAuto()) 1873 if (outlineStyleIsAuto())
1856 return GraphicsContext::focusRingOutsetExtent(outlineOffset(), outlineWi dth()); 1874 return GraphicsContext::focusRingOutsetExtent(outlineOffset(), outlineWi dth());
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
2028 if (value < 0) 2046 if (value < 0)
2029 fvalue -= 0.5f; 2047 fvalue -= 0.5f;
2030 else 2048 else
2031 fvalue += 0.5f; 2049 fvalue += 0.5f;
2032 } 2050 }
2033 2051
2034 return roundForImpreciseConversion<int>(fvalue / zoomFactor); 2052 return roundForImpreciseConversion<int>(fvalue / zoomFactor);
2035 } 2053 }
2036 2054
2037 } // namespace blink 2055 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/style/ComputedStyle.h ('k') | third_party/WebKit/Source/core/style/ComputedStyleConstants.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698