Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(480)

Side by Side Diff: ui/gfx/render_text_pango.cc

Issue 779793006: MacViews: Use RenderTextHarfBuzz only for Textfields (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rename to CreateInstanceOfSameType Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ui/gfx/render_text_pango.h ('k') | ui/gfx/render_text_win.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ui/gfx/render_text_pango.h" 5 #include "ui/gfx/render_text_pango.h"
6 6
7 #include <pango/pangocairo.h> 7 #include <pango/pangocairo.h>
8 #include <algorithm> 8 #include <algorithm>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 current_line_(NULL), 82 current_line_(NULL),
83 log_attrs_(NULL), 83 log_attrs_(NULL),
84 num_log_attrs_(0), 84 num_log_attrs_(0),
85 layout_text_(NULL) { 85 layout_text_(NULL) {
86 } 86 }
87 87
88 RenderTextPango::~RenderTextPango() { 88 RenderTextPango::~RenderTextPango() {
89 ResetLayout(); 89 ResetLayout();
90 } 90 }
91 91
92 scoped_ptr<RenderText> RenderTextPango::CreateInstanceOfSameType() const {
93 return scoped_ptr<RenderTextPango>(new RenderTextPango);
94 }
95
92 Size RenderTextPango::GetStringSize() { 96 Size RenderTextPango::GetStringSize() {
93 EnsureLayout(); 97 EnsureLayout();
94 int width = 0, height = 0; 98 int width = 0, height = 0;
95 pango_layout_get_pixel_size(layout_, &width, &height); 99 pango_layout_get_pixel_size(layout_, &width, &height);
96 100
97 // Pango returns 0 widths for very long strings (of 0x40000 chars or more). 101 // Pango returns 0 widths for very long strings (of 0x40000 chars or more).
98 // This is caused by an int overflow in pango_glyph_string_extents_range. 102 // This is caused by an int overflow in pango_glyph_string_extents_range.
99 // Absurdly long strings may even report non-zero garbage values for width; 103 // Absurdly long strings may even report non-zero garbage values for width;
100 // while detecting that isn't worthwhile, this handles the 0 width cases. 104 // while detecting that isn't worthwhile, this handles the 0 width cases.
101 const long kAbsurdLength = 100000; 105 const long kAbsurdLength = 100000;
(...skipping 420 matching lines...) Expand 10 before | Expand all | Expand 10 after
522 int glyph_index) const { 526 int glyph_index) const {
523 return LayoutIndexToTextIndex(run->item->offset + 527 return LayoutIndexToTextIndex(run->item->offset +
524 run->glyphs->log_clusters[glyph_index]); 528 run->glyphs->log_clusters[glyph_index]);
525 } 529 }
526 530
527 RenderText* RenderText::CreateNativeInstance() { 531 RenderText* RenderText::CreateNativeInstance() {
528 return new RenderTextPango; 532 return new RenderTextPango;
529 } 533 }
530 534
531 } // namespace gfx 535 } // namespace gfx
OLDNEW
« no previous file with comments | « ui/gfx/render_text_pango.h ('k') | ui/gfx/render_text_win.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698