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,40 +197,36 @@ TextPaintStyle HighlightPaintingUtils::SelectionPaintingStyle(
const Document& document,
const ComputedStyle& style,
Node* node,
bool have_selection,
const TextPaintStyle& text_style,
const PaintInfo& paint_info) {
TextPaintStyle selection_style = text_style;
bool uses_text_as_clip = paint_info.phase == PaintPhase::kTextClip;
bool is_printing = paint_info.IsPrinting();
const GlobalPaintFlags global_paint_flags = paint_info.GetGlobalPaintFlags();
if (have_selection) {
if (!uses_text_as_clip) {
selection_style.fill_color =
SelectionForegroundColor(document, style, node, global_paint_flags);
selection_style.emphasis_mark_color =
SelectionEmphasisMarkColor(document, style, node, global_paint_flags);
}
if (scoped_refptr<const ComputedStyle> pseudo_style =
HighlightPseudoStyle(node, kPseudoIdSelection)) {
selection_style.stroke_color =
uses_text_as_clip ? Color::kBlack
: pseudo_style->VisitedDependentColor(
GetCSSPropertyWebkitTextStrokeColor());
selection_style.stroke_width = pseudo_style->TextStrokeWidth();
selection_style.shadow =
uses_text_as_clip ? nullptr : pseudo_style->TextShadow();
selection_style.selection_text_decoration =
SelectionTextDecoration(style, *pseudo_style);
}
if (!uses_text_as_clip) {
selection_style.fill_color =
SelectionForegroundColor(document, style, node, global_paint_flags);
selection_style.emphasis_mark_color =
SelectionEmphasisMarkColor(document, style, node, global_paint_flags);
}
// Text shadows are disabled when printing. http://crbug.com/258321
if (is_printing)
selection_style.shadow = nullptr;
if (scoped_refptr<const ComputedStyle> pseudo_style =
HighlightPseudoStyle(node, kPseudoIdSelection)) {
selection_style.stroke_color =
uses_text_as_clip ? Color::kBlack
: pseudo_style->VisitedDependentColor(
GetCSSPropertyWebkitTextStrokeColor());
selection_style.stroke_width = pseudo_style->TextStrokeWidth();
selection_style.shadow =
uses_text_as_clip ? nullptr : pseudo_style->TextShadow();
selection_style.selection_text_decoration =
SelectionTextDecoration(style, *pseudo_style);
}
// Text shadows are disabled when printing. http://crbug.com/258321
if (paint_info.IsPrinting())
selection_style.shadow = nullptr;
return selection_style;
}
......
......@@ -41,7 +41,6 @@ class CORE_EXPORT HighlightPaintingUtils {
static TextPaintStyle SelectionPaintingStyle(const Document&,
const ComputedStyle&,
Node*,
bool have_selection,
const TextPaintStyle& text_style,
const PaintInfo&);
};
......
......@@ -169,8 +169,7 @@ TEST_F(HighlightPaintingUtilsTest, SelectedTextInputShadow) {
TextPaintStyle paint_style;
paint_style = HighlightPaintingUtils::SelectionPaintingStyle(
GetDocument(), text_style, text_node, true /* have_selection */,
paint_style, paint_info);
GetDocument(), text_style, text_node, paint_style, paint_info);
EXPECT_EQ(Color(0, 128, 0), paint_style.fill_color);
EXPECT_TRUE(paint_style.shadow);
......
......@@ -260,10 +260,12 @@ void InlineTextBoxPainter::Paint(const PaintInfo& paint_info,
TextPaintStyle text_style = TextPainterBase::TextPaintingStyle(
inline_text_box_.GetLineLayoutItem().GetDocument(), style_to_use,
paint_info);
TextPaintStyle selection_style = TextPainterBase::SelectionPaintingStyle(
inline_text_box_.GetLineLayoutItem().GetDocument(), style_to_use,
inline_text_box_.GetLineLayoutItem().GetNode(), have_selection,
paint_info, text_style);
TextPaintStyle selection_style = text_style;
if (have_selection) {
selection_style = TextPainterBase::SelectionPaintingStyle(
inline_text_box_.GetLineLayoutItem().GetDocument(), style_to_use,
inline_text_box_.GetLineLayoutItem().GetNode(), paint_info, text_style);
}
bool paint_selected_text_only =
(paint_info.phase == PaintPhase::kSelectionDragImage);
bool paint_selected_text_separately =
......
......@@ -382,7 +382,7 @@ class SelectionPaintState {
const PaintInfo& paint_info,
const TextPaintStyle& text_style) {
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_info.phase == PaintPhase::kSelectionDragImage);
paint_selected_text_separately_ =
......
......@@ -163,11 +163,10 @@ TextPaintStyle TextPainterBase::SelectionPaintingStyle(
const Document& document,
const ComputedStyle& style,
Node* node,
bool have_selection,
const PaintInfo& paint_info,
const TextPaintStyle& text_style) {
return HighlightPaintingUtils::SelectionPaintingStyle(
document, style, node, have_selection, text_style, paint_info);
return HighlightPaintingUtils::SelectionPaintingStyle(document, style, node,
text_style, paint_info);
}
void TextPainterBase::DecorationsStripeIntercepts(
......
......@@ -74,7 +74,6 @@ class CORE_EXPORT TextPainterBase {
const Document&,
const ComputedStyle&,
Node*,
bool have_selection,
const PaintInfo&,
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