diff options
-rw-r--r-- | WebCore/platform/android/RenderThemeAndroid.cpp | 3 | ||||
-rw-r--r-- | WebKit/android/RenderSkinMediaButton.cpp | 36 | ||||
-rw-r--r-- | WebKit/android/RenderSkinMediaButton.h | 5 |
3 files changed, 39 insertions, 5 deletions
diff --git a/WebCore/platform/android/RenderThemeAndroid.cpp b/WebCore/platform/android/RenderThemeAndroid.cpp index 1cfe871..113fa63 100644 --- a/WebCore/platform/android/RenderThemeAndroid.cpp +++ b/WebCore/platform/android/RenderThemeAndroid.cpp @@ -341,7 +341,8 @@ bool RenderThemeAndroid::paintMediaSliderTrack(RenderObject* o, const PaintInfo& bool translucent = false; if (o && toParentMediaElement(o) && toParentMediaElement(o)->hasTagName(HTMLNames::videoTag)) translucent = true; - RenderSkinMediaButton::Draw(getCanvasFromInfo(paintInfo), rect, RenderSkinMediaButton::SLIDER_TRACK, translucent); + RenderSkinMediaButton::Draw(getCanvasFromInfo(paintInfo), rect, + RenderSkinMediaButton::SLIDER_TRACK, translucent, o); return false; } diff --git a/WebKit/android/RenderSkinMediaButton.cpp b/WebKit/android/RenderSkinMediaButton.cpp index 8d426a3..9969763 100644 --- a/WebKit/android/RenderSkinMediaButton.cpp +++ b/WebKit/android/RenderSkinMediaButton.cpp @@ -30,7 +30,9 @@ #include "Document.h" #include "IntRect.h" #include "Node.h" +#include "RenderObject.h" #include "RenderSkinMediaButton.h" +#include "RenderSlider.h" #include "SkCanvas.h" #include "SkNinePatch.h" #include "SkRect.h" @@ -45,7 +47,7 @@ struct PatchData { static const PatchData gFiles[] = { - { "btn_media_player.9.png", 0, 0 }, // DEFAULT BGD BUTTON + { "scrubber_primary_holo.9.png", 0, 0 }, // SLIDER_TRACK, left of the SLIDER_THUMB { "ic_media_pause.png", 0, 0}, // PAUSE { "ic_media_play.png", 0, 0 }, // PLAY { "ic_media_pause.png", 0, 0 }, // MUTE @@ -82,7 +84,8 @@ void RenderSkinMediaButton::Init(android::AssetManager* am, String drawableDirec } } -void RenderSkinMediaButton::Draw(SkCanvas* canvas, const IntRect& r, int buttonType, bool translucent) +void RenderSkinMediaButton::Draw(SkCanvas* canvas, const IntRect& r, int buttonType, + bool translucent, RenderObject* o) { // If we failed to decode, do nothing. This way the browser still works, // and webkit will still draw the label and layout space for us. @@ -163,7 +166,34 @@ void RenderSkinMediaButton::Draw(SkCanvas* canvas, const IntRect& r, int buttonT SkIRect margin; margin.set(marginValue, marginValue, marginValue, marginValue); - SkNinePatch::DrawNine(canvas, bounds, gButton[0], margin); + if (buttonType == SLIDER_TRACK) { + // Cut the height in half (with some extra slop determined by trial + // and error to get the placement just right. + SkScalar quarterHeight = SkScalarHalf(SkScalarHalf(bounds.height())); + bounds.fTop += quarterHeight + SkScalarHalf(3); + bounds.fBottom += -quarterHeight + SK_ScalarHalf; + if (o && o->isSlider()) { + RenderSlider* slider = toRenderSlider(o); + IntRect thumb = slider->thumbRect(); + // Inset the track by half the width of the thumb, so the track + // does not appear to go beyond the space where the thumb can + // be. + SkScalar thumbHalfWidth = SkIntToScalar(thumb.width()/2); + bounds.fLeft += thumbHalfWidth; + bounds.fRight -= thumbHalfWidth; + if (thumb.x() > 0) { + // The video is past the starting point. Show the area to + // left of the thumb as having been played. + SkScalar alreadyPlayed = SkIntToScalar(thumb.center().x() + r.x()); + SkRect playedRect(bounds); + playedRect.fRight = alreadyPlayed; + SkNinePatch::DrawNine(canvas, playedRect, gButton[0], margin); + bounds.fLeft = alreadyPlayed; + } + + } + } + SkNinePatch::DrawNine(canvas, bounds, gButton[ninePatchIndex], margin); } if (drawsImage) { diff --git a/WebKit/android/RenderSkinMediaButton.h b/WebKit/android/RenderSkinMediaButton.h index 9dccc29..f1b87b1 100644 --- a/WebKit/android/RenderSkinMediaButton.h +++ b/WebKit/android/RenderSkinMediaButton.h @@ -32,6 +32,8 @@ class SkCanvas; namespace WebCore { class IntRect; +class RenderObject; + class RenderSkinMediaButton { public: @@ -44,7 +46,8 @@ public: * Draw the skin to the canvas, using the rectangle for its bounds and the * State to determine which skin to use, i.e. focused or not focused. */ - static void Draw(SkCanvas* , const IntRect& , int buttonType, bool translucent = false); + static void Draw(SkCanvas* , const IntRect& , int buttonType, bool translucent = false, + RenderObject* o = 0); /** * Button types */ |