Upstream version 7.36.149.0
[platform/framework/web/crosswalk.git] / src / content / shell / renderer / test_runner / web_ax_object_proxy.cc
index 3ff89f8..ac8c2a1 100644 (file)
@@ -2,9 +2,6 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
-// TODO(hajimehoshi): Remove this when UnsafePersistent is removed.
-#define V8_ALLOW_ACCESS_TO_RAW_HANDLE_CONSTRUCTOR
-
 #include "content/shell/renderer/test_runner/web_ax_object_proxy.h"
 
 #include "base/strings/stringprintf.h"
@@ -615,18 +612,22 @@ std::string WebAXObjectProxy::StringValue() {
 }
 
 int WebAXObjectProxy::X() {
+  accessibility_object_.updateBackingStoreAndCheckValidity();
   return accessibility_object().boundingBoxRect().x;
 }
 
 int WebAXObjectProxy::Y() {
+  accessibility_object_.updateBackingStoreAndCheckValidity();
   return accessibility_object().boundingBoxRect().y;
 }
 
 int WebAXObjectProxy::Width() {
+  accessibility_object_.updateBackingStoreAndCheckValidity();
   return accessibility_object().boundingBoxRect().width;
 }
 
 int WebAXObjectProxy::Height() {
+  accessibility_object_.updateBackingStoreAndCheckValidity();
   return accessibility_object().boundingBoxRect().height;
 }
 
@@ -785,6 +786,9 @@ std::string WebAXObjectProxy::BoundsForRange(int start, int end) {
   if (accessibility_object().role() != blink::WebAXRoleStaticText)
     return std::string();
 
+  if (!accessibility_object_.updateBackingStoreAndCheckValidity())
+    return std::string();
+
   int len = end - start;
 
   // Get the bounds for each character and union them into one large rectangle.
@@ -973,7 +977,8 @@ bool RootWebAXObjectProxy::IsRoot() const {
   return true;
 }
 
-WebAXObjectProxyList::WebAXObjectProxyList() {
+WebAXObjectProxyList::WebAXObjectProxyList()
+    : elements_(blink::mainThreadIsolate()) {
 }
 
 WebAXObjectProxyList::~WebAXObjectProxyList() {
@@ -981,9 +986,7 @@ WebAXObjectProxyList::~WebAXObjectProxyList() {
 }
 
 void WebAXObjectProxyList::Clear() {
-  for (ElementList::iterator i = elements_.begin(); i != elements_.end(); ++i)
-    i->Dispose();
-  elements_.clear();
+  elements_.Clear();
 }
 
 v8::Handle<v8::Object> WebAXObjectProxyList::GetOrCreate(
@@ -993,15 +996,15 @@ v8::Handle<v8::Object> WebAXObjectProxyList::GetOrCreate(
 
   v8::Isolate* isolate = blink::mainThreadIsolate();
 
-  size_t elementCount = elements_.size();
+  size_t elementCount = elements_.Size();
   for (size_t i = 0; i < elementCount; i++) {
     WebAXObjectProxy* unwrapped_object = NULL;
-    bool result = gin::ConvertFromV8(isolate, elements_[i].NewLocal(isolate),
+    bool result = gin::ConvertFromV8(isolate, elements_.Get(i),
                                      &unwrapped_object);
     DCHECK(result);
     DCHECK(unwrapped_object);
     if (unwrapped_object->IsEqualToObject(object))
-      return elements_[i].NewLocal(isolate);
+      return elements_.Get(i);
   }
 
   v8::Handle<v8::Value> value_handle = gin::CreateHandle(
@@ -1009,9 +1012,8 @@ v8::Handle<v8::Object> WebAXObjectProxyList::GetOrCreate(
   if (value_handle.IsEmpty())
     return v8::Handle<v8::Object>();
   v8::Handle<v8::Object> handle = value_handle->ToObject();
-  UnsafePersistent<v8::Object> unsafe_handle(isolate, handle);
-  elements_.push_back(unsafe_handle);
-  return unsafe_handle.NewLocal(isolate);
+  elements_.Append(handle);
+  return handle;
 }
 
 v8::Handle<v8::Object> WebAXObjectProxyList::CreateRoot(
@@ -1022,9 +1024,8 @@ v8::Handle<v8::Object> WebAXObjectProxyList::CreateRoot(
   if (value_handle.IsEmpty())
     return v8::Handle<v8::Object>();
   v8::Handle<v8::Object> handle = value_handle->ToObject();
-  UnsafePersistent<v8::Object> unsafe_handle(isolate, handle);
-  elements_.push_back(unsafe_handle);
-  return unsafe_handle.NewLocal(isolate);
+  elements_.Append(handle);
+  return handle;
 }
 
 }  // namespace content