accessible/src/windows/msaa/HTMLWin32ObjectAccessible.cpp

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/accessible/src/windows/msaa/HTMLWin32ObjectAccessible.cpp	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,92 @@
     1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.8 +
     1.9 +#include "HTMLWin32ObjectAccessible.h"
    1.10 +
    1.11 +#include "Role.h"
    1.12 +#include "States.h"
    1.13 +
    1.14 +using namespace mozilla::a11y;
    1.15 +
    1.16 +////////////////////////////////////////////////////////////////////////////////
    1.17 +// HTMLWin32ObjectOwnerAccessible
    1.18 +////////////////////////////////////////////////////////////////////////////////
    1.19 +
    1.20 +HTMLWin32ObjectOwnerAccessible::
    1.21 +  HTMLWin32ObjectOwnerAccessible(nsIContent* aContent,
    1.22 +                                 DocAccessible* aDoc, void* aHwnd) :
    1.23 +  AccessibleWrap(aContent, aDoc), mHwnd(aHwnd)
    1.24 +{
    1.25 +  // Our only child is a HTMLWin32ObjectAccessible object.
    1.26 +  if (mHwnd)
    1.27 +    mNativeAccessible = new HTMLWin32ObjectAccessible(mHwnd);
    1.28 +}
    1.29 +
    1.30 +////////////////////////////////////////////////////////////////////////////////
    1.31 +// HTMLWin32ObjectOwnerAccessible: Accessible implementation
    1.32 +
    1.33 +void
    1.34 +HTMLWin32ObjectOwnerAccessible::Shutdown()
    1.35 +{
    1.36 +  AccessibleWrap::Shutdown();
    1.37 +  mNativeAccessible = nullptr;
    1.38 +}
    1.39 +
    1.40 +role
    1.41 +HTMLWin32ObjectOwnerAccessible::NativeRole()
    1.42 +{
    1.43 +  return roles::EMBEDDED_OBJECT;
    1.44 +}
    1.45 +
    1.46 +bool
    1.47 +HTMLWin32ObjectOwnerAccessible::NativelyUnavailable() const
    1.48 +{
    1.49 +  // XXX: No HWND means this is windowless plugin which is not accessible in
    1.50 +  // the meantime.
    1.51 +  return !mHwnd;
    1.52 +}
    1.53 +
    1.54 +////////////////////////////////////////////////////////////////////////////////
    1.55 +// HTMLWin32ObjectOwnerAccessible: Accessible protected implementation
    1.56 +
    1.57 +void
    1.58 +HTMLWin32ObjectOwnerAccessible::CacheChildren()
    1.59 +{
    1.60 +  if (mNativeAccessible)
    1.61 +    AppendChild(mNativeAccessible);
    1.62 +}
    1.63 +
    1.64 +
    1.65 +////////////////////////////////////////////////////////////////////////////////
    1.66 +// HTMLWin32ObjectAccessible
    1.67 +////////////////////////////////////////////////////////////////////////////////
    1.68 +
    1.69 +HTMLWin32ObjectAccessible::HTMLWin32ObjectAccessible(void* aHwnd) :
    1.70 +  DummyAccessible()
    1.71 +{
    1.72 +  mHwnd = aHwnd;
    1.73 +  if (mHwnd) {
    1.74 +    // The plugin is not windowless. In this situation we use 
    1.75 +    // use its inner child owned by the plugin so that we don't get
    1.76 +    // in an infinite loop, where the WM_GETOBJECT's get forwarded
    1.77 +    // back to us and create another HTMLWin32ObjectAccessible
    1.78 +    HWND childWnd = ::GetWindow((HWND)aHwnd, GW_CHILD);
    1.79 +    if (childWnd) {
    1.80 +      mHwnd = childWnd;
    1.81 +    }
    1.82 +  }
    1.83 +}
    1.84 +
    1.85 +NS_IMETHODIMP 
    1.86 +HTMLWin32ObjectAccessible::GetNativeInterface(void** aNativeAccessible)
    1.87 +{
    1.88 +  if (mHwnd) {
    1.89 +    ::AccessibleObjectFromWindow(static_cast<HWND>(mHwnd),
    1.90 +                                 OBJID_WINDOW, IID_IAccessible,
    1.91 +                                 aNativeAccessible);
    1.92 +  }
    1.93 +  return NS_OK;
    1.94 +}
    1.95 +

mercurial