Changeset 60604 in webkit
- Timestamp:
- Jun 2, 2010 9:45:51 PM (14 years ago)
- Location:
- trunk/WebCore
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r60591 r60604 1 2010-06-02 MORITA Hajime <morrita@google.com> 2 3 Reviewed by Kent Tamura. 4 5 [Chromium] Support HTML5 <progress> element on Linux. 6 https://bugs.webkit.org/show_bug.cgi?id=37310 7 8 Implemented RenderThemeChromiumSkia::paintProgressBar(), extracing 9 determinateProgressValueRectFor() from RenderThemeChromiumWin to 10 RenderThemeChromiumSkia 11 12 No new tests. Expectations will come after ENABLE_PROGRESS_BAR get 13 enabled on chromium. 14 15 * rendering/RenderThemeChromiumSkia.cpp: 16 (WebCore::RenderThemeChromiumSkia::determinateProgressValueRectFor): 17 (WebCore::RenderThemeChromiumSkia::indeterminateProgressValueRectFor): 18 (WebCore::RenderThemeChromiumSkia::animationRepeatIntervalForProgressBar): 19 (WebCore::RenderThemeChromiumSkia::animationDurationForProgressBar): 20 (WebCore::RenderThemeChromiumSkia::paintProgressBar): 21 (WebCore::RenderThemeChromiumSkia::progressValueRectFor): 22 * rendering/RenderThemeChromiumSkia.h: 23 * rendering/RenderThemeChromiumWin.cpp: 24 (WebCore::RenderThemeChromiumWin::paintProgressBar): 25 1 26 2010-06-02 Nico Weber <thakis@chromium.org> 2 27 -
trunk/WebCore/rendering/RenderThemeChromiumSkia.cpp
r59956 r60604 27 27 #include "ChromiumBridge.h" 28 28 #include "CSSValueKeywords.h" 29 #include "CurrentTime.h" 29 30 #include "GraphicsContext.h" 30 31 #include "HTMLMediaElement.h" … … 36 37 #include "RenderMediaControlsChromium.h" 37 38 #include "RenderObject.h" 39 #include "RenderProgress.h" 38 40 #include "RenderSlider.h" 39 41 #include "ScrollbarTheme.h" … … 769 771 } 770 772 773 #if ENABLE(PROGRESS_TAG) 774 775 // 776 // Following values are come from default of GTK+ 777 // 778 static const int progressDeltaPixelsPerSecond = 100; 779 static const int progressActivityBlocks = 5; 780 static const int progressAnimationFrmaes = 10; 781 static const double progressAnimationInterval = 0.125; 782 783 IntRect RenderThemeChromiumSkia::determinateProgressValueRectFor(RenderProgress* renderProgress, const IntRect& rect) const 784 { 785 int dx = rect.width() * renderProgress->position(); 786 if (renderProgress->style()->direction() == RTL) 787 return IntRect(rect.x() + rect.width() - dx, rect.y(), dx, rect.height()); 788 return IntRect(rect.x(), rect.y(), dx, rect.height()); 789 } 790 791 IntRect RenderThemeChromiumSkia::indeterminateProgressValueRectFor(RenderProgress* renderProgress, const IntRect& rect) const 792 { 793 794 int valueWidth = rect.width() / progressActivityBlocks; 795 int movableWidth = rect.width() - valueWidth; 796 if (movableWidth <= 0) 797 return IntRect(); 798 799 double progress = renderProgress->animationProgress(); 800 if (progress < 0.5) 801 return IntRect(rect.x() + progress * 2 * movableWidth, rect.y(), valueWidth, rect.height()); 802 return IntRect(rect.x() + (1.0 - progress) * 2 * movableWidth, rect.y(), valueWidth, rect.height()); 803 } 804 805 806 double RenderThemeChromiumSkia::animationRepeatIntervalForProgressBar(RenderProgress*) const 807 { 808 return progressAnimationInterval; 809 } 810 811 double RenderThemeChromiumSkia::animationDurationForProgressBar(RenderProgress* renderProgress) const 812 { 813 return progressAnimationInterval * progressAnimationFrmaes * 2; // "2" for back and forth 814 } 815 816 bool RenderThemeChromiumSkia::paintProgressBar(RenderObject* renderObject, const RenderObject::PaintInfo& paintInfo, const IntRect& rect) 817 { 818 static Image* barImage = Image::loadPlatformResource("linuxProgressBar").releaseRef(); 819 static Image* valueImage = Image::loadPlatformResource("linuxProgressValue").releaseRef(); 820 static Image* leftBorderImage = Image::loadPlatformResource("linuxProgressBorderLeft").releaseRef(); 821 static Image* rightBorderImage = Image::loadPlatformResource("linuxProgressBorderRight").releaseRef(); 822 ASSERT(barImage->height() == valueImage->height()); 823 824 825 RenderProgress* renderProgress = toRenderProgress(renderObject); 826 double tileScale = static_cast<double>(rect.height()) / barImage->height(); 827 IntSize barTileSize(static_cast<int>(barImage->width() * tileScale), rect.height()); 828 ColorSpace colorSpace = renderObject->style()->colorSpace(); 829 830 paintInfo.context->drawTiledImage(barImage, colorSpace, rect, IntPoint(0, 0), barTileSize); 831 832 IntRect valueRect = progressValueRectFor(renderProgress, rect); 833 if (valueRect.width()) { 834 835 IntSize valueTileSize(static_cast<int>(valueImage->width() * tileScale), valueRect.height()); 836 int leftOffset = valueRect.x() - rect.x(); 837 int roundedLeftOffset= (leftOffset / valueTileSize.width()) * valueTileSize.width(); 838 int dstLeftValueWidth = roundedLeftOffset - leftOffset + (leftOffset % valueImage->width()) ? valueTileSize.width() : 0; 839 840 IntRect dstLeftValueRect(valueRect.x(), valueRect.y(), dstLeftValueWidth, valueRect.height()); 841 int srcLeftValueWidth = dstLeftValueWidth / tileScale; 842 IntRect srcLeftValueRect(valueImage->width() - srcLeftValueWidth, 0, srcLeftValueWidth, valueImage->height()); 843 paintInfo.context->drawImage(valueImage, colorSpace, dstLeftValueRect, srcLeftValueRect); 844 845 int rightOffset = valueRect.right() - rect.x(); 846 int roundedRightOffset = (rightOffset / valueTileSize.width()) * valueTileSize.width(); 847 int dstRightValueWidth = rightOffset - roundedRightOffset; 848 IntRect dstRightValueRect(rect.x() + roundedRightOffset, valueRect.y(), dstRightValueWidth, valueTileSize.height()); 849 int srcRightValueWidth = dstRightValueWidth / tileScale; 850 IntRect srcRightValueRect(0, 0, srcRightValueWidth, valueImage->height()); 851 paintInfo.context->drawImage(valueImage, colorSpace, dstRightValueRect, srcRightValueRect); 852 853 IntRect alignedValueRect(dstLeftValueRect.right(), dstLeftValueRect.y(), 854 dstRightValueRect.x() - dstLeftValueRect.right(), dstLeftValueRect.height()); 855 paintInfo.context->drawTiledImage(valueImage, colorSpace, alignedValueRect, IntPoint(0, 0), valueTileSize); 856 } 857 858 int dstLeftBorderWidth = leftBorderImage->width() * tileScale; 859 IntRect dstLeftBorderRect(rect.x(), rect.y(), dstLeftBorderWidth, rect.height()); 860 paintInfo.context->drawImage(leftBorderImage, colorSpace, dstLeftBorderRect, leftBorderImage->rect()); 861 862 int dstRightBorderWidth = rightBorderImage->width() * tileScale; 863 IntRect dstRightBorderRect(rect.right() - dstRightBorderWidth, rect.y(), dstRightBorderWidth, rect.height()); 864 paintInfo.context->drawImage(rightBorderImage, colorSpace, dstRightBorderRect, rightBorderImage->rect()); 865 866 return false; 867 } 868 869 870 IntRect RenderThemeChromiumSkia::progressValueRectFor(RenderProgress* renderProgress, const IntRect& rect) const 871 { 872 return renderProgress->isDeterminate() ? determinateProgressValueRectFor(renderProgress, rect) : indeterminateProgressValueRectFor(renderProgress, rect); 873 } 874 875 #endif 876 771 877 } // namespace WebCore -
trunk/WebCore/rendering/RenderThemeChromiumSkia.h
r55714 r60604 32 32 33 33 namespace WebCore { 34 35 class RenderProgress; 34 36 35 37 class RenderThemeChromiumSkia : public RenderTheme { … … 118 120 virtual bool paintSliderThumb(RenderObject*, const RenderObject::PaintInfo&, const IntRect&); 119 121 122 #if ENABLE(PROGRESS_TAG) 123 virtual double animationRepeatIntervalForProgressBar(RenderProgress*) const; 124 virtual double animationDurationForProgressBar(RenderProgress*) const; 125 virtual bool paintProgressBar(RenderObject*, const RenderObject::PaintInfo&, const IntRect&); 126 #endif 127 120 128 // These methods define the padding for the MenuList's inner block. 121 129 virtual int popupInternalPaddingLeft(RenderStyle*) const; … … 146 154 virtual double caretBlinkIntervalInternal() const; 147 155 156 #if ENABLE(PROGRESS_TAG) 157 IntRect determinateProgressValueRectFor(RenderProgress*, const IntRect&) const; 158 IntRect indeterminateProgressValueRectFor(RenderProgress*, const IntRect&) const; 159 IntRect progressValueRectFor(RenderProgress*, const IntRect&) const; 160 #endif 161 148 162 private: 149 163 int menuListInternalPadding(RenderStyle*, int paddingType) const; -
trunk/WebCore/rendering/RenderThemeChromiumWin.cpp
r59959 r60604 681 681 { 682 682 RenderProgress* renderProgress = toRenderProgress(o); 683 684 IntRect valueRect; 685 if (renderProgress->isDeterminate()) { 686 int dx = r.width() * renderProgress->position(); 687 if (renderProgress->style()->direction() == RTL) 688 valueRect = IntRect(r.x() + r.width() - dx, r.y(), dx, r.height()); 689 else 690 valueRect = IntRect(r.x(), r.y(), dx, r.height()); 691 } else { 692 // For indeterminate bar, valueRect is ignored and it is computed by the theme engine 693 // because the animation is a platform detail and WebKit doesn't need to know how. 694 valueRect = IntRect(0, 0, 0, 0); 695 } 696 683 // For indeterminate bar, valueRect is ignored and it is computed by the theme engine 684 // because the animation is a platform detail and WebKit doesn't need to know how. 685 IntRect valueRect = renderProgress->isDeterminate() ? determianteProgressValueRectFor(renderProgress, r) : IntRect(0, 0, 0, 0); 697 686 double animatedSeconds = renderProgress->animationStartTime() ? WTF::currentTime() - renderProgress->animationStartTime() : 0; 698 687 ThemePainter painter(i.context, r);
Note: See TracChangeset
for help on using the changeset viewer.