1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=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
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #ifndef nsDocShellLoadTypes_h_
8 #define nsDocShellLoadTypes_h_
10 #ifdef MOZILLA_INTERNAL_API
12 # include "nsDOMNavigationTiming.h"
13 # include "nsIDocShell.h"
14 # include "nsIWebNavigation.h"
17 * Load flag for error pages. This uses one of the reserved flag
18 * values from nsIWebNavigation.
20 # define LOAD_FLAGS_ERROR_PAGE 0x0001U
22 # define MAKE_LOAD_TYPE(type, flags) ((type) | ((flags) << 16))
23 # define LOAD_TYPE_HAS_FLAGS(type, flags) ((type) & ((flags) << 16))
26 * These are flags that confuse ConvertLoadTypeToDocShellLoadInfo and should
27 * not be passed to MAKE_LOAD_TYPE. In particular this includes all flags
28 * above 0xffff (e.g. LOAD_FLAGS_BYPASS_CLASSIFIER), since MAKE_LOAD_TYPE would
29 * just shift them out anyway.
31 # define EXTRA_LOAD_FLAGS \
32 (nsIWebNavigation::LOAD_FLAGS_FROM_EXTERNAL | \
33 nsIWebNavigation::LOAD_FLAGS_FIRST_LOAD | \
34 nsIWebNavigation::LOAD_FLAGS_ALLOW_POPUPS | 0xffff0000)
36 /* load types are legal combinations of load commands and flags
39 * Remember to update the IsValidLoadType function below if you change this
40 * enum to ensure bad flag combinations will be rejected.
42 enum LoadType
: uint32_t {
43 LOAD_NORMAL
= MAKE_LOAD_TYPE(nsIDocShell::LOAD_CMD_NORMAL
,
44 nsIWebNavigation::LOAD_FLAGS_NONE
),
46 MAKE_LOAD_TYPE(nsIDocShell::LOAD_CMD_NORMAL
,
47 nsIWebNavigation::LOAD_FLAGS_REPLACE_HISTORY
),
48 LOAD_HISTORY
= MAKE_LOAD_TYPE(nsIDocShell::LOAD_CMD_HISTORY
,
49 nsIWebNavigation::LOAD_FLAGS_NONE
),
50 LOAD_NORMAL_BYPASS_CACHE
= MAKE_LOAD_TYPE(
51 nsIDocShell::LOAD_CMD_NORMAL
, nsIWebNavigation::LOAD_FLAGS_BYPASS_CACHE
),
52 LOAD_NORMAL_BYPASS_PROXY
= MAKE_LOAD_TYPE(
53 nsIDocShell::LOAD_CMD_NORMAL
, nsIWebNavigation::LOAD_FLAGS_BYPASS_PROXY
),
54 LOAD_NORMAL_BYPASS_PROXY_AND_CACHE
=
55 MAKE_LOAD_TYPE(nsIDocShell::LOAD_CMD_NORMAL
,
56 nsIWebNavigation::LOAD_FLAGS_BYPASS_CACHE
|
57 nsIWebNavigation::LOAD_FLAGS_BYPASS_PROXY
),
58 LOAD_RELOAD_NORMAL
= MAKE_LOAD_TYPE(nsIDocShell::LOAD_CMD_RELOAD
,
59 nsIWebNavigation::LOAD_FLAGS_NONE
),
60 LOAD_RELOAD_BYPASS_CACHE
= MAKE_LOAD_TYPE(
61 nsIDocShell::LOAD_CMD_RELOAD
, nsIWebNavigation::LOAD_FLAGS_BYPASS_CACHE
),
62 LOAD_RELOAD_BYPASS_PROXY
= MAKE_LOAD_TYPE(
63 nsIDocShell::LOAD_CMD_RELOAD
, nsIWebNavigation::LOAD_FLAGS_BYPASS_PROXY
),
64 LOAD_RELOAD_BYPASS_PROXY_AND_CACHE
=
65 MAKE_LOAD_TYPE(nsIDocShell::LOAD_CMD_RELOAD
,
66 nsIWebNavigation::LOAD_FLAGS_BYPASS_CACHE
|
67 nsIWebNavigation::LOAD_FLAGS_BYPASS_PROXY
),
68 LOAD_LINK
= MAKE_LOAD_TYPE(nsIDocShell::LOAD_CMD_NORMAL
,
69 nsIWebNavigation::LOAD_FLAGS_IS_LINK
),
70 LOAD_REFRESH
= MAKE_LOAD_TYPE(nsIDocShell::LOAD_CMD_NORMAL
,
71 nsIWebNavigation::LOAD_FLAGS_IS_REFRESH
),
72 LOAD_REFRESH_REPLACE
=
73 MAKE_LOAD_TYPE(nsIDocShell::LOAD_CMD_NORMAL
,
74 nsIWebNavigation::LOAD_FLAGS_IS_REFRESH
|
75 nsIWebNavigation::LOAD_FLAGS_REPLACE_HISTORY
),
76 LOAD_RELOAD_CHARSET_CHANGE
=
77 MAKE_LOAD_TYPE(nsIDocShell::LOAD_CMD_RELOAD
,
78 nsIWebNavigation::LOAD_FLAGS_CHARSET_CHANGE
),
79 LOAD_RELOAD_CHARSET_CHANGE_BYPASS_PROXY_AND_CACHE
=
80 MAKE_LOAD_TYPE(nsIDocShell::LOAD_CMD_RELOAD
,
81 nsIWebNavigation::LOAD_FLAGS_CHARSET_CHANGE
|
82 nsIWebNavigation::LOAD_FLAGS_BYPASS_CACHE
|
83 nsIWebNavigation::LOAD_FLAGS_BYPASS_PROXY
),
84 LOAD_RELOAD_CHARSET_CHANGE_BYPASS_CACHE
=
85 MAKE_LOAD_TYPE(nsIDocShell::LOAD_CMD_RELOAD
,
86 nsIWebNavigation::LOAD_FLAGS_CHARSET_CHANGE
|
87 nsIWebNavigation::LOAD_FLAGS_BYPASS_CACHE
),
89 MAKE_LOAD_TYPE(nsIDocShell::LOAD_CMD_NORMAL
,
90 nsIWebNavigation::LOAD_FLAGS_BYPASS_HISTORY
),
91 LOAD_STOP_CONTENT
= MAKE_LOAD_TYPE(nsIDocShell::LOAD_CMD_NORMAL
,
92 nsIWebNavigation::LOAD_FLAGS_STOP_CONTENT
),
93 LOAD_STOP_CONTENT_AND_REPLACE
=
94 MAKE_LOAD_TYPE(nsIDocShell::LOAD_CMD_NORMAL
,
95 nsIWebNavigation::LOAD_FLAGS_STOP_CONTENT
|
96 nsIWebNavigation::LOAD_FLAGS_REPLACE_HISTORY
),
97 LOAD_PUSHSTATE
= MAKE_LOAD_TYPE(nsIDocShell::LOAD_CMD_PUSHSTATE
,
98 nsIWebNavigation::LOAD_FLAGS_NONE
),
99 LOAD_REPLACE_BYPASS_CACHE
=
100 MAKE_LOAD_TYPE(nsIDocShell::LOAD_CMD_NORMAL
,
101 nsIWebNavigation::LOAD_FLAGS_REPLACE_HISTORY
|
102 nsIWebNavigation::LOAD_FLAGS_BYPASS_CACHE
),
104 * Load type for an error page. These loads are never triggered by users of
105 * Docshell. Instead, Docshell triggers the load itself when a
106 * consumer-triggered load failed.
109 MAKE_LOAD_TYPE(nsIDocShell::LOAD_CMD_NORMAL
, LOAD_FLAGS_ERROR_PAGE
)
111 // NOTE: Adding a new value? Remember to update IsValidLoadType!
114 static inline bool IsForceReloadType(uint32_t aLoadType
) {
116 case LOAD_RELOAD_BYPASS_CACHE
:
117 case LOAD_RELOAD_BYPASS_PROXY
:
118 case LOAD_RELOAD_BYPASS_PROXY_AND_CACHE
:
124 static inline bool IsValidLoadType(uint32_t aLoadType
) {
127 case LOAD_NORMAL_REPLACE
:
128 case LOAD_NORMAL_BYPASS_CACHE
:
129 case LOAD_NORMAL_BYPASS_PROXY
:
130 case LOAD_NORMAL_BYPASS_PROXY_AND_CACHE
:
132 case LOAD_RELOAD_NORMAL
:
133 case LOAD_RELOAD_BYPASS_CACHE
:
134 case LOAD_RELOAD_BYPASS_PROXY
:
135 case LOAD_RELOAD_BYPASS_PROXY_AND_CACHE
:
138 case LOAD_REFRESH_REPLACE
:
139 case LOAD_RELOAD_CHARSET_CHANGE
:
140 case LOAD_RELOAD_CHARSET_CHANGE_BYPASS_PROXY_AND_CACHE
:
141 case LOAD_RELOAD_CHARSET_CHANGE_BYPASS_CACHE
:
142 case LOAD_BYPASS_HISTORY
:
143 case LOAD_STOP_CONTENT
:
144 case LOAD_STOP_CONTENT_AND_REPLACE
:
146 case LOAD_REPLACE_BYPASS_CACHE
:
147 case LOAD_ERROR_PAGE
:
153 inline nsDOMNavigationTiming::Type
ConvertLoadTypeToNavigationType(
154 uint32_t aLoadType
) {
155 // Not initialized, assume it's normal load.
156 if (aLoadType
== 0) {
157 aLoadType
= LOAD_NORMAL
;
160 auto result
= nsDOMNavigationTiming::TYPE_RESERVED
;
163 case LOAD_NORMAL_BYPASS_CACHE
:
164 case LOAD_NORMAL_BYPASS_PROXY
:
165 case LOAD_NORMAL_BYPASS_PROXY_AND_CACHE
:
166 case LOAD_NORMAL_REPLACE
:
168 case LOAD_STOP_CONTENT
:
169 // FIXME: It isn't clear that LOAD_REFRESH_REPLACE should have a different
170 // navigation type than LOAD_REFRESH. Those loads historically used the
171 // LOAD_NORMAL_REPLACE type, and therefore wound up with TYPE_NAVIGATE by
173 case LOAD_REFRESH_REPLACE
:
174 case LOAD_REPLACE_BYPASS_CACHE
:
175 result
= nsDOMNavigationTiming::TYPE_NAVIGATE
;
178 result
= nsDOMNavigationTiming::TYPE_BACK_FORWARD
;
180 case LOAD_RELOAD_NORMAL
:
181 case LOAD_RELOAD_CHARSET_CHANGE
:
182 case LOAD_RELOAD_CHARSET_CHANGE_BYPASS_PROXY_AND_CACHE
:
183 case LOAD_RELOAD_CHARSET_CHANGE_BYPASS_CACHE
:
184 case LOAD_RELOAD_BYPASS_CACHE
:
185 case LOAD_RELOAD_BYPASS_PROXY
:
186 case LOAD_RELOAD_BYPASS_PROXY_AND_CACHE
:
187 result
= nsDOMNavigationTiming::TYPE_RELOAD
;
189 case LOAD_STOP_CONTENT_AND_REPLACE
:
191 case LOAD_BYPASS_HISTORY
:
192 case LOAD_ERROR_PAGE
:
194 result
= nsDOMNavigationTiming::TYPE_RESERVED
;
197 result
= nsDOMNavigationTiming::TYPE_RESERVED
;
204 #endif // MOZILLA_INTERNAL_API