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 "nsIDocShellLoadInfo.h"
15 #include "nsIWebNavigation.h"
18 * Load flag for error pages. This uses one of the reserved flag
19 * values from nsIWebNavigation.
21 #define LOAD_FLAGS_ERROR_PAGE 0x0001U
23 #define MAKE_LOAD_TYPE(type, flags) ((type) | ((flags) << 16))
24 #define LOAD_TYPE_HAS_FLAGS(type, flags) ((type) & ((flags) << 16))
27 * These are flags that confuse ConvertLoadTypeToDocShellLoadInfo and should
28 * not be passed to MAKE_LOAD_TYPE. In particular this includes all flags
29 * above 0xffff (e.g. LOAD_FLAGS_BYPASS_CLASSIFIER), since MAKE_LOAD_TYPE would
30 * just shift them out anyway.
32 #define EXTRA_LOAD_FLAGS (LOAD_FLAGS_FIRST_LOAD | \
33 LOAD_FLAGS_ALLOW_POPUPS | \
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.
44 LOAD_NORMAL
= MAKE_LOAD_TYPE(nsIDocShell::LOAD_CMD_NORMAL
, nsIWebNavigation::LOAD_FLAGS_NONE
),
45 LOAD_NORMAL_REPLACE
= MAKE_LOAD_TYPE(nsIDocShell::LOAD_CMD_NORMAL
, nsIWebNavigation::LOAD_FLAGS_REPLACE_HISTORY
),
46 LOAD_NORMAL_EXTERNAL
= MAKE_LOAD_TYPE(nsIDocShell::LOAD_CMD_NORMAL
, nsIWebNavigation::LOAD_FLAGS_FROM_EXTERNAL
),
47 LOAD_HISTORY
= MAKE_LOAD_TYPE(nsIDocShell::LOAD_CMD_HISTORY
, nsIWebNavigation::LOAD_FLAGS_NONE
),
48 LOAD_NORMAL_BYPASS_CACHE
= MAKE_LOAD_TYPE(nsIDocShell::LOAD_CMD_NORMAL
, nsIWebNavigation::LOAD_FLAGS_BYPASS_CACHE
),
49 LOAD_NORMAL_BYPASS_PROXY
= MAKE_LOAD_TYPE(nsIDocShell::LOAD_CMD_NORMAL
, nsIWebNavigation::LOAD_FLAGS_BYPASS_PROXY
),
50 LOAD_NORMAL_BYPASS_PROXY_AND_CACHE
= MAKE_LOAD_TYPE(nsIDocShell::LOAD_CMD_NORMAL
, nsIWebNavigation::LOAD_FLAGS_BYPASS_CACHE
| nsIWebNavigation::LOAD_FLAGS_BYPASS_PROXY
),
51 LOAD_NORMAL_ALLOW_MIXED_CONTENT
= MAKE_LOAD_TYPE(nsIDocShell::LOAD_CMD_NORMAL
, nsIWebNavigation::LOAD_FLAGS_ALLOW_MIXED_CONTENT
| nsIWebNavigation::LOAD_FLAGS_BYPASS_CACHE
),
52 LOAD_RELOAD_NORMAL
= MAKE_LOAD_TYPE(nsIDocShell::LOAD_CMD_RELOAD
, nsIWebNavigation::LOAD_FLAGS_NONE
),
53 LOAD_RELOAD_BYPASS_CACHE
= MAKE_LOAD_TYPE(nsIDocShell::LOAD_CMD_RELOAD
, nsIWebNavigation::LOAD_FLAGS_BYPASS_CACHE
),
54 LOAD_RELOAD_BYPASS_PROXY
= MAKE_LOAD_TYPE(nsIDocShell::LOAD_CMD_RELOAD
, nsIWebNavigation::LOAD_FLAGS_BYPASS_PROXY
),
55 LOAD_RELOAD_ALLOW_MIXED_CONTENT
= MAKE_LOAD_TYPE(nsIDocShell::LOAD_CMD_RELOAD
, nsIWebNavigation::LOAD_FLAGS_ALLOW_MIXED_CONTENT
| nsIWebNavigation::LOAD_FLAGS_BYPASS_CACHE
),
56 LOAD_RELOAD_BYPASS_PROXY_AND_CACHE
= MAKE_LOAD_TYPE(nsIDocShell::LOAD_CMD_RELOAD
, nsIWebNavigation::LOAD_FLAGS_BYPASS_CACHE
| nsIWebNavigation::LOAD_FLAGS_BYPASS_PROXY
),
57 LOAD_LINK
= MAKE_LOAD_TYPE(nsIDocShell::LOAD_CMD_NORMAL
, nsIWebNavigation::LOAD_FLAGS_IS_LINK
),
58 LOAD_REFRESH
= MAKE_LOAD_TYPE(nsIDocShell::LOAD_CMD_NORMAL
, nsIWebNavigation::LOAD_FLAGS_IS_REFRESH
),
59 LOAD_RELOAD_CHARSET_CHANGE
= MAKE_LOAD_TYPE(nsIDocShell::LOAD_CMD_RELOAD
, nsIWebNavigation::LOAD_FLAGS_CHARSET_CHANGE
),
60 LOAD_RELOAD_CHARSET_CHANGE_BYPASS_PROXY_AND_CACHE
= MAKE_LOAD_TYPE(nsIDocShell::LOAD_CMD_RELOAD
, nsIWebNavigation::LOAD_FLAGS_CHARSET_CHANGE
| nsIWebNavigation::LOAD_FLAGS_BYPASS_CACHE
| nsIWebNavigation::LOAD_FLAGS_BYPASS_PROXY
),
61 LOAD_RELOAD_CHARSET_CHANGE_BYPASS_CACHE
= MAKE_LOAD_TYPE(nsIDocShell::LOAD_CMD_RELOAD
, nsIWebNavigation::LOAD_FLAGS_CHARSET_CHANGE
| nsIWebNavigation::LOAD_FLAGS_BYPASS_CACHE
),
62 LOAD_BYPASS_HISTORY
= MAKE_LOAD_TYPE(nsIDocShell::LOAD_CMD_NORMAL
, nsIWebNavigation::LOAD_FLAGS_BYPASS_HISTORY
),
63 LOAD_STOP_CONTENT
= MAKE_LOAD_TYPE(nsIDocShell::LOAD_CMD_NORMAL
, nsIWebNavigation::LOAD_FLAGS_STOP_CONTENT
),
64 LOAD_STOP_CONTENT_AND_REPLACE
= MAKE_LOAD_TYPE(nsIDocShell::LOAD_CMD_NORMAL
, nsIWebNavigation::LOAD_FLAGS_STOP_CONTENT
| nsIWebNavigation::LOAD_FLAGS_REPLACE_HISTORY
),
65 LOAD_PUSHSTATE
= MAKE_LOAD_TYPE(nsIDocShell::LOAD_CMD_PUSHSTATE
, nsIWebNavigation::LOAD_FLAGS_NONE
),
66 LOAD_REPLACE_BYPASS_CACHE
= MAKE_LOAD_TYPE(nsIDocShell::LOAD_CMD_NORMAL
, nsIWebNavigation::LOAD_FLAGS_REPLACE_HISTORY
| nsIWebNavigation::LOAD_FLAGS_BYPASS_CACHE
),
68 * Load type for an error page. These loads are never triggered by users of
69 * Docshell. Instead, Docshell triggers the load itself when a
70 * consumer-triggered load failed.
72 LOAD_ERROR_PAGE
= MAKE_LOAD_TYPE(nsIDocShell::LOAD_CMD_NORMAL
,
73 LOAD_FLAGS_ERROR_PAGE
)
75 // NOTE: Adding a new value? Remember to update IsValidLoadType!
79 IsValidLoadType(uint32_t aLoadType
)
83 case LOAD_NORMAL_REPLACE
:
84 case LOAD_NORMAL_EXTERNAL
:
85 case LOAD_NORMAL_BYPASS_CACHE
:
86 case LOAD_NORMAL_BYPASS_PROXY
:
87 case LOAD_NORMAL_BYPASS_PROXY_AND_CACHE
:
88 case LOAD_NORMAL_ALLOW_MIXED_CONTENT
:
90 case LOAD_RELOAD_NORMAL
:
91 case LOAD_RELOAD_BYPASS_CACHE
:
92 case LOAD_RELOAD_BYPASS_PROXY
:
93 case LOAD_RELOAD_BYPASS_PROXY_AND_CACHE
:
94 case LOAD_RELOAD_ALLOW_MIXED_CONTENT
:
97 case LOAD_RELOAD_CHARSET_CHANGE
:
98 case LOAD_RELOAD_CHARSET_CHANGE_BYPASS_PROXY_AND_CACHE
:
99 case LOAD_RELOAD_CHARSET_CHANGE_BYPASS_CACHE
:
100 case LOAD_BYPASS_HISTORY
:
101 case LOAD_STOP_CONTENT
:
102 case LOAD_STOP_CONTENT_AND_REPLACE
:
104 case LOAD_REPLACE_BYPASS_CACHE
:
105 case LOAD_ERROR_PAGE
:
112 IsForceReloadType(uint32_t aLoadType
) {
114 case LOAD_RELOAD_BYPASS_CACHE
:
115 case LOAD_RELOAD_BYPASS_PROXY
:
116 case LOAD_RELOAD_BYPASS_PROXY_AND_CACHE
:
117 case LOAD_RELOAD_ALLOW_MIXED_CONTENT
:
123 static inline nsDocShellInfoLoadType
124 ConvertLoadTypeToDocShellInfoLoadType(uint32_t aLoadType
)
126 nsDocShellInfoLoadType docShellLoadType
= nsIDocShellLoadInfo::loadNormal
;
129 docShellLoadType
= nsIDocShellLoadInfo::loadNormal
;
131 case LOAD_NORMAL_REPLACE
:
132 docShellLoadType
= nsIDocShellLoadInfo::loadNormalReplace
;
134 case LOAD_NORMAL_EXTERNAL
:
135 docShellLoadType
= nsIDocShellLoadInfo::loadNormalExternal
;
137 case LOAD_NORMAL_BYPASS_CACHE
:
138 docShellLoadType
= nsIDocShellLoadInfo::loadNormalBypassCache
;
140 case LOAD_NORMAL_BYPASS_PROXY
:
141 docShellLoadType
= nsIDocShellLoadInfo::loadNormalBypassProxy
;
143 case LOAD_NORMAL_BYPASS_PROXY_AND_CACHE
:
144 docShellLoadType
= nsIDocShellLoadInfo::loadNormalBypassProxyAndCache
;
146 case LOAD_NORMAL_ALLOW_MIXED_CONTENT
:
147 docShellLoadType
= nsIDocShellLoadInfo::loadNormalAllowMixedContent
;
150 docShellLoadType
= nsIDocShellLoadInfo::loadHistory
;
152 case LOAD_RELOAD_NORMAL
:
153 docShellLoadType
= nsIDocShellLoadInfo::loadReloadNormal
;
155 case LOAD_RELOAD_CHARSET_CHANGE
:
156 docShellLoadType
= nsIDocShellLoadInfo::loadReloadCharsetChange
;
158 case LOAD_RELOAD_CHARSET_CHANGE_BYPASS_CACHE
:
159 docShellLoadType
= nsIDocShellLoadInfo::loadReloadCharsetChangeBypassCache
;
161 case LOAD_RELOAD_CHARSET_CHANGE_BYPASS_PROXY_AND_CACHE
:
162 docShellLoadType
= nsIDocShellLoadInfo::loadReloadCharsetChangeBypassProxyAndCache
;
164 case LOAD_RELOAD_BYPASS_CACHE
:
165 docShellLoadType
= nsIDocShellLoadInfo::loadReloadBypassCache
;
167 case LOAD_RELOAD_BYPASS_PROXY
:
168 docShellLoadType
= nsIDocShellLoadInfo::loadReloadBypassProxy
;
170 case LOAD_RELOAD_BYPASS_PROXY_AND_CACHE
:
171 docShellLoadType
= nsIDocShellLoadInfo::loadReloadBypassProxyAndCache
;
174 docShellLoadType
= nsIDocShellLoadInfo::loadLink
;
177 docShellLoadType
= nsIDocShellLoadInfo::loadRefresh
;
179 case LOAD_BYPASS_HISTORY
:
180 case LOAD_ERROR_PAGE
:
181 docShellLoadType
= nsIDocShellLoadInfo::loadBypassHistory
;
183 case LOAD_STOP_CONTENT
:
184 docShellLoadType
= nsIDocShellLoadInfo::loadStopContent
;
186 case LOAD_STOP_CONTENT_AND_REPLACE
:
187 docShellLoadType
= nsIDocShellLoadInfo::loadStopContentAndReplace
;
190 docShellLoadType
= nsIDocShellLoadInfo::loadPushState
;
192 case LOAD_REPLACE_BYPASS_CACHE
:
193 docShellLoadType
= nsIDocShellLoadInfo::loadReplaceBypassCache
;
195 case LOAD_RELOAD_ALLOW_MIXED_CONTENT
:
196 docShellLoadType
= nsIDocShellLoadInfo::loadReloadMixedContent
;
199 MOZ_ASSERT_UNREACHABLE("Unexpected load type value");
202 return docShellLoadType
;
205 static inline uint32_t
206 ConvertDocShellInfoLoadTypeToLoadType(nsDocShellInfoLoadType aDocShellLoadType
)
208 uint32_t loadType
= LOAD_NORMAL
;
210 switch (aDocShellLoadType
) {
211 case nsIDocShellLoadInfo::loadNormal
:
212 loadType
= LOAD_NORMAL
;
214 case nsIDocShellLoadInfo::loadNormalReplace
:
215 loadType
= LOAD_NORMAL_REPLACE
;
217 case nsIDocShellLoadInfo::loadNormalExternal
:
218 loadType
= LOAD_NORMAL_EXTERNAL
;
220 case nsIDocShellLoadInfo::loadHistory
:
221 loadType
= LOAD_HISTORY
;
223 case nsIDocShellLoadInfo::loadNormalBypassCache
:
224 loadType
= LOAD_NORMAL_BYPASS_CACHE
;
226 case nsIDocShellLoadInfo::loadNormalBypassProxy
:
227 loadType
= LOAD_NORMAL_BYPASS_PROXY
;
229 case nsIDocShellLoadInfo::loadNormalBypassProxyAndCache
:
230 loadType
= LOAD_NORMAL_BYPASS_PROXY_AND_CACHE
;
232 case nsIDocShellLoadInfo::loadNormalAllowMixedContent
:
233 loadType
= LOAD_NORMAL_ALLOW_MIXED_CONTENT
;
235 case nsIDocShellLoadInfo::loadReloadNormal
:
236 loadType
= LOAD_RELOAD_NORMAL
;
238 case nsIDocShellLoadInfo::loadReloadCharsetChange
:
239 loadType
= LOAD_RELOAD_CHARSET_CHANGE
;
241 case nsIDocShellLoadInfo::loadReloadCharsetChangeBypassCache
:
242 loadType
= LOAD_RELOAD_CHARSET_CHANGE_BYPASS_CACHE
;
244 case nsIDocShellLoadInfo::loadReloadCharsetChangeBypassProxyAndCache
:
245 loadType
= LOAD_RELOAD_CHARSET_CHANGE_BYPASS_PROXY_AND_CACHE
;
247 case nsIDocShellLoadInfo::loadReloadBypassCache
:
248 loadType
= LOAD_RELOAD_BYPASS_CACHE
;
250 case nsIDocShellLoadInfo::loadReloadBypassProxy
:
251 loadType
= LOAD_RELOAD_BYPASS_PROXY
;
253 case nsIDocShellLoadInfo::loadReloadBypassProxyAndCache
:
254 loadType
= LOAD_RELOAD_BYPASS_PROXY_AND_CACHE
;
256 case nsIDocShellLoadInfo::loadLink
:
257 loadType
= LOAD_LINK
;
259 case nsIDocShellLoadInfo::loadRefresh
:
260 loadType
= LOAD_REFRESH
;
262 case nsIDocShellLoadInfo::loadBypassHistory
:
263 loadType
= LOAD_BYPASS_HISTORY
;
265 case nsIDocShellLoadInfo::loadStopContent
:
266 loadType
= LOAD_STOP_CONTENT
;
268 case nsIDocShellLoadInfo::loadStopContentAndReplace
:
269 loadType
= LOAD_STOP_CONTENT_AND_REPLACE
;
271 case nsIDocShellLoadInfo::loadPushState
:
272 loadType
= LOAD_PUSHSTATE
;
274 case nsIDocShellLoadInfo::loadReplaceBypassCache
:
275 loadType
= LOAD_REPLACE_BYPASS_CACHE
;
277 case nsIDocShellLoadInfo::loadReloadMixedContent
:
278 loadType
= LOAD_RELOAD_ALLOW_MIXED_CONTENT
;
281 MOZ_ASSERT_UNREACHABLE("Unexpected nsDocShellInfoLoadType value");
287 static inline nsDOMNavigationTiming::Type
288 ConvertLoadTypeToNavigationType(uint32_t aLoadType
)
290 // Not initialized, assume it's normal load.
291 if (aLoadType
== 0) {
292 aLoadType
= LOAD_NORMAL
;
295 auto result
= nsDOMNavigationTiming::TYPE_RESERVED
;
298 case LOAD_NORMAL_EXTERNAL
:
299 case LOAD_NORMAL_BYPASS_CACHE
:
300 case LOAD_NORMAL_BYPASS_PROXY
:
301 case LOAD_NORMAL_BYPASS_PROXY_AND_CACHE
:
302 case LOAD_NORMAL_REPLACE
:
303 case LOAD_NORMAL_ALLOW_MIXED_CONTENT
:
305 case LOAD_STOP_CONTENT
:
306 case LOAD_REPLACE_BYPASS_CACHE
:
307 result
= nsDOMNavigationTiming::TYPE_NAVIGATE
;
310 result
= nsDOMNavigationTiming::TYPE_BACK_FORWARD
;
312 case LOAD_RELOAD_NORMAL
:
313 case LOAD_RELOAD_CHARSET_CHANGE
:
314 case LOAD_RELOAD_CHARSET_CHANGE_BYPASS_PROXY_AND_CACHE
:
315 case LOAD_RELOAD_CHARSET_CHANGE_BYPASS_CACHE
:
316 case LOAD_RELOAD_BYPASS_CACHE
:
317 case LOAD_RELOAD_BYPASS_PROXY
:
318 case LOAD_RELOAD_BYPASS_PROXY_AND_CACHE
:
319 case LOAD_RELOAD_ALLOW_MIXED_CONTENT
:
320 result
= nsDOMNavigationTiming::TYPE_RELOAD
;
322 case LOAD_STOP_CONTENT_AND_REPLACE
:
324 case LOAD_BYPASS_HISTORY
:
325 case LOAD_ERROR_PAGE
:
327 result
= nsDOMNavigationTiming::TYPE_RESERVED
;
330 result
= nsDOMNavigationTiming::TYPE_RESERVED
;
337 #endif // MOZILLA_INTERNAL_API