LCOV - code coverage report
Current view: top level - accessible/base - nsEventShell.cpp (source / functions) Hit Total Coverage
Test: output.info Lines: 1 30 3.3 %
Date: 2017-07-14 16:53:18 Functions: 0 3 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       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 "nsAccUtils.h"
       9             : 
      10             : #include "mozilla/StaticPtr.h"
      11             : 
      12             : using namespace mozilla;
      13             : using namespace mozilla::a11y;
      14             : 
      15             : ////////////////////////////////////////////////////////////////////////////////
      16             : // nsEventShell
      17             : ////////////////////////////////////////////////////////////////////////////////
      18             : 
      19             : void
      20           0 : nsEventShell::FireEvent(AccEvent* aEvent)
      21             : {
      22           0 :   if (!aEvent || aEvent->mEventRule == AccEvent::eDoNotEmit)
      23           0 :     return;
      24             : 
      25           0 :   Accessible* accessible = aEvent->GetAccessible();
      26           0 :   NS_ENSURE_TRUE_VOID(accessible);
      27             : 
      28           0 :   nsINode* node = accessible->GetNode();
      29           0 :   if (node) {
      30           0 :     sEventTargetNode = node;
      31           0 :     sEventFromUserInput = aEvent->IsFromUserInput();
      32             :   }
      33             : 
      34             : #ifdef A11Y_LOG
      35           0 :   if (logging::IsEnabled(logging::eEvents)) {
      36           0 :     logging::MsgBegin("EVENTS", "events fired");
      37           0 :     nsAutoString type;
      38           0 :     GetAccService()->GetStringEventType(aEvent->GetEventType(), type);
      39           0 :     logging::MsgEntry("type: %s", NS_ConvertUTF16toUTF8(type).get());
      40           0 :     logging::AccessibleInfo("target", aEvent->GetAccessible());
      41           0 :     logging::MsgEnd();
      42             :   }
      43             : #endif
      44             : 
      45           0 :   accessible->HandleAccEvent(aEvent);
      46           0 :   aEvent->mEventRule = AccEvent::eDoNotEmit;
      47             : 
      48           0 :   sEventTargetNode = nullptr;
      49             : }
      50             : 
      51             : void
      52           0 : nsEventShell::FireEvent(uint32_t aEventType, Accessible* aAccessible,
      53             :                         EIsFromUserInput aIsFromUserInput)
      54             : {
      55           0 :   NS_ENSURE_TRUE_VOID(aAccessible);
      56             : 
      57             :   RefPtr<AccEvent> event = new AccEvent(aEventType, aAccessible,
      58           0 :                                           aIsFromUserInput);
      59             : 
      60           0 :   FireEvent(event);
      61             : }
      62             : 
      63             : void
      64           0 : nsEventShell::GetEventAttributes(nsINode *aNode,
      65             :                                  nsIPersistentProperties *aAttributes)
      66             : {
      67           0 :   if (aNode != sEventTargetNode)
      68           0 :     return;
      69             : 
      70           0 :   nsAccUtils::SetAccAttr(aAttributes, nsGkAtoms::eventFromInput,
      71           0 :                          sEventFromUserInput ? NS_LITERAL_STRING("true") :
      72           0 :                                                NS_LITERAL_STRING("false"));
      73             : }
      74             : 
      75             : ////////////////////////////////////////////////////////////////////////////////
      76             : // nsEventShell: private
      77             : 
      78             : bool nsEventShell::sEventFromUserInput = false;
      79           3 : StaticRefPtr<nsINode> nsEventShell::sEventTargetNode;

Generated by: LCOV version 1.13