Commit 9f3cbbc2 authored by Emil A Eklund's avatar Emil A Eklund Committed by Commit Bot

[LayoutNG] Add support for emphasis mark painting

Add support for painting emphasis marks for LayoutNG.

Bug: 714962
Cq-Include-Trybots: master.tryserver.chromium.linux:linux_layout_tests_slimming_paint_v2
Change-Id: I0690bb284fa227408fa047adc3914e3c236ffc44
Reviewed-on: https://chromium-review.googlesource.com/691474Reviewed-by: default avatarKoji Ishii <kojii@chromium.org>
Commit-Queue: Emil A Eklund <eae@chromium.org>
Cr-Commit-Position: refs/heads/master@{#505316}
parent 60b3cd38
...@@ -27,7 +27,7 @@ NGTextFragmentPainter::NGTextFragmentPainter( ...@@ -27,7 +27,7 @@ NGTextFragmentPainter::NGTextFragmentPainter(
void NGTextFragmentPainter::Paint(const Document& document, void NGTextFragmentPainter::Paint(const Document& document,
const PaintInfo& paint_info, const PaintInfo& paint_info,
const LayoutPoint& paint_offset) { const LayoutPoint& paint_offset) {
const ComputedStyle& style_to_use = fragment_.Style(); const ComputedStyle& style = fragment_.Style();
NGPhysicalSize size_; NGPhysicalSize size_;
NGPhysicalOffset offset_; NGPhysicalOffset offset_;
...@@ -56,16 +56,16 @@ void NGTextFragmentPainter::Paint(const Document& document, ...@@ -56,16 +56,16 @@ void NGTextFragmentPainter::Paint(const Document& document,
// Determine text colors. // Determine text colors.
TextPaintStyle text_style = TextPaintStyle text_style =
TextPainterBase::TextPaintingStyle(document, style_to_use, paint_info); TextPainterBase::TextPaintingStyle(document, style, paint_info);
TextPaintStyle selection_style = TextPainterBase::SelectionPaintingStyle( TextPaintStyle selection_style = TextPainterBase::SelectionPaintingStyle(
document, style_to_use, fragment_.GetNode(), have_selection, paint_info, document, style, fragment_.GetNode(), have_selection, paint_info,
text_style); text_style);
bool paint_selected_text_only = (paint_info.phase == kPaintPhaseSelection); bool paint_selected_text_only = (paint_info.phase == kPaintPhaseSelection);
bool paint_selected_text_separately = bool paint_selected_text_separately =
!paint_selected_text_only && text_style != selection_style; !paint_selected_text_only && text_style != selection_style;
// Set our font. // Set our font.
const Font& font = style_to_use.GetFont(); const Font& font = style.GetFont();
const SimpleFontData* font_data = font.PrimaryFont(); const SimpleFontData* font_data = font.PrimaryFont();
DCHECK(font_data); DCHECK(font_data);
...@@ -107,13 +107,12 @@ void NGTextFragmentPainter::Paint(const Document& document, ...@@ -107,13 +107,12 @@ void NGTextFragmentPainter::Paint(const Document& document,
NGTextPainter text_painter(context, font, text_fragment, text_origin, NGTextPainter text_painter(context, font, text_fragment, text_origin,
box_rect, text_fragment.IsHorizontal()); box_rect, text_fragment.IsHorizontal());
TextEmphasisPosition emphasis_mark_position;
bool has_text_emphasis = false; // TODO(layout-dev): Implement. if (style.GetTextEmphasisMark() != TextEmphasisMark::kNone) {
emphasis_mark_position = TextEmphasisPosition::kOverRight; text_painter.SetEmphasisMark(style.TextEmphasisMarkString(),
if (has_text_emphasis) { style.GetTextEmphasisPosition());
text_painter.SetEmphasisMark(style_to_use.TextEmphasisMarkString(),
emphasis_mark_position);
} }
if (truncation != kCNoTruncation && ltr != flow_is_ltr) if (truncation != kCNoTruncation && ltr != flow_is_ltr)
text_painter.SetEllipsisOffset(truncation); text_painter.SetEllipsisOffset(truncation);
...@@ -121,7 +120,7 @@ void NGTextFragmentPainter::Paint(const Document& document, ...@@ -121,7 +120,7 @@ void NGTextFragmentPainter::Paint(const Document& document,
// Paint text decorations except line-through. // Paint text decorations except line-through.
DecorationInfo decoration_info; DecorationInfo decoration_info;
bool has_line_through_decoration = false; bool has_line_through_decoration = false;
if (style_to_use.TextDecorationsInEffect() != TextDecoration::kNone && if (style.TextDecorationsInEffect() != TextDecoration::kNone &&
truncation != kCFullTruncation) { truncation != kCFullTruncation) {
LayoutPoint local_origin = LayoutPoint(box_origin); LayoutPoint local_origin = LayoutPoint(box_origin);
LayoutUnit width = fragment_.Size().width; LayoutUnit width = fragment_.Size().width;
...@@ -134,13 +133,13 @@ void NGTextFragmentPainter::Paint(const Document& document, ...@@ -134,13 +133,13 @@ void NGTextFragmentPainter::Paint(const Document& document,
text_painter.ComputeDecorationInfo(decoration_info, box_origin, text_painter.ComputeDecorationInfo(decoration_info, box_origin,
local_origin, width, baseline_type, local_origin, width, baseline_type,
style_to_use, decorating_box_style); style, decorating_box_style);
NGTextDecorationOffset decoration_offset(*decoration_info.style, NGTextDecorationOffset decoration_offset(*decoration_info.style,
text_fragment, decorating_box); text_fragment, decorating_box);
text_painter.PaintDecorationsExceptLineThrough( text_painter.PaintDecorationsExceptLineThrough(
decoration_offset, decoration_info, paint_info, decoration_offset, decoration_info, paint_info,
style_to_use.AppliedTextDecorations(), text_style, style.AppliedTextDecorations(), text_style,
&has_line_through_decoration); &has_line_through_decoration);
} }
...@@ -164,7 +163,7 @@ void NGTextFragmentPainter::Paint(const Document& document, ...@@ -164,7 +163,7 @@ void NGTextFragmentPainter::Paint(const Document& document,
// Paint line-through decoration if needed. // Paint line-through decoration if needed.
if (has_line_through_decoration) { if (has_line_through_decoration) {
text_painter.PaintDecorationsOnlyLineThrough( text_painter.PaintDecorationsOnlyLineThrough(
decoration_info, paint_info, style_to_use.AppliedTextDecorations(), decoration_info, paint_info, style.AppliedTextDecorations(),
text_style); text_style);
} }
} }
......
...@@ -30,7 +30,11 @@ void NGTextPainter::Paint(unsigned start_offset, ...@@ -30,7 +30,11 @@ void NGTextPainter::Paint(unsigned start_offset,
// TODO(layout-dev): Handle combine text here or elsewhere. // TODO(layout-dev): Handle combine text here or elsewhere.
PaintInternal<kPaintText>(start_offset, end_offset, length); PaintInternal<kPaintText>(start_offset, end_offset, length);
// TODO(layout-dev): Handle emphasis marks. if (!emphasis_mark_.IsEmpty()) {
if (text_style.emphasis_mark_color != text_style.fill_color)
graphics_context_.SetFillColor(text_style.emphasis_mark_color);
PaintInternal<kPaintEmphasisMark>(start_offset, end_offset, length);
}
} }
template <NGTextPainter::PaintInternalStep step> template <NGTextPainter::PaintInternalStep step>
...@@ -63,19 +67,15 @@ void NGTextPainter::PaintInternal(unsigned start_offset, ...@@ -63,19 +67,15 @@ void NGTextPainter::PaintInternal(unsigned start_offset,
if (!fragment_.TextShapeResult()) if (!fragment_.TextShapeResult())
return; return;
NGTextFragmentPaintInfo fragment_paint_info = fragment_.PaintInfo(); NGTextFragmentPaintInfo paint_info = fragment_.PaintInfo();
if (start_offset <= end_offset) { if (start_offset <= end_offset) {
PaintInternalFragment<Step>(fragment_paint_info, start_offset, end_offset); PaintInternalFragment<Step>(paint_info, start_offset, end_offset);
} else { } else {
if (end_offset > 0) { if (end_offset > 0)
PaintInternalFragment<Step>(fragment_paint_info, ellipsis_offset_, PaintInternalFragment<Step>(paint_info, ellipsis_offset_, end_offset);
end_offset); if (start_offset < truncation_point)
} PaintInternalFragment<Step>(paint_info, start_offset, truncation_point);
if (start_offset < truncation_point) {
PaintInternalFragment<Step>(fragment_paint_info, start_offset,
truncation_point);
}
} }
} }
......
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