tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

nsEventShell.cpp (2079B)


      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/. */
      5 
      6 #include "nsEventShell.h"
      7 
      8 #include "nsAccessibilityService.h"
      9 #include "Logging.h"
     10 
     11 #include "mozilla/dom/DOMStringList.h"
     12 
     13 using namespace mozilla;
     14 using namespace mozilla::a11y;
     15 
     16 ////////////////////////////////////////////////////////////////////////////////
     17 // nsEventShell
     18 ////////////////////////////////////////////////////////////////////////////////
     19 
     20 void nsEventShell::FireEvent(AccEvent* aEvent) {
     21  if (!aEvent || aEvent->mEventRule == AccEvent::eDoNotEmit) return;
     22 
     23  LocalAccessible* accessible = aEvent->GetAccessible();
     24  NS_ENSURE_TRUE_VOID(accessible);
     25 
     26 #ifdef A11Y_LOG
     27  if (logging::IsEnabled(logging::eEvents)) {
     28    logging::MsgBegin("EVENTS", "events fired");
     29    nsAutoString type;
     30    GetAccService()->GetStringEventType(aEvent->GetEventType(), type);
     31    logging::MsgEntry("type: %s", NS_ConvertUTF16toUTF8(type).get());
     32    if (aEvent->GetEventType() == nsIAccessibleEvent::EVENT_STATE_CHANGE) {
     33      AccStateChangeEvent* event = downcast_accEvent(aEvent);
     34      RefPtr<dom::DOMStringList> stringStates =
     35          GetAccService()->GetStringStates(event->GetState());
     36      nsAutoString state;
     37      stringStates->Item(0, state);
     38      logging::MsgEntry("state: %s = %s", NS_ConvertUTF16toUTF8(state).get(),
     39                        event->IsStateEnabled() ? "true" : "false");
     40    }
     41    logging::AccessibleInfo("target", aEvent->GetAccessible());
     42    logging::MsgEnd();
     43  }
     44 #endif
     45 
     46  accessible->HandleAccEvent(aEvent);
     47  aEvent->mEventRule = AccEvent::eDoNotEmit;
     48 }
     49 
     50 void nsEventShell::FireEvent(uint32_t aEventType, LocalAccessible* aAccessible,
     51                             EIsFromUserInput aIsFromUserInput) {
     52  NS_ENSURE_TRUE_VOID(aAccessible);
     53 
     54  RefPtr<AccEvent> event =
     55      new AccEvent(aEventType, aAccessible, aIsFromUserInput);
     56 
     57  FireEvent(event);
     58 }