michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* vim: set ts=2 et sw=2 tw=80: */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this file, michael@0: * You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef mozilla_a11y_DocAccessible_inl_h_ michael@0: #define mozilla_a11y_DocAccessible_inl_h_ michael@0: michael@0: #include "DocAccessible.h" michael@0: #include "nsAccessibilityService.h" michael@0: #include "NotificationController.h" michael@0: #include "States.h" michael@0: #include "nsIScrollableFrame.h" michael@0: michael@0: #ifdef A11Y_LOG michael@0: #include "Logging.h" michael@0: #endif michael@0: michael@0: namespace mozilla { michael@0: namespace a11y { michael@0: michael@0: inline void michael@0: DocAccessible::FireDelayedEvent(AccEvent* aEvent) michael@0: { michael@0: #ifdef A11Y_LOG michael@0: if (logging::IsEnabled(logging::eDocLoad)) michael@0: logging::DocLoadEventFired(aEvent); michael@0: #endif michael@0: michael@0: mNotificationController->QueueEvent(aEvent); michael@0: } michael@0: michael@0: inline void michael@0: DocAccessible::FireDelayedEvent(uint32_t aEventType, Accessible* aTarget) michael@0: { michael@0: nsRefPtr event = new AccEvent(aEventType, aTarget); michael@0: FireDelayedEvent(event); michael@0: } michael@0: michael@0: inline void michael@0: DocAccessible::BindChildDocument(DocAccessible* aDocument) michael@0: { michael@0: mNotificationController->ScheduleChildDocBinding(aDocument); michael@0: } michael@0: michael@0: template michael@0: inline void michael@0: DocAccessible::HandleNotification(Class* aInstance, michael@0: typename TNotification::Callback aMethod, michael@0: Arg* aArg) michael@0: { michael@0: if (mNotificationController) { michael@0: mNotificationController->HandleNotification(aInstance, michael@0: aMethod, aArg); michael@0: } michael@0: } michael@0: michael@0: inline void michael@0: DocAccessible::UpdateText(nsIContent* aTextNode) michael@0: { michael@0: NS_ASSERTION(mNotificationController, "The document was shut down!"); michael@0: michael@0: // Ignore the notification if initial tree construction hasn't been done yet. michael@0: if (mNotificationController && HasLoadState(eTreeConstructed)) michael@0: mNotificationController->ScheduleTextUpdate(aTextNode); michael@0: } michael@0: michael@0: inline void michael@0: DocAccessible::AddScrollListener() michael@0: { michael@0: // Delay scroll initializing until the document has a root frame. michael@0: if (!mPresShell->GetRootFrame()) michael@0: return; michael@0: michael@0: mDocFlags |= eScrollInitialized; michael@0: nsIScrollableFrame* sf = mPresShell->GetRootScrollFrameAsScrollable(); michael@0: if (sf) { michael@0: sf->AddScrollPositionListener(this); michael@0: michael@0: #ifdef A11Y_LOG michael@0: if (logging::IsEnabled(logging::eDocCreate)) michael@0: logging::Text("add scroll listener"); michael@0: #endif michael@0: } michael@0: } michael@0: michael@0: inline void michael@0: DocAccessible::RemoveScrollListener() michael@0: { michael@0: nsIScrollableFrame* sf = mPresShell->GetRootScrollFrameAsScrollable(); michael@0: if (sf) michael@0: sf->RemoveScrollPositionListener(this); michael@0: } michael@0: michael@0: inline void michael@0: DocAccessible::NotifyOfLoad(uint32_t aLoadEventType) michael@0: { michael@0: mLoadState |= eDOMLoaded; michael@0: mLoadEventType = aLoadEventType; michael@0: michael@0: // If the document is loaded completely then network activity was presumingly michael@0: // caused by file loading. Fire busy state change event. michael@0: if (HasLoadState(eCompletelyLoaded) && IsLoadEventTarget()) { michael@0: nsRefPtr stateEvent = michael@0: new AccStateChangeEvent(this, states::BUSY, false); michael@0: FireDelayedEvent(stateEvent); michael@0: } michael@0: } michael@0: michael@0: inline void michael@0: DocAccessible::MaybeNotifyOfValueChange(Accessible* aAccessible) michael@0: { michael@0: a11y::role role = aAccessible->Role(); michael@0: if (role == roles::ENTRY || role == roles::COMBOBOX) michael@0: FireDelayedEvent(nsIAccessibleEvent::EVENT_VALUE_CHANGE, aAccessible); michael@0: } michael@0: michael@0: inline Accessible* michael@0: DocAccessible::GetAccessibleEvenIfNotInMapOrContainer(nsINode* aNode) const michael@0: { michael@0: Accessible* acc = GetAccessibleEvenIfNotInMap(aNode); michael@0: return acc ? acc : GetContainerAccessible(aNode); michael@0: } michael@0: michael@0: } // namespace a11y michael@0: } // namespace mozilla michael@0: michael@0: #endif