Commit 4a99ae87 authored by Rune Lillesveen's avatar Rune Lillesveen Committed by Commit Bot

Get rid of have_selection parameter

Check the call site instead. There should be no behavioral change.
Preparing for making HighlightPaintingUtils::SelectionPaintingStyle
HighlightPaintingStyle and share the code with other highlight pseudo
elements.

Bug: 1136817
Change-Id: I240fdc2689db914862bc4ae64f64969ed3099acd
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2503552Reviewed-by: default avatarXianzhu Wang <wangxianzhu@chromium.org>
Commit-Queue: Rune Lillesveen <futhark@chromium.org>
Cr-Commit-Position: refs/heads/master@{#821815}
parent 1a15b1f1
...@@ -197,15 +197,12 @@ TextPaintStyle HighlightPaintingUtils::SelectionPaintingStyle( ...@@ -197,15 +197,12 @@ TextPaintStyle HighlightPaintingUtils::SelectionPaintingStyle(
const Document& document, const Document& document,
const ComputedStyle& style, const ComputedStyle& style,
Node* node, Node* node,
bool have_selection,
const TextPaintStyle& text_style, const TextPaintStyle& text_style,
const PaintInfo& paint_info) { const PaintInfo& paint_info) {
TextPaintStyle selection_style = text_style; TextPaintStyle selection_style = text_style;
bool uses_text_as_clip = paint_info.phase == PaintPhase::kTextClip; bool uses_text_as_clip = paint_info.phase == PaintPhase::kTextClip;
bool is_printing = paint_info.IsPrinting();
const GlobalPaintFlags global_paint_flags = paint_info.GetGlobalPaintFlags(); const GlobalPaintFlags global_paint_flags = paint_info.GetGlobalPaintFlags();
if (have_selection) {
if (!uses_text_as_clip) { if (!uses_text_as_clip) {
selection_style.fill_color = selection_style.fill_color =
SelectionForegroundColor(document, style, node, global_paint_flags); SelectionForegroundColor(document, style, node, global_paint_flags);
...@@ -227,9 +224,8 @@ TextPaintStyle HighlightPaintingUtils::SelectionPaintingStyle( ...@@ -227,9 +224,8 @@ TextPaintStyle HighlightPaintingUtils::SelectionPaintingStyle(
} }
// Text shadows are disabled when printing. http://crbug.com/258321 // Text shadows are disabled when printing. http://crbug.com/258321
if (is_printing) if (paint_info.IsPrinting())
selection_style.shadow = nullptr; selection_style.shadow = nullptr;
}
return selection_style; return selection_style;
} }
......
...@@ -41,7 +41,6 @@ class CORE_EXPORT HighlightPaintingUtils { ...@@ -41,7 +41,6 @@ class CORE_EXPORT HighlightPaintingUtils {
static TextPaintStyle SelectionPaintingStyle(const Document&, static TextPaintStyle SelectionPaintingStyle(const Document&,
const ComputedStyle&, const ComputedStyle&,
Node*, Node*,
bool have_selection,
const TextPaintStyle& text_style, const TextPaintStyle& text_style,
const PaintInfo&); const PaintInfo&);
}; };
......
...@@ -169,8 +169,7 @@ TEST_F(HighlightPaintingUtilsTest, SelectedTextInputShadow) { ...@@ -169,8 +169,7 @@ TEST_F(HighlightPaintingUtilsTest, SelectedTextInputShadow) {
TextPaintStyle paint_style; TextPaintStyle paint_style;
paint_style = HighlightPaintingUtils::SelectionPaintingStyle( paint_style = HighlightPaintingUtils::SelectionPaintingStyle(
GetDocument(), text_style, text_node, true /* have_selection */, GetDocument(), text_style, text_node, paint_style, paint_info);
paint_style, paint_info);
EXPECT_EQ(Color(0, 128, 0), paint_style.fill_color); EXPECT_EQ(Color(0, 128, 0), paint_style.fill_color);
EXPECT_TRUE(paint_style.shadow); EXPECT_TRUE(paint_style.shadow);
......
...@@ -260,10 +260,12 @@ void InlineTextBoxPainter::Paint(const PaintInfo& paint_info, ...@@ -260,10 +260,12 @@ void InlineTextBoxPainter::Paint(const PaintInfo& paint_info,
TextPaintStyle text_style = TextPainterBase::TextPaintingStyle( TextPaintStyle text_style = TextPainterBase::TextPaintingStyle(
inline_text_box_.GetLineLayoutItem().GetDocument(), style_to_use, inline_text_box_.GetLineLayoutItem().GetDocument(), style_to_use,
paint_info); paint_info);
TextPaintStyle selection_style = TextPainterBase::SelectionPaintingStyle( TextPaintStyle selection_style = text_style;
if (have_selection) {
selection_style = TextPainterBase::SelectionPaintingStyle(
inline_text_box_.GetLineLayoutItem().GetDocument(), style_to_use, inline_text_box_.GetLineLayoutItem().GetDocument(), style_to_use,
inline_text_box_.GetLineLayoutItem().GetNode(), have_selection, inline_text_box_.GetLineLayoutItem().GetNode(), paint_info, text_style);
paint_info, text_style); }
bool paint_selected_text_only = bool paint_selected_text_only =
(paint_info.phase == PaintPhase::kSelectionDragImage); (paint_info.phase == PaintPhase::kSelectionDragImage);
bool paint_selected_text_separately = bool paint_selected_text_separately =
......
...@@ -382,7 +382,7 @@ class SelectionPaintState { ...@@ -382,7 +382,7 @@ class SelectionPaintState {
const PaintInfo& paint_info, const PaintInfo& paint_info,
const TextPaintStyle& text_style) { const TextPaintStyle& text_style) {
selection_style_ = TextPainterBase::SelectionPaintingStyle( selection_style_ = TextPainterBase::SelectionPaintingStyle(
document, style, node, /*have_selection*/ true, paint_info, text_style); document, style, node, paint_info, text_style);
paint_selected_text_only_ = paint_selected_text_only_ =
(paint_info.phase == PaintPhase::kSelectionDragImage); (paint_info.phase == PaintPhase::kSelectionDragImage);
paint_selected_text_separately_ = paint_selected_text_separately_ =
......
...@@ -163,11 +163,10 @@ TextPaintStyle TextPainterBase::SelectionPaintingStyle( ...@@ -163,11 +163,10 @@ TextPaintStyle TextPainterBase::SelectionPaintingStyle(
const Document& document, const Document& document,
const ComputedStyle& style, const ComputedStyle& style,
Node* node, Node* node,
bool have_selection,
const PaintInfo& paint_info, const PaintInfo& paint_info,
const TextPaintStyle& text_style) { const TextPaintStyle& text_style) {
return HighlightPaintingUtils::SelectionPaintingStyle( return HighlightPaintingUtils::SelectionPaintingStyle(document, style, node,
document, style, node, have_selection, text_style, paint_info); text_style, paint_info);
} }
void TextPainterBase::DecorationsStripeIntercepts( void TextPainterBase::DecorationsStripeIntercepts(
......
...@@ -74,7 +74,6 @@ class CORE_EXPORT TextPainterBase { ...@@ -74,7 +74,6 @@ class CORE_EXPORT TextPainterBase {
const Document&, const Document&,
const ComputedStyle&, const ComputedStyle&,
Node*, Node*,
bool have_selection,
const PaintInfo&, const PaintInfo&,
const TextPaintStyle& text_style); const TextPaintStyle& text_style);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment