Skip to content

Commit

Permalink
[dark] Treat text underlines the same way as the associated text.
Browse files Browse the repository at this point in the history
Bug: 992146
Change-Id: Ib7c3ae979bebc79f64a455ecd29c6e4f2b76512b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1751796
Reviewed-by: Aran Gilman <gilmanmh@google.com>
Reviewed-by: Stephen Chenney <schenney@chromium.org>
Commit-Queue: Anna Malova <amalova@chromium.org>
Cr-Commit-Position: refs/heads/master@{#687297}
  • Loading branch information
Anna Malova authored and Commit Bot committed Aug 15, 2019
1 parent a7f10cf commit c2bfb8f
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 11 deletions.
20 changes: 11 additions & 9 deletions third_party/blink/renderer/platform/graphics/graphics_context.cc
Original file line number Diff line number Diff line change
Expand Up @@ -669,7 +669,9 @@ static void EnforceDotsAtEndpoints(GraphicsContext& context,
}
}

void GraphicsContext::DrawLine(const IntPoint& point1, const IntPoint& point2) {
void GraphicsContext::DrawLine(const IntPoint& point1,
const IntPoint& point2,
const DarkModeFilter::ElementRole role) {
if (ContextDisabled())
return;
DCHECK(canvas_);
Expand All @@ -688,8 +690,7 @@ void GraphicsContext::DrawLine(const IntPoint& point1, const IntPoint& point2) {
// probably worth the speed up of no square root, which also won't be exact.
FloatSize disp = p2 - p1;
int length = SkScalarRoundToInt(disp.Width() + disp.Height());
const DarkModeFlags flags(this, ImmutableState()->StrokeFlags(length),
DarkModeFilter::ElementRole::kBackground);
const DarkModeFlags flags(this, ImmutableState()->StrokeFlags(length), role);

if (pen_style == kDottedStroke) {
if (StrokeData::StrokeIsDashed(width, pen_style)) {
Expand Down Expand Up @@ -742,13 +743,14 @@ void GraphicsContext::DrawLineForText(const FloatPoint& pt, float width) {
flags = ImmutableState()->FillFlags();
// Text lines are drawn using the stroke color.
flags.setColor(StrokeColor().Rgb());
DrawRect(r, flags);
DrawRect(r, flags, DarkModeFilter::ElementRole::kText);
return;
}
case kDottedStroke:
case kDashedStroke: {
int y = floorf(pt.Y() + std::max<float>(StrokeThickness() / 2.0f, 0.5f));
DrawLine(IntPoint(pt.X(), y), IntPoint(pt.X() + width, y));
DrawLine(IntPoint(pt.X(), y), IntPoint(pt.X() + width, y),
DarkModeFilter::ElementRole::kText);
return;
}
case kWavyStroke:
Expand Down Expand Up @@ -1046,14 +1048,14 @@ void GraphicsContext::DrawPath(const SkPath& path, const PaintFlags& flags) {
DarkModeFlags(this, flags, DarkModeFilter::ElementRole::kBackground));
}

void GraphicsContext::DrawRect(const SkRect& rect, const PaintFlags& flags) {
void GraphicsContext::DrawRect(const SkRect& rect,
const PaintFlags& flags,
const DarkModeFilter::ElementRole role) {
if (ContextDisabled())
return;
DCHECK(canvas_);

canvas_->drawRect(
rect,
DarkModeFlags(this, flags, DarkModeFilter::ElementRole::kBackground));
canvas_->drawRect(rect, DarkModeFlags(this, flags, role));
}

void GraphicsContext::DrawRRect(const SkRRect& rrect, const PaintFlags& flags) {
Expand Down
10 changes: 8 additions & 2 deletions third_party/blink/renderer/platform/graphics/graphics_context.h
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,10 @@ class PLATFORM_EXPORT GraphicsContext {

// DrawLine() only operates on horizontal or vertical lines and uses the
// current stroke settings.
void DrawLine(const IntPoint&, const IntPoint&);
void DrawLine(const IntPoint&,
const IntPoint&,
const DarkModeFilter::ElementRole role =
DarkModeFilter::ElementRole::kBackground);

void FillPath(const Path&);

Expand Down Expand Up @@ -236,7 +239,10 @@ class PLATFORM_EXPORT GraphicsContext {
// fillRoundedRect().
void DrawOval(const SkRect&, const PaintFlags&);
void DrawPath(const SkPath&, const PaintFlags&);
void DrawRect(const SkRect&, const PaintFlags&);
void DrawRect(const SkRect&,
const PaintFlags&,
const DarkModeFilter::ElementRole role =
DarkModeFilter::ElementRole::kBackground);
void DrawRRect(const SkRRect&, const PaintFlags&);

void Clip(const IntRect& rect) { ClipRect(rect); }
Expand Down

0 comments on commit c2bfb8f

Please sign in to comment.