Bug 1774261 part 2: Simplify nsCSSRendering::FindBackgroundFrame to directly return its result instead of using an outparam. r=emilio

This patch doesn't change behavior.

This is similar to the previous patch in this series, but now for
FindBackgroundFrame().

Differential Revision: https://phabricator.services.mozilla.com/D149338
This commit is contained in:
Daniel Holbert 2022-06-17 21:55:21 +00:00
Родитель e4309c976e
Коммит cdb88a2da1
4 изменённых файлов: 22 добавлений и 19 удалений

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

@ -461,13 +461,15 @@ void nsCanvasFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
ComputedStyle* bg = nullptr;
nsIFrame* dependentFrame = nullptr;
bool isThemed = IsThemed();
if (!isThemed &&
nsCSSRendering::FindBackgroundFrame(this, &dependentFrame)) {
if (!isThemed) {
dependentFrame = nsCSSRendering::FindBackgroundFrame(this);
if (dependentFrame) {
bg = dependentFrame->Style();
if (dependentFrame == this) {
dependentFrame = nullptr;
}
}
}
if (isThemed) {
aLists.BorderBackground()

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

@ -1138,8 +1138,8 @@ auto nsCSSRendering::FindNonTransparentBackgroundFrame(nsIFrame* aFrame,
}
if (IsCanvasFrame(frame)) {
nsIFrame* bgFrame = nullptr;
if (FindBackgroundFrame(frame, &bgFrame) &&
nsIFrame* bgFrame = FindBackgroundFrame(frame);
if (bgFrame &&
NS_GET_A(bgFrame->StyleBackground()->BackgroundColor(bgFrame))) {
return {bgFrame, false, true};
}
@ -1273,22 +1273,24 @@ inline bool FindElementBackground(const nsIFrame* aForFrame,
return !htmlBG->IsTransparent(aRootElementFrame);
}
bool nsCSSRendering::FindBackgroundFrame(const nsIFrame* aForFrame,
nsIFrame** aBackgroundFrame) {
nsIFrame* nsCSSRendering::FindBackgroundFrame(const nsIFrame* aForFrame) {
nsIFrame* rootElementFrame =
aForFrame->PresShell()->FrameConstructor()->GetRootElementStyleFrame();
if (IsCanvasFrame(aForFrame)) {
*aBackgroundFrame = FindCanvasBackgroundFrame(aForFrame, rootElementFrame);
return true;
return FindCanvasBackgroundFrame(aForFrame, rootElementFrame);
}
*aBackgroundFrame = const_cast<nsIFrame*>(aForFrame);
return FindElementBackground(aForFrame, rootElementFrame);
// XXXdholbert FindElementBackground will be renamed for clarity later
// in this series.
if (FindElementBackground(aForFrame, rootElementFrame)) {
return const_cast<nsIFrame*>(aForFrame);
}
return nullptr;
}
ComputedStyle* nsCSSRendering::FindBackground(const nsIFrame* aForFrame) {
nsIFrame* backgroundFrame = nullptr;
if (FindBackgroundFrame(aForFrame, &backgroundFrame)) {
if (auto* backgroundFrame = FindBackgroundFrame(aForFrame)) {
return backgroundFrame->Style();
}
return nullptr;

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

@ -292,8 +292,7 @@ struct nsCSSRendering {
* background.
*/
static mozilla::ComputedStyle* FindBackground(const nsIFrame* aForFrame);
static bool FindBackgroundFrame(const nsIFrame* aForFrame,
nsIFrame** aBackgroundFrame);
static nsIFrame* FindBackgroundFrame(const nsIFrame* aForFrame);
/**
* As FindBackground, but the passed-in frame is known to be a root frame

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

@ -2957,8 +2957,8 @@ nsDisplayBackgroundImage::~nsDisplayBackgroundImage() {
}
static nsIFrame* GetBackgroundComputedStyleFrame(nsIFrame* aFrame) {
nsIFrame* f;
if (!nsCSSRendering::FindBackgroundFrame(aFrame, &f)) {
nsIFrame* f = nsCSSRendering::FindBackgroundFrame(aFrame);
if (!f) {
// We don't want to bail out if moz-appearance is set on a root
// node. If it has a parent content node, bail because it's not
// a root, other wise keep going in order to let the theme stuff