summaryrefslogtreecommitdiff
path: root/chromium/ui/gfx/render_text.cc
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@theqtcompany.com>2016-05-09 14:22:11 +0200
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2016-05-09 15:11:45 +0000
commit2ddb2d3e14eef3de7dbd0cef553d669b9ac2361c (patch)
treee75f511546c5fd1a173e87c1f9fb11d7ac8d1af3 /chromium/ui/gfx/render_text.cc
parenta4f3d46271c57e8155ba912df46a05559d14726e (diff)
downloadqtwebengine-chromium-2ddb2d3e14eef3de7dbd0cef553d669b9ac2361c.tar.gz
BASELINE: Update Chromium to 51.0.2704.41
Also adds in all smaller components by reversing logic for exclusion. Change-Id: Ibf90b506e7da088ea2f65dcf23f2b0992c504422 Reviewed-by: Joerg Bornemann <joerg.bornemann@theqtcompany.com>
Diffstat (limited to 'chromium/ui/gfx/render_text.cc')
-rw-r--r--chromium/ui/gfx/render_text.cc47
1 files changed, 26 insertions, 21 deletions
diff --git a/chromium/ui/gfx/render_text.cc b/chromium/ui/gfx/render_text.cc
index 1757575b32f..b133b976d96 100644
--- a/chromium/ui/gfx/render_text.cc
+++ b/chromium/ui/gfx/render_text.cc
@@ -139,11 +139,15 @@ void AddFadeEffect(const Rect& text_rect,
// Creates a SkShader to fade the text, with |left_part| specifying the left
// fade effect, if any, and |right_part| specifying the right fade effect.
-skia::RefPtr<SkShader> CreateFadeShader(const FontList& font_list,
- const Rect& text_rect,
- const Rect& left_part,
- const Rect& right_part,
- SkColor color) {
+sk_sp<SkShader> CreateFadeShader(const FontList& font_list,
+ const Rect& text_rect,
+ const Rect& left_part,
+ const Rect& right_part,
+ SkColor color) {
+ // The shader should only specify transparency of the fade itself, not the
+ // original transparency, which will be applied by the actual renderer.
+ DCHECK_EQ(SkColorGetA(color), static_cast<uint8_t>(0xff));
+
// In general, fade down to 0 alpha. But when the available width is less
// than four characters, linearly ramp up the fade target alpha to as high as
// 20% at zero width. This allows the user to see the last faded characters a
@@ -174,9 +178,9 @@ skia::RefPtr<SkShader> CreateFadeShader(const FontList& font_list,
const SkPoint points[2] = { PointToSkPoint(text_rect.origin()),
PointToSkPoint(text_rect.top_right()) };
- return skia::AdoptRef(
- SkGradientShader::CreateLinear(&points[0], &colors[0], &positions[0],
- colors.size(), SkShader::kClamp_TileMode));
+ return
+ SkGradientShader::MakeLinear(&points[0], &colors[0], &positions[0],
+ colors.size(), SkShader::kClamp_TileMode);
}
// Converts a FontRenderParams::Hinting value to the corresponding
@@ -236,8 +240,8 @@ SkiaTextRenderer::SkiaTextRenderer(Canvas* canvas)
SkiaTextRenderer::~SkiaTextRenderer() {
}
-void SkiaTextRenderer::SetDrawLooper(SkDrawLooper* draw_looper) {
- paint_.setLooper(draw_looper);
+void SkiaTextRenderer::SetDrawLooper(sk_sp<SkDrawLooper> draw_looper) {
+ paint_.setLooper(std::move(draw_looper));
}
void SkiaTextRenderer::SetFontRenderParams(const FontRenderParams& params,
@@ -269,8 +273,8 @@ void SkiaTextRenderer::SetForegroundColor(SkColor foreground) {
paint_.setColor(foreground);
}
-void SkiaTextRenderer::SetShader(SkShader* shader) {
- paint_.setShader(shader);
+void SkiaTextRenderer::SetShader(sk_sp<SkShader> shader) {
+ paint_.setShader(std::move(shader));
}
void SkiaTextRenderer::SetUnderlineMetrics(SkScalar thickness,
@@ -415,6 +419,8 @@ LineSegment::~LineSegment() {}
Line::Line() : preceding_heights(0), baseline(0) {}
+Line::Line(const Line& other) = default;
+
Line::~Line() {}
#if !defined(OS_MACOSX)
@@ -632,7 +638,8 @@ void RenderText::MoveCursor(BreakType break_type,
bool RenderText::MoveCursorTo(const SelectionModel& model) {
// Enforce valid selection model components.
size_t text_length = text().length();
- Range range(std::min(model.selection().start(), text_length),
+ Range range(std::min(model.selection().start(),
+ static_cast<uint32_t>(text_length)),
std::min(model.caret_pos(), text_length));
// The current model only supports caret positions at valid cursor indices.
if (!IsValidCursorIndex(range.start()) || !IsValidCursorIndex(range.end()))
@@ -644,8 +651,9 @@ bool RenderText::MoveCursorTo(const SelectionModel& model) {
}
bool RenderText::SelectRange(const Range& range) {
- Range sel(std::min(range.start(), text().length()),
- std::min(range.end(), text().length()));
+ uint32_t text_length = static_cast<uint32_t>(text().length());
+ Range sel(std::min(range.start(), text_length),
+ std::min(range.end(), text_length));
// Allow selection bounds at valid indicies amid multi-character graphemes.
if (!IsValidLogicalIndex(sel.start()) || !IsValidLogicalIndex(sel.end()))
return false;
@@ -1227,16 +1235,13 @@ void RenderText::ApplyFadeEffects(internal::SkiaTextRenderer* renderer) {
text_rect.Inset(GetAlignmentOffset(0).x(), 0, 0, 0);
// TODO(msw): Use the actual text colors corresponding to each faded part.
- skia::RefPtr<SkShader> shader =
+ renderer->SetShader(
CreateFadeShader(font_list(), text_rect, left_part, right_part,
- colors_.breaks().front().second);
- if (shader)
- renderer->SetShader(shader.get());
+ SkColorSetA(colors_.breaks().front().second, 0xff)));
}
void RenderText::ApplyTextShadows(internal::SkiaTextRenderer* renderer) {
- skia::RefPtr<SkDrawLooper> looper = CreateShadowDrawLooper(shadows_);
- renderer->SetDrawLooper(looper.get());
+ renderer->SetDrawLooper(CreateShadowDrawLooper(shadows_));
}
base::i18n::TextDirection RenderText::GetTextDirection(