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/. */
10 * nsWindowDbg - Debug related utilities for nsWindow.
13 #include "nsWindowDefs.h"
15 // Enables debug output for popup rollup hooks
16 // #define POPUP_ROLLUP_DEBUG_OUTPUT
18 // Enable window size and state debug output
19 // #define WINSTATE_DEBUG_OUTPUT
21 // nsIWidget defines a set of debug output statements
22 // that are called in various places within the code.
23 // #define WIDGET_DEBUG_OUTPUT
25 // Enable IS_VK_DOWN debug output
28 namespace mozilla::widget
{
29 // Windows message debugging data
33 std::function
<nsAutoCString(WPARAM
, LPARAM
, bool)> mParamInfoFn
;
34 std::function
<void(nsCString
&, WPARAM
, const char*, bool)> mWParamInfoFn
;
35 const char* mWParamName
;
36 std::function
<void(nsCString
&, LPARAM
, const char*, bool)> mLParamInfoFn
;
37 const char* mLParamName
;
38 void LogParameters(nsCString
& str
, WPARAM wParam
, LPARAM lParam
,
41 extern std::unordered_map
<UINT
, EventMsgInfo
> gAllEvents
;
43 // RAII-style class to log before and after an event is handled.
44 class PrintEvent final
{
46 PrintEvent(HWND hwnd
, UINT msg
, WPARAM wParam
, LPARAM lParam
);
47 void SetResult(LRESULT lresult
, bool result
) {
49 mResult
= mozilla::Some(result
);
54 bool PrintEventInternal();
60 mozilla::Maybe
<long> mEventCounter
;
61 // not const because these will be set after the event is handled
62 mozilla::Maybe
<bool> mResult
;
63 LRESULT mRetValue
= 0;
65 bool mShouldLogPostCall
;
68 struct EnumValueAndName
{
73 // Appends to str a description of the flags passed in.
74 // flagsAndNames is a list of flag values with a string description
75 // for each one. These are processed in order, so if there are
76 // flag values that are combination of individual values (for example
77 // something like WS_OVERLAPPEDWINDOW) they need to come first
78 // in the flagsAndNames array.
79 // A 0 flag value will only be written if the flags input is exactly
80 // 0, and it must come last in the flagsAndNames array.
81 // Returns whether any info was appended to str.
82 bool AppendFlagsInfo(nsCString
& str
, uint64_t flags
,
83 const nsTArray
<EnumValueAndName
>& flagsAndNames
,
86 nsAutoCString
WmSizeParamInfo(uint64_t wParam
, uint64_t lParam
, bool isPreCall
);
87 void XLowWordYHighWordParamInfo(nsCString
& str
, uint64_t value
,
88 const char* name
, bool isPreCall
);
89 void WindowPosParamInfo(nsCString
& str
, uint64_t value
, const char* name
,
91 void WindowEdgeParamInfo(nsCString
& str
, uint64_t value
, const char* name
,
93 void RectParamInfo(nsCString
& str
, uint64_t value
, const char* name
,
95 void UiActionParamInfo(nsCString
& str
, uint64_t value
, const char* name
,
97 void WideStringParamInfo(nsCString
& result
, uint64_t value
, const char* name
,
99 void MinMaxInfoParamInfo(nsCString
& result
, uint64_t value
, const char* name
,
101 nsAutoCString
WmNcCalcSizeParamInfo(uint64_t wParam
, uint64_t lParam
,
103 } // namespace mozilla::widget
105 #if defined(POPUP_ROLLUP_DEBUG_OUTPUT)
111 # define DISPLAY_NMM_PRT(_arg) \
112 MOZ_LOG(gWindowsLog, mozilla::LogLevel::Info, ((_arg)));
114 # define DISPLAY_NMM_PRT(_arg)
115 #endif // defined(POPUP_ROLLUP_DEBUG_OUTPUT)
118 void DDError(const char* msg
, HRESULT hr
);
119 #endif // defined(DEBUG)
121 #if defined(DEBUG_VK)
122 bool is_vk_down(int vk
);
123 # define IS_VK_DOWN is_vk_down
125 # define IS_VK_DOWN(a) (GetKeyState(a) < 0)
126 #endif // defined(DEBUG_VK)
128 #endif /* WindowDbg_h__ */