diff options
author | Zeno Albisser <zeno.albisser@digia.com> | 2013-11-21 14:09:57 +0100 |
---|---|---|
committer | Andras Becsi <andras.becsi@digia.com> | 2013-11-29 15:14:36 +0100 |
commit | eb32ba6f51d0c21d58cd7d89785285ff8fa64624 (patch) | |
tree | 2c7c940e1dbee81b89d935626110816b494aa32c /chromium/ui/views | |
parent | 9427c1a0222ebd67efef1a2c7990a0fa5c9aac84 (diff) | |
download | qtwebengine-chromium-eb32ba6f51d0c21d58cd7d89785285ff8fa64624.tar.gz |
Update chromium to branch 1599.
Change-Id: I04e775a946a208bb4500d3b722bcb05c82b9d7cb
Reviewed-by: Andras Becsi <andras.becsi@digia.com>
Diffstat (limited to 'chromium/ui/views')
19 files changed, 171 insertions, 30 deletions
diff --git a/chromium/ui/views/accessibility/native_view_accessibility_win.cc b/chromium/ui/views/accessibility/native_view_accessibility_win.cc index a0367fe1f1e..279c99d3d29 100644 --- a/chromium/ui/views/accessibility/native_view_accessibility_win.cc +++ b/chromium/ui/views/accessibility/native_view_accessibility_win.cc @@ -582,8 +582,8 @@ STDMETHODIMP NativeViewAccessibilityWin::get_accState( return S_OK; } -STDMETHODIMP NativeViewAccessibilityWin::get_accValue( - VARIANT var_id, BSTR* value) { +STDMETHODIMP NativeViewAccessibilityWin::get_accValue(VARIANT var_id, + BSTR* value) { if (!IsValidId(var_id) || !value) return E_INVALIDARG; @@ -607,6 +607,24 @@ STDMETHODIMP NativeViewAccessibilityWin::get_accValue( return S_OK; } +STDMETHODIMP NativeViewAccessibilityWin::put_accValue(VARIANT var_id, + BSTR new_value) { + if (!IsValidId(var_id) || !new_value) + return E_INVALIDARG; + + if (!view_) + return E_FAIL; + + // Return an error if the view can't set the value. + ui::AccessibleViewState state; + view_->GetAccessibleState(&state); + if (state.set_value_callback.is_null()) + return E_FAIL; + + state.set_value_callback.Run(new_value); + return S_OK; +} + // IAccessible functions not supported. STDMETHODIMP NativeViewAccessibilityWin::get_accSelection(VARIANT* selected) { @@ -644,12 +662,6 @@ STDMETHODIMP NativeViewAccessibilityWin::put_accName( return E_NOTIMPL; } -STDMETHODIMP NativeViewAccessibilityWin::put_accValue( - VARIANT var_id, BSTR put_val) { - // Deprecated. - return E_NOTIMPL; -} - // // IAccessible2 // diff --git a/chromium/ui/views/accessibility/native_view_accessibility_win.h b/chromium/ui/views/accessibility/native_view_accessibility_win.h index aff2a6f6e87..e616551b968 100644 --- a/chromium/ui/views/accessibility/native_view_accessibility_win.h +++ b/chromium/ui/views/accessibility/native_view_accessibility_win.h @@ -114,10 +114,11 @@ NativeViewAccessibilityWin // Retrieves the current state of the specified object. STDMETHODIMP get_accState(VARIANT var_id, VARIANT* state); - // Retrieves the current value associated with the specified object. + // Retrieve or set the string value associated with the specified object. + // Setting the value is not typically used by screen readers, but it's + // used frequently by automation software. STDMETHODIMP get_accValue(VARIANT var_id, BSTR* value); - - // Non-supported IAccessible methods. + STDMETHODIMP put_accValue(VARIANT var_id, BSTR new_value); // Selections not applicable to views. STDMETHODIMP get_accSelection(VARIANT* selected); @@ -131,7 +132,6 @@ NativeViewAccessibilityWin // Deprecated functions, not implemented here. STDMETHODIMP put_accName(VARIANT var_id, BSTR put_name); - STDMETHODIMP put_accValue(VARIANT var_id, BSTR put_val); // // IAccessible2 diff --git a/chromium/ui/views/accessibility/native_view_accessibility_win_unittest.cc b/chromium/ui/views/accessibility/native_view_accessibility_win_unittest.cc new file mode 100644 index 00000000000..7dcbac22145 --- /dev/null +++ b/chromium/ui/views/accessibility/native_view_accessibility_win_unittest.cc @@ -0,0 +1,65 @@ +// Copyright 2013 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include <oleacc.h> + +#include "base/win/scoped_bstr.h" +#include "base/win/scoped_comptr.h" +#include "base/win/scoped_variant.h" +#include "ui/views/controls/textfield/textfield.h" +#include "ui/views/test/views_test_base.h" + +namespace views { +namespace test { + +typedef ViewsTestBase NativeViewAcccessibilityWinTest; + +TEST_F(NativeViewAcccessibilityWinTest, TextfieldAccessibility) { + Widget widget; + Widget::InitParams init_params = + CreateParams(Widget::InitParams::TYPE_POPUP); + init_params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; + widget.Init(init_params); + + View* content = new View; + widget.SetContentsView(content); + + Textfield* textfield = new Textfield; + textfield->SetAccessibleName(L"Name"); + textfield->SetText(L"Value"); + content->AddChildView(textfield); + + base::win::ScopedComPtr<IAccessible> content_accessible( + content->GetNativeViewAccessible()); + LONG child_count = 0; + ASSERT_EQ(S_OK, content_accessible->get_accChildCount(&child_count)); + ASSERT_EQ(1L, child_count); + + base::win::ScopedComPtr<IDispatch> textfield_dispatch; + base::win::ScopedComPtr<IAccessible> textfield_accessible; + base::win::ScopedVariant child_index(1); + ASSERT_EQ(S_OK, content_accessible->get_accChild( + child_index, textfield_dispatch.Receive())); + ASSERT_EQ(S_OK, textfield_dispatch.QueryInterface( + textfield_accessible.Receive())); + + base::win::ScopedBstr name; + base::win::ScopedVariant childid_self(CHILDID_SELF); + ASSERT_EQ(S_OK, textfield_accessible->get_accName( + childid_self, name.Receive())); + ASSERT_STREQ(L"Name", name); + + base::win::ScopedBstr value; + ASSERT_EQ(S_OK, textfield_accessible->get_accValue( + childid_self, value.Receive())); + ASSERT_STREQ(L"Value", value); + + base::win::ScopedBstr new_value(L"New value"); + ASSERT_EQ(S_OK, textfield_accessible->put_accValue(childid_self, new_value)); + + ASSERT_STREQ(L"New value", textfield->text().c_str()); +} + +} // namespace test +} // namespace views diff --git a/chromium/ui/views/controls/button/blue_button.cc b/chromium/ui/views/controls/button/blue_button.cc index 516363018f4..a17441e1cbe 100644 --- a/chromium/ui/views/controls/button/blue_button.cc +++ b/chromium/ui/views/controls/button/blue_button.cc @@ -78,4 +78,9 @@ const char* BlueButton::GetClassName() const { return BlueButton::kViewClassName; } +// TODO(msw): Re-enable animations for blue buttons. See crbug.com/239121. +const ui::Animation* BlueButton::GetThemeAnimation() const { + return NULL; +} + } // namespace views diff --git a/chromium/ui/views/controls/button/blue_button.h b/chromium/ui/views/controls/button/blue_button.h index c939e00cd31..0415bf429c7 100644 --- a/chromium/ui/views/controls/button/blue_button.h +++ b/chromium/ui/views/controls/button/blue_button.h @@ -6,6 +6,7 @@ #define UI_VIEWS_CONTROLS_BUTTON_BLUE_BUTTON_H_ #include "base/compiler_specific.h" +#include "base/strings/string16.h" #include "ui/views/controls/button/label_button.h" namespace views { @@ -21,6 +22,7 @@ class VIEWS_EXPORT BlueButton : public LabelButton { private: // Overridden from LabelButton: virtual const char* GetClassName() const OVERRIDE; + virtual const ui::Animation* GetThemeAnimation() const OVERRIDE; DISALLOW_COPY_AND_ASSIGN(BlueButton); }; diff --git a/chromium/ui/views/controls/button/label_button.cc b/chromium/ui/views/controls/button/label_button.cc index 7abdc3b3ae8..9fab63b0086 100644 --- a/chromium/ui/views/controls/button/label_button.cc +++ b/chromium/ui/views/controls/button/label_button.cc @@ -128,7 +128,7 @@ void LabelButton::SetIsDefault(bool is_default) { // STYLE_BUTTON uses bold text to indicate default buttons. if (style_ == STYLE_BUTTON) { int style = label_->font().GetStyle(); - style = is_default ? style | gfx::Font::BOLD : style & ~gfx::Font::BOLD; + style = is_default ? style | gfx::Font::BOLD : style & !gfx::Font::BOLD; label_->SetFont(label_->font().DeriveFont(0, style)); } } diff --git a/chromium/ui/views/controls/button/label_button_border.cc b/chromium/ui/views/controls/button/label_button_border.cc index 34ea502ebe9..efb80df3a1b 100644 --- a/chromium/ui/views/controls/button/label_button_border.cc +++ b/chromium/ui/views/controls/button/label_button_border.cc @@ -6,13 +6,10 @@ #include "base/logging.h" #include "grit/ui_resources.h" -#include "third_party/skia/include/core/SkPaint.h" -#include "third_party/skia/include/effects/SkLerpXfermode.h" #include "ui/base/animation/animation.h" #include "ui/base/resource/resource_bundle.h" #include "ui/gfx/canvas.h" #include "ui/gfx/rect.h" -#include "ui/gfx/skia_util.h" #include "ui/gfx/sys_color_change_listener.h" #include "ui/native_theme/native_theme.h" #include "ui/views/controls/button/label_button.h" @@ -122,22 +119,17 @@ void LabelButtonBorder::Paint(const View& view, gfx::Canvas* canvas) { ui::NativeTheme::State state = native_theme_delegate->GetThemeState(&extra); if (animation && animation->is_animating()) { - // Linearly interpolate background and foreground painters during animation. - const SkRect sk_rect = gfx::RectToSkRect(rect); - canvas->sk_canvas()->saveLayer(&sk_rect, NULL); + // Composite the background and foreground painters during state animations. + int alpha = animation->CurrentValueBetween(0, 0xff); state = native_theme_delegate->GetBackgroundThemeState(&extra); + canvas->SaveLayerAlpha(static_cast<uint8>(0xff - alpha)); PaintHelper(this, canvas, theme, part, state, rect, extra); + canvas->Restore(); - SkPaint paint; - skia::RefPtr<SkXfermode> sk_lerp_xfer = - skia::AdoptRef(SkLerpXfermode::Create(animation->GetCurrentValue())); - paint.setXfermode(sk_lerp_xfer.get()); - canvas->sk_canvas()->saveLayer(&sk_rect, &paint); state = native_theme_delegate->GetForegroundThemeState(&extra); + canvas->SaveLayerAlpha(static_cast<uint8>(alpha)); PaintHelper(this, canvas, theme, part, state, rect, extra); - canvas->sk_canvas()->restore(); - - canvas->sk_canvas()->restore(); + canvas->Restore(); } else { PaintHelper(this, canvas, theme, part, state, rect, extra); } diff --git a/chromium/ui/views/controls/combobox/combobox.cc b/chromium/ui/views/controls/combobox/combobox.cc index 4c107886234..34f48484755 100644 --- a/chromium/ui/views/controls/combobox/combobox.cc +++ b/chromium/ui/views/controls/combobox/combobox.cc @@ -14,6 +14,7 @@ #include "ui/views/controls/combobox/combobox_listener.h" #include "ui/views/controls/native/native_view_host.h" #include "ui/views/controls/prefix_selector.h" +#include "ui/views/ime/input_method.h" #include "ui/views/widget/widget.h" namespace views { @@ -140,6 +141,7 @@ bool Combobox::OnKeyReleased(const ui::KeyEvent& e) { } void Combobox::OnFocus() { + GetInputMethod()->OnFocus(); // Forward the focus to the wrapper. if (native_wrapper_) { native_wrapper_->SetFocus(); @@ -151,6 +153,7 @@ void Combobox::OnFocus() { } void Combobox::OnBlur() { + GetInputMethod()->OnBlur(); if (selector_) selector_->OnViewBlur(); if (native_wrapper_) diff --git a/chromium/ui/views/controls/textfield/native_textfield_views.cc b/chromium/ui/views/controls/textfield/native_textfield_views.cc index bf514d6f48d..822bbdf5fb0 100644 --- a/chromium/ui/views/controls/textfield/native_textfield_views.cc +++ b/chromium/ui/views/controls/textfield/native_textfield_views.cc @@ -84,6 +84,7 @@ NativeTextfieldViews::NativeTextfieldViews(Textfield* parent) GetRenderText()->SetFontList(textfield_->font_list()); UpdateColorsFromTheme(GetNativeTheme()); set_context_menu_controller(this); + parent->set_context_menu_controller(this); set_drag_controller(this); } diff --git a/chromium/ui/views/controls/textfield/native_textfield_views_unittest.cc b/chromium/ui/views/controls/textfield/native_textfield_views_unittest.cc index a54144d8922..c2e32c998a4 100644 --- a/chromium/ui/views/controls/textfield/native_textfield_views_unittest.cc +++ b/chromium/ui/views/controls/textfield/native_textfield_views_unittest.cc @@ -179,7 +179,6 @@ class NativeTextfieldViewsTest : public ViewsTestBase, textfield_view_ = static_cast<NativeTextfieldViews*>( textfield_->GetNativeWrapperForTesting()); - DCHECK(textfield_view_); textfield_view_->SetBoundsRect(params.bounds); textfield_->set_id(1); @@ -189,6 +188,7 @@ class NativeTextfieldViewsTest : public ViewsTestBase, textfield->set_id(i + 1); } + DCHECK(textfield_view_); model_ = textfield_view_->model_.get(); model_->ClearEditHistory(); @@ -784,6 +784,7 @@ TEST_F(NativeTextfieldViewsTest, FocusTraversalTest) { TEST_F(NativeTextfieldViewsTest, ContextMenuDisplayTest) { InitTextfield(Textfield::STYLE_DEFAULT); + EXPECT_TRUE(textfield_->context_menu_controller()); textfield_->SetText(ASCIIToUTF16("hello world")); EXPECT_TRUE(GetContextMenuModel()); VerifyTextfieldContextMenuContents(false, GetContextMenuModel()); diff --git a/chromium/ui/views/controls/textfield/textfield.cc b/chromium/ui/views/controls/textfield/textfield.cc index 4787e4e4af6..b76c20c8ac8 100644 --- a/chromium/ui/views/controls/textfield/textfield.cc +++ b/chromium/ui/views/controls/textfield/textfield.cc @@ -89,7 +89,8 @@ Textfield::Textfield() vertical_margins_were_set_(false), vertical_alignment_(gfx::ALIGN_VCENTER), placeholder_text_color_(kDefaultPlaceholderTextColor), - text_input_type_(ui::TEXT_INPUT_TYPE_TEXT) { + text_input_type_(ui::TEXT_INPUT_TYPE_TEXT), + weak_ptr_factory_(this) { set_focusable(true); if (ViewsDelegate::views_delegate) { @@ -114,7 +115,8 @@ Textfield::Textfield(StyleFlags style) vertical_margins_were_set_(false), vertical_alignment_(gfx::ALIGN_VCENTER), placeholder_text_color_(kDefaultPlaceholderTextColor), - text_input_type_(ui::TEXT_INPUT_TYPE_TEXT) { + text_input_type_(ui::TEXT_INPUT_TYPE_TEXT), + weak_ptr_factory_(this) { set_focusable(true); if (IsObscured()) SetTextInputType(ui::TEXT_INPUT_TYPE_PASSWORD); @@ -506,6 +508,12 @@ void Textfield::GetAccessibleState(ui::AccessibleViewState* state) { const ui::Range range = native_wrapper_->GetSelectedRange(); state->selection_start = range.start(); state->selection_end = range.end(); + + if (!read_only()) { + state->set_value_callback = + base::Bind(&Textfield::AccessibilitySetValue, + weak_ptr_factory_.GetWeakPtr()); + } } ui::TextInputClient* Textfield::GetTextInputClient() { @@ -547,6 +555,9 @@ const char* Textfield::GetClassName() const { return kViewClassName; } +//////////////////////////////////////////////////////////////////////////////// +// Textfield, private: + gfx::Insets Textfield::GetTextInsets() const { gfx::Insets insets = GetInsets(); if (draw_border_ && native_wrapper_) @@ -554,6 +565,13 @@ gfx::Insets Textfield::GetTextInsets() const { return insets; } +void Textfield::AccessibilitySetValue(const string16& new_value) { + if (!read_only()) { + SetText(new_value); + ClearSelection(); + } +} + //////////////////////////////////////////////////////////////////////////////// // NativeTextfieldWrapper, public: diff --git a/chromium/ui/views/controls/textfield/textfield.h b/chromium/ui/views/controls/textfield/textfield.h index 2004a0a8b71..71b663bd2e5 100644 --- a/chromium/ui/views/controls/textfield/textfield.h +++ b/chromium/ui/views/controls/textfield/textfield.h @@ -9,6 +9,7 @@ #include "base/basictypes.h" #include "base/compiler_specific.h" +#include "base/memory/weak_ptr.h" #include "base/strings/string16.h" #include "base/time/time.h" #include "build/build_config.h" @@ -288,6 +289,11 @@ class VIEWS_EXPORT Textfield : public View { // Returns the insets to the rectangle where text is actually painted. gfx::Insets GetTextInsets() const; + // Handles a request to change the value of this text field from software + // using an accessibility API (typically automation software, screen readers + // don't normally use this). Sets the value and clears the selection. + void AccessibilitySetValue(const string16& new_value); + // This is the current listener for events from this Textfield. TextfieldController* controller_; @@ -347,6 +353,9 @@ class VIEWS_EXPORT Textfield : public View { // The duration to reveal the last typed char for obscured textfields. base::TimeDelta obscured_reveal_duration_; + // Used to bind callback functions to this object. + base::WeakPtrFactory<Textfield> weak_ptr_factory_; + DISALLOW_COPY_AND_ASSIGN(Textfield); }; diff --git a/chromium/ui/views/controls/tree/tree_view.cc b/chromium/ui/views/controls/tree/tree_view.cc index 1d550a2ff75..0157902fad4 100644 --- a/chromium/ui/views/controls/tree/tree_view.cc +++ b/chromium/ui/views/controls/tree/tree_view.cc @@ -598,6 +598,7 @@ void TreeView::OnPaint(gfx::Canvas* canvas) { } void TreeView::OnFocus() { + GetInputMethod()->OnFocus(); View::OnFocus(); SchedulePaintForNode(selected_node_); @@ -607,6 +608,7 @@ void TreeView::OnFocus() { } void TreeView::OnBlur() { + GetInputMethod()->OnBlur(); SchedulePaintForNode(selected_node_); if (selector_) selector_->OnViewBlur(); diff --git a/chromium/ui/views/views.gyp b/chromium/ui/views/views.gyp index ff3ab0aaa61..de8cdef4e19 100644 --- a/chromium/ui/views/views.gyp +++ b/chromium/ui/views/views.gyp @@ -684,6 +684,7 @@ '..', ], 'sources': [ + 'accessibility/native_view_accessibility_win_unittest.cc', 'accessible_pane_view_unittest.cc', 'animation/bounds_animator_unittest.cc', 'bubble/bubble_border_unittest.cc', diff --git a/chromium/ui/views/widget/desktop_aura/desktop_root_window_host_win.cc b/chromium/ui/views/widget/desktop_aura/desktop_root_window_host_win.cc index 6b0de6a4628..159ffc1080e 100644 --- a/chromium/ui/views/widget/desktop_aura/desktop_root_window_host_win.cc +++ b/chromium/ui/views/widget/desktop_aura/desktop_root_window_host_win.cc @@ -506,6 +506,14 @@ void DesktopRootWindowHostWin::MoveCursorTo(const gfx::Point& location) { void DesktopRootWindowHostWin::SetFocusWhenShown(bool focus_when_shown) { } +bool DesktopRootWindowHostWin::CopyAreaToSkCanvas( + const gfx::Rect& source_bounds, + const gfx::Point& dest_offset, + SkCanvas* canvas) { + NOTIMPLEMENTED(); + return false; +} + void DesktopRootWindowHostWin::PostNativeEvent( const base::NativeEvent& native_event) { } diff --git a/chromium/ui/views/widget/desktop_aura/desktop_root_window_host_win.h b/chromium/ui/views/widget/desktop_aura/desktop_root_window_host_win.h index 13f043d81c2..9ad6b6998c9 100644 --- a/chromium/ui/views/widget/desktop_aura/desktop_root_window_host_win.h +++ b/chromium/ui/views/widget/desktop_aura/desktop_root_window_host_win.h @@ -119,6 +119,9 @@ class VIEWS_EXPORT DesktopRootWindowHostWin virtual void OnCursorVisibilityChanged(bool show) OVERRIDE; virtual void MoveCursorTo(const gfx::Point& location) OVERRIDE; virtual void SetFocusWhenShown(bool focus_when_shown) OVERRIDE; + virtual bool CopyAreaToSkCanvas(const gfx::Rect& source_bounds, + const gfx::Point& dest_offset, + SkCanvas* canvas) OVERRIDE; virtual void PostNativeEvent(const base::NativeEvent& native_event) OVERRIDE; virtual void OnDeviceScaleFactorChanged(float device_scale_factor) OVERRIDE; virtual void PrepareForShutdown() OVERRIDE; diff --git a/chromium/ui/views/widget/desktop_aura/desktop_root_window_host_x11.cc b/chromium/ui/views/widget/desktop_aura/desktop_root_window_host_x11.cc index 67610684875..8c4ba7c8da5 100644 --- a/chromium/ui/views/widget/desktop_aura/desktop_root_window_host_x11.cc +++ b/chromium/ui/views/widget/desktop_aura/desktop_root_window_host_x11.cc @@ -731,6 +731,14 @@ void DesktopRootWindowHostX11::SetFocusWhenShown(bool focus_when_shown) { } } +bool DesktopRootWindowHostX11::CopyAreaToSkCanvas( + const gfx::Rect& source_bounds, + const gfx::Point& dest_offset, + SkCanvas* canvas) { + NOTIMPLEMENTED(); + return false; +} + void DesktopRootWindowHostX11::PostNativeEvent( const base::NativeEvent& native_event) { DCHECK(xwindow_); diff --git a/chromium/ui/views/widget/desktop_aura/desktop_root_window_host_x11.h b/chromium/ui/views/widget/desktop_aura/desktop_root_window_host_x11.h index c3630293dc8..e1dcc766930 100644 --- a/chromium/ui/views/widget/desktop_aura/desktop_root_window_host_x11.h +++ b/chromium/ui/views/widget/desktop_aura/desktop_root_window_host_x11.h @@ -146,6 +146,9 @@ class VIEWS_EXPORT DesktopRootWindowHostX11 : virtual void OnCursorVisibilityChanged(bool show) OVERRIDE; virtual void MoveCursorTo(const gfx::Point& location) OVERRIDE; virtual void SetFocusWhenShown(bool focus_when_shown) OVERRIDE; + virtual bool CopyAreaToSkCanvas(const gfx::Rect& source_bounds, + const gfx::Point& dest_offset, + SkCanvas* canvas) OVERRIDE; virtual void PostNativeEvent(const base::NativeEvent& native_event) OVERRIDE; virtual void OnDeviceScaleFactorChanged(float device_scale_factor) OVERRIDE; virtual void PrepareForShutdown() OVERRIDE; diff --git a/chromium/ui/views/win/appbar.cc b/chromium/ui/views/win/appbar.cc index 062eb34c038..92151d47756 100644 --- a/chromium/ui/views/win/appbar.cc +++ b/chromium/ui/views/win/appbar.cc @@ -41,6 +41,14 @@ Appbar* Appbar::instance() { } int Appbar::GetAutohideEdges(HMONITOR monitor, const base::Closure& callback) { + // Initialize the map with EDGE_BOTTOM. This is important, as if we return an + // initial value of 0 (no auto-hide edges) then we'll go fullscreen and + // windows will automatically remove WS_EX_TOPMOST from the appbar resulting + // in us thinking there is no auto-hide edges. By returning at least one edge + // we don't initially go fullscreen until we figure out the real auto-hide + // edges. + if (edge_map_.find(monitor) == edge_map_.end()) + edge_map_[monitor] = Appbar::EDGE_BOTTOM; if (!in_callback_) { int* edge = new int; base::WorkerPool::PostTaskAndReply( |