Index: WebKit/win/AccessibleDocument.h
===================================================================
--- WebKit/win/AccessibleDocument.h	(revision 56859)
+++ WebKit/win/AccessibleDocument.h	(working copy)
@@ -33,11 +33,13 @@
 
 class AccessibleDocument : public AccessibleBase {
 public:
-    AccessibleDocument(Document*);
+    AccessibleDocument(Document*, HWND);
     Document* document() const;
 
 protected:
-    virtual long role() const;
+    virtual long MSAARole() const;
+    virtual long state() const;
+    virtual void takeFocus();
 };
 
 #endif // AccessibleDocument_h
Index: WebKit/win/AccessibleImage.cpp
===================================================================
--- WebKit/win/AccessibleImage.cpp	(revision 56859)
+++ WebKit/win/AccessibleImage.cpp	(working copy)
@@ -32,8 +32,8 @@
 using namespace WebCore;
 using namespace WebCore::HTMLNames;
 
-AccessibleImage::AccessibleImage(AccessibilityObject* obj)
-    : AccessibleBase(obj)
+AccessibleImage::AccessibleImage(AccessibilityObject* obj, HWND window)
+    : AccessibleBase(obj, window)
 {
     ASSERT_ARG(obj, obj->isImage());
     ASSERT_ARG(obj, obj->isAccessibilityRenderObject());
Index: WebKit/win/AccessibleDocument.cpp
===================================================================
--- WebKit/win/AccessibleDocument.cpp	(revision 56859)
+++ WebKit/win/AccessibleDocument.cpp	(working copy)
@@ -33,16 +33,38 @@
 using namespace WebCore;
 
 // AccessibleDocument
-AccessibleDocument::AccessibleDocument(Document* doc)
-    : AccessibleBase(doc->axObjectCache()->getOrCreate(doc->renderer()))
+AccessibleDocument::AccessibleDocument(Document* doc, HWND window)
+    : AccessibleBase(doc->axObjectCache()->getOrCreate(doc->renderer()),
+                     window)
 {
 }
 
-long AccessibleDocument::role() const
+long AccessibleDocument::MSAARole() const
 {
     return ROLE_SYSTEM_DOCUMENT;
 }
 
+long AccessibleDocument::state() const
+{
+    long state = AccessibleBase::state();
+
+    // The document is considered focusable on Windows.
+    state |= STATE_SYSTEM_FOCUSABLE;
+
+    // The document must expose itself as focused if no element has focus.
+    if (m_object->focusedUIElement() == m_object)
+        state |= STATE_SYSTEM_FOCUSED;
+
+    return state;
+}
+
+void AccessibleDocument::takeFocus()
+{
+    AccessibilityObject* focusedObj = m_object->focusedUIElement();
+    if (focusedObj != m_object)
+        focusedObj->setFocused(false);
+}
+
 Document* AccessibleDocument::document() const
 {
     if (!m_object)
Index: WebKit/win/AccessibleBase.h
===================================================================
--- WebKit/win/AccessibleBase.h	(revision 56859)
+++ WebKit/win/AccessibleBase.h	(working copy)
@@ -29,11 +29,13 @@
 #include <WebCore/AccessibilityObject.h>
 #include <WebCore/AccessibilityObjectWrapperWin.h>
 #include <WebKit/WebKit.h>
+#include <Accessible2.h>
 #include <oleacc.h>
+#include <servprov.h>
 
-class DECLSPEC_UUID("3dbd565b-db22-4d88-8e0e-778bde54524a") AccessibleBase : public IAccessibleComparable, public IServiceProvider, public WebCore::AccessibilityObjectWrapper {
+class DECLSPEC_UUID("3dbd565b-db22-4d88-8e0e-778bde54524a") AccessibleBase : public IAccessible2, public IServiceProvider, public WebCore::AccessibilityObjectWrapper {
 public:
-    static AccessibleBase* createInstance(WebCore::AccessibilityObject*);
+    static AccessibleBase* createInstance(WebCore::AccessibilityObject*, HWND window);
 
     // IServiceProvider
     virtual HRESULT STDMETHODCALLTYPE QueryService(REFGUID guidService, REFIID riid, void **ppv);
@@ -73,6 +75,26 @@
         return E_NOTIMPL;
     }
 
+    // IAccessible2
+    virtual HRESULT STDMETHODCALLTYPE get_nRelations(long* nRelations);
+    virtual HRESULT STDMETHODCALLTYPE get_relation(long relationIndex, IAccessibleRelation** relation);
+    virtual HRESULT STDMETHODCALLTYPE get_relations(long maxRelations, IAccessibleRelation** relations, long* nRelations);
+    virtual HRESULT STDMETHODCALLTYPE role(long* role);
+    virtual HRESULT STDMETHODCALLTYPE scrollTo(IA2ScrollType scrollType);
+    virtual HRESULT STDMETHODCALLTYPE scrollToPoint(IA2CoordinateType coordinateType, long x, long y);
+    virtual HRESULT STDMETHODCALLTYPE get_groupPosition(long* groupLevel, long* similarItemsInGroup, long* positionInGroup);
+    virtual HRESULT STDMETHODCALLTYPE get_states(AccessibleStates* states);
+    virtual HRESULT STDMETHODCALLTYPE get_extendedRole(BSTR* extendedRole);
+    virtual HRESULT STDMETHODCALLTYPE get_localizedExtendedRole(BSTR* localizedExtendedRole);
+    virtual HRESULT STDMETHODCALLTYPE get_nExtendedStates(long* nExtendedStates);
+    virtual HRESULT STDMETHODCALLTYPE get_extendedStates(long maxExtendedStates, BSTR** extendedStates, long* nExtendedStates);
+    virtual HRESULT STDMETHODCALLTYPE get_localizedExtendedStates(long maxLocalizedExtendedStates, BSTR** localizedExtendedStates, long* nLocalizedExtendedStates);
+    virtual HRESULT STDMETHODCALLTYPE get_uniqueID(long* uniqueID);
+    virtual HRESULT STDMETHODCALLTYPE get_windowHandle(HWND* windowHandle);
+    virtual HRESULT STDMETHODCALLTYPE get_indexInParent(long* indexInParent);
+    virtual HRESULT STDMETHODCALLTYPE get_locale(IA2Locale* locale);
+    virtual HRESULT STDMETHODCALLTYPE get_attributes(BSTR* attributes);
+
     // IDispatch - Not to be implemented.
     virtual HRESULT STDMETHODCALLTYPE GetTypeInfoCount(UINT* count)
     {
@@ -93,22 +115,22 @@
         m_object = 0;
     }
 
-    // IAccessibleComparable
-    virtual HRESULT STDMETHODCALLTYPE isSameObject(IAccessibleComparable* other, BOOL* result);
-
 protected:
-    AccessibleBase(WebCore::AccessibilityObject*);
+    AccessibleBase(WebCore::AccessibilityObject*, HWND window);
     virtual ~AccessibleBase();
 
     virtual WebCore::String name() const;
     virtual WebCore::String value() const;
-    virtual long role() const;
+    virtual long MSAARole() const;
+    virtual long state() const;
+    virtual void takeFocus();
 
     HRESULT getAccessibilityObjectForChild(VARIANT vChild, WebCore::AccessibilityObject*&) const;
 
-    static AccessibleBase* wrapper(WebCore::AccessibilityObject*);
+    AccessibleBase* wrapper(WebCore::AccessibilityObject*);
 
     int m_refCount;
+    HWND m_window;
 
 private:
     AccessibleBase() { }
Index: WebKit/win/WebFrame.cpp
===================================================================
--- WebKit/win/WebFrame.cpp	(revision 56859)
+++ WebKit/win/WebFrame.cpp	(working copy)
@@ -2458,7 +2458,7 @@
         // the Document renderer was destroyed and its wrapper was detached, or
         // the previous Document is in the page cache, and the current document
         // needs to be wrapped.
-        m_accessible = new AccessibleDocument(currentDocument);
+        m_accessible = new AccessibleDocument(currentDocument, webView()->viewWindow());
     }
     return m_accessible.get();
 }
Index: WebKit/win/WebView.h
===================================================================
--- WebKit/win/WebView.h	(revision 56859)
+++ WebKit/win/WebView.h	(working copy)
@@ -866,6 +866,7 @@
     void cancelDeleteBackingStoreSoon();
 
     HWND topLevelParent() const { return m_topLevelParent; }
+    HWND viewWindow() const { return m_viewWindow; }
 
     void updateActiveState();
 
Index: WebKit/win/AccessibleImage.h
===================================================================
--- WebKit/win/AccessibleImage.h	(revision 56859)
+++ WebKit/win/AccessibleImage.h	(working copy)
@@ -31,7 +31,7 @@
 class AccessibleImage : public AccessibleBase
 {
 public:
-    AccessibleImage(WebCore::AccessibilityObject*);
+    AccessibleImage(WebCore::AccessibilityObject*, HWND window);
     virtual ~AccessibleImage() { }
 
 private:
Index: WebKit/win/WebKit.vcproj/Interfaces.vcproj
===================================================================
--- WebKit/win/WebKit.vcproj/Interfaces.vcproj	(revision 56859)
+++ WebKit/win/WebKit.vcproj/Interfaces.vcproj	(working copy)
@@ -37,7 +37,7 @@
 			/>
 			<Tool
 				Name="VCMIDLTool"
-				AdditionalIncludeDirectories="&quot;$(WebKitOutputDir)\obj\WebKit\DerivedSources&quot;;..\Interfaces;&quot;$(IntDir)\include&quot;"
+				AdditionalIncludeDirectories="&quot;$(WebKitOutputDir)\obj\WebKit\DerivedSources&quot;;..\Interfaces;..\Interfaces\IA2;&quot;$(IntDir)\include&quot;"
 				TypeLibraryName="$(WebKitOutputDir)\lib\WebKit.tlb"
 				OutputDirectory="$(WebKitOutputDir)\obj\WebKit\$(ProjectName)"
 			/>
@@ -105,7 +105,7 @@
 			/>
 			<Tool
 				Name="VCMIDLTool"
-				AdditionalIncludeDirectories="&quot;$(WebKitOutputDir)\obj\WebKit\DerivedSources&quot;;..\Interfaces;&quot;$(IntDir)\include&quot;"
+				AdditionalIncludeDirectories="&quot;$(WebKitOutputDir)\obj\WebKit\DerivedSources&quot;;..\Interfaces;..\Interfaces\IA2;&quot;$(IntDir)\include&quot;"
 				TypeLibraryName="$(WebKitOutputDir)\lib\WebKit.tlb"
 				OutputDirectory="$(WebKitOutputDir)\obj\WebKit\$(ProjectName)"
 			/>
@@ -1783,6 +1783,294 @@
 				/>
 			</FileConfiguration>
 		</File>
+		<File
+			RelativePath="..\Interfaces\IA2\Accessible2.idl"
+			>
+			<FileConfiguration
+				Name="Debug|Win32"
+				>
+				<Tool
+					Name="VCMIDLTool"
+				/>
+			</FileConfiguration>
+			<FileConfiguration
+				Name="Release|Win32"
+				>
+				<Tool
+					Name="VCMIDLTool"
+				/>
+			</FileConfiguration>
+		</File>
+		<File
+			RelativePath="..\Interfaces\IA2\AccessibleAction.idl"
+			>
+			<FileConfiguration
+				Name="Debug|Win32"
+				>
+				<Tool
+					Name="VCMIDLTool"
+				/>
+			</FileConfiguration>
+			<FileConfiguration
+				Name="Release|Win32"
+				>
+				<Tool
+					Name="VCMIDLTool"
+				/>
+			</FileConfiguration>
+		</File>
+		<File
+			RelativePath="..\Interfaces\IA2\AccessibleApplication.idl"
+			>
+			<FileConfiguration
+				Name="Debug|Win32"
+				>
+				<Tool
+					Name="VCMIDLTool"
+				/>
+			</FileConfiguration>
+			<FileConfiguration
+				Name="Release|Win32"
+				>
+				<Tool
+					Name="VCMIDLTool"
+				/>
+			</FileConfiguration>
+		</File>
+		<File
+			RelativePath="..\Interfaces\IA2\AccessibleComponent.idl"
+			>
+			<FileConfiguration
+				Name="Debug|Win32"
+				>
+				<Tool
+					Name="VCMIDLTool"
+				/>
+			</FileConfiguration>
+			<FileConfiguration
+				Name="Release|Win32"
+				>
+				<Tool
+					Name="VCMIDLTool"
+				/>
+			</FileConfiguration>
+		</File>
+		<File
+			RelativePath="..\Interfaces\IA2\AccessibleEditableText.idl"
+			>
+			<FileConfiguration
+				Name="Debug|Win32"
+				>
+				<Tool
+					Name="VCMIDLTool"
+				/>
+			</FileConfiguration>
+			<FileConfiguration
+				Name="Release|Win32"
+				>
+				<Tool
+					Name="VCMIDLTool"
+				/>
+			</FileConfiguration>
+		</File>
+		<File
+			RelativePath="..\Interfaces\IA2\AccessibleEventId.idl"
+			>
+			<FileConfiguration
+				Name="Debug|Win32"
+				>
+				<Tool
+					Name="VCMIDLTool"
+				/>
+			</FileConfiguration>
+			<FileConfiguration
+				Name="Release|Win32"
+				>
+				<Tool
+					Name="VCMIDLTool"
+				/>
+			</FileConfiguration>
+		</File>
+		<File
+			RelativePath="..\Interfaces\IA2\AccessibleHyperlink.idl"
+			>
+			<FileConfiguration
+				Name="Debug|Win32"
+				>
+				<Tool
+					Name="VCMIDLTool"
+				/>
+			</FileConfiguration>
+			<FileConfiguration
+				Name="Release|Win32"
+				>
+				<Tool
+					Name="VCMIDLTool"
+				/>
+			</FileConfiguration>
+		</File>
+		<File
+			RelativePath="..\Interfaces\IA2\AccessibleHypertext.idl"
+			>
+			<FileConfiguration
+				Name="Debug|Win32"
+				>
+				<Tool
+					Name="VCMIDLTool"
+				/>
+			</FileConfiguration>
+			<FileConfiguration
+				Name="Release|Win32"
+				>
+				<Tool
+					Name="VCMIDLTool"
+				/>
+			</FileConfiguration>
+		</File>
+		<File
+			RelativePath="..\Interfaces\IA2\AccessibleImage.idl"
+			>
+			<FileConfiguration
+				Name="Debug|Win32"
+				>
+				<Tool
+					Name="VCMIDLTool"
+				/>
+			</FileConfiguration>
+			<FileConfiguration
+				Name="Release|Win32"
+				>
+				<Tool
+					Name="VCMIDLTool"
+				/>
+			</FileConfiguration>
+		</File>
+		<File
+			RelativePath="..\Interfaces\IA2\AccessibleRelation.idl"
+			>
+			<FileConfiguration
+				Name="Debug|Win32"
+				>
+				<Tool
+					Name="VCMIDLTool"
+				/>
+			</FileConfiguration>
+			<FileConfiguration
+				Name="Release|Win32"
+				>
+				<Tool
+					Name="VCMIDLTool"
+				/>
+			</FileConfiguration>
+		</File>
+		<File
+			RelativePath="..\Interfaces\IA2\AccessibleRole.idl"
+			>
+			<FileConfiguration
+				Name="Debug|Win32"
+				>
+				<Tool
+					Name="VCMIDLTool"
+				/>
+			</FileConfiguration>
+			<FileConfiguration
+				Name="Release|Win32"
+				>
+				<Tool
+					Name="VCMIDLTool"
+				/>
+			</FileConfiguration>
+		</File>
+		<File
+			RelativePath="..\Interfaces\IA2\AccessibleStates.idl"
+			>
+			<FileConfiguration
+				Name="Debug|Win32"
+				>
+				<Tool
+					Name="VCMIDLTool"
+				/>
+			</FileConfiguration>
+			<FileConfiguration
+				Name="Release|Win32"
+				>
+				<Tool
+					Name="VCMIDLTool"
+				/>
+			</FileConfiguration>
+		</File>
+		<File
+			RelativePath="..\Interfaces\IA2\AccessibleTable.idl"
+			>
+			<FileConfiguration
+				Name="Debug|Win32"
+				>
+				<Tool
+					Name="VCMIDLTool"
+				/>
+			</FileConfiguration>
+			<FileConfiguration
+				Name="Release|Win32"
+				>
+				<Tool
+					Name="VCMIDLTool"
+				/>
+			</FileConfiguration>
+		</File>
+		<File
+			RelativePath="..\Interfaces\IA2\AccessibleText.idl"
+			>
+			<FileConfiguration
+				Name="Debug|Win32"
+				>
+				<Tool
+					Name="VCMIDLTool"
+				/>
+			</FileConfiguration>
+			<FileConfiguration
+				Name="Release|Win32"
+				>
+				<Tool
+					Name="VCMIDLTool"
+				/>
+			</FileConfiguration>
+		</File>
+		<File
+			RelativePath="..\Interfaces\IA2\AccessibleValue.idl"
+			>
+			<FileConfiguration
+				Name="Debug|Win32"
+				>
+				<Tool
+					Name="VCMIDLTool"
+				/>
+			</FileConfiguration>
+			<FileConfiguration
+				Name="Release|Win32"
+				>
+				<Tool
+					Name="VCMIDLTool"
+				/>
+			</FileConfiguration>
+		</File>
+		<File
+			RelativePath="..\Interfaces\IA2\IA2CommonTypes.idl"
+			>
+			<FileConfiguration
+				Name="Debug|Win32"
+				>
+				<Tool
+					Name="VCMIDLTool"
+				/>
+			</FileConfiguration>
+			<FileConfiguration
+				Name="Release|Win32"
+				>
+				<Tool
+					Name="VCMIDLTool"
+				/>
+			</FileConfiguration>
+		</File>
 	</Files>
 	<Globals>
 	</Globals>
Index: WebKit/win/WebKit.vcproj/WebKitGUID.vcproj
===================================================================
--- WebKit/win/WebKit.vcproj/WebKitGUID.vcproj	(revision 56859)
+++ WebKit/win/WebKit.vcproj/WebKitGUID.vcproj	(working copy)
@@ -264,6 +264,54 @@
 			RelativePath="$(WebKitOutputDir)\obj\WebKit\Interfaces\WebKit_i.c"
 			>
 		</File>
+		<File
+			RelativePath="$(WebKitOutputDir)\obj\WebKit\Interfaces\Accessible2_i.c"
+			>
+		</File>
+		<File
+			RelativePath="$(WebKitOutputDir)\obj\WebKit\Interfaces\AccessibleAction_i.c"
+			>
+		</File>
+		<File
+			RelativePath="$(WebKitOutputDir)\obj\WebKit\Interfaces\AccessibleApplication_i.c"
+			>
+		</File>
+		<File
+			RelativePath="$(WebKitOutputDir)\obj\WebKit\Interfaces\AccessibleComponent_i.c"
+			>
+		</File>
+		<File
+			RelativePath="$(WebKitOutputDir)\obj\WebKit\Interfaces\AccessibleEditableText_i.c"
+			>
+		</File>
+		<File
+			RelativePath="$(WebKitOutputDir)\obj\WebKit\Interfaces\AccessibleHyperlink_i.c"
+			>
+		</File>
+		<File
+			RelativePath="$(WebKitOutputDir)\obj\WebKit\Interfaces\AccessibleHypertext_i.c"
+			>
+		</File>
+		<File
+			RelativePath="$(WebKitOutputDir)\obj\WebKit\Interfaces\AccessibleImage_i.c"
+			>
+		</File>
+		<File
+			RelativePath="$(WebKitOutputDir)\obj\WebKit\Interfaces\AccessibleRelation_i.c"
+			>
+		</File>
+		<File
+			RelativePath="$(WebKitOutputDir)\obj\WebKit\Interfaces\AccessibleTable_i.c"
+			>
+		</File>
+		<File
+			RelativePath="$(WebKitOutputDir)\obj\WebKit\Interfaces\AccessibleText_i.c"
+			>
+		</File>
+		<File
+			RelativePath="$(WebKitOutputDir)\obj\WebKit\Interfaces\AccessibleValue_i.c"
+			>
+		</File>
 	</Files>
 	<Globals>
 	</Globals>
Index: WebKit/win/AccessibleBase.cpp
===================================================================
--- WebKit/win/AccessibleBase.cpp	(revision 56859)
+++ WebKit/win/AccessibleBase.cpp	(working copy)
@@ -46,14 +46,16 @@
 #include <WebCore/RenderFrame.h>
 #include <WebCore/RenderObject.h>
 #include <WebCore/RenderView.h>
+#include "AccessibleDocument.h"
 #include <oleacc.h>
 #include <wtf/RefPtr.h>
 
 using namespace WebCore;
 
-AccessibleBase::AccessibleBase(AccessibilityObject* obj)
+AccessibleBase::AccessibleBase(AccessibilityObject* obj, HWND window)
     : AccessibilityObjectWrapper(obj)
     , m_refCount(0)
+    , m_window(window)
 {
     ASSERT_ARG(obj, obj);
     m_object->setWrapper(this);
@@ -67,22 +69,21 @@
     gClassNameCount.remove("AccessibleBase");
 }
 
-AccessibleBase* AccessibleBase::createInstance(AccessibilityObject* obj)
+AccessibleBase* AccessibleBase::createInstance(AccessibilityObject* obj, HWND window)
 {
     ASSERT_ARG(obj, obj);
 
     if (obj->isImage())
-        return new AccessibleImage(obj);
+        return new AccessibleImage(obj, window);
 
-    return new AccessibleBase(obj);
+    if (obj->isDocument())
+        return new AccessibleDocument(obj->document(), window);
+
+    return new AccessibleBase(obj, window);
 }
 
 HRESULT AccessibleBase::QueryService(REFGUID guidService, REFIID riid, void **ppvObject)
 {
-    if (!IsEqualGUID(guidService, SID_AccessibleComparable)) {
-        *ppvObject = 0;
-        return E_INVALIDARG;
-    }
     return QueryInterface(riid, ppvObject);
 }
 
@@ -95,8 +96,8 @@
         *ppvObject = static_cast<IAccessible*>(this);
     else if (IsEqualGUID(riid, __uuidof(IUnknown)))
         *ppvObject = static_cast<IAccessible*>(this);
-    else if (IsEqualGUID(riid, __uuidof(IAccessibleComparable)))
-        *ppvObject = static_cast<IAccessibleComparable*>(this);
+    else if (IsEqualGUID(riid, __uuidof(IAccessible2)))
+        *ppvObject = static_cast<IAccessible2*>(this);
     else if (IsEqualGUID(riid, __uuidof(IServiceProvider)))
         *ppvObject = static_cast<IServiceProvider*>(this);
     else if (IsEqualGUID(riid, __uuidof(AccessibleBase)))
@@ -133,10 +134,7 @@
         return S_OK;
     }
 
-    if (!m_object->topDocumentFrameView())
-        return E_FAIL;
-
-    return WebView::AccessibleObjectFromWindow(m_object->topDocumentFrameView()->hostWindow()->platformPageClient(),
+    return WebView::AccessibleObjectFromWindow(m_window,
         OBJID_WINDOW, __uuidof(IAccessible), reinterpret_cast<void**>(parent));
 }
 
@@ -244,7 +242,7 @@
     }
 
     pvRole->vt = VT_I4;
-    pvRole->lVal = wrapper(childObj)->role();
+    pvRole->lVal = wrapper(childObj)->MSAARole();
     return S_OK;
 }
 
@@ -262,66 +260,7 @@
         return hr;
 
     pvState->vt = VT_I4;
-    pvState->lVal = 0;
-
-    if (childObj->isLinked())
-        pvState->lVal |= STATE_SYSTEM_LINKED;
-
-    if (childObj->isHovered())
-        pvState->lVal |= STATE_SYSTEM_HOTTRACKED;
-
-    if (!childObj->isEnabled())
-        pvState->lVal |= STATE_SYSTEM_UNAVAILABLE;
-
-    if (childObj->isReadOnly())
-        pvState->lVal |= STATE_SYSTEM_READONLY;
-
-    if (childObj->isOffScreen())
-        pvState->lVal |= STATE_SYSTEM_OFFSCREEN;
-
-    if (childObj->isPasswordField())
-        pvState->lVal |= STATE_SYSTEM_PROTECTED;
-
-    if (childObj->isIndeterminate())
-        pvState->lVal |= STATE_SYSTEM_INDETERMINATE;
-
-    if (childObj->isChecked())
-        pvState->lVal |= STATE_SYSTEM_CHECKED;
-
-    if (childObj->isPressed())
-        pvState->lVal |= STATE_SYSTEM_PRESSED;
-
-    if (childObj->isFocused())
-        pvState->lVal |= STATE_SYSTEM_FOCUSED;
-
-    if (childObj->isVisited())
-        pvState->lVal |= STATE_SYSTEM_TRAVERSED;
-
-    if (childObj->canSetFocusAttribute())
-        pvState->lVal |= STATE_SYSTEM_FOCUSABLE;
-
-    if (childObj->isSelected())
-        pvState->lVal |= STATE_SYSTEM_SELECTED;
-
-    if (childObj->canSetSelectedAttribute())
-        pvState->lVal |= STATE_SYSTEM_SELECTABLE;
-
-    if (childObj->isMultiSelectable())
-        pvState->lVal |= STATE_SYSTEM_EXTSELECTABLE | STATE_SYSTEM_MULTISELECTABLE;
-
-    if (!childObj->isVisible())
-        pvState->lVal |= STATE_SYSTEM_INVISIBLE;
-
-    if (childObj->isCollapsed())
-        pvState->lVal |= STATE_SYSTEM_COLLAPSED;
-
-    if (childObj->roleValue() == PopUpButtonRole) {
-        pvState->lVal |= STATE_SYSTEM_HASPOPUP;
-
-        if (!childObj->isCollapsed())
-            pvState->lVal |= STATE_SYSTEM_EXPANDED;
-    }
-
+    pvState->lVal = wrapper(childObj)->state();
     return S_OK;
 }
 
@@ -395,8 +334,11 @@
         return hr;
 
     if (selectionFlags & SELFLAG_TAKEFOCUS)
-        childObject->setFocused(true);
+        wrapper(childObject)->takeFocus();
 
+    if (selectionFlags == SELFLAG_TAKEFOCUS)
+        return S_OK;
+
     AccessibilityObject* parentObject = childObject->parentObject();
     if (!parentObject)
         return E_INVALIDARG;
@@ -609,6 +551,123 @@
     return S_OK;
 }
 
+// IAccessible2
+HRESULT STDMETHODCALLTYPE AccessibleBase::get_nRelations(long* nRelations)
+{
+    if (!m_object)
+        return E_FAIL;
+    *nRelations = 0;
+    return S_OK;
+}
+
+HRESULT STDMETHODCALLTYPE AccessibleBase::get_relation(long relationIndex, IAccessibleRelation** relation)
+{
+    return E_NOTIMPL;
+}
+
+HRESULT STDMETHODCALLTYPE AccessibleBase::get_relations(long maxRelations, IAccessibleRelation** relations, long* nRelations)
+{
+    return E_NOTIMPL;
+}
+
+HRESULT STDMETHODCALLTYPE AccessibleBase::role(long* role)
+{
+    if (!m_object)
+        return E_FAIL;
+    *role = MSAARole();
+    return S_OK;
+}
+
+HRESULT STDMETHODCALLTYPE AccessibleBase::scrollTo(IA2ScrollType scrollType)
+{
+    if (!m_object)
+        return E_FAIL;
+    return S_FALSE;
+}
+
+HRESULT STDMETHODCALLTYPE AccessibleBase::scrollToPoint(IA2CoordinateType coordinateType, long x, long y)
+{
+    if (!m_object)
+        return E_FAIL;
+    return S_FALSE;
+}
+
+HRESULT STDMETHODCALLTYPE AccessibleBase::get_groupPosition(long* groupLevel, long* similarItemsInGroup, long* positionInGroup)
+{
+    return E_NOTIMPL;
+}
+
+HRESULT STDMETHODCALLTYPE AccessibleBase::get_states(AccessibleStates* states)
+{
+    if (!m_object)
+        return E_FAIL;
+    *states = 0;
+    return S_OK;
+}
+
+HRESULT STDMETHODCALLTYPE AccessibleBase::get_extendedRole(BSTR* extendedRole)
+{
+    if (!m_object)
+        return E_FAIL;
+    return S_FALSE;
+}
+
+HRESULT STDMETHODCALLTYPE AccessibleBase::get_localizedExtendedRole(BSTR* localizedExtendedRole)
+{
+    if (!m_object)
+        return E_FAIL;
+    return S_FALSE;
+}
+
+HRESULT STDMETHODCALLTYPE AccessibleBase::get_nExtendedStates(long* nExtendedStates)
+{
+    if (!m_object)
+        return E_FAIL;
+    *nExtendedStates = 0;
+    return S_OK;
+}
+
+HRESULT STDMETHODCALLTYPE AccessibleBase::get_extendedStates(long maxExtendedStates, BSTR** extendedStates, long* nExtendedStates)
+{
+    return E_NOTIMPL;
+}
+
+HRESULT STDMETHODCALLTYPE AccessibleBase::get_localizedExtendedStates(long maxLocalizedExtendedStates, BSTR** localizedExtendedStates, long* nLocalizedExtendedStates)
+{
+    return E_NOTIMPL;
+}
+
+HRESULT STDMETHODCALLTYPE AccessibleBase::get_uniqueID(long* uniqueID)
+{
+    if (!m_object)
+        return E_FAIL;
+    *uniqueID = static_cast<long>(m_object->axObjectID());
+    return S_OK;
+}
+
+HRESULT STDMETHODCALLTYPE AccessibleBase::get_windowHandle(HWND* windowHandle)
+{
+    *windowHandle = m_window;
+    return S_OK;
+}
+
+HRESULT STDMETHODCALLTYPE AccessibleBase::get_indexInParent(long* indexInParent)
+{
+    return E_NOTIMPL;
+}
+
+HRESULT STDMETHODCALLTYPE AccessibleBase::get_locale(IA2Locale* locale)
+{
+    return E_NOTIMPL;
+}
+
+HRESULT STDMETHODCALLTYPE AccessibleBase::get_attributes(BSTR* attributes)
+{
+    if (!m_object)
+        return E_FAIL;
+    return S_FALSE;
+}
+
 // AccessibleBase
 String AccessibleBase::name() const
 {
@@ -672,11 +731,81 @@
     }
 }
 
-long AccessibleBase::role() const
+long AccessibleBase::MSAARole() const
 {
-    return MSAARole(m_object->roleValueForMSAA());
+    return ::MSAARole(m_object->roleValueForMSAA());
 }
 
+long AccessibleBase::state() const
+{
+    long state = 0;
+
+    if (m_object->isLinked())
+        state |= STATE_SYSTEM_LINKED;
+
+    if (m_object->isHovered())
+        state |= STATE_SYSTEM_HOTTRACKED;
+
+    if (!m_object->isEnabled())
+        state |= STATE_SYSTEM_UNAVAILABLE;
+
+    if (m_object->isReadOnly())
+        state |= STATE_SYSTEM_READONLY;
+
+    if (m_object->isOffScreen())
+        state |= STATE_SYSTEM_OFFSCREEN;
+
+    if (m_object->isPasswordField())
+        state |= STATE_SYSTEM_PROTECTED;
+
+    if (m_object->isIndeterminate())
+        state |= STATE_SYSTEM_INDETERMINATE;
+
+    if (m_object->isChecked())
+        state |= STATE_SYSTEM_CHECKED;
+
+    if (m_object->isPressed())
+        state |= STATE_SYSTEM_PRESSED;
+
+    if (m_object->isFocused())
+        state |= STATE_SYSTEM_FOCUSED;
+
+    if (m_object->isVisited())
+        state |= STATE_SYSTEM_TRAVERSED;
+
+    if (m_object->canSetFocusAttribute())
+        state |= STATE_SYSTEM_FOCUSABLE;
+
+    if (m_object->isSelected())
+        state |= STATE_SYSTEM_SELECTED;
+
+    if (m_object->canSetSelectedAttribute())
+        state |= STATE_SYSTEM_SELECTABLE;
+
+    if (m_object->isMultiSelectable())
+        state |= STATE_SYSTEM_EXTSELECTABLE | STATE_SYSTEM_MULTISELECTABLE;
+
+    if (!m_object->isVisible())
+        state |= STATE_SYSTEM_INVISIBLE;
+
+    if (m_object->isCollapsed())
+        state |= STATE_SYSTEM_COLLAPSED;
+
+    if (m_object->roleValue() == PopUpButtonRole) {
+        state |= STATE_SYSTEM_HASPOPUP;
+
+        if (!m_object->isCollapsed())
+            state |= STATE_SYSTEM_EXPANDED;
+    }
+
+    return state;
+}
+
+void AccessibleBase::takeFocus()
+{
+    m_object->setFocused(true);
+}
+
 HRESULT AccessibleBase::getAccessibilityObjectForChild(VARIANT vChild, AccessibilityObject*& childObj) const
 {
     childObj = 0;
@@ -715,13 +844,6 @@
 {
     AccessibleBase* result = static_cast<AccessibleBase*>(obj->wrapper());
     if (!result)
-        result = createInstance(obj);
+        result = createInstance(obj, m_window);
     return result;
 }
-
-HRESULT AccessibleBase::isSameObject(IAccessibleComparable* other, BOOL* result)
-{
-    COMPtr<AccessibleBase> otherAccessibleBase(Query, other);
-    *result = (otherAccessibleBase == this || otherAccessibleBase->m_object == m_object);
-    return S_OK;
-}
Index: WebCore/dom/Document.cpp
===================================================================
--- WebCore/dom/Document.cpp	(revision 56859)
+++ WebCore/dom/Document.cpp	(working copy)
@@ -1863,7 +1863,7 @@
             view()->layout();
     }
 
-#if PLATFORM(MAC)
+#if PLATFORM(MAC) || PLATFORM(WIN)
     if (f && renderObject && this == topDocument() && AXObjectCache::accessibilityEnabled()) {
         // The AX cache may have been cleared at this point, but we need to make sure it contains an
         // AX object to send the notification to. getOrCreate will make sure that an valid AX object
Index: WebCore/page/FrameView.cpp
===================================================================
--- WebCore/page/FrameView.cpp	(revision 56859)
+++ WebCore/page/FrameView.cpp	(working copy)
@@ -750,7 +750,7 @@
     
     m_layoutCount++;
 
-#if PLATFORM(MAC)
+#if PLATFORM(MAC) || PLATFORM(WIN)
     if (AXObjectCache::accessibilityEnabled())
         root->document()->axObjectCache()->postNotification(root, AXObjectCache::AXLayoutComplete, true);
 #endif
Index: WebCore/accessibility/AccessibilityObject.h
===================================================================
--- WebCore/accessibility/AccessibilityObject.h	(revision 56859)
+++ WebCore/accessibility/AccessibilityObject.h	(working copy)
@@ -291,6 +291,7 @@
     bool isTabList() const { return roleValue() == TabListRole; }
     bool isTabItem() const { return roleValue() == TabRole; }
     bool isRadioGroup() const { return roleValue() == RadioGroupRole; }
+    virtual bool isDocument() const { return false; }
     bool isComboBox() const { return roleValue() == ComboBoxRole; }
     bool isTree() const { return roleValue() == TreeRole; }
     bool isTreeItem() const { return roleValue() == TreeItemRole; }
Index: WebCore/accessibility/AccessibilityRenderObject.h
===================================================================
--- WebCore/accessibility/AccessibilityRenderObject.h	(revision 56859)
+++ WebCore/accessibility/AccessibilityRenderObject.h	(working copy)
@@ -88,6 +88,7 @@
     virtual bool isControl() const;
     virtual bool isFieldset() const;
     virtual bool isGroup() const;
+    virtual bool isDocument() const;
 
     virtual bool isEnabled() const;
     virtual bool isSelected() const;
Index: WebCore/accessibility/win/AXObjectCacheWin.cpp
===================================================================
--- WebCore/accessibility/win/AXObjectCacheWin.cpp	(revision 56859)
+++ WebCore/accessibility/win/AXObjectCacheWin.cpp	(working copy)
@@ -33,6 +33,8 @@
 #include "Page.h"
 #include "RenderObject.h"
 
+#define IA2_EVENT_DOCUMENT_LOAD_COMPLETE 261
+
 using namespace std;
 
 namespace WebCore {
@@ -74,6 +76,10 @@
 
     DWORD msaaEvent;
     switch (notification) {
+        case AXCheckedStateChanged:
+            msaaEvent = EVENT_OBJECT_STATECHANGE;
+            break;
+
         case AXFocusedUIElementChanged:
         case AXActiveDescendantChanged:
             msaaEvent = EVENT_OBJECT_FOCUS;
@@ -83,6 +89,14 @@
             msaaEvent = EVENT_SYSTEM_SCROLLINGSTART;
             break;
 
+        case AXLayoutComplete:
+            msaaEvent = EVENT_OBJECT_REORDER;
+            break;
+
+        case AXLoadComplete:
+            msaaEvent = IA2_EVENT_DOCUMENT_LOAD_COMPLETE;
+            break;
+
         case AXValueChanged:
         case AXMenuListValueChanged:
             msaaEvent = EVENT_OBJECT_VALUECHANGE;
Index: WebCore/accessibility/AccessibilityRenderObject.cpp
===================================================================
--- WebCore/accessibility/AccessibilityRenderObject.cpp	(revision 56859)
+++ WebCore/accessibility/AccessibilityRenderObject.cpp	(working copy)
@@ -512,6 +512,12 @@
 {
     return roleValue() == GroupRole;
 }
+
+bool AccessibilityRenderObject::isDocument() const
+{
+    Node* node = m_renderer->node();
+    return node && node->isDocumentNode();
+}
     
 AccessibilityObject* AccessibilityRenderObject::selectedRadioButton()
 {
