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

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

Issue 7458014: Implement Uniscribe RenderText for Windows. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix RenderText::RightEndSelectionModel. Created 9 years, 3 months 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 #ifndef UI_GFX_RENDER_TEXT_WIN_H_ 5 #ifndef UI_GFX_RENDER_TEXT_WIN_H_
6 #define UI_GFX_RENDER_TEXT_WIN_H_ 6 #define UI_GFX_RENDER_TEXT_WIN_H_
7 #pragma once 7 #pragma once
8 8
9 #include <usp10.h>
10
11 #include "base/memory/scoped_ptr.h"
9 #include "ui/gfx/render_text.h" 12 #include "ui/gfx/render_text.h"
10 13
11 namespace gfx { 14 namespace gfx {
12 15
16 namespace internal {
17
18 struct TextRun {
19 TextRun();
20
21 ui::Range range;
22 Font font;
23 // TODO(msw): Disambiguate color, strike, etc. from TextRuns.
24 // Otherwise, this breaks the glyph shaping process.
25 // See the example at: http://www.catch22.net/tuts/neatpad/12.
26 SkColor foreground;
27 bool strike;
28
29 int width;
30 // The cumulative widths of preceding runs.
31 int preceding_run_widths;
32
33 SCRIPT_ANALYSIS script_analysis;
34
35 scoped_array<WORD> glyphs;
36 scoped_array<WORD> logical_clusters;
37 scoped_array<SCRIPT_VISATTR> visible_attributes;
38 int glyph_count;
39
40 scoped_array<int> advance_widths;
41 scoped_array<GOFFSET> offsets;
42 ABC abc_widths;
43
44 scoped_array<SCRIPT_LOGATTR> logical_attributes;
45
46 private:
47 DISALLOW_COPY_AND_ASSIGN(TextRun);
48 };
49
50 } // namespace internal
51
13 // RenderTextWin is the Windows implementation of RenderText using Uniscribe. 52 // RenderTextWin is the Windows implementation of RenderText using Uniscribe.
14 class RenderTextWin : public RenderText { 53 class RenderTextWin : public RenderText {
15 public: 54 public:
16 RenderTextWin(); 55 RenderTextWin();
17 virtual ~RenderTextWin(); 56 virtual ~RenderTextWin();
18 57
58 // Overridden from RenderText:
59 virtual void SetText(const string16& text) OVERRIDE;
60 virtual void SetDisplayRect(const Rect& r) OVERRIDE;
61 virtual void ApplyStyleRange(StyleRange style_range) OVERRIDE;
62 virtual void ApplyDefaultStyle() OVERRIDE;
63 virtual int GetStringWidth() OVERRIDE;
64 virtual void Draw(Canvas* canvas) OVERRIDE;
65 virtual SelectionModel FindCursorPosition(const Point& point) OVERRIDE;
66 virtual Rect GetCursorBounds(const SelectionModel& selection,
67 bool insert_mode) OVERRIDE;
68
69 protected:
70 // Overridden from RenderText:
71 virtual SelectionModel GetLeftSelectionModel(const SelectionModel& current,
72 BreakType break_type) OVERRIDE;
73 virtual SelectionModel GetRightSelectionModel(const SelectionModel& current,
74 BreakType break_type) OVERRIDE;
75 virtual SelectionModel LeftEndSelectionModel() OVERRIDE;
76 virtual SelectionModel RightEndSelectionModel() OVERRIDE;
77 virtual std::vector<Rect> GetSubstringBounds(size_t from, size_t to) OVERRIDE;
78
79 // TODO(msw): Implement this with complex script support.
80 // virtual size_t GetIndexOfPreviousGrapheme(size_t position) OVERRIDE;
81
19 private: 82 private:
83 void ItemizeLogicalText();
84 void LayoutVisualText(HDC hdc);
85
86 // Return the run index that contains the argument; or the length of the
87 // |runs_| vector if argument exceeds the text length or width.
88 size_t GetRunContainingPosition(size_t position) const;
89 size_t GetRunContainingPoint(const Point& point) const;
90
91 // Get the neighboring selection model, which may not be at a valid stop.
92 SelectionModel LeftSelectionModel(const SelectionModel& selection);
93 SelectionModel RightSelectionModel(const SelectionModel& selection);
94
95 // Draw the text, cursor, and selection.
96 void DrawSelection(Canvas* canvas);
97 void DrawVisualText(Canvas* canvas);
98 void DrawCursor(Canvas* canvas);
99
100 bool text_is_dirty_;
101 bool style_is_dirty_;
102
103 // National Language Support native digit and digit substitution settings.
104 SCRIPT_DIGITSUBSTITUTE digit_substitute_;
105
106 SCRIPT_CONTROL script_control_;
107 SCRIPT_STATE script_state_;
108
109 SCRIPT_CACHE script_cache_;
110
111 std::vector<internal::TextRun*> runs_;
112 int string_width_;
113
114 scoped_array<int> visual_to_logical_;
115 scoped_array<int> logical_to_visual_;
116
20 DISALLOW_COPY_AND_ASSIGN(RenderTextWin); 117 DISALLOW_COPY_AND_ASSIGN(RenderTextWin);
21 }; 118 };
22 119
23 } // namespace gfx; 120 } // namespace gfx;
24 121
25 #endif // UI_GFX_RENDER_TEXT_WIN_H_ 122 #endif // UI_GFX_RENDER_TEXT_WIN_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698