| 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 |
| 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 12 * Library General Public License for more details. | 12 * Library General Public License for more details. |
| 13 * | 13 * |
| 14 * You should have received a copy of the GNU Library General Public License | 14 * You should have received a copy of the GNU Library General Public License |
| 15 * along with this library; see the file COPYING.LIB. If not, write to | 15 * along with this library; see the file COPYING.LIB. If not, write to |
| 16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
| 17 * Boston, MA 02110-1301, USA. | 17 * Boston, MA 02110-1301, USA. |
| 18 * | 18 * |
| 19 */ | 19 */ |
| 20 | 20 |
| 21 #include "config.h" | 21 #include "config.h" |
| 22 | 22 |
| 23 #include "core/rendering/RenderProgress.h" | 23 #include "core/layout/LayoutProgress.h" |
| 24 | 24 |
| 25 #include "core/html/HTMLProgressElement.h" | 25 #include "core/html/HTMLProgressElement.h" |
| 26 #include "core/layout/LayoutTheme.h" | 26 #include "core/layout/LayoutTheme.h" |
| 27 #include "wtf/CurrentTime.h" | 27 #include "wtf/CurrentTime.h" |
| 28 #include "wtf/RefPtr.h" | 28 #include "wtf/RefPtr.h" |
| 29 | 29 |
| 30 namespace blink { | 30 namespace blink { |
| 31 | 31 |
| 32 RenderProgress::RenderProgress(HTMLElement* element) | 32 LayoutProgress::LayoutProgress(HTMLElement* element) |
| 33 : RenderBlockFlow(element) | 33 : RenderBlockFlow(element) |
| 34 , m_position(HTMLProgressElement::InvalidPosition) | 34 , m_position(HTMLProgressElement::InvalidPosition) |
| 35 , m_animationStartTime(0) | 35 , m_animationStartTime(0) |
| 36 , m_animationRepeatInterval(0) | 36 , m_animationRepeatInterval(0) |
| 37 , m_animationDuration(0) | 37 , m_animationDuration(0) |
| 38 , m_animating(false) | 38 , m_animating(false) |
| 39 , m_animationTimer(this, &RenderProgress::animationTimerFired) | 39 , m_animationTimer(this, &LayoutProgress::animationTimerFired) |
| 40 { | 40 { |
| 41 } | 41 } |
| 42 | 42 |
| 43 RenderProgress::~RenderProgress() | 43 LayoutProgress::~LayoutProgress() |
| 44 { | 44 { |
| 45 } | 45 } |
| 46 | 46 |
| 47 void RenderProgress::destroy() | 47 void LayoutProgress::destroy() |
| 48 { | 48 { |
| 49 if (m_animating) { | 49 if (m_animating) { |
| 50 m_animationTimer.stop(); | 50 m_animationTimer.stop(); |
| 51 m_animating = false; | 51 m_animating = false; |
| 52 } | 52 } |
| 53 RenderBlockFlow::destroy(); | 53 RenderBlockFlow::destroy(); |
| 54 } | 54 } |
| 55 | 55 |
| 56 void RenderProgress::updateFromElement() | 56 void LayoutProgress::updateFromElement() |
| 57 { | 57 { |
| 58 HTMLProgressElement* element = progressElement(); | 58 HTMLProgressElement* element = progressElement(); |
| 59 if (m_position == element->position()) | 59 if (m_position == element->position()) |
| 60 return; | 60 return; |
| 61 m_position = element->position(); | 61 m_position = element->position(); |
| 62 | 62 |
| 63 updateAnimationState(); | 63 updateAnimationState(); |
| 64 setShouldDoFullPaintInvalidation(); | 64 setShouldDoFullPaintInvalidation(); |
| 65 RenderBlockFlow::updateFromElement(); | 65 RenderBlockFlow::updateFromElement(); |
| 66 } | 66 } |
| 67 | 67 |
| 68 double RenderProgress::animationProgress() const | 68 double LayoutProgress::animationProgress() const |
| 69 { | 69 { |
| 70 return m_animating ? (fmod((currentTime() - m_animationStartTime), m_animati
onDuration) / m_animationDuration) : 0; | 70 return m_animating ? (fmod((currentTime() - m_animationStartTime), m_animati
onDuration) / m_animationDuration) : 0; |
| 71 } | 71 } |
| 72 | 72 |
| 73 bool RenderProgress::isDeterminate() const | 73 bool LayoutProgress::isDeterminate() const |
| 74 { | 74 { |
| 75 return (HTMLProgressElement::IndeterminatePosition != position() | 75 return (HTMLProgressElement::IndeterminatePosition != position() |
| 76 && HTMLProgressElement::InvalidPosition != position()); | 76 && HTMLProgressElement::InvalidPosition != position()); |
| 77 } | 77 } |
| 78 | 78 |
| 79 void RenderProgress::animationTimerFired(Timer<RenderProgress>*) | 79 void LayoutProgress::animationTimerFired(Timer<LayoutProgress>*) |
| 80 { | 80 { |
| 81 setShouldDoFullPaintInvalidation(); | 81 setShouldDoFullPaintInvalidation(); |
| 82 if (!m_animationTimer.isActive() && m_animating) | 82 if (!m_animationTimer.isActive() && m_animating) |
| 83 m_animationTimer.startOneShot(m_animationRepeatInterval, FROM_HERE); | 83 m_animationTimer.startOneShot(m_animationRepeatInterval, FROM_HERE); |
| 84 } | 84 } |
| 85 | 85 |
| 86 void RenderProgress::updateAnimationState() | 86 void LayoutProgress::updateAnimationState() |
| 87 { | 87 { |
| 88 m_animationDuration = LayoutTheme::theme().animationDurationForProgressBar(t
his); | 88 m_animationDuration = LayoutTheme::theme().animationDurationForProgressBar(t
his); |
| 89 m_animationRepeatInterval = LayoutTheme::theme().animationRepeatIntervalForP
rogressBar(this); | 89 m_animationRepeatInterval = LayoutTheme::theme().animationRepeatIntervalForP
rogressBar(this); |
| 90 | 90 |
| 91 bool animating = style()->hasAppearance() && m_animationDuration > 0; | 91 bool animating = style()->hasAppearance() && m_animationDuration > 0; |
| 92 if (animating == m_animating) | 92 if (animating == m_animating) |
| 93 return; | 93 return; |
| 94 | 94 |
| 95 m_animating = animating; | 95 m_animating = animating; |
| 96 if (m_animating) { | 96 if (m_animating) { |
| 97 m_animationStartTime = currentTime(); | 97 m_animationStartTime = currentTime(); |
| 98 m_animationTimer.startOneShot(m_animationRepeatInterval, FROM_HERE); | 98 m_animationTimer.startOneShot(m_animationRepeatInterval, FROM_HERE); |
| 99 } else | 99 } else { |
| 100 m_animationTimer.stop(); | 100 m_animationTimer.stop(); |
| 101 } |
| 101 } | 102 } |
| 102 | 103 |
| 103 HTMLProgressElement* RenderProgress::progressElement() const | 104 HTMLProgressElement* LayoutProgress::progressElement() const |
| 104 { | 105 { |
| 105 if (!node()) | 106 if (!node()) |
| 106 return 0; | 107 return 0; |
| 107 | 108 |
| 108 if (isHTMLProgressElement(*node())) | 109 if (isHTMLProgressElement(*node())) |
| 109 return toHTMLProgressElement(node()); | 110 return toHTMLProgressElement(node()); |
| 110 | 111 |
| 111 ASSERT(node()->shadowHost()); | 112 ASSERT(node()->shadowHost()); |
| 112 return toHTMLProgressElement(node()->shadowHost()); | 113 return toHTMLProgressElement(node()->shadowHost()); |
| 113 } | 114 } |
| 114 | 115 |
| 115 } // namespace blink | 116 } // namespace blink |
| OLD | NEW |