Chromium Code Reviews| Index: third_party/WebKit/Source/core/paint/NGTextPainter.cpp |
| diff --git a/third_party/WebKit/Source/core/paint/NGTextPainter.cpp b/third_party/WebKit/Source/core/paint/NGTextPainter.cpp |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..7031ffc740106666968df14dfb7cad9e3bd29936 |
| --- /dev/null |
| +++ b/third_party/WebKit/Source/core/paint/NGTextPainter.cpp |
| @@ -0,0 +1,101 @@ |
| +// Copyright 2017 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "core/paint/NGTextPainter.h" |
| + |
| +#include "core/CSSPropertyNames.h" |
| +#include "core/frame/Settings.h" |
| +#include "core/layout/ng/inline/ng_physical_text_fragment.h" |
| +#include "core/paint/BoxPainter.h" |
| +#include "core/paint/PaintInfo.h" |
| +#include "core/style/ComputedStyle.h" |
| +#include "core/style/ShadowList.h" |
| +#include "platform/fonts/Font.h" |
| +#include "platform/graphics/GraphicsContext.h" |
| +#include "platform/graphics/GraphicsContextStateSaver.h" |
| +#include "platform/wtf/Assertions.h" |
| +#include "platform/wtf/text/CharacterNames.h" |
| + |
| +namespace blink { |
| + |
| +void NGTextPainter::Paint(unsigned start_offset, |
| + unsigned end_offset, |
| + unsigned length, |
| + const Style& text_style) { |
| + GraphicsContextStateSaver state_saver(graphics_context_, false); |
| + UpdateGraphicsContext(text_style, state_saver); |
| + // if (combined_text_) { |
| + // graphics_context_.Save(); |
| + // combined_text_->TransformToInlineCoordinates(graphics_context_, |
| + // text_bounds_); |
| + // PaintInternal<kPaintText>(start_offset, end_offset, length); |
| + // graphics_context_.Restore(); |
| + //} else { |
| + PaintInternal<kPaintText>(start_offset, end_offset, length); |
| + //} |
| + |
| + // if (!emphasis_mark_.IsEmpty()) { |
| + // if (text_style.emphasis_mark_color != text_style.fill_color) |
| + // graphics_context_.SetFillColor(text_style.emphasis_mark_color); |
| + // |
| + // if (combined_text_) |
| + // PaintEmphasisMarkForCombinedText(); |
| + // else |
| + // PaintInternal<kPaintEmphasisMark>(start_offset, end_offset, length); |
| + //} |
| +} |
| + |
| +template <NGTextPainter::PaintInternalStep step> |
| +void NGTextPainter::PaintInternalFragment( |
| + TextFragmentPaintInfo& fragment_paint_info, |
| + unsigned from, |
| + unsigned to) { |
| + DCHECK(from <= fragment_paint_info.text.length()); |
|
yosin_UTC9
2017/05/22 09:14:15
nit: s/DCHECK/DCHECK_LE/
|
| + DCHECK(to <= fragment_paint_info.text.length()); |
|
yosin_UTC9
2017/05/22 09:14:15
nit: s/DCHECK/DCHECK_LE/
It is better to write
D
|
| + |
| + fragment_paint_info.from = from; |
| + fragment_paint_info.to = to; |
| + |
| + if (step == kPaintEmphasisMark) { |
| + graphics_context_.DrawEmphasisMarks( |
| + font_, fragment_paint_info, emphasis_mark_, |
| + FloatPoint(text_origin_) + IntSize(0, emphasis_mark_offset_)); |
| + } else { |
| + DCHECK(step == kPaintText); |
|
yosin_UTC9
2017/05/22 09:14:15
nit: s/DCHECK/DCHECK_EQ/
|
| + graphics_context_.DrawText(font_, fragment_paint_info, |
| + FloatPoint(text_origin_)); |
| + } |
| +} |
| + |
| +template <NGTextPainter::PaintInternalStep Step> |
| +void NGTextPainter::PaintInternal(unsigned start_offset, |
| + unsigned end_offset, |
| + unsigned truncation_point) { |
| + unsigned offset = 0; |
| + TextFragmentPaintInfo fragment_paint_info = { |
| + text_fragment_->Text(), TextDirection::kLtr, offset, |
| + text_fragment_->Text().length(), text_fragment_->TextShapeResult()}; |
| + |
| + // fragment_paint_info.bounds = FloatRect(text_bounds_); |
| + if (start_offset <= end_offset) { |
| + PaintInternalFragment<Step>(fragment_paint_info, start_offset, end_offset); |
| + } else { |
| + if (end_offset > 0) { |
| + PaintInternalFragment<Step>(fragment_paint_info, ellipsis_offset_, |
| + end_offset); |
| + } |
| + if (start_offset < truncation_point) { |
| + PaintInternalFragment<Step>(fragment_paint_info, start_offset, |
| + truncation_point); |
| + } |
| + } |
| +} |
| + |
| +void NGTextPainter::ClipDecorationsStripe(float upper, |
| + float stripe_width, |
| + float dilation) {} |
| + |
| +void NGTextPainter::PaintEmphasisMarkForCombinedText() {} |
| + |
| +} // namespace blink |