Skip to content
This repository was archived by the owner on Jul 9, 2025. It is now read-only.

Commit c4cf618

Browse files
committed
Bug 1917715 - Rename nsLayoutUtils::GetColor. r=longsonr,dholbert
It's suitable for foreground colors only. Differential Revision: https://phabricator.services.mozilla.com/D221557
1 parent 4395828 commit c4cf618

File tree

6 files changed

+14
-13
lines changed

6 files changed

+14
-13
lines changed

layout/base/nsLayoutUtils.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1591,12 +1591,12 @@ class nsLayoutUtils {
15911591
// Get a suitable foreground color for painting aColor for aFrame.
15921592
static nscolor DarkenColorIfNeeded(nsIFrame* aFrame, nscolor aColor);
15931593
1594-
// Get a suitable foreground color for painting aField for aFrame.
1594+
// Get a suitable text foreground color for painting aField for aFrame.
15951595
// Type of aFrame is made a template parameter because nsIFrame is not
15961596
// a complete type in the header. Type-safety is not harmed given that
15971597
// DarkenColorIfNeeded requires an nsIFrame pointer.
15981598
template <typename Frame, typename T, typename S>
1599-
static nscolor GetColor(Frame* aFrame, T S::*aField) {
1599+
static nscolor GetTextColor(Frame* aFrame, T S::*aField) {
16001600
nscolor color = aFrame->GetVisitedDependentColor(aField);
16011601
return DarkenColorIfNeeded(aFrame, color);
16021602
}

layout/generic/TextOverflow.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ static void PaintTextShadowCallback(gfxContext* aCtx, nsPoint aShadowOffset,
207207
void nsDisplayTextOverflowMarker::Paint(nsDisplayListBuilder* aBuilder,
208208
gfxContext* aCtx) {
209209
nscolor foregroundColor =
210-
nsLayoutUtils::GetColor(mFrame, &nsStyleText::mWebkitTextFillColor);
210+
nsLayoutUtils::GetTextColor(mFrame, &nsStyleText::mWebkitTextFillColor);
211211

212212
// Paint the text-shadows for the overflow marker
213213
nsLayoutUtils::PaintTextShadow(mFrame, aCtx, mRect,

layout/generic/nsIFrame.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2618,7 +2618,7 @@ void nsIFrame::DisplayCaret(nsDisplayListBuilder* aBuilder,
26182618
}
26192619

26202620
nscolor nsIFrame::GetCaretColorAt(int32_t aOffset) {
2621-
return nsLayoutUtils::GetColor(this, &nsStyleUI::mCaretColor);
2621+
return nsLayoutUtils::GetTextColor(this, &nsStyleUI::mCaretColor);
26222622
}
26232623

26242624
auto nsIFrame::ComputeShouldPaintBackground() const -> ShouldPaintBackground {

layout/generic/nsTextFrame.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4883,8 +4883,8 @@ void nsTextFrame::GetTextDecorations(
48834883
// This handles the <a href="blah.html"><font color="green">La
48844884
// la la</font></a> case. The link underline should be green.
48854885
useOverride = true;
4886-
overrideColor =
4887-
nsLayoutUtils::GetColor(f, &nsStyleTextReset::mTextDecorationColor);
4886+
overrideColor = nsLayoutUtils::GetTextColor(
4887+
f, &nsStyleTextReset::mTextDecorationColor);
48884888
}
48894889

48904890
nsBlockFrame* fBlock = do_QueryFrame(f);
@@ -4938,11 +4938,11 @@ void nsTextFrame::GetTextDecorations(
49384938
// for SVG text, and have e.g. text-decoration-color:red to
49394939
// override the fill paint of the decoration.
49404940
color = aColorResolution == eResolvedColors
4941-
? nsLayoutUtils::GetColor(f, &nsStyleSVG::mFill)
4941+
? nsLayoutUtils::GetTextColor(f, &nsStyleSVG::mFill)
49424942
: NS_SAME_AS_FOREGROUND_COLOR;
49434943
} else {
4944-
color =
4945-
nsLayoutUtils::GetColor(f, &nsStyleTextReset::mTextDecorationColor);
4944+
color = nsLayoutUtils::GetTextColor(
4945+
f, &nsStyleTextReset::mTextDecorationColor);
49464946
}
49474947

49484948
bool swapUnderlineAndOverline =
@@ -6538,7 +6538,7 @@ void nsTextFrame::DrawEmphasisMarks(gfxContext* aContext, WritingMode aWM,
65386538
nscolor color =
65396539
aDecorationOverrideColor
65406540
? *aDecorationOverrideColor
6541-
: nsLayoutUtils::GetColor(this, &nsStyleText::mTextEmphasisColor);
6541+
: nsLayoutUtils::GetTextColor(this, &nsStyleText::mTextEmphasisColor);
65426542
aContext->SetColor(sRGBColor::FromABGR(color));
65436543
gfx::Point pt;
65446544
if (!isTextCombined) {

layout/generic/nsTextPaintStyle.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,14 +96,15 @@ nscolor nsTextPaintStyle::GetTextColor() {
9696
case StyleSVGPaintKind::Tag::None:
9797
return NS_RGBA(0, 0, 0, 0);
9898
case StyleSVGPaintKind::Tag::Color:
99-
return nsLayoutUtils::GetColor(mFrame, &nsStyleSVG::mFill);
99+
return nsLayoutUtils::GetTextColor(mFrame, &nsStyleSVG::mFill);
100100
default:
101101
NS_ERROR("cannot resolve SVG paint to nscolor");
102102
return NS_RGBA(0, 0, 0, 255);
103103
}
104104
}
105105

106-
return nsLayoutUtils::GetColor(mFrame, &nsStyleText::mWebkitTextFillColor);
106+
return nsLayoutUtils::GetTextColor(mFrame,
107+
&nsStyleText::mWebkitTextFillColor);
107108
}
108109

109110
bool nsTextPaintStyle::GetSelectionColors(nscolor* aForeColor,

widget/Theme.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -839,7 +839,7 @@ void Theme::PaintMenulistArrow(nsIFrame* aFrame, DrawTarget& aDrawTarget,
839839
}();
840840

841841
const auto arrowColor = sRGBColor::FromABGR(
842-
nsLayoutUtils::GetColor(aFrame, &nsStyleText::mWebkitTextFillColor));
842+
nsLayoutUtils::GetTextColor(aFrame, &nsStyleText::mWebkitTextFillColor));
843843
ThemeDrawing::PaintArrow(aDrawTarget, aRect, xs, ys, kPolygonSize,
844844
ArrayLength(polygonX), arrowColor);
845845
}

0 commit comments

Comments
 (0)