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

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: example 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
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 1326 matching lines...) Expand 10 before | Expand all | Expand 10 after
1337 translate()->apply(result, boundingBox.size()); 1337 translate()->apply(result, boundingBox.size());
1338 1338
1339 if (rotate()) 1339 if (rotate())
1340 rotate()->apply(result, boundingBox.size()); 1340 rotate()->apply(result, boundingBox.size());
1341 1341
1342 if (scale()) 1342 if (scale())
1343 scale()->apply(result, boundingBox.size()); 1343 scale()->apply(result, boundingBox.size());
1344 } 1344 }
1345 1345
1346 if (applyMotionPath == ComputedStyle::IncludeMotionPath) 1346 if (applyMotionPath == ComputedStyle::IncludeMotionPath)
1347 applyMotionPathTransform(originX, originY, result); 1347 applyMotionPathTransform(originX, originY, boundingBox, result);
1348 1348
1349 const Vector<RefPtr<TransformOperation>>& transformOperations = 1349 const Vector<RefPtr<TransformOperation>>& transformOperations =
1350 transform().operations(); 1350 transform().operations();
1351 unsigned size = transformOperations.size(); 1351 unsigned size = transformOperations.size();
1352 for (unsigned i = 0; i < size; ++i) 1352 for (unsigned i = 0; i < size; ++i)
1353 transformOperations[i]->apply(result, boundingBox.size()); 1353 transformOperations[i]->apply(result, boundingBox.size());
1354 1354
1355 if (applyTransformOrigin) { 1355 if (applyTransformOrigin) {
1356 result.translate3d(-originX, -originY, -originZ); 1356 result.translate3d(-originX, -originY, -originZ);
1357 } 1357 }
1358 } 1358 }
1359 1359
1360 void ComputedStyle::applyMotionPathTransform( 1360 void ComputedStyle::applyMotionPathTransform(
1361 float originX, 1361 float originX,
1362 float originY, 1362 float originY,
1363 const FloatRect& boundingBox,
1363 TransformationMatrix& transform) const { 1364 TransformationMatrix& transform) const {
1364 const StyleMotionData& motionData = 1365 const StyleMotionData& motionData =
1365 m_rareNonInheritedData->m_transform->m_motion; 1366 m_rareNonInheritedData->m_transform->m_motion;
1366 // TODO(ericwilligers): crbug.com/638055 Apply offset-position and 1367 // TODO(ericwilligers): crbug.com/638055 Apply offset-position.
1367 // offset-anchor.
1368 if (!motionData.m_path) { 1368 if (!motionData.m_path) {
1369 return; 1369 return;
1370 } 1370 }
1371 const StylePath& motionPath = *motionData.m_path; 1371 const StylePath& motionPath = *motionData.m_path;
1372 float pathLength = motionPath.length(); 1372 float pathLength = motionPath.length();
1373 float distance = floatValueForLength(motionData.m_distance, pathLength); 1373 float distance = floatValueForLength(motionData.m_distance, pathLength);
1374 float computedDistance; 1374 float computedDistance;
1375 if (motionPath.isClosed() && pathLength > 0) { 1375 if (motionPath.isClosed() && pathLength > 0) {
1376 computedDistance = fmod(distance, pathLength); 1376 computedDistance = fmod(distance, pathLength);
1377 if (computedDistance < 0) 1377 if (computedDistance < 0)
1378 computedDistance += pathLength; 1378 computedDistance += pathLength;
1379 } else { 1379 } else {
1380 computedDistance = clampTo<float>(distance, 0, pathLength); 1380 computedDistance = clampTo<float>(distance, 0, pathLength);
1381 } 1381 }
1382 1382
1383 FloatPoint point; 1383 FloatPoint point;
1384 float angle; 1384 float angle;
1385 motionPath.path().pointAndNormalAtLength(computedDistance, point, angle); 1385 motionPath.path().pointAndNormalAtLength(computedDistance, point, angle);
1386 1386
1387 if (motionData.m_rotation.type == OffsetRotationFixed) 1387 if (motionData.m_rotation.type == OffsetRotationFixed)
1388 angle = 0; 1388 angle = 0;
1389 1389
1390 transform.translate(point.x() - originX, point.y() - originY); 1390 float originShiftX = 0;
1391 float originShiftY = 0;
1392 if (RuntimeEnabledFeatures::cssOffsetPositionAnchorEnabled()) {
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());
alancutter (OOO until 2018) 2016/11/01 05:45:34 Needs a test for non-zero percentages.
Eric Willigers 2016/11/01 06:34:40 Done. combine-independent-anchor-transform.html (c
1399 }
1400
1401 transform.translate(point.x() - originX + originShiftX,
1402 point.y() - originY + originShiftY);
1391 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 }
1392 } 1408 }
1393 1409
1394 void ComputedStyle::setTextShadow(PassRefPtr<ShadowList> s) { 1410 void ComputedStyle::setTextShadow(PassRefPtr<ShadowList> s) {
1395 m_rareInheritedData.access()->textShadow = s; 1411 m_rareInheritedData.access()->textShadow = s;
1396 } 1412 }
1397 1413
1398 void ComputedStyle::setBoxShadow(PassRefPtr<ShadowList> s) { 1414 void ComputedStyle::setBoxShadow(PassRefPtr<ShadowList> s) {
1399 m_rareNonInheritedData.access()->m_boxShadow = s; 1415 m_rareNonInheritedData.access()->m_boxShadow = s;
1400 } 1416 }
1401 1417
(...skipping 998 matching lines...) Expand 10 before | Expand all | Expand 10 after
2400 if (value < 0) 2416 if (value < 0)
2401 fvalue -= 0.5f; 2417 fvalue -= 0.5f;
2402 else 2418 else
2403 fvalue += 0.5f; 2419 fvalue += 0.5f;
2404 } 2420 }
2405 2421
2406 return roundForImpreciseConversion<int>(fvalue / zoomFactor); 2422 return roundForImpreciseConversion<int>(fvalue / zoomFactor);
2407 } 2423 }
2408 2424
2409 } // namespace blink 2425 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698