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 "base/i18n/break_iterator.h" | 7 #include "base/i18n/break_iterator.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/stl_util.h" | 9 #include "base/stl_util.h" |
10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
184 bool leading = selection.caret_placement() == SelectionModel::LEADING; | 184 bool leading = selection.caret_placement() == SelectionModel::LEADING; |
185 // Adjust the x value for right-side placement. | 185 // Adjust the x value for right-side placement. |
186 if (run->script_analysis.fRTL == leading) | 186 if (run->script_analysis.fRTL == leading) |
187 rect.set_x(rect.right()); | 187 rect.set_x(rect.right()); |
188 rect.set_width(0); | 188 rect.set_width(0); |
189 } | 189 } |
190 rect.set_origin(ToViewPoint(rect.origin())); | 190 rect.set_origin(ToViewPoint(rect.origin())); |
191 return rect; | 191 return rect; |
192 } | 192 } |
193 | 193 |
194 size_t RenderTextWin::GetIndexOfNextGrapheme(size_t position) { | |
195 return IndexOfAdjacentGrapheme(position, true); | |
196 } | |
197 | |
194 SelectionModel RenderTextWin::GetLeftSelectionModel( | 198 SelectionModel RenderTextWin::GetLeftSelectionModel( |
195 const SelectionModel& selection, | 199 const SelectionModel& selection, |
196 BreakType break_type) { | 200 BreakType break_type) { |
197 if (break_type == LINE_BREAK || text().empty()) | 201 if (break_type == LINE_BREAK || text().empty()) |
198 return LeftEndSelectionModel(); | 202 return LeftEndSelectionModel(); |
199 if (break_type == CHARACTER_BREAK) | 203 if (break_type == CHARACTER_BREAK) |
200 return LeftSelectionModel(selection); | 204 return LeftSelectionModel(selection); |
201 // TODO(msw): Implement word breaking. | 205 // TODO(msw): Implement word breaking. |
202 return RenderText::GetLeftSelectionModel(selection, break_type); | 206 return RenderText::GetLeftSelectionModel(selection, break_type); |
203 } | 207 } |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
288 if (!bounds.empty() && rect.SharesEdgeWith(bounds.back())) { | 292 if (!bounds.empty() && rect.SharesEdgeWith(bounds.back())) { |
289 rect = rect.Union(bounds.back()); | 293 rect = rect.Union(bounds.back()); |
290 bounds.pop_back(); | 294 bounds.pop_back(); |
291 } | 295 } |
292 bounds.push_back(rect); | 296 bounds.push_back(rect); |
293 } | 297 } |
294 } | 298 } |
295 return bounds; | 299 return bounds; |
296 } | 300 } |
297 | 301 |
302 bool RenderTextLinux::IsCursorablePosition(size_t position) { | |
msw
2011/09/14 02:43:48
RenderText*Win*
xji
2011/09/15 23:38:13
Done.
| |
303 if (position == 0 || position == text().length()) | |
304 return true; | |
305 | |
306 size_t run_index = GetRunContainingPosition(position); | |
307 internal::TextRun* run = run_index < runs_.size() ? runs_[run_index] : NULL; | |
308 if (!run) | |
msw
2011/09/14 02:43:48
This could just be "if (run_index >= runs_.size())
xji
2011/09/15 23:38:13
Done.
| |
309 return false; | |
310 if (position == run->range.start()) | |
311 return true; | |
312 return run->logical_clusters[position] != run->logical_clusters[position -1]; | |
msw
2011/09/14 02:43:48
The logical clusters array is indexed by offsets f
xji
2011/09/15 23:38:13
Done.
| |
313 } | |
314 | |
298 void RenderTextWin::ItemizeLogicalText() { | 315 void RenderTextWin::ItemizeLogicalText() { |
299 text_is_dirty_ = false; | 316 text_is_dirty_ = false; |
300 STLDeleteContainerPointers(runs_.begin(), runs_.end()); | 317 STLDeleteContainerPointers(runs_.begin(), runs_.end()); |
301 runs_.clear(); | 318 runs_.clear(); |
302 if (text().empty()) | 319 if (text().empty()) |
303 return; | 320 return; |
304 | 321 |
305 const wchar_t* raw_text = text().c_str(); | 322 const wchar_t* raw_text = text().c_str(); |
306 const int text_length = text().length(); | 323 const int text_length = text().length(); |
307 | 324 |
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
637 Rect r(GetUpdatedCursorBounds()); | 654 Rect r(GetUpdatedCursorBounds()); |
638 canvas->DrawRectInt(kCursorColor, r.x(), r.y(), r.width(), r.height()); | 655 canvas->DrawRectInt(kCursorColor, r.x(), r.y(), r.width(), r.height()); |
639 } | 656 } |
640 } | 657 } |
641 | 658 |
642 RenderText* RenderText::CreateRenderText() { | 659 RenderText* RenderText::CreateRenderText() { |
643 return new RenderTextWin; | 660 return new RenderTextWin; |
644 } | 661 } |
645 | 662 |
646 } // namespace gfx | 663 } // namespace gfx |
OLD | NEW |