Bug 794757 - add build config option to enable logging on release build, r=surkov

This commit is contained in:
Trevor Saunders 2012-10-04 18:57:09 +09:00
parent 91b9ec6c7d
commit ee8c478091
24 changed files with 109 additions and 56 deletions

View File

@ -10,6 +10,15 @@ VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
A11Y_LOG = 0
ifdef MOZ_DEBUG
A11Y_LOG = 1
endif
ifeq (,$(filter aurora beta release esr,$(MOZ_UPDATE_CHANNEL)))
A11Y_LOG = 1
endif
export A11Y_LOG
ifeq ($(MOZ_WIDGET_TOOLKIT),gtk2)
PLATFORM_DIR = atk
else

View File

@ -68,3 +68,7 @@ LOCAL_INCLUDES += \
-I$(srcdir)/../xul \
-I$(topsrcdir)/other-licenses/atk-1.0 \
$(NULL)
ifneq ($(A11Y_LOG),0)
DEFINES += -DA11Y_LOG
endif

View File

@ -114,7 +114,7 @@ FocusManager::IsInOrContainsFocus(const Accessible* aAccessible) const
void
FocusManager::NotifyOfDOMFocus(nsISupports* aTarget)
{
#ifdef DEBUG
#ifdef A11Y_LOG
if (logging::IsEnabled(logging::eFocus))
logging::FocusNotificationTarget("DOM focus", "Target", aTarget);
#endif
@ -142,7 +142,7 @@ FocusManager::NotifyOfDOMFocus(nsISupports* aTarget)
void
FocusManager::NotifyOfDOMBlur(nsISupports* aTarget)
{
#ifdef DEBUG
#ifdef A11Y_LOG
if (logging::IsEnabled(logging::eFocus))
logging::FocusNotificationTarget("DOM blur", "Target", aTarget);
#endif
@ -166,7 +166,7 @@ FocusManager::NotifyOfDOMBlur(nsISupports* aTarget)
void
FocusManager::ActiveItemChanged(Accessible* aItem, bool aCheckIfActive)
{
#ifdef DEBUG
#ifdef A11Y_LOG
if (logging::IsEnabled(logging::eFocus))
logging::FocusNotificationTarget("active item changed", "Item", aItem);
#endif
@ -179,7 +179,7 @@ FocusManager::ActiveItemChanged(Accessible* aItem, bool aCheckIfActive)
if (aItem && aCheckIfActive) {
Accessible* widget = aItem->ContainerWidget();
#ifdef DEBUG
#ifdef A11Y_LOG
if (logging::IsEnabled(logging::eFocus))
logging::ActiveWidget(widget);
#endif
@ -221,7 +221,7 @@ FocusManager::DispatchFocusEvent(DocAccessible* aDocument,
eAutoDetect, AccEvent::eCoalesceOfSameType);
aDocument->FireDelayedAccessibleEvent(event);
#ifdef DEBUG
#ifdef A11Y_LOG
if (logging::IsEnabled(logging::eFocus))
logging::FocusDispatched(aTarget);
#endif
@ -231,7 +231,7 @@ FocusManager::DispatchFocusEvent(DocAccessible* aDocument,
void
FocusManager::ProcessDOMFocus(nsINode* aTarget)
{
#ifdef DEBUG
#ifdef A11Y_LOG
if (logging::IsEnabled(logging::eFocus))
logging::FocusNotificationTarget("process DOM focus", "Target", aTarget);
#endif
@ -322,7 +322,7 @@ FocusManager::ProcessFocusEvent(AccEvent* aEvent)
mActiveARIAMenubar = nullptr;
}
#ifdef DEBUG
#ifdef A11Y_LOG
if (logging::IsEnabled(logging::eFocus))
logging::FocusNotificationTarget("fire focus event", "Target", target);
#endif

View File

@ -40,7 +40,7 @@ CPPSRCS = \
TextUpdater.cpp \
$(NULL)
ifdef MOZ_DEBUG
ifneq ($(A11Y_LOG),0)
CPPSRCS += \
Logging.cpp \
$(NULL)
@ -106,3 +106,7 @@ LOCAL_INCLUDES += \
endif
endif
endif
ifneq ($(A11Y_LOG),0)
DEFINES += -DA11Y_LOG
endif

View File

@ -16,7 +16,7 @@
#include "TextLeafAccessible.h"
#include "TextUpdater.h"
#ifdef DEBUG
#ifdef A11Y_LOG
#include "Logging.h"
#endif
@ -198,7 +198,7 @@ NotificationController::WillRefresh(mozilla::TimeStamp aTime)
return;
}
#ifdef DEBUG
#ifdef A11Y_LOG
if (logging::IsEnabled(logging::eTree)) {
logging::MsgBegin("TREE", "initial tree created");
logging::Address("document", mDocument);
@ -303,7 +303,7 @@ NotificationController::WillRefresh(mozilla::TimeStamp aTime)
events.SwapElements(mEvents);
uint32_t eventCount = events.Length();
#ifdef DEBUG
#ifdef A11Y_LOG
if (eventCount > 0 && logging::IsEnabled(logging::eEvents)) {
logging::MsgBegin("EVENTS", "events processing");
logging::Address("document", mDocument);
@ -728,7 +728,7 @@ NotificationController::TextEnumerator(nsCOMPtrHashKey<nsIContent>* aEntry,
// Remove text accessible if rendered text is empty.
if (textAcc) {
if (text.IsEmpty()) {
#ifdef DEBUG
#ifdef A11Y_LOG
if (logging::IsEnabled(logging::eTree | logging::eText)) {
logging::MsgBegin("TREE", "text node lost its content");
logging::Node("container", containerElm);
@ -742,7 +742,7 @@ NotificationController::TextEnumerator(nsCOMPtrHashKey<nsIContent>* aEntry,
}
// Update text of the accessible and fire text change events.
#ifdef DEBUG
#ifdef A11Y_LOG
if (logging::IsEnabled(logging::eText)) {
logging::MsgBegin("TEXT", "text may be changed");
logging::Node("container", containerElm);
@ -761,7 +761,7 @@ NotificationController::TextEnumerator(nsCOMPtrHashKey<nsIContent>* aEntry,
// Append an accessible if rendered text is not empty.
if (!text.IsEmpty()) {
#ifdef DEBUG
#ifdef A11Y_LOG
if (logging::IsEnabled(logging::eTree | logging::eText)) {
logging::MsgBegin("TREE", "text node gains new content");
logging::Node("container", containerElm);

View File

@ -10,7 +10,7 @@
#include "nsCycleCollectionParticipant.h"
#include "nsRefreshDriver.h"
#ifdef DEBUG
#ifdef A11Y_LOG
#include "Logging.h"
#endif
@ -136,7 +136,7 @@ public:
Arg* aArg)
{
if (!IsUpdatePending()) {
#ifdef DEBUG
#ifdef A11Y_LOG
if (mozilla::a11y::logging::IsEnabled(mozilla::a11y::logging::eNotifications))
mozilla::a11y::logging::Text("sync notification processing");
#endif

View File

@ -13,7 +13,7 @@
#include "RootAccessibleWrap.h"
#include "States.h"
#ifdef DEBUG
#ifdef A11Y_LOG
#include "Logging.h"
#endif
@ -145,7 +145,7 @@ nsAccDocManager::OnStateChange(nsIWebProgress *aWebProgress,
// Document was loaded.
if (aStateFlags & STATE_STOP) {
#ifdef DEBUG
#ifdef A11Y_LOG
if (logging::IsEnabled(logging::eDocLoad))
logging::DocLoad("document loaded", aWebProgress, aRequest, aStateFlags);
#endif
@ -174,7 +174,7 @@ nsAccDocManager::OnStateChange(nsIWebProgress *aWebProgress,
}
// Document loading was started.
#ifdef DEBUG
#ifdef A11Y_LOG
if (logging::IsEnabled(logging::eDocLoad))
logging::DocLoad("start document loading", aWebProgress, aRequest, aStateFlags);
#endif
@ -263,7 +263,7 @@ nsAccDocManager::HandleEvent(nsIDOMEvent *aEvent)
// accessible and all its sub document accessible are shutdown as result of
// processing.
#ifdef DEBUG
#ifdef A11Y_LOG
if (logging::IsEnabled(logging::eDocDestroy))
logging::DocDestroy("received 'pagehide' event", document);
#endif
@ -289,7 +289,7 @@ nsAccDocManager::HandleEvent(nsIDOMEvent *aEvent)
// webprogress notifications nor 'pageshow' event.
if (type.EqualsLiteral("DOMContentLoaded") &&
nsCoreUtils::IsErrorPage(document)) {
#ifdef DEBUG
#ifdef A11Y_LOG
if (logging::IsEnabled(logging::eDocLoad))
logging::DocLoad("handled 'DOMContentLoaded' event", document);
#endif
@ -330,7 +330,7 @@ nsAccDocManager::AddListeners(nsIDocument *aDocument,
elm->AddEventListenerByType(this, NS_LITERAL_STRING("pagehide"),
NS_EVENT_FLAG_CAPTURE);
#ifdef DEBUG
#ifdef A11Y_LOG
if (logging::IsEnabled(logging::eDocCreate))
logging::Text("added 'pagehide' listener");
#endif
@ -338,7 +338,7 @@ nsAccDocManager::AddListeners(nsIDocument *aDocument,
if (aAddDOMContentLoadedListener) {
elm->AddEventListenerByType(this, NS_LITERAL_STRING("DOMContentLoaded"),
NS_EVENT_FLAG_CAPTURE);
#ifdef DEBUG
#ifdef A11Y_LOG
if (logging::IsEnabled(logging::eDocCreate))
logging::Text("added 'DOMContentLoaded' listener");
#endif
@ -411,7 +411,7 @@ nsAccDocManager::CreateDocOrRootAccessible(nsIDocument* aDocument)
parentDocAcc->BindChildDocument(docAcc);
}
#ifdef DEBUG
#ifdef A11Y_LOG
if (logging::IsEnabled(logging::eDocCreate)) {
logging::DocCreate("document creation finished", aDocument);
logging::Stack();

View File

@ -39,7 +39,7 @@
#endif
#include "TextLeafAccessibleWrap.h"
#ifdef DEBUG
#ifdef A11Y_LOG
#include "Logging.h"
#endif
@ -470,7 +470,7 @@ nsAccessibilityService::ContentRangeInserted(nsIPresShell* aPresShell,
nsIContent* aStartChild,
nsIContent* aEndChild)
{
#ifdef DEBUG
#ifdef A11Y_LOG
if (logging::IsEnabled(logging::eTree)) {
logging::MsgBegin("TREE", "content inserted");
logging::Node("container", aContainer);
@ -492,7 +492,7 @@ nsAccessibilityService::ContentRemoved(nsIPresShell* aPresShell,
nsIContent* aContainer,
nsIContent* aChild)
{
#ifdef DEBUG
#ifdef A11Y_LOG
if (logging::IsEnabled(logging::eTree)) {
logging::MsgBegin("TREE", "content removed");
logging::Node("container", aContainer);
@ -843,7 +843,7 @@ nsAccessibilityService::CreateAccessiblePivot(nsIAccessible* aRoot,
NS_IMETHODIMP
nsAccessibilityService::SetLogging(const nsACString& aModules)
{
#ifdef DEBUG
#ifdef A11Y_LOG
logging::Enable(PromiseFlatCString(aModules));
#endif
return NS_OK;
@ -1181,7 +1181,7 @@ nsAccessibilityService::Init()
static const PRUnichar kInitIndicator[] = { '1', 0 };
observerService->NotifyObservers(nullptr, "a11y-init-or-shutdown", kInitIndicator);
#ifdef DEBUG
#ifdef A11Y_LOG
logging::CheckEnv();
#endif

View File

@ -95,10 +95,8 @@ nsCaretAccessible::SetControlSelectionListener(nsIContent *aCurrentNode)
nsCOMPtr<nsISelectionController> controller =
GetSelectionControllerForNode(mCurrentControl);
#ifdef DEBUG
NS_ASSERTION(controller || aCurrentNode->IsNodeOfType(nsINode::eDOCUMENT),
"No selection controller for non document node!");
#endif
if (!controller)
return NS_OK;
@ -180,7 +178,7 @@ nsCaretAccessible::NotifySelectionChanged(nsIDOMDocument* aDOMDocument,
nsCOMPtr<nsIDocument> documentNode(do_QueryInterface(aDOMDocument));
DocAccessible* document = GetAccService()->GetDocAccessible(documentNode);
#ifdef DEBUG
#ifdef A11Y_LOG
if (logging::IsEnabled(logging::eSelection))
logging::SelChange(aSelection, document);
#endif

View File

@ -45,7 +45,7 @@
#include "nsFocusManager.h"
#include "mozilla/dom/Element.h"
#ifdef DEBUG
#ifdef A11Y_LOG
#include "Logging.h"
#endif
@ -607,7 +607,7 @@ DocAccessible::GetAccessible(nsINode* aNode) const
void
DocAccessible::Init()
{
#ifdef DEBUG
#ifdef A11Y_LOG
if (logging::IsEnabled(logging::eDocCreate))
logging::DocCreate("document initialize", mDocument, this);
#endif
@ -630,7 +630,7 @@ DocAccessible::Shutdown()
if (!mPresShell) // already shutdown
return;
#ifdef DEBUG
#ifdef A11Y_LOG
if (logging::IsEnabled(logging::eDocDestroy))
logging::DocDestroy("document shutdown", mDocument, this);
#endif
@ -856,7 +856,7 @@ DocAccessible::AddScrollListener()
nsIScrollableFrame* sf = mPresShell->GetRootScrollFrameAsScrollableExternal();
if (sf) {
sf->AddScrollPositionListener(this);
#ifdef DEBUG
#ifdef A11Y_LOG
if (logging::IsEnabled(logging::eDocCreate))
logging::Text("add scroll listener");
#endif
@ -1230,7 +1230,7 @@ DocAccessible::ARIAActiveDescendantChanged(nsIContent* aElm)
Accessible* activeDescendant = GetAccessible(activeDescendantElm);
if (activeDescendant) {
FocusMgr()->ActiveItemChanged(activeDescendant, false);
#ifdef DEBUG
#ifdef A11Y_LOG
if (logging::IsEnabled(logging::eFocus))
logging::ActiveItemChangeCausedBy("ARIA activedescedant changed",
activeDescendant);
@ -1318,7 +1318,7 @@ DocAccessible::ParentChainChanged(nsIContent* aContent)
////////////////////////////////////////////////////////////////////////////////
// Accessible
#ifdef DEBUG
#ifdef A11Y_LOG
nsresult
DocAccessible::HandleAccEvent(AccEvent* aEvent)
{
@ -1416,7 +1416,7 @@ DocAccessible::UnbindFromDocument(Accessible* aAccessible)
// from the tree.
if (FocusMgr()->IsActiveItem(aAccessible)) {
FocusMgr()->ActiveItemChanged(nullptr);
#ifdef DEBUG
#ifdef A11Y_LOG
if (logging::IsEnabled(logging::eFocus))
logging::ActiveItemChangeCausedBy("tree shutdown", aAccessible);
#endif
@ -1764,7 +1764,7 @@ DocAccessible::FireDelayedAccessibleEvent(AccEvent* aEvent)
{
NS_ENSURE_ARG(aEvent);
#ifdef DEBUG
#ifdef A11Y_LOG
if (logging::IsEnabled(logging::eDocLoad))
logging::DocLoadEventFired(aEvent);
#endif
@ -1855,7 +1855,7 @@ DocAccessible::UpdateTree(Accessible* aContainer, nsIContent* aChildNode,
// If child node is not accessible then look for its accessible children.
Accessible* child = GetAccessible(aChildNode);
#ifdef DEBUG
#ifdef A11Y_LOG
if (logging::IsEnabled(logging::eTree)) {
logging::MsgBegin("TREE", "process content %s",
(aIsInsert ? "insertion" : "removal"));

View File

@ -97,7 +97,7 @@ public:
virtual void SetRoleMapEntry(nsRoleMapEntry* aRoleMapEntry);
#ifdef DEBUG
#ifdef A11Y_LOG
virtual nsresult HandleAccEvent(AccEvent* aEvent);
#endif

View File

@ -74,3 +74,7 @@ LOCAL_INCLUDES += \
endif
endif
endif
ifneq ($(A11Y_LOG),0)
DEFINES += -DA11Y_LOG
endif

View File

@ -10,7 +10,7 @@
#include "Role.h"
#include "States.h"
#ifdef DEBUG
#ifdef A11Y_LOG
#include "Logging.h"
#endif
@ -123,14 +123,14 @@ OuterDocAccessible::Shutdown()
// change however the presshell of underlying document isn't destroyed and
// the document doesn't get pagehide events. Shutdown underlying document if
// any to avoid hanging document accessible.
#ifdef DEBUG
#ifdef A11Y_LOG
if (logging::IsEnabled(logging::eDocDestroy))
logging::OuterDocDestroy(this);
#endif
Accessible* childAcc = mChildren.SafeElementAt(0, nullptr);
if (childAcc) {
#ifdef DEBUG
#ifdef A11Y_LOG
if (logging::IsEnabled(logging::eDocDestroy)) {
logging::DocDestroy("outerdoc's child document shutdown",
childAcc->GetDocumentNode());
@ -174,7 +174,7 @@ OuterDocAccessible::AppendChild(Accessible* aAccessible)
if (!AccessibleWrap::AppendChild(aAccessible))
return false;
#ifdef DEBUG
#ifdef A11Y_LOG
if (logging::IsEnabled(logging::eDocCreate)) {
logging::DocCreate("append document to outerdoc",
aAccessible->GetDocumentNode());
@ -194,7 +194,7 @@ OuterDocAccessible::RemoveChild(Accessible* aAccessible)
return false;
}
#ifdef DEBUG
#ifdef A11Y_LOG
if (logging::IsEnabled(logging::eDocDestroy)) {
logging::DocDestroy("remove document from outerdoc", child->GetDocumentNode(),
child->AsDoc());

View File

@ -262,7 +262,7 @@ RootAccessible::HandleEvent(nsIDOMEvent* aDOMEvent)
GetAccService()->GetDocAccessible(origTargetNode->OwnerDoc());
if (document) {
#ifdef DEBUG
#ifdef A11Y_LOG
if (logging::IsEnabled(logging::eDOMEvents)) {
nsAutoString eventType;
aDOMEvent->GetType(eventType);
@ -342,7 +342,7 @@ RootAccessible::ProcessDOMEvent(nsIDOMEvent* aDOMEvent)
if (isEnabled) {
FocusMgr()->ActiveItemChanged(accessible);
#ifdef DEBUG
#ifdef A11Y_LOG
if (logging::IsEnabled(logging::eFocus))
logging::ActiveItemChangeCausedBy("RadioStateChange", accessible);
#endif
@ -424,7 +424,7 @@ RootAccessible::ProcessDOMEvent(nsIDOMEvent* aDOMEvent)
}
else if (eventType.EqualsLiteral("DOMMenuItemActive")) {
FocusMgr()->ActiveItemChanged(accessible);
#ifdef DEBUG
#ifdef A11Y_LOG
if (logging::IsEnabled(logging::eFocus))
logging::ActiveItemChangeCausedBy("DOMMenuItemActive", accessible);
#endif
@ -438,7 +438,7 @@ RootAccessible::ProcessDOMEvent(nsIDOMEvent* aDOMEvent)
accessible->IsWidget() ? accessible : accessible->ContainerWidget();
if (widget && widget->IsAutoCompletePopup()) {
FocusMgr()->ActiveItemChanged(nullptr);
#ifdef DEBUG
#ifdef A11Y_LOG
if (logging::IsEnabled(logging::eFocus))
logging::ActiveItemChangeCausedBy("DOMMenuItemInactive", accessible);
#endif
@ -457,7 +457,7 @@ RootAccessible::ProcessDOMEvent(nsIDOMEvent* aDOMEvent)
Accessible* activeItem = accessible->CurrentItem();
if (activeItem) {
FocusMgr()->ActiveItemChanged(activeItem);
#ifdef DEBUG
#ifdef A11Y_LOG
if (logging::IsEnabled(logging::eFocus))
logging::ActiveItemChangeCausedBy("DOMMenuBarActive", accessible);
#endif
@ -468,7 +468,7 @@ RootAccessible::ProcessDOMEvent(nsIDOMEvent* aDOMEvent)
accessible, eFromUserInput);
FocusMgr()->ActiveItemChanged(nullptr);
#ifdef DEBUG
#ifdef A11Y_LOG
if (logging::IsEnabled(logging::eFocus))
logging::ActiveItemChangeCausedBy("DOMMenuBarInactive", accessible);
#endif
@ -662,7 +662,7 @@ RootAccessible::HandlePopupHidingEvent(nsINode* aPopupNode)
// Restore focus to where it was.
if (notifyOf & kNotifyOfFocus) {
FocusMgr()->ActiveItemChanged(nullptr);
#ifdef DEBUG
#ifdef A11Y_LOG
if (logging::IsEnabled(logging::eFocus))
logging::ActiveItemChangeCausedBy("popuphiding", popup);
#endif

View File

@ -63,3 +63,7 @@ LOCAL_INCLUDES += \
endif
endif
endif
ifneq ($(A11Y_LOG),0)
DEFINES += -DA11Y_LOG
endif

View File

@ -57,3 +57,6 @@ LOCAL_INCLUDES += \
-I$(topsrcdir)/layout/generic \
$(NULL)
ifneq ($(A11Y_LOG),0)
DEFINES += -DA11Y_LOG
endif

View File

@ -20,7 +20,7 @@
#include "States.h"
#include "uiaRawElmProvider.h"
#ifdef DEBUG
#ifdef A11Y_LOG
#include "Logging.h"
#endif
@ -1577,7 +1577,7 @@ AccessibleWrap::FirePlatformEvent(AccEvent* aEvent)
aid->ToUTF8String(id);
}
#ifdef DEBUG
#ifdef A11Y_LOG
if (logging::IsEnabled(logging::ePlatforms)) {
printf("\n\nMSAA event: event: %d, target: %s@id='%s', childid: %d, hwnd: %d\n\n",
eventType, NS_ConvertUTF16toUTF8(tag).get(), id.get(),

View File

@ -88,3 +88,7 @@ LOCAL_INCLUDES += \
-I$(srcdir)/../../../content/base/src \
-I$(srcdir)/../../../content/events/src \
$(NULL)
ifneq ($(A11Y_LOG),0)
DEFINES += -DA11Y_LOG
endif

View File

@ -44,3 +44,6 @@ LOCAL_INCLUDES += \
-I$(srcdir)/../xul \
$(NULL)
ifneq ($(A11Y_LOG),0)
DEFINES += -DA11Y_LOG
endif

View File

@ -14,3 +14,7 @@ DIRS += uia \
$(null)
include $(topsrcdir)/config/rules.mk
ifneq ($(A11Y_LOG),0)
DEFINES += -DA11Y_LOG
endif

View File

@ -34,3 +34,7 @@ LOCAL_INCLUDES += \
-I$(srcdir)/../../xpcom \
-I$(srcdir)/../../xul \
$(NULL)
ifdef A11Y_LOG
DEFINES += -DA11Y_LOG
endif

View File

@ -55,3 +55,7 @@ LOCAL_INCLUDES += \
endif
endif
endif
ifneq ($(A11Y_LOG),0)
DEFINES += -DA11Y_LOG
endif

View File

@ -52,3 +52,7 @@ LOCAL_INCLUDES += \
endif
endif
endif
ifneq ($(A11Y_LOG),0)
DEFINES += -DA11Y_LOG
endif

View File

@ -67,3 +67,7 @@ LOCAL_INCLUDES += \
endif
endif
endif
ifneq ($(A11Y_LOG),0)
DEFINES += -DA11Y_LOG
endif