Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). | 2 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). |
| 3 * | 3 * |
| 4 * This library is free software; you can redistribute it and/or | 4 * This library is free software; you can redistribute it and/or |
| 5 * modify it under the terms of the GNU Library General Public | 5 * modify it under the terms of the GNU Library General Public |
| 6 * License as published by the Free Software Foundation; either | 6 * License as published by the Free Software Foundation; either |
| 7 * version 2 of the License, or (at your option) any later version. | 7 * version 2 of the License, or (at your option) any later version. |
| 8 * | 8 * |
| 9 * This library is distributed in the hope that it will be useful, | 9 * This library is distributed in the hope that it will be useful, |
| 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 67 { | 67 { |
| 68 return m_animating ? (fmod((currentTime() - m_animationStartTime), m_animati onDuration) / m_animationDuration) : 0; | 68 return m_animating ? (fmod((currentTime() - m_animationStartTime), m_animati onDuration) / m_animationDuration) : 0; |
| 69 } | 69 } |
| 70 | 70 |
| 71 bool LayoutProgress::isDeterminate() const | 71 bool LayoutProgress::isDeterminate() const |
| 72 { | 72 { |
| 73 return (HTMLProgressElement::IndeterminatePosition != position() | 73 return (HTMLProgressElement::IndeterminatePosition != position() |
| 74 && HTMLProgressElement::InvalidPosition != position()); | 74 && HTMLProgressElement::InvalidPosition != position()); |
| 75 } | 75 } |
| 76 | 76 |
| 77 bool LayoutProgress::isAnimationTimerActive() const | |
| 78 { | |
| 79 return m_animationTimer.isActive(); | |
|
Xianzhu
2016/02/22 23:17:27
Nit: Can you use m_animating (and rename this func
Stephen Chennney
2016/02/23 19:24:01
I would rather check the timer itself, as that wil
| |
| 80 } | |
| 81 | |
| 77 void LayoutProgress::animationTimerFired(Timer<LayoutProgress>*) | 82 void LayoutProgress::animationTimerFired(Timer<LayoutProgress>*) |
| 78 { | 83 { |
| 79 setShouldDoFullPaintInvalidation(); | 84 setShouldDoFullPaintInvalidation(); |
| 80 if (!m_animationTimer.isActive() && m_animating) | 85 if (!m_animationTimer.isActive() && m_animating) |
| 81 m_animationTimer.startOneShot(m_animationRepeatInterval, BLINK_FROM_HERE ); | 86 m_animationTimer.startOneShot(m_animationRepeatInterval, BLINK_FROM_HERE ); |
| 82 } | 87 } |
| 83 | 88 |
| 84 void LayoutProgress::updateAnimationState() | 89 void LayoutProgress::updateAnimationState() |
| 85 { | 90 { |
| 86 m_animationDuration = LayoutTheme::theme().animationDurationForProgressBar() ; | 91 m_animationDuration = LayoutTheme::theme().animationDurationForProgressBar() ; |
| 87 m_animationRepeatInterval = LayoutTheme::theme().animationRepeatIntervalForP rogressBar(); | 92 m_animationRepeatInterval = LayoutTheme::theme().animationRepeatIntervalForP rogressBar(); |
| 88 | 93 |
| 89 bool animating = style()->hasAppearance() && m_animationDuration > 0; | 94 bool animating = !isDeterminate() && style()->hasAppearance() && m_animation Duration > 0; |
| 90 if (animating == m_animating) | 95 if (animating == m_animating) |
| 91 return; | 96 return; |
| 92 | 97 |
| 93 m_animating = animating; | 98 m_animating = animating; |
| 94 if (m_animating) { | 99 if (m_animating) { |
| 95 m_animationStartTime = currentTime(); | 100 m_animationStartTime = currentTime(); |
| 96 m_animationTimer.startOneShot(m_animationRepeatInterval, BLINK_FROM_HERE ); | 101 m_animationTimer.startOneShot(m_animationRepeatInterval, BLINK_FROM_HERE ); |
| 97 } else { | 102 } else { |
| 98 m_animationTimer.stop(); | 103 m_animationTimer.stop(); |
| 99 } | 104 } |
| 100 } | 105 } |
| 101 | 106 |
| 102 HTMLProgressElement* LayoutProgress::progressElement() const | 107 HTMLProgressElement* LayoutProgress::progressElement() const |
| 103 { | 108 { |
| 104 if (!node()) | 109 if (!node()) |
| 105 return nullptr; | 110 return nullptr; |
| 106 | 111 |
| 107 if (isHTMLProgressElement(*node())) | 112 if (isHTMLProgressElement(*node())) |
| 108 return toHTMLProgressElement(node()); | 113 return toHTMLProgressElement(node()); |
| 109 | 114 |
| 110 ASSERT(node()->shadowHost()); | 115 ASSERT(node()->shadowHost()); |
| 111 return toHTMLProgressElement(node()->shadowHost()); | 116 return toHTMLProgressElement(node()->shadowHost()); |
| 112 } | 117 } |
| 113 | 118 |
| 114 } // namespace blink | 119 } // namespace blink |
| OLD | NEW |