michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #include "HTMLWin32ObjectAccessible.h" michael@0: michael@0: #include "Role.h" michael@0: #include "States.h" michael@0: michael@0: using namespace mozilla::a11y; michael@0: michael@0: //////////////////////////////////////////////////////////////////////////////// michael@0: // HTMLWin32ObjectOwnerAccessible michael@0: //////////////////////////////////////////////////////////////////////////////// michael@0: michael@0: HTMLWin32ObjectOwnerAccessible:: michael@0: HTMLWin32ObjectOwnerAccessible(nsIContent* aContent, michael@0: DocAccessible* aDoc, void* aHwnd) : michael@0: AccessibleWrap(aContent, aDoc), mHwnd(aHwnd) michael@0: { michael@0: // Our only child is a HTMLWin32ObjectAccessible object. michael@0: if (mHwnd) michael@0: mNativeAccessible = new HTMLWin32ObjectAccessible(mHwnd); michael@0: } michael@0: michael@0: //////////////////////////////////////////////////////////////////////////////// michael@0: // HTMLWin32ObjectOwnerAccessible: Accessible implementation michael@0: michael@0: void michael@0: HTMLWin32ObjectOwnerAccessible::Shutdown() michael@0: { michael@0: AccessibleWrap::Shutdown(); michael@0: mNativeAccessible = nullptr; michael@0: } michael@0: michael@0: role michael@0: HTMLWin32ObjectOwnerAccessible::NativeRole() michael@0: { michael@0: return roles::EMBEDDED_OBJECT; michael@0: } michael@0: michael@0: bool michael@0: HTMLWin32ObjectOwnerAccessible::NativelyUnavailable() const michael@0: { michael@0: // XXX: No HWND means this is windowless plugin which is not accessible in michael@0: // the meantime. michael@0: return !mHwnd; michael@0: } michael@0: michael@0: //////////////////////////////////////////////////////////////////////////////// michael@0: // HTMLWin32ObjectOwnerAccessible: Accessible protected implementation michael@0: michael@0: void michael@0: HTMLWin32ObjectOwnerAccessible::CacheChildren() michael@0: { michael@0: if (mNativeAccessible) michael@0: AppendChild(mNativeAccessible); michael@0: } michael@0: michael@0: michael@0: //////////////////////////////////////////////////////////////////////////////// michael@0: // HTMLWin32ObjectAccessible michael@0: //////////////////////////////////////////////////////////////////////////////// michael@0: michael@0: HTMLWin32ObjectAccessible::HTMLWin32ObjectAccessible(void* aHwnd) : michael@0: DummyAccessible() michael@0: { michael@0: mHwnd = aHwnd; michael@0: if (mHwnd) { michael@0: // The plugin is not windowless. In this situation we use michael@0: // use its inner child owned by the plugin so that we don't get michael@0: // in an infinite loop, where the WM_GETOBJECT's get forwarded michael@0: // back to us and create another HTMLWin32ObjectAccessible michael@0: HWND childWnd = ::GetWindow((HWND)aHwnd, GW_CHILD); michael@0: if (childWnd) { michael@0: mHwnd = childWnd; michael@0: } michael@0: } michael@0: } michael@0: michael@0: NS_IMETHODIMP michael@0: HTMLWin32ObjectAccessible::GetNativeInterface(void** aNativeAccessible) michael@0: { michael@0: if (mHwnd) { michael@0: ::AccessibleObjectFromWindow(static_cast(mHwnd), michael@0: OBJID_WINDOW, IID_IAccessible, michael@0: aNativeAccessible); michael@0: } michael@0: return NS_OK; michael@0: } michael@0: