| Index: ui/views/selection_controller_delegate.h
|
| diff --git a/ui/views/selection_controller_delegate.h b/ui/views/selection_controller_delegate.h
|
| index d9c823d607d3692f527dc2d7418860ae17a5fc5c..b30e5fee78a7fdb36fc56cfc2d4a2d7cce37ebb9 100644
|
| --- a/ui/views/selection_controller_delegate.h
|
| +++ b/ui/views/selection_controller_delegate.h
|
| @@ -5,17 +5,37 @@
|
| #ifndef UI_VIEWS_SELECTION_CONTROLLER_DELEGATE_H_
|
| #define UI_VIEWS_SELECTION_CONTROLLER_DELEGATE_H_
|
|
|
| +#include "third_party/skia/include/core/SkColor.h"
|
| +#include "ui/views/focus/focus_manager.h"
|
| #include "ui/views/views_export.h"
|
|
|
| +namespace gfx {
|
| +class RenderText;
|
| +}
|
| +
|
| namespace ui {
|
| class MouseEvent;
|
| }
|
|
|
| namespace views {
|
|
|
| +// For cosmetic use only. TODO(patricialor): Probably this can be removed.
|
| +enum class TextSelectionDrawState {
|
| + // The control has focus, the selection text color and selection background
|
| + // color are used.
|
| + kDrawAsFocused,
|
| + // The control doesn't have focus, but it was last to be focused before
|
| + // changing to a different views::Widget or application. The selection text
|
| + // color and selection background unfocused color are used.
|
| + kDrawAsLastFocused,
|
| + // In all other cases, the selection is not drawn at all.
|
| + kDrawAsUnfocused
|
| +};
|
| +
|
| // An interface implemented/managed by a view which uses the
|
| // SelectionController.
|
| -class VIEWS_EXPORT SelectionControllerDelegate {
|
| +class VIEWS_EXPORT SelectionControllerDelegate
|
| + : virtual public FocusChangeListener {
|
| public:
|
| // Returns the associated RenderText instance to be used for selection.
|
| virtual gfx::RenderText* GetRenderTextForSelectionController() = 0;
|
| @@ -61,8 +81,31 @@ class VIEWS_EXPORT SelectionControllerDelegate {
|
| // the render text instance, it may be called outside of a pointer action.
|
| virtual void UpdateSelectionClipboard() = 0;
|
|
|
| + // These methods are used for drawing the selected text while also considering
|
| + // its focused state. See TextSelectionDrawState.
|
| + virtual SkColor GetSelectionTextColor() const = 0;
|
| + virtual SkColor GetSelectionBackgroundColor() const = 0;
|
| + virtual SkColor GetSelectionBackgroundUnfocusedColor() const = 0;
|
| + TextSelectionDrawState UpdateTextSelectionDrawState(
|
| + const View* this_view,
|
| + const View* focused_before,
|
| + const View* focused_now);
|
| +
|
| + // Set the FocusManager observed for focus change events. The
|
| + // SelectionControllerDelegate implementation must call this in order for
|
| + // selection drawing to reflect changes in focus.
|
| + virtual void ObserveWidgetFocusChanges(FocusManager* new_focus_manager,
|
| + bool add_as_listener);
|
| +
|
| + // FocusChangeListener overrides:
|
| + // Subclasses must pass the call below to UpdateTextSelectionDrawState().
|
| + void OnWillChangeFocus(View* focused_before, View* focused_now) override = 0;
|
| + void OnDidChangeFocus(View* focused_before, View* focused_now) override;
|
| +
|
| protected:
|
| - virtual ~SelectionControllerDelegate() {}
|
| + ~SelectionControllerDelegate() override;
|
| +
|
| + FocusManager* focus_manager_ = nullptr;
|
| };
|
|
|
| } // namespace views
|
|
|