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; ComputedStyle* bg = nullptr;
nsIFrame* dependentFrame = nullptr; nsIFrame* dependentFrame = nullptr;
bool isThemed = IsThemed(); bool isThemed = IsThemed();
if (!isThemed && if (!isThemed) {
nsCSSRendering::FindBackgroundFrame(this, &dependentFrame)) { dependentFrame = nsCSSRendering::FindBackgroundFrame(this);
if (dependentFrame) {
bg = dependentFrame->Style(); bg = dependentFrame->Style();
if (dependentFrame == this) { if (dependentFrame == this) {
dependentFrame = nullptr; dependentFrame = nullptr;
} }
} }
}
if (isThemed) { if (isThemed) {
aLists.BorderBackground() aLists.BorderBackground()

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

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

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

@ -292,8 +292,7 @@ struct nsCSSRendering {
* background. * background.
*/ */
static mozilla::ComputedStyle* FindBackground(const nsIFrame* aForFrame); static mozilla::ComputedStyle* FindBackground(const nsIFrame* aForFrame);
static bool FindBackgroundFrame(const nsIFrame* aForFrame, static nsIFrame* FindBackgroundFrame(const nsIFrame* aForFrame);
nsIFrame** aBackgroundFrame);
/** /**
* As FindBackground, but the passed-in frame is known to be a root frame * 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) { static nsIFrame* GetBackgroundComputedStyleFrame(nsIFrame* aFrame) {
nsIFrame* f; nsIFrame* f = nsCSSRendering::FindBackgroundFrame(aFrame);
if (!nsCSSRendering::FindBackgroundFrame(aFrame, &f)) { if (!f) {
// We don't want to bail out if moz-appearance is set on a root // 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 // 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 // a root, other wise keep going in order to let the theme stuff