Upstream version 7.36.149.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / Source / web / WebAXObject.cpp
index 2eb2a5e..76cfc64 100644 (file)
  */
 
 #include "config.h"
-#include "WebAXObject.h"
+#include "public/web/WebAXObject.h"
 
 #include "HTMLNames.h"
-#include "WebDocument.h"
-#include "WebNode.h"
 #include "core/accessibility/AXObject.h"
 #include "core/accessibility/AXObjectCache.h"
 #include "core/accessibility/AXTable.h"
 #include "core/css/CSSPrimitiveValueMappings.h"
 #include "core/dom/Document.h"
 #include "core/dom/Node.h"
-#include "core/page/EventHandler.h"
 #include "core/frame/FrameView.h"
+#include "core/page/EventHandler.h"
+#include "core/rendering/RenderView.h"
 #include "core/rendering/style/RenderStyle.h"
 #include "platform/PlatformKeyboardEvent.h"
 #include "public/platform/WebPoint.h"
 #include "public/platform/WebRect.h"
 #include "public/platform/WebString.h"
 #include "public/platform/WebURL.h"
+#include "public/web/WebDocument.h"
+#include "public/web/WebNode.h"
 #include "wtf/text/StringBuilder.h"
 
 using namespace WebCore;
 
-namespace WebKit {
+namespace blink {
 
 void WebAXObject::reset()
 {
     m_private.reset();
 }
 
-void WebAXObject::assign(const WebKit::WebAXObject& other)
+void WebAXObject::assign(const blink::WebAXObject& other)
 {
     m_private = other.m_private;
 }
@@ -90,16 +91,6 @@ void WebAXObject::enableInlineTextBoxAccessibility()
     AXObjectCache::setInlineTextBoxAccessibility(true);
 }
 
-void WebAXObject::startCachingComputedObjectAttributesUntilTreeMutates()
-{
-    m_private->axObjectCache()->startCachingComputedObjectAttributesUntilTreeMutates();
-}
-
-void WebAXObject::stopCachingComputedObjectAttributes()
-{
-    m_private->axObjectCache()->stopCachingComputedObjectAttributes();
-}
-
 bool WebAXObject::isDetached() const
 {
     if (m_private.isNull())
@@ -414,6 +405,46 @@ WebString WebAXObject::accessKey() const
     return WebString(m_private->accessKey());
 }
 
+WebAXObject WebAXObject::ariaActiveDescendant() const
+{
+    if (isDetached())
+        return WebAXObject();
+
+    return WebAXObject(m_private->activeDescendant());
+}
+
+bool WebAXObject::ariaControls(WebVector<WebAXObject>& controlsElements) const
+{
+    if (isDetached())
+        return false;
+
+    AXObject::AccessibilityChildrenVector controls;
+    m_private->ariaControlsElements(controls);
+
+    WebVector<WebAXObject> result(controls.size());
+    for (size_t i = 0; i < controls.size(); i++)
+        result[i] = WebAXObject(controls[i]);
+    controlsElements.swap(result);
+
+    return true;
+}
+
+bool WebAXObject::ariaDescribedby(WebVector<WebAXObject>& describedbyElements) const
+{
+    if (isDetached())
+        return false;
+
+    AXObject::AccessibilityChildrenVector describedby;
+    m_private->ariaDescribedbyElements(describedby);
+
+    WebVector<WebAXObject> result(describedby.size());
+    for (size_t i = 0; i < describedby.size(); i++)
+        result[i] = WebAXObject(describedby[i]);
+    describedbyElements.swap(result);
+
+    return true;
+}
+
 bool WebAXObject::ariaHasPopup() const
 {
     if (isDetached())
@@ -422,6 +453,38 @@ bool WebAXObject::ariaHasPopup() const
     return m_private->ariaHasPopup();
 }
 
+bool WebAXObject::ariaFlowTo(WebVector<WebAXObject>& flowToElements) const
+{
+    if (isDetached())
+        return false;
+
+    AXObject::AccessibilityChildrenVector flowTo;
+    m_private->ariaFlowToElements(flowTo);
+
+    WebVector<WebAXObject> result(flowTo.size());
+    for (size_t i = 0; i < flowTo.size(); i++)
+        result[i] = WebAXObject(flowTo[i]);
+    flowToElements.swap(result);
+
+    return true;
+}
+
+bool WebAXObject::ariaLabelledby(WebVector<WebAXObject>& labelledbyElements) const
+{
+    if (isDetached())
+        return false;
+
+    AXObject::AccessibilityChildrenVector labelledby;
+    m_private->ariaLabelledbyElements(labelledby);
+
+    WebVector<WebAXObject> result(labelledby.size());
+    for (size_t i = 0; i < labelledby.size(); i++)
+        result[i] = WebAXObject(labelledby[i]);
+    labelledbyElements.swap(result);
+
+    return true;
+}
+
 bool WebAXObject::ariaLiveRegionAtomic() const
 {
     if (isDetached())
@@ -454,11 +517,31 @@ WebString WebAXObject::ariaLiveRegionStatus() const
     return m_private->ariaLiveRegionStatus();
 }
 
+bool WebAXObject::ariaOwns(WebVector<WebAXObject>& ownsElements) const
+{
+    if (isDetached())
+        return false;
+
+    AXObject::AccessibilityChildrenVector owns;
+    m_private->ariaOwnsElements(owns);
+
+    WebVector<WebAXObject> result(owns.size());
+    for (size_t i = 0; i < owns.size(); i++)
+        result[i] = WebAXObject(owns[i]);
+    ownsElements.swap(result);
+
+    return true;
+}
+
 WebRect WebAXObject::boundingBoxRect() const
 {
     if (isDetached())
         return WebRect();
 
+    // It's not safe to call boundingBoxRect if a layout is pending.
+    // Clients should call updateBackingStoreAndCheckValidity first.
+    ASSERT(m_private->document() && m_private->document()->lifecycle().state() >= DocumentLifecycle::LayoutClean);
+
     return pixelSnappedIntRect(m_private->elementRect());
 }
 
@@ -608,7 +691,7 @@ bool WebAXObject::press() const
 WebAXRole WebAXObject::role() const
 {
     if (isDetached())
-        return WebKit::WebAXRoleUnknown;
+        return blink::WebAXRoleUnknown;
 
     return static_cast<WebAXRole>(m_private->roleValue());
 }
@@ -773,7 +856,7 @@ bool WebAXObject::hasComputedStyle() const
 
     Document* document = m_private->document();
     if (document)
-        document->updateStyleIfNeeded();
+        document->updateRenderTreeIfNeeded();
 
     Node* node = m_private->node();
     if (!node)
@@ -789,7 +872,7 @@ WebString WebAXObject::computedStyleDisplay() const
 
     Document* document = m_private->document();
     if (document)
-        document->updateStyleIfNeeded();
+        document->updateRenderTreeIfNeeded();
 
     Node* node = m_private->node();
     if (!node)
@@ -1073,4 +1156,4 @@ WebAXObject::operator WTF::PassRefPtr<WebCore::AXObject>() const
     return m_private.get();
 }
 
-} // namespace WebKit
+} // namespace blink