Commit 43d7cedb authored by Alison Maher's avatar Alison Maher Committed by Commit Bot

Forced colors mode backplate for hidden elements

If an element is hidden, we shouldn't paint a backplate behind it
when in forced colors mode.

Bug: 970285
Change-Id: I378776c71a6977722305e91df84418493be4f290
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2363443Reviewed-by: default avatarPhilip Rogers <pdr@chromium.org>
Commit-Queue: Alison Maher <almaher@microsoft.com>
Cr-Commit-Position: refs/heads/master@{#799705}
parent 17154cb6
...@@ -149,10 +149,12 @@ void LineBoxListPainter::PaintBackplate( ...@@ -149,10 +149,12 @@ void LineBoxListPainter::PaintBackplate(
if (!ShouldPaint(layout_object, paint_info, paint_offset)) if (!ShouldPaint(layout_object, paint_info, paint_offset))
return; return;
// Only paint backplates behind text when forced-color-adjust is auto. // Only paint backplates behind text when forced-color-adjust is auto and the
// element is visible.
const ComputedStyle& style = const ComputedStyle& style =
line_box_list_.First()->GetLineLayoutItem().StyleRef(); line_box_list_.First()->GetLineLayoutItem().StyleRef();
if (style.ForcedColorAdjust() == EForcedColorAdjust::kNone) if (style.ForcedColorAdjust() == EForcedColorAdjust::kNone ||
style.Visibility() != EVisibility::kVisible)
return; return;
if (DrawingRecorder::UseCachedDrawingIfPossible( if (DrawingRecorder::UseCachedDrawingIfPossible(
......
...@@ -1516,9 +1516,11 @@ void NGBoxFragmentPainter::PaintBackplate(NGInlineCursor* line_boxes, ...@@ -1516,9 +1516,11 @@ void NGBoxFragmentPainter::PaintBackplate(NGInlineCursor* line_boxes,
if (paint_info.phase != PaintPhase::kForcedColorsModeBackplate) if (paint_info.phase != PaintPhase::kForcedColorsModeBackplate)
return; return;
// Only paint backplates behind text when forced-color-adjust is auto. // Only paint backplates behind text when forced-color-adjust is auto and the
// element is visible.
const ComputedStyle& style = PhysicalFragment().Style(); const ComputedStyle& style = PhysicalFragment().Style();
if (style.ForcedColorAdjust() == EForcedColorAdjust::kNone) if (style.ForcedColorAdjust() == EForcedColorAdjust::kNone ||
style.Visibility() != EVisibility::kVisible)
return; return;
if (DrawingRecorder::UseCachedDrawingIfPossible( if (DrawingRecorder::UseCachedDrawingIfPossible(
......
<!DOCTYPE html>
<meta charset="utf-8">
<title>
Forced colors mode - backplate.
Tests that backplates are not painted behind hidden elements.
</title>
<style>
body {
background-image: url("../resources/test-image.jpg");
}
</style>
<!DOCTYPE html>
<meta charset="utf-8">
<title>
Forced colors mode - backplate.
Tests that backplates are not painted behind hidden elements.
</title>
<link rel="help" href="https://www.w3.org/TR/css-color-adjust-1/#forced">
<link rel=match href="forced-colors-mode-backplate-11-ref.html">
<style>
body {
background-image: url("../resources/test-image.jpg");
}
</style>
<div style="visibility: hidden;">
No blackplate should be painted in forced colors mode.
</div>
<div style="visibility: collapse;">
No blackplate should be painted in forced colors mode.
</div>
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