OLD | NEW |
---|---|
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 <algorithm> | 7 #include <algorithm> |
8 #include <map> | 8 #include <map> |
9 | 9 |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
309 size_t start = run->range.start(); | 309 size_t start = run->range.start(); |
310 if (position == start) | 310 if (position == start) |
311 return true; | 311 return true; |
312 return run->logical_clusters[position - start] != | 312 return run->logical_clusters[position - start] != |
313 run->logical_clusters[position - start - 1]; | 313 run->logical_clusters[position - start - 1]; |
314 } | 314 } |
315 | 315 |
316 void RenderTextWin::UpdateLayout() { | 316 void RenderTextWin::UpdateLayout() { |
317 // TODO(msw): Skip complex processing if ScriptIsComplex returns false. | 317 // TODO(msw): Skip complex processing if ScriptIsComplex returns false. |
318 ItemizeLogicalText(); | 318 ItemizeLogicalText(); |
319 HDC hdc = CreateCompatibleDC(NULL); | 319 if (!runs_.empty()) { |
320 LayoutVisualText(hdc); | 320 HDC hdc = CreateCompatibleDC(NULL); |
sky
2011/11/10 21:49:04
nit: use ScopedCreateDC.
Alexei Svitkine (slow)
2011/11/10 22:10:35
Done.
| |
321 DeleteDC(hdc); | 321 LayoutVisualText(hdc); |
322 DeleteDC(hdc); | |
323 } | |
322 } | 324 } |
323 | 325 |
324 size_t RenderTextWin::IndexOfAdjacentGrapheme(size_t index, bool next) { | 326 size_t RenderTextWin::IndexOfAdjacentGrapheme(size_t index, bool next) { |
325 size_t run_index = GetRunContainingPosition(index); | 327 size_t run_index = GetRunContainingPosition(index); |
326 internal::TextRun* run = run_index < runs_.size() ? runs_[run_index] : NULL; | 328 internal::TextRun* run = run_index < runs_.size() ? runs_[run_index] : NULL; |
327 int start = run ? run->range.start() : 0; | 329 int start = run ? run->range.start() : 0; |
328 int length = run ? run->range.length() : text().length(); | 330 int length = run ? run->range.length() : text().length(); |
329 int ch = index - start; | 331 int ch = index - start; |
330 WORD cluster = run ? run->logical_clusters[ch] : 0; | 332 WORD cluster = run ? run->logical_clusters[ch] : 0; |
331 | 333 |
(...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
666 Rect r(GetUpdatedCursorBounds()); | 668 Rect r(GetUpdatedCursorBounds()); |
667 canvas->DrawRectInt(kCursorColor, r.x(), r.y(), r.width(), r.height()); | 669 canvas->DrawRectInt(kCursorColor, r.x(), r.y(), r.width(), r.height()); |
668 } | 670 } |
669 } | 671 } |
670 | 672 |
671 RenderText* RenderText::CreateRenderText() { | 673 RenderText* RenderText::CreateRenderText() { |
672 return new RenderTextWin; | 674 return new RenderTextWin; |
673 } | 675 } |
674 | 676 |
675 } // namespace gfx | 677 } // namespace gfx |
OLD | NEW |