Changeset 56850 in webkit
- Timestamp:
- Mar 31, 2010 10:06:57 AM (14 years ago)
- Location:
- trunk/WebCore
- Files:
-
- 2 added
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r56849 r56850 1 2010-03-31 Yael Aharon <yael.aharon@nokia.com> 2 3 Reviewed by Antti Koivisto. 4 5 Add animation to progress element 6 https://bugs.webkit.org/show_bug.cgi?id=36664 7 8 Add a timer to control the animation. The timer is started after painting 9 or a state change in the progress bar, to prevent animation from running 10 when the progress bar is not visible. 11 12 * html/HTMLProgressElement.cpp: 13 (WebCore::HTMLProgressElement::createRenderer): 14 * manual-tests/dom: Added. 15 * manual-tests/dom/progressbar.html: Added. 16 * platform/qt/RenderThemeQt.cpp: 17 (WebCore::RenderThemeQt::animationRepeatIntervalForProgressBar): 18 (WebCore::RenderThemeQt::animationDurationForProgressBar): 19 (WebCore::RenderThemeQt::paintProgressBar): 20 * platform/qt/RenderThemeQt.h: 21 * rendering/RenderProgress.cpp: 22 (WebCore::RenderProgress::RenderProgress): 23 (WebCore::RenderProgress::layout): 24 (WebCore::RenderProgress::updateFromElement): 25 (WebCore::RenderProgress::animationProgress): 26 (WebCore::RenderProgress::animationTimerFired): 27 (WebCore::RenderProgress::paint): 28 (WebCore::RenderProgress::updateAnimationState): 29 * rendering/RenderProgress.h: 30 * rendering/RenderTheme.cpp: 31 (WebCore::RenderTheme::animationRepeatIntervalForProgressBar): 32 (WebCore::RenderTheme::animationDurationForProgressBar): 33 * rendering/RenderTheme.h: 34 1 35 2010-03-31 Pavel Feldman <pfeldman@chromium.org> 2 36 -
trunk/WebCore/html/HTMLProgressElement.cpp
r56126 r56850 46 46 } 47 47 48 RenderObject* HTMLProgressElement::createRenderer(RenderArena* arena, RenderStyle* style)48 RenderObject* HTMLProgressElement::createRenderer(RenderArena* arena, RenderStyle*) 49 49 { 50 50 return new (arena) RenderProgress(this); -
trunk/WebCore/platform/qt/RenderThemeQt.cpp
r56629 r56850 654 654 655 655 #if ENABLE(PROGRESS_TAG) 656 bool RenderThemeQt::getNumberOfPixelsForProgressPosition(double position, int& progressSize) const 657 { 658 progressSize = 65536 * position; 659 return false; 656 double RenderThemeQt::animationRepeatIntervalForProgressBar(RenderProgress* renderProgress) const 657 { 658 if (renderProgress->position() >= 0) 659 return 0; 660 661 // FIXME: Use hard-coded value until http://bugreports.qt.nokia.com/browse/QTBUG-9171 is fixed. 662 // Use the value from windows style which is 10 fps. 663 return 0.1; 664 } 665 666 double RenderThemeQt::animationDurationForProgressBar(RenderProgress* renderProgress) const 667 { 668 if (renderProgress->position() >= 0) 669 return 0; 670 671 QStyleOptionProgressBarV2 option; 672 option.rect.setSize(renderProgress->size()); 673 // FIXME: Until http://bugreports.qt.nokia.com/browse/QTBUG-9171 is fixed, 674 // we simulate one square animating across the progress bar. 675 return (option.rect.width() / qStyle()->pixelMetric(QStyle::PM_ProgressBarChunkWidth, &option)) * animationRepeatIntervalForProgressBar(renderProgress); 660 676 } 661 677 … … 687 703 option.rect.setSize(r.size()); 688 704 689 p.drawControl(QStyle::CE_ProgressBar, option); 705 if (option.progress < 0) { 706 // FIXME: Until http://bugreports.qt.nokia.com/browse/QTBUG-9171 is fixed, 707 // we simulate one square animating across the progress bar. 708 p.drawControl(QStyle::CE_ProgressBarGroove, option); 709 int chunkWidth = qStyle()->pixelMetric(QStyle::PM_ProgressBarChunkWidth, &option); 710 QColor color = (option.palette.highlight() == option.palette.background()) ? option.palette.color(QPalette::Active, QPalette::Highlight) : option.palette.color(QPalette::Highlight); 711 if (renderProgress->style()->direction() == RTL) 712 p.painter->fillRect(option.rect.right() - chunkWidth - renderProgress->animationProgress() * option.rect.width(), 0, chunkWidth, option.rect.height(), color); 713 else 714 p.painter->fillRect(renderProgress->animationProgress() * option.rect.width(), 0, chunkWidth, option.rect.height(), color); 715 } else 716 p.drawControl(QStyle::CE_ProgressBar, option); 717 690 718 p.painter->translate(-topLeft); 691 719 -
trunk/WebCore/platform/qt/RenderThemeQt.h
r56343 r56850 35 35 namespace WebCore { 36 36 37 #if ENABLE(PROGRESS_TAG) 38 class RenderProgress; 39 #endif 37 40 class RenderStyle; 38 41 class HTMLMediaElement; … … 129 132 130 133 #if ENABLE(PROGRESS_TAG) 131 // Helper method for optimizing the paint area ofthe progress bar.132 // If supported, it returns number of pixels needed to draw the progress bar up to the progress position.133 // progressSize is the value that is passed back to RenderTheme during drawing.134 virtual bool getNumberOfPixelsForProgressPosition(double position, int& progressSize) const;134 // Returns the repeat interval of the animation for the progress bar. 135 virtual double animationRepeatIntervalForProgressBar(RenderProgress* renderProgress) const; 136 // Returns the duration of the animation for the progress bar. 137 virtual double animationDurationForProgressBar(RenderProgress* renderProgress) const; 135 138 #endif 136 139 -
trunk/WebCore/rendering/RenderProgress.cpp
r56629 r56850 36 36 : RenderBlock(element) 37 37 , m_position(-1) 38 , m_animationStartTime(0) 39 , m_animationRepeatInterval(0) 40 , m_animationDuration(0) 41 , m_animating(false) 42 , m_animationTimer(this, &RenderProgress::animationTimerFired) 38 43 { 39 44 } … … 50 55 m_overflow.clear(); 51 56 57 updateAnimationState(); 58 52 59 repainter.repaintAfterLayout(); 53 60 … … 62 69 m_position = element->position(); 63 70 71 updateAnimationState(); 72 64 73 repaint(); 74 } 75 76 double RenderProgress::animationProgress() 77 { 78 return m_animating ? (fmod((currentTime() - m_animationStartTime), m_animationDuration) / m_animationDuration) : 0; 79 } 80 81 void RenderProgress::animationTimerFired(Timer<RenderProgress>*) 82 { 83 repaint(); 84 } 85 86 void RenderProgress::paint(PaintInfo& paintInfo, int tx, int ty) 87 { 88 if (paintInfo.phase == PaintPhaseBlockBackground) { 89 if (!m_animationTimer.isActive() && m_animating) 90 m_animationTimer.startOneShot(m_animationRepeatInterval); 91 } 92 93 RenderBlock::paint(paintInfo, tx, ty); 94 } 95 96 void RenderProgress::updateAnimationState() 97 { 98 m_animationDuration = theme()->animationDurationForProgressBar(this); 99 m_animationRepeatInterval = theme()->animationRepeatIntervalForProgressBar(this); 100 101 bool animating = m_animationDuration > 0; 102 if (animating == m_animating) 103 return; 104 105 m_animating = animating; 106 if (m_animating) { 107 m_animationStartTime = currentTime(); 108 m_animationTimer.startOneShot(m_animationRepeatInterval); 109 } else 110 m_animationTimer.stop(); 65 111 } 66 112 -
trunk/WebCore/rendering/RenderProgress.h
r56629 r56850 33 33 RenderProgress(HTMLProgressElement*); 34 34 double position() { return m_position; } 35 double animationProgress(); 35 36 36 37 private: … … 39 40 virtual void layout(); 40 41 virtual void updateFromElement(); 42 virtual void paint(PaintInfo&, int tx, int ty); 43 44 void animationTimerFired(Timer<RenderProgress>*); 45 void updateAnimationState(); 46 41 47 double m_position; 48 double m_animationStartTime; 49 double m_animationRepeatInterval; 50 double m_animationDuration; 51 bool m_animating; 52 Timer<RenderProgress> m_animationTimer; 42 53 }; 43 54 -
trunk/WebCore/rendering/RenderTheme.cpp
r56126 r56850 841 841 842 842 #if ENABLE(PROGRESS_TAG) 843 bool RenderTheme::getNumberOfPixelsForProgressPosition(double , int& progressSize) const 844 { 845 progressSize = 0; 846 return false; 843 double RenderTheme::animationRepeatIntervalForProgressBar(RenderProgress*) const 844 { 845 return 0; 846 } 847 848 double RenderTheme::animationDurationForProgressBar(RenderProgress*) const 849 { 850 return 0; 847 851 } 848 852 -
trunk/WebCore/rendering/RenderTheme.h
r56126 r56850 40 40 class PopupMenu; 41 41 class RenderMenuList; 42 #if ENABLE(PROGRESS_TAG) 43 class RenderProgress; 44 #endif 42 45 class CSSStyleSheet; 43 46 … … 171 174 172 175 #if ENABLE(PROGRESS_TAG) 173 // Helper method for optimizing the paint area ofthe progress bar.174 // If supported, it returns number of pixels needed to draw the progress bar up to the progress position.175 // progressSize is the value that is passed back to RenderTheme during drawing.176 virtual bool getNumberOfPixelsForProgressPosition(double position, int& progressSize) const;176 // Returns the repeat interval of the animation for the progress bar. 177 virtual double animationRepeatIntervalForProgressBar(RenderProgress*) const; 178 // Returns the duration of the animation for the progress bar. 179 virtual double animationDurationForProgressBar(RenderProgress*) const; 177 180 #endif 178 181
Note: See TracChangeset
for help on using the changeset viewer.