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

Unified Diff: chrome/browser/chromeos/input_method/candidate_window_view.h

Issue 121163003: Cleanup CandidateWindowView. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix Created 7 years 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/chromeos/input_method/candidate_window_view.h
diff --git a/chrome/browser/chromeos/input_method/candidate_window_view.h b/chrome/browser/chromeos/input_method/candidate_window_view.h
index dc69f758f823a32fbd5e2c4764ceede36734a1a7..f5848f1f18f476ff413ebed2523e20cc367f27d4 100644
--- a/chrome/browser/chromeos/input_method/candidate_window_view.h
+++ b/chrome/browser/chromeos/input_method/candidate_window_view.h
@@ -5,25 +5,19 @@
#ifndef CHROME_BROWSER_CHROMEOS_INPUT_METHOD_CANDIDATE_WINDOW_VIEW_H_
#define CHROME_BROWSER_CHROMEOS_INPUT_METHOD_CANDIDATE_WINDOW_VIEW_H_
-#include "base/gtest_prod_util.h"
-#include "base/memory/scoped_ptr.h"
#include "chromeos/ime/candidate_window.h"
-#include "ui/views/view.h"
-
-namespace gfx {
-class Font;
-}
+#include "ui/views/bubble/bubble_delegate.h"
+#include "ui/views/controls/button/button.h"
namespace chromeos {
namespace input_method {
class CandidateView;
-class CandidateWindow;
-class HidableArea;
class InformationTextArea;
// CandidateWindowView is the main container of the candidate window UI.
-class CandidateWindowView : public views::View {
+class CandidateWindowView : public views::BubbleDelegateView,
+ public views::ButtonListener {
public:
// The object can be monitored by the observer.
class Observer {
@@ -31,14 +25,11 @@ class CandidateWindowView : public views::View {
virtual ~Observer() {}
// The function is called when a candidate is committed.
virtual void OnCandidateCommitted(int index) = 0;
-
- virtual void OnCandidateWindowOpened() = 0;
- virtual void OnCandidateWindowClosed() = 0;
};
- explicit CandidateWindowView(views::Widget* parent_frame);
+ explicit CandidateWindowView(gfx::NativeView parent);
virtual ~CandidateWindowView();
- void Init();
+ views::Widget* InitWidget();
// Adds the given observer. The ownership is not transferred.
void AddObserver(Observer* observer) {
@@ -50,19 +41,6 @@ class CandidateWindowView : public views::View {
observers_.RemoveObserver(observer);
}
- // Selects the candidate specified by the index in the current page
- // (zero-origin). Changes the appearance of the selected candidate,
- // updates the information in the candidate window as needed.
- void SelectCandidateAt(int index_in_page);
-
- // The function is called when a candidate is being dragged. From the
- // given point, locates the candidate under the mouse cursor, and
- // selects it.
- void OnCandidatePressed(const gfx::Point& point);
-
- // Commits the candidate currently being selected.
- void CommitCandidate();
-
// Hides the lookup table.
void HideLookupTable();
@@ -72,9 +50,6 @@ class CandidateWindowView : public views::View {
// Hides the preedit text.
void HidePreeditText();
- // Hides whole the candidate window.
- void HideAll();
-
// Shows the lookup table.
void ShowLookupTable();
@@ -87,83 +62,27 @@ class CandidateWindowView : public views::View {
// Updates the preedit text.
void UpdatePreeditText(const std::string& utf8_text);
- // Returns true if we should update candidate views in the window. For
- // instance, if we are going to show the same candidates as before, we
- // don't have to update candidate views. This happens when the user just
- // moves the cursor in the same page in the candidate window.
- static bool ShouldUpdateCandidateViews(
- const CandidateWindow& old_candidate_window,
- const CandidateWindow& new_candidate_window);
-
// Updates candidates of the candidate window from |candidate_window|.
// Candidates are arranged per |orientation|.
void UpdateCandidates(const CandidateWindow& candidate_window);
- // Resizes and moves the parent frame. The two actions should be
- // performed consecutively as resizing may require the candidate window
- // to move. For instance, we may need to move the candidate window from
- // below the cursor to above the cursor, if the candidate window becomes
- // too big to be shown near the bottom of the screen. This function
- // needs to be called when the visible contents of the candidate window
- // are modified.
- void ResizeAndMoveParentFrame();
-
- // Returns the horizontal offset used for placing the vertical candidate
- // window so that the first candidate is aligned with the the text being
- // converted like:
- //
- // XXX <- The user is converting XXX
- // +-----+
- // |1 XXX|
- // |2 YYY|
- // |3 ZZZ|
- //
- // Returns 0 if no candidate is present.
- int GetHorizontalOffset();
-
- void set_cursor_bounds(const gfx::Rect& cursor_bounds) {
- cursor_bounds_ = cursor_bounds;
- }
-
- void set_composition_head_bounds(
- const gfx::Rect& composition_head_bounds) {
- composition_head_bounds_ = composition_head_bounds;
- }
+ void SetCursorBounds(const gfx::Rect& cursor_bounds,
+ const gfx::Rect& composition_head);
- const gfx::Rect& cursor_bounds() const { return cursor_bounds_; }
- const gfx::Rect& composition_head_bounds() const {
- return composition_head_bounds_;
- }
-
- protected:
- // Override View::VisibilityChanged()
- virtual void VisibilityChanged(View* starting_from, bool is_visible) OVERRIDE;
+ private:
+ friend class CandidateWindowViewTest;
- // Override View::OnBoundsChanged()
- virtual void OnBoundsChanged(const gfx::Rect& previous_bounds) OVERRIDE;
+ // Overridden from views::ButtonListener:
+ virtual void ButtonPressed(views::Button* sender,
+ const ui::Event& event) OVERRIDE;
- private:
- FRIEND_TEST_ALL_PREFIXES(CandidateWindowViewTest,
- UpdateCandidatesTest_CursorVisibility);
- FRIEND_TEST_ALL_PREFIXES(CandidateWindowViewTest, ShortcutSettingTest);
- FRIEND_TEST_ALL_PREFIXES(CandidateWindowViewTest,
- DoNotChangeRowHeightWithLabelSwitchTest);
+ void SelectCandidateAt(int index_in_page);
+ void UpdateVisibility();
// Initializes the candidate views if needed.
void MaybeInitializeCandidateViews(const CandidateWindow& candidate_window);
- // Returns the appropriate area (header or footer) to put auxiliary texts.
- InformationTextArea* GetAuxiliaryTextArea();
-
- // Returns true if the candidate window is open. The suggestion window does
- // not count as the candidate window.
- bool IsCandidateWindowOpen() const;
-
- // Notifies observers if the candidate window's opened/closed state has
- // changed from the previous call to this function.
- void NotifyIfCandidateWindowOpenedOrClosed();
-
- // The candidate window.
+ // The candidate window data model.
CandidateWindow candidate_window_;
// The index in the current page of the candidate currently being selected.
@@ -172,28 +91,14 @@ class CandidateWindowView : public views::View {
// The observers of the object.
ObserverList<Observer> observers_;
- // The parent frame.
- views::Widget* parent_frame_;
-
// Views created in the class will be part of tree of |this|, so these
// child views will be deleted when |this| is deleted.
+ InformationTextArea* auxiliary_text_;
+ InformationTextArea* preedit_;
+ views::View* candidate_area_;
- // The preedit area is where the preedit text is shown, if it is needed
- // in cases such as the focus is on a plugin that doesn't support in-line
- // preedit drawing.
- InformationTextArea* preedit_area_;
- // The header area is where the auxiliary text is shown, if the
- // orientation is horizontal. If the auxiliary text is not provided, we
- // show nothing. For instance, we show pinyin text like "zhong'guo".
- InformationTextArea* header_area_;
- // The candidate area is where candidates are rendered.
- HidableArea* candidate_area_;
// The candidate views are used for rendering candidates.
std::vector<CandidateView*> candidate_views_;
- // The footer area is where the auxiliary text is shown, if the
- // orientation is vertical. Usually the auxiliary text is used for
- // showing candidate number information like 2/19.
- InformationTextArea* footer_area_;
// Current columns size in |candidate_area_|.
gfx::Size previous_shortcut_column_size_;
@@ -218,10 +123,6 @@ class CandidateWindowView : public views::View {
// send OnCandidateWindowOpened and OnCandidateWindowClosed events.
bool was_candidate_window_open_;
- // This function judge whether the candidate window should be shown or not,
- // if should be, shows parent_frame and if not, hides parent_frame.
- void UpdateParentArea();
-
DISALLOW_COPY_AND_ASSIGN(CandidateWindowView);
};

Powered by Google App Engine
This is Rietveld 408576698