Bug 1832928. Handle drawing themed borders in buttons without going to fallback unnecessarily. r=jrmuizel

We hit this case in nsDisplayButtonBorder::CreateWebRenderCommands
https://searchfox.org/mozilla-central/rev/e77d89c414eac63a295a2124600045775a6f4715/layout/forms/nsButtonFrameRenderer.cpp#394
and borderIsEmpty is false.

The reason we return nothing from nsCSSRendering::CreateBorderRenderer is the return here
https://searchfox.org/mozilla-central/rev/e77d89c414eac63a295a2124600045775a6f4715/layout/painting/nsCSSRendering.cpp#924
because ThemeSupportsWidget and the button has the default button moz-appearance.

But then when we do the fallback via nsDisplayButtonBorder::Paint we hit this early return
https://searchfox.org/mozilla-central/rev/45b20d00311bc2170dfbdae8a91bc4dca29717d8/layout/painting/nsCSSRendering.cpp#837
for the exact same reason and we don't actually draw anything.

The border is actually drawn by the nsDisplayThemedBackground item for the same frame as part of the background.

This is also how it worked before webrender. And nsDisplayBorder, if you follow the code hits the same ThemeSupportsWidget early return, ie it just does not draw themed borders. It handles the case here
https://searchfox.org/mozilla-central/rev/45b20d00311bc2170dfbdae8a91bc4dca29717d8/layout/painting/nsCSSRendering.cpp#691
by not handling the case, and then it returns ImgDrawResult::SUCCESS
https://searchfox.org/mozilla-central/rev/45b20d00311bc2170dfbdae8a91bc4dca29717d8/layout/painting/nsCSSRendering.cpp#709

Differential Revision: https://phabricator.services.mozilla.com/D178372
This commit is contained in:
Timothy Nikkel 2023-05-17 19:31:31 +00:00
Родитель c1684f752d
Коммит 67cffee4c5
1 изменённых файлов: 7 добавлений и 0 удалений

Просмотреть файл

@ -921,6 +921,13 @@ nsCSSRendering::CreateNullBorderRendererWithStyleBorder(
if (appearance != StyleAppearance::None) {
nsITheme* theme = aPresContext->Theme();
if (theme->ThemeSupportsWidget(aPresContext, aForFrame, appearance)) {
// The border will be draw as part of the themed background item created
// for this same frame. If no themed background item was created then not
// drawing also matches that we do without webrender and what
// nsDisplayBorder does for themed borders.
if (aOutBorderIsEmpty) {
*aOutBorderIsEmpty = true;
}
return Nothing();
}
}