initial import
[vuplus_webkit] / Source / WebCore / rendering / RenderThemeChromiumSkia.cpp
1 /*
2  * Copyright (C) 2007 Apple Inc.
3  * Copyright (C) 2007 Alp Toker <alp@atoker.com>
4  * Copyright (C) 2008 Collabora Ltd.
5  * Copyright (C) 2008, 2009 Google Inc.
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Library General Public
9  * License as published by the Free Software Foundation; either
10  * version 2 of the License, or (at your option) any later version.
11  *
12  * This library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  * Library General Public License for more details.
16  *
17  * You should have received a copy of the GNU Library General Public License
18  * along with this library; see the file COPYING.LIB.  If not, write to
19  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20  * Boston, MA 02110-1301, USA.
21  *
22  */
23
24 #include "config.h"
25 #include "RenderThemeChromiumSkia.h"
26
27 #include "CSSValueKeywords.h"
28 #include "CurrentTime.h"
29 #include "GraphicsContext.h"
30 #include "HTMLMediaElement.h"
31 #include "HTMLNames.h"
32 #include "Image.h"
33 #include "MediaControlElements.h"
34 #include "PaintInfo.h"
35 #include "PlatformSupport.h"
36 #include "PlatformContextSkia.h"
37 #include "RenderBox.h"
38 #include "RenderMediaControlsChromium.h"
39 #include "RenderObject.h"
40 #include "RenderProgress.h"
41 #include "RenderSlider.h"
42 #include "ScrollbarTheme.h"
43 #include "TimeRanges.h"
44 #include "TransformationMatrix.h"
45 #include "UserAgentStyleSheets.h"
46
47 #include "SkShader.h"
48 #include "SkGradientShader.h"
49
50 namespace WebCore {
51
52 enum PaddingType {
53     TopPadding,
54     RightPadding,
55     BottomPadding,
56     LeftPadding
57 };
58
59 static const int styledMenuListInternalPadding[4] = { 1, 4, 1, 4 };
60
61 // These values all match Safari/Win.
62 static const float defaultControlFontPixelSize = 13;
63 static const float defaultCancelButtonSize = 9;
64 static const float minCancelButtonSize = 5;
65 static const float maxCancelButtonSize = 21;
66 static const float defaultSearchFieldResultsDecorationSize = 13;
67 static const float minSearchFieldResultsDecorationSize = 9;
68 static const float maxSearchFieldResultsDecorationSize = 30;
69 static const float defaultSearchFieldResultsButtonWidth = 18;
70
71 // We aim to match IE here.
72 // -IE uses a font based on the encoding as the default font for form controls.
73 // -Gecko uses MS Shell Dlg (actually calls GetStockObject(DEFAULT_GUI_FONT),
74 // which returns MS Shell Dlg)
75 // -Safari uses Lucida Grande.
76 //
77 // FIXME: The only case where we know we don't match IE is for ANSI encodings.
78 // IE uses MS Shell Dlg there, which we render incorrectly at certain pixel
79 // sizes (e.g. 15px). So, for now we just use Arial.
80 const String& RenderThemeChromiumSkia::defaultGUIFont()
81 {
82     DEFINE_STATIC_LOCAL(String, fontFace, ("Arial"));
83     return fontFace;
84 }
85
86 float RenderThemeChromiumSkia::defaultFontSize = 16.0;
87
88 RenderThemeChromiumSkia::RenderThemeChromiumSkia()
89 {
90 }
91
92 RenderThemeChromiumSkia::~RenderThemeChromiumSkia()
93 {
94 }
95
96 // Use the Windows style sheets to match their metrics.
97 String RenderThemeChromiumSkia::extraDefaultStyleSheet()
98 {
99     return String(themeWinUserAgentStyleSheet, sizeof(themeWinUserAgentStyleSheet)) +
100            String(themeChromiumSkiaUserAgentStyleSheet, sizeof(themeChromiumSkiaUserAgentStyleSheet)) +
101            String(themeChromiumUserAgentStyleSheet, sizeof(themeChromiumUserAgentStyleSheet));
102 }
103
104 String RenderThemeChromiumSkia::extraQuirksStyleSheet()
105 {
106     return String(themeWinQuirksUserAgentStyleSheet, sizeof(themeWinQuirksUserAgentStyleSheet));
107 }
108
109 #if ENABLE(VIDEO)
110 String RenderThemeChromiumSkia::extraMediaControlsStyleSheet()
111 {
112     return String(mediaControlsChromiumUserAgentStyleSheet, sizeof(mediaControlsChromiumUserAgentStyleSheet));
113 }
114 #endif
115
116 bool RenderThemeChromiumSkia::supportsHover(const RenderStyle* style) const
117 {
118     return true;
119 }
120
121 bool RenderThemeChromiumSkia::supportsFocusRing(const RenderStyle* style) const
122 {
123     // This causes WebKit to draw the focus rings for us.
124     return false;
125 }
126
127 Color RenderThemeChromiumSkia::platformActiveSelectionBackgroundColor() const
128 {
129     return Color(0x1e, 0x90, 0xff);
130 }
131
132 Color RenderThemeChromiumSkia::platformInactiveSelectionBackgroundColor() const
133 {
134     return Color(0xc8, 0xc8, 0xc8);
135 }
136
137 Color RenderThemeChromiumSkia::platformActiveSelectionForegroundColor() const
138 {
139     return Color::black;
140 }
141
142 Color RenderThemeChromiumSkia::platformInactiveSelectionForegroundColor() const
143 {
144     return Color(0x32, 0x32, 0x32);
145 }
146
147 Color RenderThemeChromiumSkia::platformFocusRingColor() const
148 {
149     static Color focusRingColor(229, 151, 0, 255);
150     return focusRingColor;
151 }
152
153 double RenderThemeChromiumSkia::caretBlinkInterval() const
154 {
155     // Disable the blinking caret in layout test mode, as it introduces
156     // a race condition for the pixel tests. http://b/1198440
157     if (PlatformSupport::layoutTestMode())
158         return 0;
159
160     return caretBlinkIntervalInternal();
161 }
162
163 void RenderThemeChromiumSkia::systemFont(int propId, FontDescription& fontDescription) const
164 {
165     float fontSize = defaultFontSize;
166
167     switch (propId) {
168     case CSSValueWebkitMiniControl:
169     case CSSValueWebkitSmallControl:
170     case CSSValueWebkitControl:
171         // Why 2 points smaller? Because that's what Gecko does. Note that we
172         // are assuming a 96dpi screen, which is the default that we use on
173         // Windows.
174         static const float pointsPerInch = 72.0f;
175         static const float pixelsPerInch = 96.0f;
176         fontSize -= (2.0f / pointsPerInch) * pixelsPerInch;
177         break;
178     }
179
180     fontDescription.firstFamily().setFamily(defaultGUIFont());
181     fontDescription.setSpecifiedSize(fontSize);
182     fontDescription.setIsAbsoluteSize(true);
183     fontDescription.setGenericFamily(FontDescription::NoFamily);
184     fontDescription.setWeight(FontWeightNormal);
185     fontDescription.setItalic(false);
186 }
187
188 int RenderThemeChromiumSkia::minimumMenuListSize(RenderStyle* style) const
189 {
190     return 0;
191 }
192
193 // These are the default dimensions of radio buttons and checkboxes.
194 static const int widgetStandardWidth = 13;
195 static const int widgetStandardHeight = 13;
196
197 // Return a rectangle that has the same center point as |original|, but with a
198 // size capped at |width| by |height|.
199 IntRect center(const IntRect& original, int width, int height)
200 {
201     width = std::min(original.width(), width);
202     height = std::min(original.height(), height);
203     int x = original.x() + (original.width() - width) / 2;
204     int y = original.y() + (original.height() - height) / 2;
205
206     return IntRect(x, y, width, height);
207 }
208
209 void RenderThemeChromiumSkia::setCheckboxSize(RenderStyle* style) const
210 {
211     // If the width and height are both specified, then we have nothing to do.
212     if (!style->width().isIntrinsicOrAuto() && !style->height().isAuto())
213         return;
214
215     // FIXME:  A hard-coded size of 13 is used.  This is wrong but necessary
216     // for now.  It matches Firefox.  At different DPI settings on Windows,
217     // querying the theme gives you a larger size that accounts for the higher
218     // DPI.  Until our entire engine honors a DPI setting other than 96, we
219     // can't rely on the theme's metrics.
220     const IntSize size(widgetStandardWidth, widgetStandardHeight);
221     setSizeIfAuto(style, size);
222 }
223
224 void RenderThemeChromiumSkia::setRadioSize(RenderStyle* style) const
225 {
226     // Use same sizing for radio box as checkbox.
227     setCheckboxSize(style);
228 }
229
230 void RenderThemeChromiumSkia::adjustButtonStyle(CSSStyleSelector*, RenderStyle* style, Element*) const
231 {
232     if (style->appearance() == PushButtonPart) {
233         // Ignore line-height.
234         style->setLineHeight(RenderStyle::initialLineHeight());
235     }
236 }
237
238 bool RenderThemeChromiumSkia::paintTextArea(RenderObject* o, const PaintInfo& i, const IntRect& r)
239 {
240     return paintTextField(o, i, r);
241 }
242
243 void RenderThemeChromiumSkia::adjustSearchFieldStyle(CSSStyleSelector*, RenderStyle* style, Element*) const
244 {
245      // Ignore line-height.
246      style->setLineHeight(RenderStyle::initialLineHeight());
247 }
248
249 bool RenderThemeChromiumSkia::paintSearchField(RenderObject* o, const PaintInfo& i, const IntRect& r)
250 {
251     return paintTextField(o, i, r);
252 }
253
254 void RenderThemeChromiumSkia::adjustSearchFieldCancelButtonStyle(CSSStyleSelector*, RenderStyle* style, Element*) const
255 {
256     // Scale the button size based on the font size
257     float fontScale = style->fontSize() / defaultControlFontPixelSize;
258     int cancelButtonSize = lroundf(std::min(std::max(minCancelButtonSize, defaultCancelButtonSize * fontScale), maxCancelButtonSize));
259     style->setWidth(Length(cancelButtonSize, Fixed));
260     style->setHeight(Length(cancelButtonSize, Fixed));
261 }
262
263 IntRect RenderThemeChromiumSkia::convertToPaintingRect(RenderObject* inputRenderer, const RenderObject* partRenderer, IntRect partRect, const IntRect& localOffset) const
264 {
265     // Compute an offset between the part renderer and the input renderer.
266     IntSize offsetFromInputRenderer = -(partRenderer->offsetFromAncestorContainer(inputRenderer));
267     // Move the rect into partRenderer's coords.
268     partRect.move(offsetFromInputRenderer);
269     // Account for the local drawing offset.
270     partRect.move(localOffset.x(), localOffset.y());
271
272     return partRect;
273 }
274
275 bool RenderThemeChromiumSkia::paintSearchFieldCancelButton(RenderObject* cancelButtonObject, const PaintInfo& paintInfo, const IntRect& r)
276 {
277     // Get the renderer of <input> element.
278     Node* input = cancelButtonObject->node()->shadowAncestorNode();
279     if (!input->renderer()->isBox())
280         return false;
281     RenderBox* inputRenderBox = toRenderBox(input->renderer());
282     IntRect inputContentBox = inputRenderBox->contentBoxRect();
283
284     // Make sure the scaled button stays square and will fit in its parent's box.
285     int cancelButtonSize = std::min(inputContentBox.width(), std::min(inputContentBox.height(), r.height()));
286     // Calculate cancel button's coordinates relative to the input element.
287     // Center the button vertically.  Round up though, so if it has to be one pixel off-center, it will
288     // be one pixel closer to the bottom of the field.  This tends to look better with the text.
289     IntRect cancelButtonRect(cancelButtonObject->offsetFromAncestorContainer(inputRenderBox).width(),
290                              inputContentBox.y() + (inputContentBox.height() - cancelButtonSize + 1) / 2,
291                              cancelButtonSize, cancelButtonSize);
292     IntRect paintingRect = convertToPaintingRect(inputRenderBox, cancelButtonObject, cancelButtonRect, r);
293
294     static Image* cancelImage = Image::loadPlatformResource("searchCancel").releaseRef();
295     static Image* cancelPressedImage = Image::loadPlatformResource("searchCancelPressed").releaseRef();
296     paintInfo.context->drawImage(isPressed(cancelButtonObject) ? cancelPressedImage : cancelImage,
297                                  cancelButtonObject->style()->colorSpace(), paintingRect);
298     return false;
299 }
300
301 void RenderThemeChromiumSkia::adjustSearchFieldDecorationStyle(CSSStyleSelector*, RenderStyle* style, Element*) const
302 {
303     IntSize emptySize(1, 11);
304     style->setWidth(Length(emptySize.width(), Fixed));
305     style->setHeight(Length(emptySize.height(), Fixed));
306 }
307
308 void RenderThemeChromiumSkia::adjustSearchFieldResultsDecorationStyle(CSSStyleSelector*, RenderStyle* style, Element*) const
309 {
310     // Scale the decoration size based on the font size
311     float fontScale = style->fontSize() / defaultControlFontPixelSize;
312     int magnifierSize = lroundf(std::min(std::max(minSearchFieldResultsDecorationSize, defaultSearchFieldResultsDecorationSize * fontScale),
313                                          maxSearchFieldResultsDecorationSize));
314     style->setWidth(Length(magnifierSize, Fixed));
315     style->setHeight(Length(magnifierSize, Fixed));
316 }
317
318 bool RenderThemeChromiumSkia::paintSearchFieldResultsDecoration(RenderObject* magnifierObject, const PaintInfo& paintInfo, const IntRect& r)
319 {
320     // Get the renderer of <input> element.
321     Node* input = magnifierObject->node()->shadowAncestorNode();
322     if (!input->renderer()->isBox())
323         return false;
324     RenderBox* inputRenderBox = toRenderBox(input->renderer());
325     IntRect inputContentBox = inputRenderBox->contentBoxRect();
326
327     // Make sure the scaled decoration stays square and will fit in its parent's box.
328     int magnifierSize = std::min(inputContentBox.width(), std::min(inputContentBox.height(), r.height()));
329     // Calculate decoration's coordinates relative to the input element.
330     // Center the decoration vertically.  Round up though, so if it has to be one pixel off-center, it will
331     // be one pixel closer to the bottom of the field.  This tends to look better with the text.
332     IntRect magnifierRect(magnifierObject->offsetFromAncestorContainer(inputRenderBox).width(),
333                           inputContentBox.y() + (inputContentBox.height() - magnifierSize + 1) / 2,
334                           magnifierSize, magnifierSize);
335     IntRect paintingRect = convertToPaintingRect(inputRenderBox, magnifierObject, magnifierRect, r);
336
337     static Image* magnifierImage = Image::loadPlatformResource("searchMagnifier").releaseRef();
338     paintInfo.context->drawImage(magnifierImage, magnifierObject->style()->colorSpace(), paintingRect);
339     return false;
340 }
341
342 void RenderThemeChromiumSkia::adjustSearchFieldResultsButtonStyle(CSSStyleSelector*, RenderStyle* style, Element*) const
343 {
344     // Scale the button size based on the font size
345     float fontScale = style->fontSize() / defaultControlFontPixelSize;
346     int magnifierHeight = lroundf(std::min(std::max(minSearchFieldResultsDecorationSize, defaultSearchFieldResultsDecorationSize * fontScale),
347                                            maxSearchFieldResultsDecorationSize));
348     int magnifierWidth = lroundf(magnifierHeight * defaultSearchFieldResultsButtonWidth / defaultSearchFieldResultsDecorationSize);
349     style->setWidth(Length(magnifierWidth, Fixed));
350     style->setHeight(Length(magnifierHeight, Fixed));
351 }
352
353 bool RenderThemeChromiumSkia::paintSearchFieldResultsButton(RenderObject* magnifierObject, const PaintInfo& paintInfo, const IntRect& r)
354 {
355     // Get the renderer of <input> element.
356     Node* input = magnifierObject->node()->shadowAncestorNode();
357     if (!input->renderer()->isBox())
358         return false;
359     RenderBox* inputRenderBox = toRenderBox(input->renderer());
360     IntRect inputContentBox = inputRenderBox->contentBoxRect();
361
362     // Make sure the scaled decoration will fit in its parent's box.
363     int magnifierHeight = std::min(inputContentBox.height(), r.height());
364     int magnifierWidth = std::min(inputContentBox.width(), static_cast<int>(magnifierHeight * defaultSearchFieldResultsButtonWidth / defaultSearchFieldResultsDecorationSize));
365     IntRect magnifierRect(magnifierObject->offsetFromAncestorContainer(inputRenderBox).width(),
366                           inputContentBox.y() + (inputContentBox.height() - magnifierHeight + 1) / 2,
367                           magnifierWidth, magnifierHeight);
368     IntRect paintingRect = convertToPaintingRect(inputRenderBox, magnifierObject, magnifierRect, r);
369
370     static Image* magnifierImage = Image::loadPlatformResource("searchMagnifierResults").releaseRef();
371     paintInfo.context->drawImage(magnifierImage, magnifierObject->style()->colorSpace(), paintingRect);
372     return false;
373 }
374
375 bool RenderThemeChromiumSkia::paintMediaControlsBackground(RenderObject* object, const PaintInfo& paintInfo, const IntRect& rect)
376 {
377 #if ENABLE(VIDEO)
378     return RenderMediaControlsChromium::paintMediaControlsPart(MediaTimelineContainer, object, paintInfo, rect);
379 #else
380     UNUSED_PARAM(object);
381     UNUSED_PARAM(paintInfo);
382     UNUSED_PARAM(rect);
383     return false;
384 #endif
385 }
386
387 bool RenderThemeChromiumSkia::paintMediaSliderTrack(RenderObject* object, const PaintInfo& paintInfo, const IntRect& rect)
388 {
389 #if ENABLE(VIDEO)
390     return RenderMediaControlsChromium::paintMediaControlsPart(MediaSlider, object, paintInfo, rect);
391 #else
392     UNUSED_PARAM(object);
393     UNUSED_PARAM(paintInfo);
394     UNUSED_PARAM(rect);
395     return false;
396 #endif
397 }
398
399 bool RenderThemeChromiumSkia::paintMediaVolumeSliderTrack(RenderObject* object, const PaintInfo& paintInfo, const IntRect& rect)
400 {
401 #if ENABLE(VIDEO)
402     return RenderMediaControlsChromium::paintMediaControlsPart(MediaVolumeSlider, object, paintInfo, rect);
403 #else
404     UNUSED_PARAM(object);
405     UNUSED_PARAM(paintInfo);
406     UNUSED_PARAM(rect);
407     return false;
408 #endif
409 }
410
411 void RenderThemeChromiumSkia::adjustSliderThumbSize(RenderStyle* style) const
412 {
413 #if ENABLE(VIDEO)
414     RenderMediaControlsChromium::adjustMediaSliderThumbSize(style);
415 #else
416     UNUSED_PARAM(style);
417 #endif
418 }
419
420 bool RenderThemeChromiumSkia::paintMediaSliderThumb(RenderObject* object, const PaintInfo& paintInfo, const IntRect& rect)
421 {
422 #if ENABLE(VIDEO)
423     return RenderMediaControlsChromium::paintMediaControlsPart(MediaSliderThumb, object, paintInfo, rect);
424 #else
425     UNUSED_PARAM(object);
426     UNUSED_PARAM(paintInfo);
427     UNUSED_PARAM(rect);
428     return false;
429 #endif
430 }
431
432 bool RenderThemeChromiumSkia::paintMediaVolumeSliderThumb(RenderObject* object, const PaintInfo& paintInfo, const IntRect& rect)
433 {
434 #if ENABLE(VIDEO)
435     return RenderMediaControlsChromium::paintMediaControlsPart(MediaVolumeSliderThumb, object, paintInfo, rect);
436 #else
437     UNUSED_PARAM(object);
438     UNUSED_PARAM(paintInfo);
439     UNUSED_PARAM(rect);
440     return false;
441 #endif
442 }
443
444 bool RenderThemeChromiumSkia::paintMediaPlayButton(RenderObject* object, const PaintInfo& paintInfo, const IntRect& rect)
445 {
446 #if ENABLE(VIDEO)
447     return RenderMediaControlsChromium::paintMediaControlsPart(MediaPlayButton, object, paintInfo, rect);
448 #else
449     UNUSED_PARAM(object);
450     UNUSED_PARAM(paintInfo);
451     UNUSED_PARAM(rect);
452     return false;
453 #endif
454 }
455
456 bool RenderThemeChromiumSkia::paintMediaMuteButton(RenderObject* object, const PaintInfo& paintInfo, const IntRect& rect)
457 {
458 #if ENABLE(VIDEO)
459     return RenderMediaControlsChromium::paintMediaControlsPart(MediaMuteButton, object, paintInfo, rect);
460 #else
461     UNUSED_PARAM(object);
462     UNUSED_PARAM(paintInfo);
463     UNUSED_PARAM(rect);
464     return false;
465 #endif
466 }
467
468 void RenderThemeChromiumSkia::adjustMenuListStyle(CSSStyleSelector* selector, RenderStyle* style, WebCore::Element* e) const
469 {
470     // Height is locked to auto on all browsers.
471     style->setLineHeight(RenderStyle::initialLineHeight());
472 }
473
474 void RenderThemeChromiumSkia::adjustMenuListButtonStyle(CSSStyleSelector* selector, RenderStyle* style, Element* e) const
475 {
476     adjustMenuListStyle(selector, style, e);
477 }
478
479 // Used to paint styled menulists (i.e. with a non-default border)
480 bool RenderThemeChromiumSkia::paintMenuListButton(RenderObject* o, const PaintInfo& i, const IntRect& rect)
481 {
482     return paintMenuList(o, i, rect);
483 }
484
485 int RenderThemeChromiumSkia::popupInternalPaddingLeft(RenderStyle* style) const
486 {
487     return menuListInternalPadding(style, LeftPadding);
488 }
489
490 int RenderThemeChromiumSkia::popupInternalPaddingRight(RenderStyle* style) const
491 {
492     return menuListInternalPadding(style, RightPadding);
493 }
494
495 int RenderThemeChromiumSkia::popupInternalPaddingTop(RenderStyle* style) const
496 {
497     return menuListInternalPadding(style, TopPadding);
498 }
499
500 int RenderThemeChromiumSkia::popupInternalPaddingBottom(RenderStyle* style) const
501 {
502     return menuListInternalPadding(style, BottomPadding);
503 }
504
505 // static
506 void RenderThemeChromiumSkia::setDefaultFontSize(int fontSize)
507 {
508     defaultFontSize = static_cast<float>(fontSize);
509 }
510
511 double RenderThemeChromiumSkia::caretBlinkIntervalInternal() const
512 {
513     return RenderTheme::caretBlinkInterval();
514 }
515
516 // static
517 void RenderThemeChromiumSkia::setSizeIfAuto(RenderStyle* style, const IntSize& size)
518 {
519     if (style->width().isIntrinsicOrAuto())
520         style->setWidth(Length(size.width(), Fixed));
521     if (style->height().isAuto())
522         style->setHeight(Length(size.height(), Fixed));
523 }
524
525 int RenderThemeChromiumSkia::menuListInternalPadding(RenderStyle* style, int paddingType) const
526 {
527     // This internal padding is in addition to the user-supplied padding.
528     // Matches the FF behavior.
529     int padding = styledMenuListInternalPadding[paddingType];
530
531     // Reserve the space for right arrow here. The rest of the padding is
532     // set by adjustMenuListStyle, since PopMenuWin.cpp uses the padding from
533     // RenderMenuList to lay out the individual items in the popup.
534     // If the MenuList actually has appearance "NoAppearance", then that means
535     // we don't draw a button, so don't reserve space for it.
536     const int barType = style->direction() == LTR ? RightPadding : LeftPadding;
537     if (paddingType == barType && style->appearance() != NoControlPart)
538         padding += ScrollbarTheme::nativeTheme()->scrollbarThickness();
539
540     return padding;
541 }
542
543 #if ENABLE(PROGRESS_TAG)
544
545 //
546 // Following values are come from default of GTK+
547 //
548 static const int progressDeltaPixelsPerSecond = 100;
549 static const int progressActivityBlocks = 5;
550 static const int progressAnimationFrmaes = 10;
551 static const double progressAnimationInterval = 0.125;
552
553 IntRect RenderThemeChromiumSkia::determinateProgressValueRectFor(RenderProgress* renderProgress, const IntRect& rect) const
554 {
555     int dx = rect.width() * renderProgress->position();
556     if (renderProgress->style()->direction() == RTL)
557         return IntRect(rect.x() + rect.width() - dx, rect.y(), dx, rect.height());
558     return IntRect(rect.x(), rect.y(), dx, rect.height());
559 }
560
561 IntRect RenderThemeChromiumSkia::indeterminateProgressValueRectFor(RenderProgress* renderProgress, const IntRect& rect) const
562 {
563
564     int valueWidth = rect.width() / progressActivityBlocks;
565     int movableWidth = rect.width() - valueWidth;
566     if (movableWidth <= 0)
567         return IntRect();
568
569     double progress = renderProgress->animationProgress();
570     if (progress < 0.5)
571         return IntRect(rect.x() + progress * 2 * movableWidth, rect.y(), valueWidth, rect.height());
572     return IntRect(rect.x() + (1.0 - progress) * 2 * movableWidth, rect.y(), valueWidth, rect.height());
573 }
574
575 double RenderThemeChromiumSkia::animationRepeatIntervalForProgressBar(RenderProgress*) const
576 {
577     return progressAnimationInterval;
578 }
579
580 double RenderThemeChromiumSkia::animationDurationForProgressBar(RenderProgress* renderProgress) const
581 {
582     return progressAnimationInterval * progressAnimationFrmaes * 2; // "2" for back and forth
583 }
584
585 IntRect RenderThemeChromiumSkia::progressValueRectFor(RenderProgress* renderProgress, const IntRect& rect) const
586 {
587     return renderProgress->isDeterminate() ? determinateProgressValueRectFor(renderProgress, rect) : indeterminateProgressValueRectFor(renderProgress, rect);
588 }
589
590 #endif
591
592 } // namespace WebCore