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

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

Issue 8405002: ui/gfx: Convert Canvas::FillRectInt() to use gfx::Rect. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 1 month 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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_win.h" 5 #include "ui/gfx/render_text_win.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/stl_util.h" 8 #include "base/stl_util.h"
9 #include "base/string_util.h" 9 #include "base/string_util.h"
10 #include "third_party/skia/include/core/SkTypeface.h"
10 #include "ui/gfx/canvas.h" 11 #include "ui/gfx/canvas.h"
11 #include "ui/gfx/canvas_skia.h" 12 #include "ui/gfx/canvas_skia.h"
12 #include "third_party/skia/include/core/SkTypeface.h"
13 13
14 namespace { 14 namespace {
15 15
16 // The maximum supported number of Uniscribe runs; a SCRIPT_ITEM is 8 bytes. 16 // The maximum supported number of Uniscribe runs; a SCRIPT_ITEM is 8 bytes.
17 // TODO(msw): Review memory use/failure? Max string length? Alternate approach? 17 // TODO(msw): Review memory use/failure? Max string length? Alternate approach?
18 const int kGuessItems = 100; 18 const int kGuessItems = 100;
19 const int kMaxItems = 10000; 19 const int kMaxItems = 10000;
20 20
21 // The maximum supported number of Uniscribe glyphs; a glyph is 1 word. 21 // The maximum supported number of Uniscribe glyphs; a glyph is 1 word.
22 // TODO(msw): Review memory use/failure? Max string length? Alternate approach? 22 // TODO(msw): Review memory use/failure? Max string length? Alternate approach?
(...skipping 547 matching lines...) Expand 10 before | Expand all | Expand 10 after
570 internal::TextRun* next = runs_[visual_to_logical_[visual_index + 1]]; 570 internal::TextRun* next = runs_[visual_to_logical_[visual_index + 1]];
571 return next->script_analysis.fRTL ? LastSelectionModelInsideRun(next) : 571 return next->script_analysis.fRTL ? LastSelectionModelInsideRun(next) :
572 FirstSelectionModelInsideRun(next); 572 FirstSelectionModelInsideRun(next);
573 } 573 }
574 574
575 void RenderTextWin::DrawSelection(Canvas* canvas) { 575 void RenderTextWin::DrawSelection(Canvas* canvas) {
576 std::vector<Rect> sel( 576 std::vector<Rect> sel(
577 GetSubstringBounds(GetSelectionStart(), GetCursorPosition())); 577 GetSubstringBounds(GetSelectionStart(), GetCursorPosition()));
578 SkColor color = focused() ? kFocusedSelectionColor : kUnfocusedSelectionColor; 578 SkColor color = focused() ? kFocusedSelectionColor : kUnfocusedSelectionColor;
579 for (std::vector<Rect>::const_iterator i = sel.begin(); i < sel.end(); ++i) 579 for (std::vector<Rect>::const_iterator i = sel.begin(); i < sel.end(); ++i)
580 canvas->FillRectInt(color, i->x(), i->y(), i->width(), i->height()); 580 canvas->FillRect(color, *i);
581 } 581 }
582 582
583 void RenderTextWin::DrawVisualText(Canvas* canvas) { 583 void RenderTextWin::DrawVisualText(Canvas* canvas) {
584 if (text().empty()) 584 if (text().empty())
585 return; 585 return;
586 586
587 SkCanvas* canvas_skia = canvas->GetSkCanvas(); 587 SkCanvas* canvas_skia = canvas->GetSkCanvas();
588 588
589 Point offset(ToViewPoint(Point())); 589 Point offset(ToViewPoint(Point()));
590 // TODO(msw): Establish a vertical baseline for strings of mixed font heights. 590 // TODO(msw): Establish a vertical baseline for strings of mixed font heights.
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
652 Rect r(GetUpdatedCursorBounds()); 652 Rect r(GetUpdatedCursorBounds());
653 canvas->DrawRectInt(kCursorColor, r.x(), r.y(), r.width(), r.height()); 653 canvas->DrawRectInt(kCursorColor, r.x(), r.y(), r.width(), r.height());
654 } 654 }
655 } 655 }
656 656
657 RenderText* RenderText::CreateRenderText() { 657 RenderText* RenderText::CreateRenderText() {
658 return new RenderTextWin; 658 return new RenderTextWin;
659 } 659 }
660 660
661 } // namespace gfx 661 } // namespace gfx
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698