Bug 1857669 - Install libavcodec/libavutil for Selenium tests r=releng-reviewers...
[gecko.git] / docshell / base / nsDocShellLoadTypes.h
blob1de19e81eb732b63a92b06271fe2b5f382aca3ba
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"
16 /**
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))
25 /**
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
38 * NOTE:
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),
45 LOAD_NORMAL_REPLACE =
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),
88 LOAD_BYPASS_HISTORY =
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.
108 LOAD_ERROR_PAGE =
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) {
115 switch (aLoadType) {
116 case LOAD_RELOAD_BYPASS_CACHE:
117 case LOAD_RELOAD_BYPASS_PROXY:
118 case LOAD_RELOAD_BYPASS_PROXY_AND_CACHE:
119 return true;
121 return false;
124 static inline bool IsValidLoadType(uint32_t aLoadType) {
125 switch (aLoadType) {
126 case LOAD_NORMAL:
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:
131 case LOAD_HISTORY:
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:
136 case LOAD_LINK:
137 case LOAD_REFRESH:
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:
145 case LOAD_PUSHSTATE:
146 case LOAD_REPLACE_BYPASS_CACHE:
147 case LOAD_ERROR_PAGE:
148 return true;
150 return false;
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;
161 switch (aLoadType) {
162 case LOAD_NORMAL:
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:
167 case LOAD_LINK:
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
172 // default.
173 case LOAD_REFRESH_REPLACE:
174 case LOAD_REPLACE_BYPASS_CACHE:
175 result = nsDOMNavigationTiming::TYPE_NAVIGATE;
176 break;
177 case LOAD_HISTORY:
178 result = nsDOMNavigationTiming::TYPE_BACK_FORWARD;
179 break;
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;
188 break;
189 case LOAD_STOP_CONTENT_AND_REPLACE:
190 case LOAD_REFRESH:
191 case LOAD_BYPASS_HISTORY:
192 case LOAD_ERROR_PAGE:
193 case LOAD_PUSHSTATE:
194 result = nsDOMNavigationTiming::TYPE_RESERVED;
195 break;
196 default:
197 result = nsDOMNavigationTiming::TYPE_RESERVED;
198 break;
201 return result;
204 #endif // MOZILLA_INTERNAL_API
205 #endif