Bug 51874

Summary: [GTK] Port slider painting to GtkStyleContext
Product: WebKit Reporter: Carlos Garcia Campos <cgarcia>
Component: WebKitGTKAssignee: Nobody <webkit-unassigned>
Status: RESOLVED FIXED    
Severity: Normal CC: mrobinson, webkit.review.bot
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: PC   
OS: Linux   
Bug Depends on: 51764    
Bug Blocks: 50820    
Attachments:
Description Flags
Use GtkStyleContext to paint sliders
mrobinson: review-
Updated patch
none
Patch moving focus width and focus pad outside of the slider rect
none
Updated patch taking into account the trough border none

Carlos Garcia Campos
Reported 2011-01-04 08:11:38 PST
This depends on bug #51764 since the patch for stock icons contains the initial GtkStyleContext port.
Attachments
Use GtkStyleContext to paint sliders (9.68 KB, patch)
2011-01-04 08:16 PST, Carlos Garcia Campos
mrobinson: review-
Updated patch (12.13 KB, patch)
2011-01-05 03:40 PST, Carlos Garcia Campos
no flags
Patch moving focus width and focus pad outside of the slider rect (13.12 KB, patch)
2011-01-05 12:18 PST, Martin Robinson
no flags
Updated patch taking into account the trough border (13.00 KB, patch)
2011-01-07 01:25 PST, Carlos Garcia Campos
no flags
Carlos Garcia Campos
Comment 1 2011-01-04 08:16:13 PST
Created attachment 77889 [details] Use GtkStyleContext to paint sliders
Martin Robinson
Comment 2 2011-01-04 10:16:41 PST
Comment on attachment 77889 [details] Use GtkStyleContext to paint sliders View in context: https://bugs.webkit.org/attachment.cgi?id=77889&action=review Looks great, but I think it makes sense to create a RenderThemeGtk::adjustMediaSliderThumbSize. See below. > WebCore/platform/gtk/RenderThemeGtk3.cpp:621 > + gint sliderWidth, sliderLength, troughBorder; > + gint focusWidth, focusPad; Please put these all on one line. > WebCore/platform/gtk/RenderThemeGtk3.cpp:628 > + 0); Doesn't this produce a warning? > WebCore/platform/gtk/RenderThemeGtk3.cpp:660 > #if ENABLE(VIDEO) > - if (part == MediaSliderThumbPart) { > - o->style()->setWidth(Length(m_mediaSliderThumbWidth, Fixed)); > - o->style()->setHeight(Length(m_mediaSliderThumbHeight, Fixed)); > - return; > - } > - if (part == MediaVolumeSliderThumbPart) > - return; > + if (part == MediaSliderThumbPart) { > + renderObject->style()->setWidth(Length(m_mediaSliderThumbWidth, Fixed)); > + renderObject->style()->setHeight(Length(m_mediaSliderThumbHeight, Fixed)); > + } > #endif Instead of using a switch statement here and duplicating this logic between RenderThemeGtk2 and RenderThemeGtk3, let's take the approach that RenderThemeMac.mm takes, but put RenderThemeGtk::adjustMediaSliderThumbSize in the platform-independent file. That way we can avoid duplicating this section. > WebCore/platform/gtk/RenderThemeGtk3.cpp:680 > + renderObject->style()->setWidth(Length((focusWidth + focusPad+ troughBorder) * 2 + sliderWidth, Fixed)); There is a space missing after focusPad.
Carlos Garcia Campos
Comment 3 2011-01-04 10:20:37 PST
(In reply to comment #2) > (From update of attachment 77889 [details]) > View in context: https://bugs.webkit.org/attachment.cgi?id=77889&action=review > > Looks great, but I think it makes sense to create a RenderThemeGtk::adjustMediaSliderThumbSize. See below. > > > WebCore/platform/gtk/RenderThemeGtk3.cpp:621 > > + gint sliderWidth, sliderLength, troughBorder; > > + gint focusWidth, focusPad; > > Please put these all on one line. Ok > > WebCore/platform/gtk/RenderThemeGtk3.cpp:628 > > + 0); > > Doesn't this produce a warning? No. > > WebCore/platform/gtk/RenderThemeGtk3.cpp:660 > > #if ENABLE(VIDEO) > > - if (part == MediaSliderThumbPart) { > > - o->style()->setWidth(Length(m_mediaSliderThumbWidth, Fixed)); > > - o->style()->setHeight(Length(m_mediaSliderThumbHeight, Fixed)); > > - return; > > - } > > - if (part == MediaVolumeSliderThumbPart) > > - return; > > + if (part == MediaSliderThumbPart) { > > + renderObject->style()->setWidth(Length(m_mediaSliderThumbWidth, Fixed)); > > + renderObject->style()->setHeight(Length(m_mediaSliderThumbHeight, Fixed)); > > + } > > #endif > > Instead of using a switch statement here and duplicating this logic between RenderThemeGtk2 and RenderThemeGtk3, let's take the approach that RenderThemeMac.mm takes, but put RenderThemeGtk::adjustMediaSliderThumbSize in the platform-independent file. That way we can avoid duplicating this section. Ok, I'll look at the mac code then. > > WebCore/platform/gtk/RenderThemeGtk3.cpp:680 > > + renderObject->style()->setWidth(Length((focusWidth + focusPad+ troughBorder) * 2 + sliderWidth, Fixed)); > > There is a space missing after focusPad. Ok.
Carlos Garcia Campos
Comment 4 2011-01-05 03:40:21 PST
Created attachment 77986 [details] Updated patch
Martin Robinson
Comment 5 2011-01-05 12:18:00 PST
Created attachment 78026 [details] Patch moving focus width and focus pad outside of the slider rect
WebKit Review Bot
Comment 6 2011-01-05 12:19:14 PST
Attachment 78026 [details] did not pass style-queue: Failed to run "['Tools/Scripts/check-webkit-style', '--diff-files', u'WebCore/ChangeLog', u'WebCore/platform/gtk/RenderThemeGtk.cpp', u'WebCore/platform/gtk/RenderThemeGtk.h', u'WebCore/platform/gtk/RenderThemeGtk2.cpp', u'WebCore/platform/gtk/RenderThemeGtk3.cpp']" exit_code: 1 WebCore/platform/gtk/RenderThemeGtk3.cpp:114: Use 0 instead of NULL. [readability/null] [5] WebCore/platform/gtk/RenderThemeGtk3.cpp:318: Use 0 instead of NULL. [readability/null] [5] WebCore/platform/gtk/RenderThemeGtk3.cpp:372: Use 0 instead of NULL. [readability/null] [5] Total errors found: 3 in 5 files If any of these errors are false positives, please file a bug against check-webkit-style.
Martin Robinson
Comment 7 2011-01-05 12:24:14 PST
(In reply to comment #5) > Created an attachment (id=78026) [details] > Patch moving focus width and focus pad outside of the slider rect This updated version of the patch has a few changes: 1. Focus width and focus padding are now drawn outside the slider rect, which makes calculating the size of slides pieces much more straight-forward. This is perfectly valid as long as you let WebCore know via adjustRepaintRect, I think. 2. Use NULL as the sentinel for calls to gtk_style_context_get_style. Zero doesn't produce a warnings, but can lead to crashes on 64-bit machines. Thus we should always use NULL. 3. Remove the static_casts wrapping gktTextDirection calls. They are no longer needed. Let me know if I've futzed anything up too badly! :)
Carlos Garcia Campos
Comment 8 2011-01-07 01:22:17 PST
(In reply to comment #7) > (In reply to comment #5) > > Created an attachment (id=78026) [details] [details] > > Patch moving focus width and focus pad outside of the slider rect > > This updated version of the patch has a few changes: > 1. Focus width and focus padding are now drawn outside the slider rect, which makes calculating the size of slides pieces much more straight-forward. This is perfectly valid as long as you let WebCore know via adjustRepaintRect, I think. Yes, it works. > 2. Use NULL as the sentinel for calls to gtk_style_context_get_style. Zero doesn't produce a warnings, but can lead to crashes on 64-bit machines. Thus we should always use NULL. Great, never liked using 0 instead of NULL, at least there's an exception here :-) > 3. Remove the static_casts wrapping gktTextDirection calls. They are no longer needed. Right. > Let me know if I've futzed anything up too badly! :) The only problem is that the slider thumb is painted outside the slider track, you still need to take into account the trough border to make the thumb fit into the slider track.
Carlos Garcia Campos
Comment 9 2011-01-07 01:25:47 PST
Created attachment 78216 [details] Updated patch taking into account the trough border
WebKit Review Bot
Comment 10 2011-01-07 01:27:58 PST
Attachment 78216 [details] did not pass style-queue: Failed to run "['Tools/Scripts/check-webkit-style', '--diff-files', u'WebCore/ChangeLog', u'WebCore/platform/gtk/RenderThemeGtk.cpp', u'WebCore/platform/gtk/RenderThemeGtk.h', u'WebCore/platform/gtk/RenderThemeGtk2.cpp', u'WebCore/platform/gtk/RenderThemeGtk3.cpp']" exit_code: 1 WebCore/platform/gtk/RenderThemeGtk3.cpp:114: Use 0 instead of NULL. [readability/null] [5] WebCore/platform/gtk/RenderThemeGtk3.cpp:318: Use 0 instead of NULL. [readability/null] [5] WebCore/platform/gtk/RenderThemeGtk3.cpp:342: Use 0 instead of NULL. [readability/null] [5] WebCore/platform/gtk/RenderThemeGtk3.cpp:378: Use 0 instead of NULL. [readability/null] [5] Total errors found: 4 in 5 files If any of these errors are false positives, please file a bug against check-webkit-style.
Xan Lopez
Comment 11 2011-01-07 05:48:21 PST
Comment on attachment 78216 [details] Updated patch taking into account the trough border Looks good to me.
Carlos Garcia Campos
Comment 12 2011-01-07 05:59:19 PST
Note You need to log in before you can comment on or make changes to this bug.