Commit 938950b5 authored by rune's avatar rune Committed by Commit bot

Adjust color for printing list-item markers as we do for text.

BUG=459022

Review-Url: https://codereview.chromium.org/2027653004
Cr-Commit-Position: refs/heads/master@{#397099}
parent 88abe361
<!DOCTYPE html>
<script>
if (window.testRunner)
testRunner.setPrinting();
</script>
<style>
#sandbox { color: #ababab; -webkit-print-color-adjust: exact }
</style>
<p>This test must be run in print preview.</p>
<div id="sandbox">
<ol>
<li>PASS if you see this text with 1. to its left.</li>
</ol>
<ul>
<li>PASS if you see this text with a disc marker.</li>
</ul>
</div>
<!DOCTYPE html>
<script>
if (window.testRunner)
testRunner.setPrinting();
</script>
<style>
#sandbox { color: white }
</style>
<p>This test must be run in print preview.</p>
<div id="sandbox">
<ol>
<li>PASS if you see this text with 1. to its left.</li>
</ol>
<ul>
<li>PASS if you see this text with a disc marker.</li>
</ul>
</div>
...@@ -8,8 +8,10 @@ ...@@ -8,8 +8,10 @@
#include "core/layout/LayoutListMarker.h" #include "core/layout/LayoutListMarker.h"
#include "core/layout/ListMarkerText.h" #include "core/layout/ListMarkerText.h"
#include "core/layout/api/SelectionState.h" #include "core/layout/api/SelectionState.h"
#include "core/paint/BoxPainter.h"
#include "core/paint/LayoutObjectDrawingRecorder.h" #include "core/paint/LayoutObjectDrawingRecorder.h"
#include "core/paint/PaintInfo.h" #include "core/paint/PaintInfo.h"
#include "core/paint/TextPainter.h"
#include "platform/geometry/LayoutPoint.h" #include "platform/geometry/LayoutPoint.h"
#include "platform/graphics/GraphicsContextStateSaver.h" #include "platform/graphics/GraphicsContextStateSaver.h"
...@@ -80,7 +82,11 @@ void ListMarkerPainter::paint(const PaintInfo& paintInfo, const LayoutPoint& pai ...@@ -80,7 +82,11 @@ void ListMarkerPainter::paint(const PaintInfo& paintInfo, const LayoutPoint& pai
if (styleCategory == LayoutListMarker::ListStyleCategory::None) if (styleCategory == LayoutListMarker::ListStyleCategory::None)
return; return;
const Color color(m_layoutListMarker.resolveColor(CSSPropertyColor)); Color color(m_layoutListMarker.resolveColor(CSSPropertyColor));
if (BoxPainter::shouldForceWhiteBackgroundForPrintEconomy(m_layoutListMarker.styleRef(), m_layoutListMarker.listItem()->document()))
color = TextPainter::textColorForWhiteBackground(color);
// Apply the color to the list marker text. // Apply the color to the list marker text.
context.setFillColor(color); context.setFillColor(color);
......
...@@ -109,7 +109,7 @@ void TextPainter::updateGraphicsContext(GraphicsContext& context, const Style& t ...@@ -109,7 +109,7 @@ void TextPainter::updateGraphicsContext(GraphicsContext& context, const Style& t
} }
} }
static Color textColorForWhiteBackground(Color textColor) Color TextPainter::textColorForWhiteBackground(Color textColor)
{ {
int distanceFromWhite = differenceSquared(textColor, Color::white); int distanceFromWhite = differenceSquared(textColor, Color::white);
// semi-arbitrarily chose 65025 (255^2) value here after a few tests; // semi-arbitrarily chose 65025 (255^2) value here after a few tests;
......
...@@ -67,6 +67,7 @@ public: ...@@ -67,6 +67,7 @@ public:
}; };
static Style textPaintingStyle(LineLayoutItem, const ComputedStyle&, const PaintInfo&); static Style textPaintingStyle(LineLayoutItem, const ComputedStyle&, const PaintInfo&);
static Style selectionPaintingStyle(LineLayoutItem, bool haveSelection, const PaintInfo&, const Style& textStyle); static Style selectionPaintingStyle(LineLayoutItem, bool haveSelection, const PaintInfo&, const Style& textStyle);
static Color textColorForWhiteBackground(Color);
enum RotationDirection { Counterclockwise, Clockwise }; enum RotationDirection { Counterclockwise, Clockwise };
static AffineTransform rotation(const LayoutRect& boxRect, RotationDirection); static AffineTransform rotation(const LayoutRect& boxRect, RotationDirection);
......
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