diff options
author | xji@chromium.org <xji@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-03-13 20:47:04 +0000 |
---|---|---|
committer | xji@chromium.org <xji@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-03-13 20:47:04 +0000 |
commit | caa9e1e23f2dadcb33e531e23f0697efb41a3895 (patch) | |
tree | 006e80626be1a644cec94680dd16da003f3f16b2 | |
parent | f91a420e470378bfa70882f3c58e4a80cf2302f4 (diff) | |
download | chromium_src-caa9e1e23f2dadcb33e531e23f0697efb41a3895.zip chromium_src-caa9e1e23f2dadcb33e531e23f0697efb41a3895.tar.gz chromium_src-caa9e1e23f2dadcb33e531e23f0697efb41a3895.tar.bz2 |
Rename UpdateLayout() to ResetLayout() which is more accurate.
Review URL: http://codereview.chromium.org/9691002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@126460 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | ui/gfx/render_text.cc | 16 | ||||
-rw-r--r-- | ui/gfx/render_text.h | 5 | ||||
-rw-r--r-- | ui/gfx/render_text_linux.cc | 44 | ||||
-rw-r--r-- | ui/gfx/render_text_linux.h | 5 | ||||
-rw-r--r-- | ui/gfx/render_text_win.cc | 4 | ||||
-rw-r--r-- | ui/gfx/render_text_win.h | 2 |
6 files changed, 34 insertions, 42 deletions
diff --git a/ui/gfx/render_text.cc b/ui/gfx/render_text.cc index 91c7fdd..cf209d6 100644 --- a/ui/gfx/render_text.cc +++ b/ui/gfx/render_text.cc @@ -340,7 +340,7 @@ void RenderText::SetText(const string16& text) { // or SetCursorPosition in upper layer. SetSelectionModel(SelectionModel()); - UpdateLayout(); + ResetLayout(); } void RenderText::SetHorizontalAlignment(HorizontalAlignment alignment) { @@ -354,13 +354,13 @@ void RenderText::SetHorizontalAlignment(HorizontalAlignment alignment) { void RenderText::SetFontList(const FontList& font_list) { font_list_ = font_list; cached_bounds_and_offset_valid_ = false; - UpdateLayout(); + ResetLayout(); } void RenderText::SetFontSize(int size) { font_list_ = font_list_.DeriveFontListWithSize(size); cached_bounds_and_offset_valid_ = false; - UpdateLayout(); + ResetLayout(); } void RenderText::SetCursorEnabled(bool cursor_enabled) { @@ -381,14 +381,14 @@ void RenderText::SetObscured(bool obscured) { if (obscured != obscured_) { obscured_ = obscured; cached_bounds_and_offset_valid_ = false; - UpdateLayout(); + ResetLayout(); } } void RenderText::SetDisplayRect(const Rect& r) { display_rect_ = r; cached_bounds_and_offset_valid_ = false; - UpdateLayout(); + ResetLayout(); } void RenderText::SetCursorPosition(size_t position) { @@ -516,7 +516,7 @@ void RenderText::SetCompositionRange(const ui::Range& composition_range) { ui::Range(0, text_.length()).Contains(composition_range)); composition_range_.set_end(composition_range.end()); composition_range_.set_start(composition_range.start()); - UpdateLayout(); + ResetLayout(); } void RenderText::ApplyStyleRange(const StyleRange& style_range) { @@ -531,7 +531,7 @@ void RenderText::ApplyStyleRange(const StyleRange& style_range) { #endif // TODO(xji): only invalidate if font or underline changes. cached_bounds_and_offset_valid_ = false; - UpdateLayout(); + ResetLayout(); } void RenderText::ApplyDefaultStyle() { @@ -540,7 +540,7 @@ void RenderText::ApplyDefaultStyle() { style.range.set_end(text_.length()); style_ranges_.push_back(style); cached_bounds_and_offset_valid_ = false; - UpdateLayout(); + ResetLayout(); } VisualCursorDirection RenderText::GetVisualDirectionOfLogicalEnd() { diff --git a/ui/gfx/render_text.h b/ui/gfx/render_text.h index 6442ab8..d5ae4dd 100644 --- a/ui/gfx/render_text.h +++ b/ui/gfx/render_text.h @@ -299,9 +299,8 @@ class UI_EXPORT RenderText { // which means it is a grapheme boundary or the first character in the text. virtual bool IsCursorablePosition(size_t position) = 0; - // Update the layout so that the next draw request can correctly - // render the text and its attributes. - virtual void UpdateLayout() = 0; + // Reset the layout to be invalid. + virtual void ResetLayout() = 0; // Ensure the text is laid out. virtual void EnsureLayout() = 0; diff --git a/ui/gfx/render_text_linux.cc b/ui/gfx/render_text_linux.cc index dafa9e1..4b14819 100644 --- a/ui/gfx/render_text_linux.cc +++ b/ui/gfx/render_text_linux.cc @@ -218,8 +218,26 @@ bool RenderTextLinux::IsCursorablePosition(size_t position) { return (offset < num_log_attrs_ && log_attrs_[offset].is_cursor_position); } -void RenderTextLinux::UpdateLayout() { - ResetLayout(); +void RenderTextLinux::ResetLayout() { + // set_cached_bounds_and_offset_valid(false) is done in RenderText for every + // operation that triggers ResetLayout(). + if (layout_) { + g_object_unref(layout_); + layout_ = NULL; + } + if (current_line_) { + pango_layout_line_unref(current_line_); + current_line_ = NULL; + } + if (log_attrs_) { + g_free(log_attrs_); + log_attrs_ = NULL; + num_log_attrs_ = 0; + } + if (!selection_visual_bounds_.empty()) + selection_visual_bounds_.clear(); + layout_text_ = NULL; + layout_text_len_ = 0; } void RenderTextLinux::EnsureLayout() { @@ -448,28 +466,6 @@ SelectionModel RenderTextLinux::LastSelectionModelInsideRun( return SelectionModel(caret, CURSOR_FORWARD); } -void RenderTextLinux::ResetLayout() { - // set_cached_bounds_and_offset_valid(false) is done in RenderText for every - // operation that triggers ResetLayout(). - if (layout_) { - g_object_unref(layout_); - layout_ = NULL; - } - if (current_line_) { - pango_layout_line_unref(current_line_); - current_line_ = NULL; - } - if (log_attrs_) { - g_free(log_attrs_); - log_attrs_ = NULL; - num_log_attrs_ = 0; - } - if (!selection_visual_bounds_.empty()) - selection_visual_bounds_.clear(); - layout_text_ = NULL; - layout_text_len_ = 0; -} - size_t RenderTextLinux::TextIndexToLayoutIndex(size_t text_index) const { // If the text is obscured then |layout_text_| is not the same as |text()|, // but whether or not the text is obscured, the character (code point) offset diff --git a/ui/gfx/render_text_linux.h b/ui/gfx/render_text_linux.h index c2c667b..b2c7235 100644 --- a/ui/gfx/render_text_linux.h +++ b/ui/gfx/render_text_linux.h @@ -38,7 +38,7 @@ class RenderTextLinux : public RenderText { virtual std::vector<Rect> GetSubstringBounds(ui::Range range) OVERRIDE; virtual void SetSelectionModel(const SelectionModel& model) OVERRIDE; virtual bool IsCursorablePosition(size_t position) OVERRIDE; - virtual void UpdateLayout() OVERRIDE; + virtual void ResetLayout() OVERRIDE; virtual void EnsureLayout() OVERRIDE; virtual void DrawVisualText(Canvas* canvas) OVERRIDE; @@ -57,9 +57,6 @@ class RenderTextLinux : public RenderText { SelectionModel FirstSelectionModelInsideRun(const PangoItem* run); SelectionModel LastSelectionModelInsideRun(const PangoItem* run); - // Unref |layout_| and |pango_line_|. Set them to NULL. - void ResetLayout(); - // Setup pango attribute: foreground, background, font, strike. void SetupPangoAttributes(PangoLayout* layout); diff --git a/ui/gfx/render_text_win.cc b/ui/gfx/render_text_win.cc index 93a5943..1d1be46 100644 --- a/ui/gfx/render_text_win.cc +++ b/ui/gfx/render_text_win.cc @@ -365,7 +365,7 @@ void RenderTextWin::SetSelectionModel(const SelectionModel& model) { // foreground, to be picked up. Eventually, we should separate styles from // layout by applying foreground, strike, and underline styles during // DrawVisualText as what RenderTextLinux does. - UpdateLayout(); + ResetLayout(); } bool RenderTextWin::IsCursorablePosition(size_t position) { @@ -386,7 +386,7 @@ bool RenderTextWin::IsCursorablePosition(size_t position) { run->logical_clusters[position - start - 1]; } -void RenderTextWin::UpdateLayout() { +void RenderTextWin::ResetLayout() { // Layout is performed lazily as needed for drawing/metrics. needs_layout_ = true; } diff --git a/ui/gfx/render_text_win.h b/ui/gfx/render_text_win.h index d980d48..ec198a2 100644 --- a/ui/gfx/render_text_win.h +++ b/ui/gfx/render_text_win.h @@ -84,7 +84,7 @@ class RenderTextWin : public RenderText { virtual std::vector<Rect> GetSubstringBounds(ui::Range range) OVERRIDE; virtual void SetSelectionModel(const SelectionModel& model) OVERRIDE; virtual bool IsCursorablePosition(size_t position) OVERRIDE; - virtual void UpdateLayout() OVERRIDE; + virtual void ResetLayout() OVERRIDE; virtual void EnsureLayout() OVERRIDE; virtual void DrawVisualText(Canvas* canvas) OVERRIDE; |