WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
[patch]
v2
sliders-2.diff (text/plain), 8.85 KB, created by
Tony Chang
on 2009-09-03 11:29:50 PDT
(
hide
)
Description:
v2
Filename:
MIME Type:
Creator:
Tony Chang
Created:
2009-09-03 11:29:50 PDT
Size:
8.85 KB
patch
obsolete
>Index: WebCore/ChangeLog >=================================================================== >--- WebCore/ChangeLog (revision 48000) >+++ WebCore/ChangeLog (working copy) >@@ -1,3 +1,24 @@ >+2009-09-02 Tony Chang <tony@chromium.org> >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Implement <input type="range"> for Chromium Linux by painting >+ the slider and the thumb using skia. >+ https://bugs.webkit.org/show_bug.cgi?id=28928 >+ >+ Covered by existing tests (we're currently hitting an assert for them). >+ >+ * rendering/RenderThemeChromiumLinux.cpp: >+ (WebCore::RenderThemeChromiumLinux::adjustSliderThumbSize): >+ * rendering/RenderThemeChromiumLinux.h: >+ * rendering/RenderThemeChromiumSkia.cpp: >+ (WebCore::drawVertLine): >+ (WebCore::drawHorizLine): >+ (WebCore::drawBox): >+ (WebCore::RenderThemeChromiumSkia::paintSliderTrack): >+ (WebCore::RenderThemeChromiumSkia::paintSliderThumb): >+ * rendering/RenderThemeChromiumSkia.h: >+ > 2009-09-02 Brady Eidson <beidson@apple.com> > > Reviewed by Darin Adler. >Index: WebCore/rendering/RenderThemeChromiumLinux.cpp >=================================================================== >--- WebCore/rendering/RenderThemeChromiumLinux.cpp (revision 48000) >+++ WebCore/rendering/RenderThemeChromiumLinux.cpp (working copy) >@@ -92,6 +92,21 @@ Color RenderThemeChromiumLinux::inactive > return Color(0x32, 0x32, 0x32); > } > >+void RenderThemeChromiumLinux::adjustSliderThumbSize(RenderObject* o) const >+{ >+ // These sizes match the sizes in Chromium Win. >+ const int sliderThumbAlongAxis = 11; >+ const int sliderThumbAcrossAxis = 21; >+ if (o->style()->appearance() == SliderThumbHorizontalPart) { >+ o->style()->setWidth(Length(sliderThumbAlongAxis, Fixed)); >+ o->style()->setHeight(Length(sliderThumbAcrossAxis, Fixed)); >+ } else if (o->style()->appearance() == SliderThumbVerticalPart) { >+ o->style()->setWidth(Length(sliderThumbAcrossAxis, Fixed)); >+ o->style()->setHeight(Length(sliderThumbAlongAxis, Fixed)); >+ } else >+ RenderThemeChromiumSkia::adjustSliderThumbSize(o); >+} >+ > void RenderThemeChromiumLinux::setFocusRingColor(const Color& color) > { > m_focusRingColor = color; >Index: WebCore/rendering/RenderThemeChromiumLinux.h >=================================================================== >--- WebCore/rendering/RenderThemeChromiumLinux.h (revision 48000) >+++ WebCore/rendering/RenderThemeChromiumLinux.h (working copy) >@@ -49,6 +49,8 @@ namespace WebCore { > virtual Color inactiveListBoxSelectionBackgroundColor() const; > virtual Color inactiveListBoxSelectionForegroundColor() const; > >+ virtual void adjustSliderThumbSize(RenderObject*) const; >+ > void setFocusRingColor(const Color&); > virtual Color platformFocusRingColor() const; > >Index: WebCore/rendering/RenderThemeChromiumSkia.cpp >=================================================================== >--- WebCore/rendering/RenderThemeChromiumSkia.cpp (revision 48000) >+++ WebCore/rendering/RenderThemeChromiumSkia.cpp (working copy) >@@ -34,6 +34,7 @@ > #include "PlatformContextSkia.h" > #include "RenderBox.h" > #include "RenderObject.h" >+#include "RenderSlider.h" > #include "ScrollbarTheme.h" > #include "TransformationMatrix.h" > #include "UserAgentStyleSheets.h" >@@ -70,6 +71,30 @@ static void setSizeIfAuto(RenderStyle* s > style->setHeight(Length(size.height(), Fixed)); > } > >+static void drawVertLine(SkCanvas* canvas, int x, int y1, int y2, const SkPaint& paint) >+{ >+ SkIRect skrect; >+ skrect.set(x, y1, x + 1, y2 + 1); >+ canvas->drawIRect(skrect, paint); >+} >+ >+static void drawHorizLine(SkCanvas* canvas, int x1, int x2, int y, const SkPaint& paint) >+{ >+ SkIRect skrect; >+ skrect.set(x1, y, x2 + 1, y + 1); >+ canvas->drawIRect(skrect, paint); >+} >+ >+static void drawBox(SkCanvas* canvas, const IntRect& rect, const SkPaint& paint) >+{ >+ const int right = rect.x() + rect.width() - 1; >+ const int bottom = rect.y() + rect.height() - 1; >+ drawHorizLine(canvas, rect.x(), right, rect.y(), paint); >+ drawVertLine(canvas, right, rect.y(), bottom, paint); >+ drawHorizLine(canvas, rect.x(), right, bottom, paint); >+ drawVertLine(canvas, rect.x(), rect.y(), bottom, paint); >+} >+ > #if ENABLE(VIDEO) > // Attempt to retrieve a HTMLMediaElement from a Node. Returns NULL if one cannot be found. > static HTMLMediaElement* mediaElementParent(Node* node) >@@ -302,7 +327,7 @@ static void paintButtonLike(RenderTheme* > canvas->drawLine(rect.x() + 1, bottom - 1, right - 1, bottom - 1, paint); > canvas->drawLine(rect.x(), rect.y() + 1, rect.x(), bottom - 1, paint); > >- paint.setARGB(0xff, 0, 0, 0); >+ paint.setColor(SK_ColorBLACK); > SkPoint p[2]; > const int lightEnd = theme->isPressed(o) ? 1 : 0; > const int darkEnd = !lightEnd; >@@ -580,7 +605,7 @@ bool RenderThemeChromiumSkia::paintMedia > > SkCanvas* canvas = paintInfo.context->platformContext()->canvas(); > SkPaint paint; >- paint.setARGB(0xff, 0xff, 0xff, 0xff); >+ paint.setColor(SK_ColorWHITE); > > int x = rect.x() + rect.width() / 2; > canvas->drawLine(x, rect.y(), x, rect.y() + rect.height(), paint); >@@ -713,7 +738,7 @@ bool RenderThemeChromiumSkia::paintMenuL > paintButtonLike(this, o, i, rect); > > SkPaint paint; >- paint.setARGB(0xff, 0, 0, 0); >+ paint.setColor(SK_ColorBLACK); > paint.setAntiAlias(true); > paint.setStyle(SkPaint::kFill_Style); > >@@ -738,6 +763,67 @@ bool RenderThemeChromiumSkia::paintMenuL > return paintMenuList(o, i, rect); > } > >+bool RenderThemeChromiumSkia::paintSliderTrack(RenderObject*, const RenderObject::PaintInfo& i, const IntRect& rect) >+{ >+ // Just paint a grey box for now (matches the color of a scrollbar background. >+ SkCanvas* const canvas = i.context->platformContext()->canvas(); >+ int verticalCenter = rect.y() + rect.height() / 2; >+ int top = std::max(rect.y(), verticalCenter - 2); >+ int bottom = std::min(rect.y() + rect.height(), verticalCenter + 2); >+ >+ SkPaint paint; >+ const SkColor grey = SkColorSetARGB(0xff, 0xe3, 0xdd, 0xd8); >+ paint.setColor(grey); >+ >+ SkRect skrect; >+ skrect.set(rect.x(), top, rect.x() + rect.width(), bottom); >+ canvas->drawRect(skrect, paint); >+ >+ return false; >+} >+ >+bool RenderThemeChromiumSkia::paintSliderThumb(RenderObject* o, const RenderObject::PaintInfo& i, const IntRect& rect) >+{ >+ // Make a thumb similar to the scrollbar thumb. >+ const bool hovered = isHovered(o) || toRenderSlider(o->parent())->inDragMode(); >+ const int midx = rect.x() + rect.width() / 2; >+ const int midy = rect.y() + rect.height() / 2; >+ const bool vertical = (o->style()->appearance() == SliderThumbVerticalPart); >+ SkCanvas* const canvas = i.context->platformContext()->canvas(); >+ >+ const SkColor thumbLightGrey = SkColorSetARGB(0xff, 0xf4, 0xf2, 0xef); >+ const SkColor thumbDarkGrey = SkColorSetARGB(0xff, 0xea, 0xe5, 0xe0); >+ SkPaint paint; >+ paint.setColor(hovered ? SK_ColorWHITE : thumbLightGrey); >+ >+ SkIRect skrect; >+ if (vertical) >+ skrect.set(rect.x(), rect.y(), midx + 1, rect.bottom()); >+ else >+ skrect.set(rect.x(), rect.y(), rect.right(), midy + 1); >+ >+ canvas->drawIRect(skrect, paint); >+ >+ paint.setColor(hovered ? thumbLightGrey : thumbDarkGrey); >+ >+ if (vertical) >+ skrect.set(midx + 1, rect.y(), rect.right(), rect.bottom()); >+ else >+ skrect.set(rect.x(), midy + 1, rect.right(), rect.bottom()); >+ >+ canvas->drawIRect(skrect, paint); >+ >+ const SkColor borderDarkGrey = SkColorSetARGB(0xff, 0x9d, 0x96, 0x8e); >+ paint.setColor(borderDarkGrey); >+ drawBox(canvas, rect, paint); >+ >+ if (rect.height() > 10 && rect.width() > 10) { >+ drawHorizLine(canvas, midx - 2, midx + 2, midy, paint); >+ drawHorizLine(canvas, midx - 2, midx + 2, midy - 3, paint); >+ drawHorizLine(canvas, midx - 2, midx + 2, midy + 3, paint); >+ } >+} >+ > int RenderThemeChromiumSkia::popupInternalPaddingLeft(RenderStyle* style) const > { > return menuListInternalPadding(style, LeftPadding); >Index: WebCore/rendering/RenderThemeChromiumSkia.h >=================================================================== >--- WebCore/rendering/RenderThemeChromiumSkia.h (revision 48000) >+++ WebCore/rendering/RenderThemeChromiumSkia.h (working copy) >@@ -112,6 +112,9 @@ namespace WebCore { > virtual void adjustMenuListButtonStyle(CSSStyleSelector*, RenderStyle*, Element*) const; > virtual bool paintMenuListButton(RenderObject*, const RenderObject::PaintInfo&, const IntRect&); > >+ virtual bool paintSliderTrack(RenderObject*, const RenderObject::PaintInfo&, const IntRect&); >+ virtual bool paintSliderThumb(RenderObject*, const RenderObject::PaintInfo&, const IntRect&); >+ > // These methods define the padding for the MenuList's inner block. > virtual int popupInternalPaddingLeft(RenderStyle*) const; > virtual int popupInternalPaddingRight(RenderStyle*) const;
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 28928
:
38953
|
38954
| 38998