LCOV - code coverage report
Current view: top level - accessible/generic - DocAccessible-inl.h (source / functions) Hit Total Coverage
Test: output.info Lines: 0 74 0.0 %
Date: 2017-07-14 16:53:18 Functions: 0 15 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             : /* vim: set ts=2 et sw=2 tw=80: */
       3             : /* This Source Code Form is subject to the terms of the Mozilla Public
       4             :  * License, v. 2.0. If a copy of the MPL was not distributed with this file,
       5             :  * You can obtain one at http://mozilla.org/MPL/2.0/. */
       6             : 
       7             : #ifndef mozilla_a11y_DocAccessible_inl_h_
       8             : #define mozilla_a11y_DocAccessible_inl_h_
       9             : 
      10             : #include "DocAccessible.h"
      11             : #include "nsAccessibilityService.h"
      12             : #include "nsAccessiblePivot.h"
      13             : #include "NotificationController.h"
      14             : #include "States.h"
      15             : #include "nsIScrollableFrame.h"
      16             : #include "nsIDocumentInlines.h"
      17             : 
      18             : #ifdef A11Y_LOG
      19             : #include "Logging.h"
      20             : #endif
      21             : 
      22             : namespace mozilla {
      23             : namespace a11y {
      24             : 
      25             : inline Accessible*
      26           0 : DocAccessible::AccessibleOrTrueContainer(nsINode* aNode) const
      27             : {
      28             :   // HTML comboboxes have no-content list accessible as an intermediate
      29             :   // containing all options.
      30           0 :   Accessible* container = GetAccessibleOrContainer(aNode);
      31           0 :   if (container && container->IsHTMLCombobox()) {
      32           0 :     return container->FirstChild();
      33             :   }
      34           0 :   return container;
      35             : }
      36             : 
      37             : inline nsIAccessiblePivot*
      38           0 : DocAccessible::VirtualCursor()
      39             : {
      40           0 :   if (!mVirtualCursor) {
      41           0 :     mVirtualCursor = new nsAccessiblePivot(this);
      42           0 :     mVirtualCursor->AddObserver(this);
      43             :   }
      44           0 :   return mVirtualCursor;
      45             : }
      46             : 
      47             : inline void
      48           0 : DocAccessible::FireDelayedEvent(AccEvent* aEvent)
      49             : {
      50             : #ifdef A11Y_LOG
      51           0 :   if (logging::IsEnabled(logging::eDocLoad))
      52           0 :     logging::DocLoadEventFired(aEvent);
      53             : #endif
      54             : 
      55           0 :   mNotificationController->QueueEvent(aEvent);
      56           0 : }
      57             : 
      58             : inline void
      59           0 : DocAccessible::FireDelayedEvent(uint32_t aEventType, Accessible* aTarget)
      60             : {
      61           0 :   RefPtr<AccEvent> event = new AccEvent(aEventType, aTarget);
      62           0 :   FireDelayedEvent(event);
      63           0 : }
      64             : 
      65             : inline void
      66           0 : DocAccessible::BindChildDocument(DocAccessible* aDocument)
      67             : {
      68           0 :   mNotificationController->ScheduleChildDocBinding(aDocument);
      69           0 : }
      70             : 
      71             : template<class Class, class Arg>
      72             : inline void
      73           0 : DocAccessible::HandleNotification(Class* aInstance,
      74             :                                   typename TNotification<Class, Arg>::Callback aMethod,
      75             :                                   Arg* aArg)
      76             : {
      77           0 :   if (mNotificationController) {
      78           0 :     mNotificationController->HandleNotification<Class, Arg>(aInstance,
      79             :                                                             aMethod, aArg);
      80             :   }
      81           0 : }
      82             : 
      83             : inline void
      84           0 : DocAccessible::UpdateText(nsIContent* aTextNode)
      85             : {
      86           0 :   NS_ASSERTION(mNotificationController, "The document was shut down!");
      87             : 
      88             :   // Ignore the notification if initial tree construction hasn't been done yet.
      89           0 :   if (mNotificationController && HasLoadState(eTreeConstructed))
      90           0 :     mNotificationController->ScheduleTextUpdate(aTextNode);
      91           0 : }
      92             : 
      93             : inline void
      94           0 : DocAccessible::AddScrollListener()
      95             : {
      96             :   // Delay scroll initializing until the document has a root frame.
      97           0 :   if (!mPresShell->GetRootFrame())
      98           0 :     return;
      99             : 
     100           0 :   mDocFlags |= eScrollInitialized;
     101           0 :   nsIScrollableFrame* sf = mPresShell->GetRootScrollFrameAsScrollable();
     102           0 :   if (sf) {
     103           0 :     sf->AddScrollPositionListener(this);
     104             : 
     105             : #ifdef A11Y_LOG
     106           0 :     if (logging::IsEnabled(logging::eDocCreate))
     107           0 :       logging::Text("add scroll listener");
     108             : #endif
     109             :   }
     110             : }
     111             : 
     112             : inline void
     113           0 : DocAccessible::RemoveScrollListener()
     114             : {
     115           0 :   nsIScrollableFrame* sf = mPresShell->GetRootScrollFrameAsScrollable();
     116           0 :   if (sf)
     117           0 :     sf->RemoveScrollPositionListener(this);
     118           0 : }
     119             : 
     120             : inline void
     121           0 : DocAccessible::NotifyOfLoad(uint32_t aLoadEventType)
     122             : {
     123           0 :   mLoadState |= eDOMLoaded;
     124           0 :   mLoadEventType = aLoadEventType;
     125             : 
     126             :   // If the document is loaded completely then network activity was presumingly
     127             :   // caused by file loading. Fire busy state change event.
     128           0 :   if (HasLoadState(eCompletelyLoaded) && IsLoadEventTarget()) {
     129             :     RefPtr<AccEvent> stateEvent =
     130           0 :       new AccStateChangeEvent(this, states::BUSY, false);
     131           0 :     FireDelayedEvent(stateEvent);
     132             :   }
     133           0 : }
     134             : 
     135             : inline void
     136           0 : DocAccessible::MaybeNotifyOfValueChange(Accessible* aAccessible)
     137             : {
     138           0 :   if (aAccessible->IsCombobox() || aAccessible->Role() == roles::ENTRY)
     139           0 :     FireDelayedEvent(nsIAccessibleEvent::EVENT_TEXT_VALUE_CHANGE, aAccessible);
     140           0 : }
     141             : 
     142             : inline Accessible*
     143           0 : DocAccessible::GetAccessibleEvenIfNotInMapOrContainer(nsINode* aNode) const
     144             : {
     145           0 :   Accessible* acc = GetAccessibleEvenIfNotInMap(aNode);
     146           0 :   return acc ? acc : GetContainerAccessible(aNode);
     147             : }
     148             : 
     149             : inline void
     150           0 : DocAccessible::CreateSubtree(Accessible* aChild)
     151             : {
     152             :   // If a focused node has been shown then it could mean its frame was recreated
     153             :   // while the node stays focused and we need to fire focus event on
     154             :   // the accessible we just created. If the queue contains a focus event for
     155             :   // this node already then it will be suppressed by this one.
     156           0 :   Accessible* focusedAcc = nullptr;
     157           0 :   CacheChildrenInSubtree(aChild, &focusedAcc);
     158             : 
     159             : #ifdef A11Y_LOG
     160           0 :   if (logging::IsEnabled(logging::eVerbose)) {
     161           0 :     logging::Tree("TREE", "Created subtree", aChild);
     162             :   }
     163             : #endif
     164             : 
     165             :   // Fire events for ARIA elements.
     166           0 :   if (aChild->HasARIARole()) {
     167           0 :     roles::Role role = aChild->ARIARole();
     168           0 :     if (role == roles::MENUPOPUP) {
     169           0 :       FireDelayedEvent(nsIAccessibleEvent::EVENT_MENUPOPUP_START, aChild);
     170             :     }
     171           0 :     else if (role == roles::ALERT) {
     172           0 :       FireDelayedEvent(nsIAccessibleEvent::EVENT_ALERT, aChild);
     173             :     }
     174             :   }
     175             : 
     176             :   // XXX: do we really want to send focus to focused DOM node not taking into
     177             :   // account active item?
     178           0 :   if (focusedAcc) {
     179           0 :     FocusMgr()->DispatchFocusEvent(this, focusedAcc);
     180             :     SelectionMgr()->
     181           0 :       SetControlSelectionListener(focusedAcc->GetNode()->AsElement());
     182             :   }
     183           0 : }
     184             : 
     185             : } // namespace a11y
     186             : } // namespace mozilla
     187             : 
     188             : #endif

Generated by: LCOV version 1.13