Commit 16e5a84d authored by Stephen Chenney's avatar Stephen Chenney Committed by Commit Bot

Fix selected text decoration when no selection style

If there is a selection style but no text-decoration in
it, and text decoration in another pseudo style that applies,
then it is possible for the style to have text decorations but
not the pseudo selection style. Avoid crashing in this case.

Also improve selection decoration color by using just the
color from the selection style if available.

Bug: 1144134
Change-Id: Id09fbaeafcc7bdf187abcf6be5d542004e61a16c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2513825Reviewed-by: default avatarKoji Ishii <kojii@chromium.org>
Commit-Queue: Stephen Chenney <schenney@chromium.org>
Cr-Commit-Position: refs/heads/master@{#823269}
parent e8f987e1
......@@ -233,19 +233,17 @@ HighlightPaintingUtils::HighlightTextDecoration(
return base::nullopt;
base::Optional<AppliedTextDecoration> highlight_text_decoration =
base::nullopt;
style_decorations.back();
if (style_decorations.back().Lines() ==
pseudo_style_decorations.back().Lines()) {
if (pseudo_style_decorations.size() &&
style_decorations.back().Lines() ==
pseudo_style_decorations.back().Lines()) {
highlight_text_decoration = pseudo_style_decorations.back();
if (style_decorations.size() == pseudo_style_decorations.size()) {
highlight_text_decoration.value().SetColor(
pseudo_style.VisitedDependentColor(
GetCSSPropertyTextDecorationColor()));
}
}
highlight_text_decoration.value().SetColor(
pseudo_style.VisitedDependentColor(GetCSSPropertyTextDecorationColor()));
return highlight_text_decoration;
}
......
<!DOCTYPE html>
<html>
<head>
<title>CSS Test: CSS3 text-decoration-color when |::selection| and another pseudo style exists, reference</title>
<link rel="author" title="Stephen Chenney" href="mailto:schenney@chromium.org">
<style>
p::first-line {
text-decoration: underline;
color: green;
}
</style>
</head>
<body>
<p>
Underlined, and green when selected.
</p>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<title>CSS Test: CSS3 text-decoration-color when |::selection| and another pseudo style exists</title>
<meta name="assert" content="When selected, text decorations apply the selection color when other pseudo styles are present">
<link rel="author" title="Stephen Chenney" href="mailto:schenney@chromium.org">
<link rel="help" href="https://www.w3.org/TR/css-text-decor-3/#text-decoration-color-property">
<link rel="help" href="https://www.w3.org/TR/css-pseudo-4/#highlight-styling">
<link rel="match" href="reference/text-decoration-color-selection-pseudo-01-ref.html">
<style>
p::first-line {
text-decoration: underline;
}
p::selection {
color: green;
}
</style>
</head>
<body>
<p>
Underlined, and green when selected.
</p>
<script>
document.execCommand("SelectAll")
</script>
</body>
</html>
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