Changeset 91002 in webkit


Ignore:
Timestamp:
Jul 14, 2011 9:20:01 AM (13 years ago)
Author:
commit-queue@webkit.org
Message:

Patch by Young Han Lee <joybro@company100.net> on 2011-07-14
Reviewed by Dirk Schulze.

REGRESSION (r89774): svg/W3C-SVG-1.1/animate-elem-82-t.svg hits assertion failure.
https://bugs.webkit.org/show_bug.cgi?id=63911

Some functions assumed calculateKeyTimesIndex() does not return the last index of
the keyTimes, but it would be right behavior for calculateKeyTimesIndex() when it
accepts 1 as the percent argument.

To avoid the assumption, and for more efficiency, this patch allows the functions
using calculateKeyTimesIndex() to return early when it accepts 1 as the percent argument.
These functions have always returned the last element of the corresponding vector
in that situation.

  • svg/SVGAnimationElement.cpp:

(WebCore::SVGAnimationElement::calculatePercentFromKeyPoints):
(WebCore::SVGAnimationElement::currentValuesForValuesAnimation):

Location:
trunk/Source/WebCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r90996 r91002  
     12011-07-14  Young Han Lee  <joybro@company100.net>
     2
     3        Reviewed by Dirk Schulze.
     4
     5        REGRESSION (r89774): svg/W3C-SVG-1.1/animate-elem-82-t.svg hits assertion failure.
     6        https://bugs.webkit.org/show_bug.cgi?id=63911
     7
     8        Some functions assumed calculateKeyTimesIndex() does not return the last index of
     9        the keyTimes, but it would be right behavior for calculateKeyTimesIndex() when it
     10        accepts 1 as the percent argument.
     11
     12        To avoid the assumption, and for more efficiency, this patch allows the functions
     13        using calculateKeyTimesIndex() to return early when it accepts 1 as the percent argument.
     14        These functions have always returned the last element of the corresponding vector
     15        in that situation.
     16
     17        * svg/SVGAnimationElement.cpp:
     18        (WebCore::SVGAnimationElement::calculatePercentFromKeyPoints):
     19        (WebCore::SVGAnimationElement::currentValuesForValuesAnimation):
     20
    1212011-07-14  Andrey Kosyakov  <caseq@chromium.org>
    222
  • trunk/Source/WebCore/svg/SVGAnimationElement.cpp

    r90680 r91002  
    439439    ASSERT(m_keyPoints.size() == m_keyTimes.size());
    440440
     441    if (percent == 1)
     442        return m_keyPoints[m_keyPoints.size() - 1];
     443
    441444    unsigned index = calculateKeyTimesIndex(percent);
    442445    float fromPercent = m_keyTimes[index];
     
    446449   
    447450    if (calcMode() == CalcModeDiscrete)
    448         return percent == 1 ? toKeyPoint : fromKeyPoint;
    449    
    450     float keyPointPercent = percent == 1 ? 1 : (percent - fromPercent) / (toPercent - fromPercent);
     451        return fromKeyPoint;
     452   
     453    float keyPointPercent = (percent - fromPercent) / (toPercent - fromPercent);
    451454   
    452455    if (calcMode() == CalcModeSpline) {
     
    474477    ASSERT(valuesCount > 1);
    475478   
     479    if (percent == 1) {
     480        from = m_values[valuesCount - 1];
     481        to = m_values[valuesCount - 1];
     482        effectivePercent = 1;
     483        return;
     484    }
     485
    476486    CalcMode calcMode = this->calcMode();
    477487    if (hasTagName(SVGNames::animateTag) || hasTagName(SVGNames::animateColorTag)) {
     
    495505    if (calcMode == CalcModeDiscrete) {
    496506        if (!keyTimesCount)
    497             index = percent == 1 ? valuesCount - 1 : static_cast<unsigned>(percent * valuesCount);
     507            index = static_cast<unsigned>(percent * valuesCount);
    498508        from = m_values[index];
    499509        to = m_values[index];
     
    518528    to = m_values[index + 1];
    519529    ASSERT(toPercent > fromPercent);
    520     effectivePercent = percent == 1 ? 1 : (percent - fromPercent) / (toPercent - fromPercent);
     530    effectivePercent = (percent - fromPercent) / (toPercent - fromPercent);
    521531   
    522532    if (calcMode == CalcModeSpline) {
Note: See TracChangeset for help on using the changeset viewer.