Changeset 275868 in webkit
- Timestamp:
- Apr 13, 2021, 1:05:24 AM (6 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 6 edited
-
LayoutTests/ChangeLog (modified) (1 diff)
-
LayoutTests/imported/w3c/ChangeLog (modified) (1 diff)
-
LayoutTests/imported/w3c/web-platform-tests/svg/animations/scripted/paced-value-animation-overwrites-keyTimes-expected.txt (modified) (1 diff)
-
LayoutTests/svg/animations/animate-calcMode-paced-overwrite-key-times-expected.html (added)
-
LayoutTests/svg/animations/animate-calcMode-paced-overwrite-key-times.html (added)
-
Source/WebCore/ChangeLog (modified) (1 diff)
-
Source/WebCore/svg/SVGAnimationElement.cpp (modified) (16 diffs)
-
Source/WebCore/svg/SVGAnimationElement.h (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r275865 r275868 1 2021-04-13 Said Abou-Hallawa <said@apple.com> 2 3 SVG paced value animations overwrite user-provided keyTimes 4 https://bugs.webkit.org/show_bug.cgi?id=109010 5 6 Reviewed by Ryosuke Niwa. 7 8 Simplified from the WPT paced-value-animation-overwrites-keyTimes.html. 9 10 * svg/animations/animate-calcMode-paced-overwrite-key-times-expected.html: Added. 11 * svg/animations/animate-calcMode-paced-overwrite-key-times.html: Added. 12 1 13 2021-04-12 Xabier Rodriguez Calvar <calvaris@igalia.com> 2 14 -
trunk/LayoutTests/imported/w3c/ChangeLog
r275855 r275868 1 2021-04-13 Said Abou-Hallawa <said@apple.com> 2 3 SVG paced value animations overwrite user-provided keyTimes 4 https://bugs.webkit.org/show_bug.cgi?id=109010 5 6 Reviewed by Ryosuke Niwa. 7 8 * web-platform-tests/svg/animations/scripted/paced-value-animation-overwrites-keyTimes-expected.txt: 9 1 10 2021-04-12 Commit Queue <commit-queue@webkit.org> 2 11 -
trunk/LayoutTests/imported/w3c/web-platform-tests/svg/animations/scripted/paced-value-animation-overwrites-keyTimes-expected.txt
r250276 r275868 1 1 2 FAIL Paced value animation doesn't overwrite keyTimes assert_approx_equals: expected 150 +/- 5 but got 120 2 PASS Paced value animation doesn't overwrite keyTimes 3 3 -
trunk/Source/WebCore/ChangeLog
r275859 r275868 1 2021-04-13 Said Abou-Hallawa <said@apple.com> 2 3 SVG paced value animations overwrite user-provided keyTimes 4 https://bugs.webkit.org/show_bug.cgi?id=109010 5 6 Reviewed by Ryosuke Niwa. 7 8 If the calcMode is Paced, the 'keyTimes' attribute is ignored. Distances 9 between the 'values' are used produce an even pace of change across the 10 animation. 11 12 When changing calcMode, times defined in the 'keyTimes' attribute should 13 be used instead. To fix this, SVGAnimationElement can maintain two lists 14 for keyTimes: (1) keyTimesFromAttribute (2) keyTimesForPaced. 15 One of these lists will be picked by a new function 'keyTimes()' based 16 on the current calcMode. 17 18 Specs: https://www.w3.org/TR/SVG11/animate.html#CalcModeAttribute 19 20 Test: svg/animations/animate-calcMode-paced-overwrite-key-times.html 21 22 * svg/SVGAnimationElement.cpp: 23 (WebCore::SVGAnimationElement::parseAttribute): 24 (WebCore::SVGAnimationElement::calculateKeyTimesForCalcModePaced): 25 (WebCore::SVGAnimationElement::keyTimes const): 26 (WebCore::SVGAnimationElement::calculateKeyTimesIndex const): 27 (WebCore::SVGAnimationElement::calculatePercentFromKeyPoints const): 28 (WebCore::SVGAnimationElement::calculatePercentForFromTo const): 29 (WebCore::SVGAnimationElement::currentValuesFromKeyPoints const): 30 (WebCore::SVGAnimationElement::currentValuesForValuesAnimation): 31 (WebCore::SVGAnimationElement::startedActiveInterval): 32 (WebCore::SVGAnimationElement::updateAnimation): 33 * svg/SVGAnimationElement.h: 34 1 35 2021-04-12 Ryosuke Niwa <rniwa@webkit.org> 2 36 -
trunk/Source/WebCore/svg/SVGAnimationElement.cpp
r275410 r275868 3 3 * Copyright (C) 2004, 2005, 2006, 2007 Rob Buis <buis@kde.org> 4 4 * Copyright (C) 2007 Eric Seidel <eric@webkit.org> 5 * Copyright (C) 2008 , 2017Apple Inc. All rights reserved.5 * Copyright (C) 2008-2021 Apple Inc. All rights reserved. 6 6 * Copyright (C) 2009 Cameron McCormack <cam@mcc.id.au> 7 7 * Copyright (C) Research In Motion Limited 2010. All rights reserved. … … 162 162 163 163 if (name == SVGNames::keyTimesAttr) { 164 parseKeyTimes(value, m_keyTimes , true);164 parseKeyTimes(value, m_keyTimesFromAttribute, true); 165 165 return; 166 166 } … … 347 347 return; 348 348 349 // FIXME, webkit.org/b/109010: m_keyTimes should not be modified in this function. 350 m_keyTimes.clear(); 349 m_keyTimesForPaced.clear(); 351 350 352 351 Vector<float> keyTimesForPaced; … … 369 368 keyTimesForPaced[keyTimesForPaced.size() - 1] = 1; 370 369 371 // Use key times calculated based on pacing instead of the user provided ones. 372 m_keyTimes = keyTimesForPaced; 370 m_keyTimesForPaced = WTFMove(keyTimesForPaced); 373 371 } 374 372 375 373 static inline double solveEpsilon(double duration) { return 1 / (200 * duration); } 376 374 375 const Vector<float>& SVGAnimationElement::keyTimes() const 376 { 377 return calcMode() == CalcMode::Paced ? m_keyTimesForPaced : m_keyTimesFromAttribute; 378 } 379 377 380 unsigned SVGAnimationElement::calculateKeyTimesIndex(float percent) const 378 381 { 382 const auto& keyTimes = this->keyTimes(); 379 383 unsigned index; 380 unsigned keyTimesCount = m_keyTimes.size();384 unsigned keyTimesCount = keyTimes.size(); 381 385 // Compare index + 1 to keyTimesCount because the last keyTimes entry is 382 386 // required to be 1, and percent can never exceed 1; i.e., the second last 383 387 // keyTimes entry defines the beginning of the final interval 384 388 for (index = 1; index + 1 < keyTimesCount; ++index) { 385 if ( m_keyTimes[index] > percent)389 if (keyTimes[index] > percent) 386 390 break; 387 391 } … … 402 406 float SVGAnimationElement::calculatePercentFromKeyPoints(float percent) const 403 407 { 408 const auto& keyTimes = this->keyTimes(); 409 404 410 ASSERT(!m_keyPoints.isEmpty()); 405 411 ASSERT(calcMode() != CalcMode::Paced); 406 ASSERT( m_keyTimes.size() > 1);407 ASSERT(m_keyPoints.size() == m_keyTimes.size());412 ASSERT(keyTimes.size() > 1); 413 ASSERT(m_keyPoints.size() == keyTimes.size()); 408 414 409 415 if (percent == 1) … … 411 417 412 418 unsigned index = calculateKeyTimesIndex(percent); 413 float fromPercent = m_keyTimes[index];414 float toPercent = m_keyTimes[index + 1];419 float fromPercent = keyTimes[index]; 420 float toPercent = keyTimes[index + 1]; 415 421 float fromKeyPoint = m_keyPoints[index]; 416 422 float toKeyPoint = m_keyPoints[index + 1]; … … 430 436 float SVGAnimationElement::calculatePercentForFromTo(float percent) const 431 437 { 432 if (calcMode() == CalcMode::Discrete && m_keyTimes.size() == 2) 433 return percent > m_keyTimes[1] ? 1 : 0; 438 const auto& keyTimes = this->keyTimes(); 439 if (calcMode() == CalcMode::Discrete && keyTimes.size() == 2) 440 return percent > keyTimes[1] ? 1 : 0; 434 441 435 442 return percent; … … 439 446 { 440 447 ASSERT(!m_keyPoints.isEmpty()); 441 ASSERT(m_keyPoints.size() == m_keyTimes.size());448 ASSERT(m_keyPoints.size() == keyTimes().size()); 442 449 ASSERT(calcMode() != CalcMode::Paced); 443 450 effectivePercent = calculatePercentFromKeyPoints(percent); … … 469 476 return currentValuesFromKeyPoints(percent, effectivePercent, from, to); 470 477 471 unsigned keyTimesCount = m_keyTimes.size(); 478 const auto& keyTimes = this->keyTimes(); 479 unsigned keyTimesCount = keyTimes.size(); 472 480 ASSERT(!keyTimesCount || valuesCount == keyTimesCount); 473 ASSERT(!keyTimesCount || (keyTimesCount > 1 && ! m_keyTimes[0]));481 ASSERT(!keyTimesCount || (keyTimesCount > 1 && !keyTimes[0])); 474 482 475 483 unsigned index = calculateKeyTimesIndex(percent); … … 486 494 float toPercent; 487 495 if (keyTimesCount) { 488 fromPercent = m_keyTimes[index];489 toPercent = m_keyTimes[index + 1];496 fromPercent = keyTimes[index]; 497 toPercent = keyTimes[index + 1]; 490 498 } else { 491 499 index = static_cast<unsigned>(floorf(percent * (valuesCount - 1))); … … 514 522 return; 515 523 524 const auto& keyTimes = this->keyTimes(); 525 516 526 // These validations are appropriate for all animation modes. 517 if (hasAttributeWithoutSynchronization(SVGNames::keyPointsAttr) && m_keyPoints.size() != m_keyTimes.size())527 if (hasAttributeWithoutSynchronization(SVGNames::keyPointsAttr) && m_keyPoints.size() != keyTimes.size()) 518 528 return; 519 529 … … 525 535 || (hasAttributeWithoutSynchronization(SVGNames::keyPointsAttr) && m_keyPoints.size() - 1 != splinesCount) 526 536 || (animationMode == AnimationMode::Values && m_values.size() - 1 != splinesCount) 527 || (hasAttributeWithoutSynchronization(SVGNames::keyTimesAttr) && m_keyTimes.size() - 1 != splinesCount))537 || (hasAttributeWithoutSynchronization(SVGNames::keyTimesAttr) && keyTimes.size() - 1 != splinesCount)) 528 538 return; 529 539 } … … 535 545 return; 536 546 if ((animationMode == AnimationMode::FromTo || animationMode == AnimationMode::FromBy || animationMode == AnimationMode::To || animationMode == AnimationMode::By) 537 && (hasAttributeWithoutSynchronization(SVGNames::keyPointsAttr) && hasAttributeWithoutSynchronization(SVGNames::keyTimesAttr) && ( m_keyTimes.size() < 2 || m_keyTimes.size() != m_keyPoints.size())))547 && (hasAttributeWithoutSynchronization(SVGNames::keyPointsAttr) && hasAttributeWithoutSynchronization(SVGNames::keyTimesAttr) && (keyTimes.size() < 2 || keyTimes.size() != m_keyPoints.size()))) 538 548 return; 539 549 if (animationMode == AnimationMode::FromTo) … … 549 559 else if (animationMode == AnimationMode::Values) { 550 560 m_animationValid = m_values.size() >= 1 551 && (calcMode == CalcMode::Paced || !hasAttributeWithoutSynchronization(SVGNames::keyTimesAttr) || hasAttributeWithoutSynchronization(SVGNames::keyPointsAttr) || (m_values.size() == m_keyTimes.size()))552 && (calcMode == CalcMode::Discrete || ! m_keyTimes.size() || m_keyTimes.last() == 1)561 && (calcMode == CalcMode::Paced || !hasAttributeWithoutSynchronization(SVGNames::keyTimesAttr) || hasAttributeWithoutSynchronization(SVGNames::keyPointsAttr) || (m_values.size() == keyTimes.size())) 562 && (calcMode == CalcMode::Discrete || !keyTimes.size() || keyTimes.last() == 1) 553 563 && (calcMode != CalcMode::Spline || ((m_keySplines.size() && (m_keySplines.size() == m_values.size() - 1)) || m_keySplines.size() == m_keyPoints.size() - 1)) 554 && (!hasAttributeWithoutSynchronization(SVGNames::keyPointsAttr) || ( m_keyTimes.size() > 1 && m_keyTimes.size() == m_keyPoints.size()));564 && (!hasAttributeWithoutSynchronization(SVGNames::keyPointsAttr) || (keyTimes.size() > 1 && keyTimes.size() == m_keyPoints.size())); 555 565 if (m_animationValid) 556 566 m_animationValid = calculateToAtEndOfDurationValue(m_values.last()); … … 558 568 calculateKeyTimesForCalcModePaced(); 559 569 } else if (animationMode == AnimationMode::Path) 560 m_animationValid = calcMode == CalcMode::Paced || !hasAttributeWithoutSynchronization(SVGNames::keyPointsAttr) || ( m_keyTimes.size() > 1 && m_keyTimes.size() == m_keyPoints.size());570 m_animationValid = calcMode == CalcMode::Paced || !hasAttributeWithoutSynchronization(SVGNames::keyPointsAttr) || (keyTimes.size() > 1 && keyTimes.size() == m_keyPoints.size()); 561 571 } 562 572 … … 582 592 } else if (!m_keyPoints.isEmpty() && calcMode != CalcMode::Paced) 583 593 effectivePercent = calculatePercentFromKeyPoints(percent); 584 else if (m_keyPoints.isEmpty() && calcMode == CalcMode::Spline && m_keyTimes.size() > 1)594 else if (m_keyPoints.isEmpty() && calcMode == CalcMode::Spline && keyTimes().size() > 1) 585 595 effectivePercent = calculatePercentForSpline(percent, calculateKeyTimesIndex(percent)); 586 596 else if (animationMode == AnimationMode::FromTo || animationMode == AnimationMode::To) -
trunk/Source/WebCore/svg/SVGAnimationElement.h
r251809 r275868 3 3 * Copyright (C) 2004, 2005, 2006 Rob Buis <buis@kde.org> 4 4 * Copyright (C) 2007 Eric Seidel <eric@webkit.org> 5 * Copyright (C) 2008-20 19Apple Inc. All rights reserved.5 * Copyright (C) 2008-2021 Apple Inc. All rights reserved. 6 6 * Copyright (C) 2008 Cameron McCormack <cam@mcc.id.au> 7 7 * Copyright (C) Research In Motion Limited 2011. All rights reserved. … … 124 124 virtual Optional<float> calculateDistance(const String& /*fromString*/, const String& /*toString*/) = 0; 125 125 126 const Vector<float>& keyTimes() const; 126 127 void currentValuesForValuesAnimation(float percent, float& effectivePercent, String& from, String& to); 127 128 void calculateKeyTimesForCalcModePaced(); … … 138 139 AttributeType m_attributeType { AttributeType::Auto }; 139 140 Vector<String> m_values; 140 Vector<float> m_keyTimes; 141 Vector<float> m_keyTimesFromAttribute; 142 Vector<float> m_keyTimesForPaced; 141 143 Vector<float> m_keyPoints; 142 144 Vector<UnitBezier> m_keySplines;
Note:
See TracChangeset
for help on using the changeset viewer.