OLD | NEW |
(Empty) | |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CONTENT_SHELL_RENDERER_TEST_RUNNER_WEB_AX_OBJECT_PROXY_H_ |
| 6 #define CONTENT_SHELL_RENDERER_TEST_RUNNER_WEB_AX_OBJECT_PROXY_H_ |
| 7 |
| 8 #include <string> |
| 9 #include <vector> |
| 10 |
| 11 #include "base/basictypes.h" |
| 12 #include "gin/object_template_builder.h" |
| 13 #include "gin/unsafe_persistent.h" |
| 14 #include "gin/wrappable.h" |
| 15 #include "third_party/WebKit/public/web/WebAXObject.h" |
| 16 #include "v8/include/v8.h" |
| 17 |
| 18 namespace blink { |
| 19 class WebFrame; |
| 20 } |
| 21 |
| 22 namespace content { |
| 23 |
| 24 class WebAXObjectProxy : public gin::Wrappable<WebAXObjectProxy> { |
| 25 public: |
| 26 class Factory { |
| 27 public: |
| 28 virtual ~Factory() { } |
| 29 virtual v8::Handle<v8::Object> GetOrCreate( |
| 30 const blink::WebAXObject& object) = 0; |
| 31 }; |
| 32 |
| 33 static gin::WrapperInfo kWrapperInfo; |
| 34 |
| 35 WebAXObjectProxy(const blink::WebAXObject& object, Factory* factory); |
| 36 virtual ~WebAXObjectProxy(); |
| 37 |
| 38 // gin::Wrappable: |
| 39 virtual gin::ObjectTemplateBuilder GetObjectTemplateBuilder( |
| 40 v8::Isolate* isolate) OVERRIDE; |
| 41 |
| 42 virtual v8::Handle<v8::Object> GetChildAtIndex(unsigned index); |
| 43 virtual bool IsRoot() const; |
| 44 bool IsEqualToObject(const blink::WebAXObject& object); |
| 45 |
| 46 void NotificationReceived(const std::string& notification_name); |
| 47 |
| 48 protected: |
| 49 const blink::WebAXObject& accessibility_object() const { |
| 50 return accessibility_object_; |
| 51 } |
| 52 |
| 53 Factory* factory() const { return factory_; } |
| 54 |
| 55 private: |
| 56 friend class WebAXObjectProxyBindings; |
| 57 |
| 58 // Bound properties. |
| 59 std::string Role(); |
| 60 std::string Title(); |
| 61 std::string Description(); |
| 62 std::string HelpText(); |
| 63 std::string StringValue(); |
| 64 int X(); |
| 65 int Y(); |
| 66 int Width(); |
| 67 int Height(); |
| 68 int IntValue(); |
| 69 int MinValue(); |
| 70 int MaxValue(); |
| 71 std::string ValueDescription(); |
| 72 int ChildrenCount(); |
| 73 int InsertionPointLineNumber(); |
| 74 std::string SelectedTextRange(); |
| 75 bool IsEnabled(); |
| 76 bool IsRequired(); |
| 77 bool IsFocused(); |
| 78 bool IsFocusable(); |
| 79 bool IsSelected(); |
| 80 bool IsSelectable(); |
| 81 bool IsMultiSelectable(); |
| 82 bool IsSelectedOptionActive(); |
| 83 bool IsExpanded(); |
| 84 bool IsChecked(); |
| 85 bool IsVisible(); |
| 86 bool IsOffScreen(); |
| 87 bool IsCollapsed(); |
| 88 bool HasPopup(); |
| 89 bool IsValid(); |
| 90 bool IsReadOnly(); |
| 91 std::string Orientation(); |
| 92 int ClickPointX(); |
| 93 int ClickPointY(); |
| 94 int32_t RowCount(); |
| 95 int32_t ColumnCount(); |
| 96 bool IsClickable(); |
| 97 |
| 98 // Bound methods. |
| 99 std::string AllAttributes(); |
| 100 std::string AttributesOfChildren(); |
| 101 int LineForIndex(int index); |
| 102 std::string BoundsForRange(int start, int end); |
| 103 v8::Handle<v8::Object> ChildAtIndex(int index); |
| 104 v8::Handle<v8::Object> ElementAtPoint(int x, int y); |
| 105 v8::Handle<v8::Object> TableHeader(); |
| 106 std::string RowIndexRange(); |
| 107 std::string ColumnIndexRange(); |
| 108 v8::Handle<v8::Object> CellForColumnAndRow(int column, int row); |
| 109 v8::Handle<v8::Object> TitleUIElement(); |
| 110 void SetSelectedTextRange(int selection_start, int selection_end); |
| 111 bool IsAttributeSettable(const std::string& attribute); |
| 112 bool IsPressActionSupported(); |
| 113 bool IsIncrementActionSupported(); |
| 114 bool IsDecrementActionSupported(); |
| 115 v8::Handle<v8::Object> ParentElement(); |
| 116 void Increment(); |
| 117 void Decrement(); |
| 118 void ShowMenu(); |
| 119 void Press(); |
| 120 bool IsEqual(v8::Handle<v8::Object> proxy); |
| 121 void AddNotificationListener(v8::Handle<v8::Function> callback); |
| 122 void RemoveNotificationListener(); |
| 123 void TakeFocus(); |
| 124 void ScrollToMakeVisible(); |
| 125 void ScrollToMakeVisibleWithSubFocus(int x, int y, int width, int height); |
| 126 void ScrollToGlobalPoint(int x, int y); |
| 127 int WordStart(int character_index); |
| 128 int WordEnd(int character_index); |
| 129 |
| 130 /*void FallbackCallback(const CppArgumentList&, CppVariant*);*/ |
| 131 |
| 132 blink::WebFrame* frame_; |
| 133 blink::WebAXObject accessibility_object_; |
| 134 Factory* factory_; |
| 135 std::vector<v8::Handle<v8::Function> > notification_callbacks_; |
| 136 |
| 137 DISALLOW_COPY_AND_ASSIGN(WebAXObjectProxy); |
| 138 }; |
| 139 |
| 140 class RootWebAXObjectProxy : public WebAXObjectProxy { |
| 141 public: |
| 142 RootWebAXObjectProxy(const blink::WebAXObject&, Factory*); |
| 143 |
| 144 virtual v8::Handle<v8::Object> GetChildAtIndex(unsigned index) OVERRIDE; |
| 145 virtual bool IsRoot() const OVERRIDE; |
| 146 }; |
| 147 |
| 148 |
| 149 // Provides simple lifetime management of the WebAXObjectProxy instances: all |
| 150 // WebAXObjectProxys ever created from the controller are stored in a list and |
| 151 // cleared explicitly. |
| 152 class WebAXObjectProxyList : public WebAXObjectProxy::Factory { |
| 153 public: |
| 154 WebAXObjectProxyList(); |
| 155 virtual ~WebAXObjectProxyList(); |
| 156 |
| 157 void Clear(); |
| 158 virtual v8::Handle<v8::Object> GetOrCreate( |
| 159 const blink::WebAXObject&) OVERRIDE; |
| 160 v8::Handle<v8::Object> CreateRoot(const blink::WebAXObject&); |
| 161 |
| 162 private: |
| 163 typedef std::vector<gin::UnsafePersistent<v8::Object> > ElementList; |
| 164 ElementList elements_; |
| 165 }; |
| 166 |
| 167 } // namespace content |
| 168 |
| 169 #endif // CONTENT_SHELL_RENDERER_TEST_RUNNER_WEB_AX_OBJECT_PROXY_H_ |
OLD | NEW |