accessible/src/base/nsEventShell.cpp

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

     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 "nsEventShell.h"
     8 #include "nsAccUtils.h"
    10 #include "mozilla/StaticPtr.h"
    12 using namespace mozilla;
    13 using namespace mozilla::a11y;
    15 ////////////////////////////////////////////////////////////////////////////////
    16 // nsEventShell
    17 ////////////////////////////////////////////////////////////////////////////////
    19 void
    20 nsEventShell::FireEvent(AccEvent* aEvent)
    21 {
    22   if (!aEvent)
    23     return;
    25   Accessible* accessible = aEvent->GetAccessible();
    26   NS_ENSURE_TRUE_VOID(accessible);
    28   nsINode* node = accessible->GetNode();
    29   if (node) {
    30     sEventTargetNode = node;
    31     sEventFromUserInput = aEvent->IsFromUserInput();
    32   }
    34   accessible->HandleAccEvent(aEvent);
    36   sEventTargetNode = nullptr;
    37 }
    39 void
    40 nsEventShell::FireEvent(uint32_t aEventType, Accessible* aAccessible,
    41                         EIsFromUserInput aIsFromUserInput)
    42 {
    43   NS_ENSURE_TRUE_VOID(aAccessible);
    45   nsRefPtr<AccEvent> event = new AccEvent(aEventType, aAccessible,
    46                                           aIsFromUserInput);
    48   FireEvent(event);
    49 }
    51 void 
    52 nsEventShell::GetEventAttributes(nsINode *aNode,
    53                                  nsIPersistentProperties *aAttributes)
    54 {
    55   if (aNode != sEventTargetNode)
    56     return;
    58   nsAccUtils::SetAccAttr(aAttributes, nsGkAtoms::eventFromInput,
    59                          sEventFromUserInput ? NS_LITERAL_STRING("true") :
    60                                                NS_LITERAL_STRING("false"));
    61 }
    63 ////////////////////////////////////////////////////////////////////////////////
    64 // nsEventShell: private
    66 bool nsEventShell::sEventFromUserInput = false;
    67 StaticRefPtr<nsINode> nsEventShell::sEventTargetNode;

mercurial