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

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

Issue 2461603003: CSS Motion Path: Place offset-anchor on the path (Closed)
Patch Set: rebase Created 4 years, 1 month 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 | « third_party/WebKit/Source/core/style/ComputedStyle.h ('k') | no next file » | 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 3 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights
4 * reserved. 4 * reserved.
5 * Copyright (C) 2011 Adobe Systems Incorporated. All rights reserved. 5 * Copyright (C) 2011 Adobe Systems Incorporated. All rights reserved.
6 * 6 *
7 * This library is free software; you can redistribute it and/or 7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Library General Public 8 * modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either 9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version. 10 * version 2 of the License, or (at your option) any later version.
(...skipping 1328 matching lines...) Expand 10 before | Expand all | Expand 10 after
1339 translate()->apply(result, boxSize); 1339 translate()->apply(result, boxSize);
1340 1340
1341 if (rotate()) 1341 if (rotate())
1342 rotate()->apply(result, boxSize); 1342 rotate()->apply(result, boxSize);
1343 1343
1344 if (scale()) 1344 if (scale())
1345 scale()->apply(result, boxSize); 1345 scale()->apply(result, boxSize);
1346 } 1346 }
1347 1347
1348 if (applyMotionPath == IncludeMotionPath) 1348 if (applyMotionPath == IncludeMotionPath)
1349 applyMotionPathTransform(originX, originY, result); 1349 applyMotionPathTransform(originX, originY, boundingBox, result);
1350 1350
1351 for (const auto& operation : transform().operations()) 1351 for (const auto& operation : transform().operations())
1352 operation->apply(result, boxSize); 1352 operation->apply(result, boxSize);
1353 1353
1354 if (applyTransformOrigin) { 1354 if (applyTransformOrigin) {
1355 result.translate3d(-originX, -originY, -originZ); 1355 result.translate3d(-originX, -originY, -originZ);
1356 } 1356 }
1357 } 1357 }
1358 1358
1359 void ComputedStyle::applyMotionPathTransform( 1359 void ComputedStyle::applyMotionPathTransform(
1360 float originX, 1360 float originX,
1361 float originY, 1361 float originY,
1362 const FloatRect& boundingBox,
1362 TransformationMatrix& transform) const { 1363 TransformationMatrix& transform) const {
1363 const StyleMotionData& motionData = 1364 const StyleMotionData& motionData =
1364 m_rareNonInheritedData->m_transform->m_motion; 1365 m_rareNonInheritedData->m_transform->m_motion;
1365 // TODO(ericwilligers): crbug.com/638055 Apply offset-position and 1366 // TODO(ericwilligers): crbug.com/638055 Apply offset-position.
1366 // offset-anchor.
1367 if (!motionData.m_path) { 1367 if (!motionData.m_path) {
1368 return; 1368 return;
1369 } 1369 }
1370 const StylePath& motionPath = *motionData.m_path; 1370 const StylePath& motionPath = *motionData.m_path;
1371 float pathLength = motionPath.length(); 1371 float pathLength = motionPath.length();
1372 float distance = floatValueForLength(motionData.m_distance, pathLength); 1372 float distance = floatValueForLength(motionData.m_distance, pathLength);
1373 float computedDistance; 1373 float computedDistance;
1374 if (motionPath.isClosed() && pathLength > 0) { 1374 if (motionPath.isClosed() && pathLength > 0) {
1375 computedDistance = fmod(distance, pathLength); 1375 computedDistance = fmod(distance, pathLength);
1376 if (computedDistance < 0) 1376 if (computedDistance < 0)
1377 computedDistance += pathLength; 1377 computedDistance += pathLength;
1378 } else { 1378 } else {
1379 computedDistance = clampTo<float>(distance, 0, pathLength); 1379 computedDistance = clampTo<float>(distance, 0, pathLength);
1380 } 1380 }
1381 1381
1382 FloatPoint point; 1382 FloatPoint point;
1383 float angle; 1383 float angle;
1384 motionPath.path().pointAndNormalAtLength(computedDistance, point, angle); 1384 motionPath.path().pointAndNormalAtLength(computedDistance, point, angle);
1385 1385
1386 if (motionData.m_rotation.type == OffsetRotationFixed) 1386 if (motionData.m_rotation.type == OffsetRotationFixed)
1387 angle = 0; 1387 angle = 0;
1388 1388
1389 transform.translate(point.x() - originX, point.y() - originY); 1389 float originShiftX = 0;
1390 float originShiftY = 0;
1391 if (RuntimeEnabledFeatures::cssOffsetPositionAnchorEnabled()) {
1392 // TODO(ericwilligers): crbug.com/638055 Support offset-anchor: auto.
1393 const LengthPoint& anchor = offsetAnchor();
1394 originShiftX = floatValueForLength(anchor.x(), boundingBox.width()) -
1395 floatValueForLength(transformOriginX(), boundingBox.width());
1396 originShiftY =
1397 floatValueForLength(anchor.y(), boundingBox.height()) -
1398 floatValueForLength(transformOriginY(), boundingBox.height());
1399 }
1400
1401 transform.translate(point.x() - originX + originShiftX,
1402 point.y() - originY + originShiftY);
1390 transform.rotate(angle + motionData.m_rotation.angle); 1403 transform.rotate(angle + motionData.m_rotation.angle);
1404
1405 if (RuntimeEnabledFeatures::cssOffsetPositionAnchorEnabled()) {
1406 transform.translate(-originShiftX, -originShiftY);
1407 }
1391 } 1408 }
1392 1409
1393 void ComputedStyle::setTextShadow(PassRefPtr<ShadowList> s) { 1410 void ComputedStyle::setTextShadow(PassRefPtr<ShadowList> s) {
1394 m_rareInheritedData.access()->textShadow = s; 1411 m_rareInheritedData.access()->textShadow = s;
1395 } 1412 }
1396 1413
1397 void ComputedStyle::setBoxShadow(PassRefPtr<ShadowList> s) { 1414 void ComputedStyle::setBoxShadow(PassRefPtr<ShadowList> s) {
1398 m_rareNonInheritedData.access()->m_boxShadow = s; 1415 m_rareNonInheritedData.access()->m_boxShadow = s;
1399 } 1416 }
1400 1417
(...skipping 998 matching lines...) Expand 10 before | Expand all | Expand 10 after
2399 if (value < 0) 2416 if (value < 0)
2400 fvalue -= 0.5f; 2417 fvalue -= 0.5f;
2401 else 2418 else
2402 fvalue += 0.5f; 2419 fvalue += 0.5f;
2403 } 2420 }
2404 2421
2405 return roundForImpreciseConversion<int>(fvalue / zoomFactor); 2422 return roundForImpreciseConversion<int>(fvalue / zoomFactor);
2406 } 2423 }
2407 2424
2408 } // namespace blink 2425 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/style/ComputedStyle.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698