WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
89908
[chromium] ScrollbarLayerChromium should support painting forward-track and back-track in different styles.
https://bugs.webkit.org/show_bug.cgi?id=89908
Summary
[chromium] ScrollbarLayerChromium should support painting forward-track and b...
W. James MacLean
Reported
2012-06-25 14:18:55 PDT
[chromium] ScrollbarLayerChromium should support painting forward-track and back-track in different styles.
Attachments
Patch
(13.09 KB, patch)
2012-06-25 14:24 PDT
,
W. James MacLean
no flags
Details
Formatted Diff
Diff
Patch
(13.46 KB, patch)
2012-06-26 11:33 PDT
,
W. James MacLean
no flags
Details
Formatted Diff
Diff
Patch
(35.54 KB, patch)
2012-06-27 10:53 PDT
,
W. James MacLean
no flags
Details
Formatted Diff
Diff
Patch
(18.47 KB, patch)
2012-06-27 12:34 PDT
,
W. James MacLean
no flags
Details
Formatted Diff
Diff
Show Obsolete
(3)
View All
Add attachment
proposed patch, testcase, etc.
W. James MacLean
Comment 1
2012-06-25 14:24:24 PDT
Created
attachment 149357
[details]
Patch
W. James MacLean
Comment 2
2012-06-25 14:26:58 PDT
Comment on
attachment 149357
[details]
Patch Not for review yet, still working on tests. I have some questions though: 1) Is it worth modifying it to just use a single background part if the forward- and back- styles are the same? 2) Is it worth trying to collect the two background parts into an "array of parts"? I'm assuming 'no', but I am flexible on this. Let me know if the overall approach looks OK.
Adrienne Walker
Comment 3
2012-06-25 14:42:02 PDT
Comment on
attachment 149357
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=149357&action=review
> Source/WebCore/platform/graphics/chromium/ScrollbarLayerChromium.cpp:161 > + ScrollbarPart m_part;
bikeshed: m_trackPart
> Source/WebCore/platform/graphics/chromium/cc/CCScrollbarLayerImpl.cpp:86 > + IntRect backTrackRect(IntPoint(), m_scrollbar.orientation() == HorizontalScrollbar ? IntSize(thumbRect.x(), thumbRect.height()) : IntSize(thumbRect.width(), thumbRect.y()));
Use theme->splitTrackRect for this.
Adrienne Walker
Comment 4
2012-06-25 14:48:29 PDT
(In reply to
comment #2
)
> (From update of
attachment 149357
[details]
) > Not for review yet, still working on tests. I have some questions though: > > 1) Is it worth modifying it to just use a single background part if the forward- and back- styles are the same?
I think it might be, just to save on painting and uploading the scrollbar on any frame where you scroll. As far as I can tell, only render theme scrollbars are capable of this (so far), so you could just set a bool on the layer based on isCustomScrollbar.
> 2) Is it worth trying to collect the two background parts into an "array of parts"? I'm assuming 'no', but I am flexible on this.
I don't think there needs to be an array of parts until we support being able to draw enabled/disabled/hovered parts on the compositor thread. I think that's the point where it goes from 2-3 parts to an array of parts in different states.
W. James MacLean
Comment 5
2012-06-26 11:33:42 PDT
Created
attachment 149573
[details]
Patch
W. James MacLean
Comment 6
2012-06-26 11:38:20 PDT
(In reply to
comment #3
)
> (From update of
attachment 149357
[details]
) > View in context:
https://bugs.webkit.org/attachment.cgi?id=149357&action=review
> > > Source/WebCore/platform/graphics/chromium/ScrollbarLayerChromium.cpp:161 > > + ScrollbarPart m_part; > > bikeshed: m_trackPart
Sure!
> > Source/WebCore/platform/graphics/chromium/cc/CCScrollbarLayerImpl.cpp:86 > > + IntRect backTrackRect(IntPoint(), m_scrollbar.orientation() == HorizontalScrollbar ? IntSize(thumbRect.x(), thumbRect.height()) : IntSize(thumbRect.width(), thumbRect.y())); > > Use theme->splitTrackRect for this.
Done. I got rid of the call to theme->thumbRect since it calls splitRect anyways, although this required tweaking the thumbRect offset calculation. (In reply to
comment #4
)
> (In reply to
comment #2
) > > (From update of
attachment 149357
[details]
[details]) > > Not for review yet, still working on tests. I have some questions though: > > > > 1) Is it worth modifying it to just use a single background part if the forward- and back- styles are the same? > > I think it might be, just to save on painting and uploading the scrollbar on any frame where you scroll. As far as I can tell, only render theme scrollbars are capable of this (so far), so you could just set a bool on the layer based on isCustomScrollbar.
Done. I didn't create any extra state, rather we only create/paint the second texture if isCustomScrollBar() returns true, and then the presence or lack of foreTrackTextureId determines how we go about appending quads.
> > 2) Is it worth trying to collect the two background parts into an "array of parts"? I'm assuming 'no', but I am flexible on this. > > I don't think there needs to be an array of parts until we support being able to draw enabled/disabled/hovered parts on the compositor thread. I think that's the point where it goes from 2-3 parts to an array of parts in different states.
SGTM. Question: are we doing layout tests for gpu-scrollbars, or should I come up with a unit test? The cl passes existing unit tests and (I think) doesn't trigger any layout test failures.
Adrienne Walker
Comment 7
2012-06-26 12:13:17 PDT
Comment on
attachment 149573
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=149573&action=review
No, there aren't existing good tests for this. This path is hit in compositing tests, but (I think) only by mock scrollbars. If you could add a pixel layout test with themed scrollbars and a different back/forward track rect for this, that'd be great. You'll need to explicitly turn off mock scrollbars in the test. You could probably just put it in platform/chromium/compositing/scrollbars or something. Other than that, looks great. Thanks!
> Source/WebCore/platform/graphics/chromium/cc/CCScrollbarLayerImpl.cpp:38 > +#include <stdio.h> > +
Debugging code?
> Source/WebCore/platform/graphics/chromium/cc/CCScrollbarLayerImpl.cpp:-64 > + IntRect thumbRect, backTrackRect, foreTrackRect; > + theme->splitTrack(&m_scrollbar, boundsRect, backTrackRect, thumbRect, foreTrackRect); > + if (m_scrollbar.orientation() == VerticalScrollbar) > + thumbRect.move(0, theme->backButtonRect(&m_scrollbar, BackButtonStartPart, true).size().height()); > + else > + thumbRect.move(theme->backButtonRect(&m_scrollbar, BackButtonStartPart, true).size().width(), 0); > > - IntRect thumbRect = theme->thumbRect(&m_scrollbar); > - thumbRect.move(-m_scrollbar.x(), -m_scrollbar.y());
Why do you need to move the thumbRect like this here? Shouldn't it be positioned properly with respect to the track?
W. James MacLean
Comment 8
2012-06-26 12:49:46 PDT
(In reply to
comment #7
)
> (From update of
attachment 149573
[details]
) > View in context:
https://bugs.webkit.org/attachment.cgi?id=149573&action=review
> > No, there aren't existing good tests for this. This path is hit in compositing tests, but (I think) only by mock scrollbars. > > If you could add a pixel layout test with themed scrollbars and a different back/forward track rect for this, that'd be great. You'll need to explicitly turn off mock scrollbars in the test. You could probably just put it in platform/chromium/compositing/scrollbars or something. > > Other than that, looks great. Thanks!
Will do this and upload, probably early tomorrow.
> > Source/WebCore/platform/graphics/chromium/cc/CCScrollbarLayerImpl.cpp:38 > > +#include <stdio.h> > > + > > Debugging code?
Ooops! (blushes)
> > Source/WebCore/platform/graphics/chromium/cc/CCScrollbarLayerImpl.cpp:-64 > > + IntRect thumbRect, backTrackRect, foreTrackRect; > > + theme->splitTrack(&m_scrollbar, boundsRect, backTrackRect, thumbRect, foreTrackRect); > > + if (m_scrollbar.orientation() == VerticalScrollbar) > > + thumbRect.move(0, theme->backButtonRect(&m_scrollbar, BackButtonStartPart, true).size().height()); > > + else > > + thumbRect.move(theme->backButtonRect(&m_scrollbar, BackButtonStartPart, true).size().width(), 0); > > > > - IntRect thumbRect = theme->thumbRect(&m_scrollbar); > > - thumbRect.move(-m_scrollbar.x(), -m_scrollbar.y()); > > Why do you need to move the thumbRect like this here? Shouldn't it be positioned properly with respect to the track?
I was a bit surprised by this too. It seems to calculate the thumbRect position as an offset from the track, but *exclusive* from the forward/backward buttons. Calling splitTrack this way is a bit different from calling it through thumbRect(), since the latter only passes the tracRect to splitTrack, whereas we are passing in the entire bounds rect (since we are bundling the buttons and the track into the texture). I found that if I called splitTrack with theme->trackRect() instead of bounds, I had to then manually append rects for the buttons.
Adrienne Walker
Comment 9
2012-06-26 12:53:07 PDT
Comment on
attachment 149573
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=149573&action=review
>>> Source/WebCore/platform/graphics/chromium/cc/CCScrollbarLayerImpl.cpp:-64 >>> - thumbRect.move(-m_scrollbar.x(), -m_scrollbar.y()); >> >> Why do you need to move the thumbRect like this here? Shouldn't it be positioned properly with respect to the track? > > I was a bit surprised by this too. > > It seems to calculate the thumbRect position as an offset from the track, but *exclusive* from the forward/backward buttons. Calling splitTrack this way is a bit different from calling it through thumbRect(), since the latter only passes the tracRect to splitTrack, whereas we are passing in the entire bounds rect (since we are bundling the buttons and the track into the texture). I found that if I called splitTrack with theme->trackRect() instead of bounds, I had to then manually append rects for the buttons.
Oh! That's the problem exactly. splitTrack should take a trackRect, not a boundsRect.
W. James MacLean
Comment 10
2012-06-26 12:56:53 PDT
(In reply to
comment #9
)
> (From update of
attachment 149573
[details]
) > View in context:
https://bugs.webkit.org/attachment.cgi?id=149573&action=review
> > >>> Source/WebCore/platform/graphics/chromium/cc/CCScrollbarLayerImpl.cpp:-64 > >>> - thumbRect.move(-m_scrollbar.x(), -m_scrollbar.y()); > >> > >> Why do you need to move the thumbRect like this here? Shouldn't it be positioned properly with respect to the track? > > > > I was a bit surprised by this too. > > > > It seems to calculate the thumbRect position as an offset from the track, but *exclusive* from the forward/backward buttons. Calling splitTrack this way is a bit different from calling it through thumbRect(), since the latter only passes the tracRect to splitTrack, whereas we are passing in the entire bounds rect (since we are bundling the buttons and the track into the texture). I found that if I called splitTrack with theme->trackRect() instead of bounds, I had to then manually append rects for the buttons. > > Oh! That's the problem exactly. splitTrack should take a trackRect, not a boundsRect.
OK, so I'll go with manually appending the button rects so as to pass a trackRect (although splitTrack() does seem to modify the trackRect internally to get it right). We'll still need to offset for the thumbRect though to align it with our bounds.
Adrienne Walker
Comment 11
2012-06-26 13:04:07 PDT
(In reply to
comment #10
)
> (In reply to
comment #9
) > > (From update of
attachment 149573
[details]
[details]) > > View in context:
https://bugs.webkit.org/attachment.cgi?id=149573&action=review
> > > > >>> Source/WebCore/platform/graphics/chromium/cc/CCScrollbarLayerImpl.cpp:-64 > > >>> - thumbRect.move(-m_scrollbar.x(), -m_scrollbar.y()); > > >> > > >> Why do you need to move the thumbRect like this here? Shouldn't it be positioned properly with respect to the track? > > > > > > I was a bit surprised by this too. > > > > > > It seems to calculate the thumbRect position as an offset from the track, but *exclusive* from the forward/backward buttons. Calling splitTrack this way is a bit different from calling it through thumbRect(), since the latter only passes the tracRect to splitTrack, whereas we are passing in the entire bounds rect (since we are bundling the buttons and the track into the texture). I found that if I called splitTrack with theme->trackRect() instead of bounds, I had to then manually append rects for the buttons. > > > > Oh! That's the problem exactly. splitTrack should take a trackRect, not a boundsRect. > > OK, so I'll go with manually appending the button rects so as to pass a trackRect (although splitTrack() does seem to modify the trackRect internally to get it right). We'll still need to offset for the thumbRect though to align it with our bounds.
By trackRect, I was trying to say that it'd be better to use ScrollbarThemeComposite::trackRect(ScrollbarThemeClient*) like thumbRect() does rather than trying to manually construct this rect. Button placement can be overridden by scrollbars, so it's not really safe to use their geometry to reposition other parts.
W. James MacLean
Comment 12
2012-06-26 13:30:43 PDT
(In reply to
comment #11
)
> (In reply to
comment #10
) > > (In reply to
comment #9
) > > > (From update of
attachment 149573
[details]
[details] [details]) > > > View in context:
https://bugs.webkit.org/attachment.cgi?id=149573&action=review
> > > > > > >>> Source/WebCore/platform/graphics/chromium/cc/CCScrollbarLayerImpl.cpp:-64 > > > >>> - thumbRect.move(-m_scrollbar.x(), -m_scrollbar.y()); > > > >> > > > >> Why do you need to move the thumbRect like this here? Shouldn't it be positioned properly with respect to the track? > > > > > > > > I was a bit surprised by this too. > > > > > > > > It seems to calculate the thumbRect position as an offset from the track, but *exclusive* from the forward/backward buttons. Calling splitTrack this way is a bit different from calling it through thumbRect(), since the latter only passes the tracRect to splitTrack, whereas we are passing in the entire bounds rect (since we are bundling the buttons and the track into the texture). I found that if I called splitTrack with theme->trackRect() instead of bounds, I had to then manually append rects for the buttons. > > > > > > Oh! That's the problem exactly. splitTrack should take a trackRect, not a boundsRect. > > > > OK, so I'll go with manually appending the button rects so as to pass a trackRect (although splitTrack() does seem to modify the trackRect internally to get it right). We'll still need to offset for the thumbRect though to align it with our bounds. > > By trackRect, I was trying to say that it'd be better to use ScrollbarThemeComposite::trackRect(ScrollbarThemeClient*) like thumbRect() does rather than trying to manually construct this rect.
Yes, this is what I was describing above. It still seems to ignore the buttons when positioning the thumbRect.
> Button placement can be overridden by scrollbars, so it's not really safe to use their geometry to reposition other parts.
Hmm, OK. Let me take a look and see what I can learn about this. But everything lives within the content bounds I assume ...
W. James MacLean
Comment 13
2012-06-26 14:55:51 PDT
(In reply to
comment #11
)
> > Button placement can be overridden by scrollbars, so it's not really safe to use their geometry to reposition other parts.
Is there a concise reference to tell me which parts can go where? I know how to do this now, once I can map the right parts to the right names.
W. James MacLean
Comment 14
2012-06-26 15:14:14 PDT
(In reply to
comment #13
)
> (In reply to
comment #11
) > > > > Button placement can be overridden by scrollbars, so it's not really safe to use their geometry to reposition other parts. > > Is there a concise reference to tell me which parts can go where? I know how to do this now, once I can map the right parts to the right names.
Got it I think ... new patch in the AM ...
W. James MacLean
Comment 15
2012-06-27 10:53:58 PDT
Created
attachment 149773
[details]
Patch
W. James MacLean
Comment 16
2012-06-27 10:55:39 PDT
(In reply to
comment #15
)
> Created an attachment (id=149773) [details] > Patch
OK ... we now have a layout test, and (I think) a more rational way of handling the buttons. My mild bout of insanity regarding thumb positioning seems also to have passed.
Adrienne Walker
Comment 17
2012-06-27 11:51:34 PDT
Comment on
attachment 149773
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=149773&action=review
So close. :)
> Source/WebCore/platform/graphics/chromium/cc/CCScrollbarLayerImpl.cpp:99 > + // Assumes backTrackRect, ForwardButtonStartPart and BackButtonStartPart form a connected, rectangular region. > + backTrackRect.unite(theme->forwardButtonRect(&m_scrollbar, ForwardButtonStartPart)); > + backTrackRect.unite(theme->backButtonRect(&m_scrollbar, BackButtonStartPart)); > + if (!backTrackRect.isEmpty()) > + quadList.append(CCTextureDrawQuad::create(sharedQuadState, backTrackRect, m_backTrackTextureId, premultipledAlpha, toUVRect(backTrackRect, boundsRect), flipped)); > + > + foreTrackRect.unite(theme->forwardButtonRect(&m_scrollbar, ForwardButtonEndPart)); > + foreTrackRect.unite(theme->backButtonRect(&m_scrollbar, BackButtonEndPart)); > + if (!foreTrackRect.isEmpty()) > + quadList.append(CCTextureDrawQuad::create(sharedQuadState, foreTrackRect, m_foreTrackTextureId, premultipledAlpha, toUVRect(foreTrackRect, boundsRect), flipped));
I still don't like the button assumptions. Is there some way to get rid of them? backTrack and foreTrack contain the entire content rect. What about appending foreTrack with the foreTrackRect (as here), but then appending the backTrack quad using boundsRect (as you do in the else case)? In other words, make the forward track quad just represent the forward track part and make the backward track quad represent the background, the buttons and the back track rect?
> LayoutTests/platform/chromium/compositing/scrollbars/custom-composited-different-track-parts.html:68 > +<h2>Composited Custom Scrollbars with Different Coloured Track Parts</h2> > +If this test succeeds, the track part before the thumb will be purple, and the track part after > +the thumb will be green. All four button rects will have different colours.
No text in pixel tests please, since it makes them have cross-platform results. You can make this a comment in the html if you want to explain what it's supposed to look like.
W. James MacLean
Comment 18
2012-06-27 12:03:17 PDT
(In reply to
comment #17
)
> (From update of
attachment 149773
[details]
) > View in context:
https://bugs.webkit.org/attachment.cgi?id=149773&action=review
> > So close. :) >
> I still don't like the button assumptions. Is there some way to get rid of them? > > backTrack and foreTrack contain the entire content rect. What about appending foreTrack with the foreTrackRect (as here), but then appending the backTrack quad using boundsRect (as you do in the else case)? In other words, make the forward track quad just represent the forward track part and make the backward track quad represent the background, the buttons and the back track rect?
Sure, this can be done (there will be a little bit of overdraw, but otherwise this will work).
> > LayoutTests/platform/chromium/compositing/scrollbars/custom-composited-different-track-parts.html:68 > > +<h2>Composited Custom Scrollbars with Different Coloured Track Parts</h2> > > +If this test succeeds, the track part before the thumb will be purple, and the track part after > > +the thumb will be green. All four button rects will have different colours. > > No text in pixel tests please, since it makes them have cross-platform results. You can make this a comment in the html if you want to explain what it's supposed to look like.
Will remove text asap ... will look kind of bare, but I can live with that.
W. James MacLean
Comment 19
2012-06-27 12:34:07 PDT
Created
attachment 149785
[details]
Patch
Adrienne Walker
Comment 20
2012-06-27 12:54:40 PDT
Comment on
attachment 149785
[details]
Patch R=me. Thanks for all the changes.
WebKit Review Bot
Comment 21
2012-06-27 14:25:12 PDT
Comment on
attachment 149785
[details]
Patch Clearing flags on attachment: 149785 Committed
r121371
: <
http://trac.webkit.org/changeset/121371
>
WebKit Review Bot
Comment 22
2012-06-27 14:25:17 PDT
All reviewed patches have been landed. Closing bug.
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug