accessible/src/windows/msaa/HTMLWin32ObjectAccessible.cpp

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     2 /* This Source Code Form is subject to the terms of the Mozilla Public
     3  * License, v. 2.0. If a copy of the MPL was not distributed with this
     4  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     6 #include "HTMLWin32ObjectAccessible.h"
     8 #include "Role.h"
     9 #include "States.h"
    11 using namespace mozilla::a11y;
    13 ////////////////////////////////////////////////////////////////////////////////
    14 // HTMLWin32ObjectOwnerAccessible
    15 ////////////////////////////////////////////////////////////////////////////////
    17 HTMLWin32ObjectOwnerAccessible::
    18   HTMLWin32ObjectOwnerAccessible(nsIContent* aContent,
    19                                  DocAccessible* aDoc, void* aHwnd) :
    20   AccessibleWrap(aContent, aDoc), mHwnd(aHwnd)
    21 {
    22   // Our only child is a HTMLWin32ObjectAccessible object.
    23   if (mHwnd)
    24     mNativeAccessible = new HTMLWin32ObjectAccessible(mHwnd);
    25 }
    27 ////////////////////////////////////////////////////////////////////////////////
    28 // HTMLWin32ObjectOwnerAccessible: Accessible implementation
    30 void
    31 HTMLWin32ObjectOwnerAccessible::Shutdown()
    32 {
    33   AccessibleWrap::Shutdown();
    34   mNativeAccessible = nullptr;
    35 }
    37 role
    38 HTMLWin32ObjectOwnerAccessible::NativeRole()
    39 {
    40   return roles::EMBEDDED_OBJECT;
    41 }
    43 bool
    44 HTMLWin32ObjectOwnerAccessible::NativelyUnavailable() const
    45 {
    46   // XXX: No HWND means this is windowless plugin which is not accessible in
    47   // the meantime.
    48   return !mHwnd;
    49 }
    51 ////////////////////////////////////////////////////////////////////////////////
    52 // HTMLWin32ObjectOwnerAccessible: Accessible protected implementation
    54 void
    55 HTMLWin32ObjectOwnerAccessible::CacheChildren()
    56 {
    57   if (mNativeAccessible)
    58     AppendChild(mNativeAccessible);
    59 }
    62 ////////////////////////////////////////////////////////////////////////////////
    63 // HTMLWin32ObjectAccessible
    64 ////////////////////////////////////////////////////////////////////////////////
    66 HTMLWin32ObjectAccessible::HTMLWin32ObjectAccessible(void* aHwnd) :
    67   DummyAccessible()
    68 {
    69   mHwnd = aHwnd;
    70   if (mHwnd) {
    71     // The plugin is not windowless. In this situation we use 
    72     // use its inner child owned by the plugin so that we don't get
    73     // in an infinite loop, where the WM_GETOBJECT's get forwarded
    74     // back to us and create another HTMLWin32ObjectAccessible
    75     HWND childWnd = ::GetWindow((HWND)aHwnd, GW_CHILD);
    76     if (childWnd) {
    77       mHwnd = childWnd;
    78     }
    79   }
    80 }
    82 NS_IMETHODIMP 
    83 HTMLWin32ObjectAccessible::GetNativeInterface(void** aNativeAccessible)
    84 {
    85   if (mHwnd) {
    86     ::AccessibleObjectFromWindow(static_cast<HWND>(mHwnd),
    87                                  OBJID_WINDOW, IID_IAccessible,
    88                                  aNativeAccessible);
    89   }
    90   return NS_OK;
    91 }

mercurial