Source code

Revision control

Other Tools

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/. */
6
7
#ifndef nsDocShellLoadTypes_h_
8
#define nsDocShellLoadTypes_h_
9
10
#ifdef MOZILLA_INTERNAL_API
11
12
# include "nsDOMNavigationTiming.h"
13
# include "nsIDocShell.h"
14
# include "nsIWebNavigation.h"
15
16
/**
17
* Load flag for error pages. This uses one of the reserved flag
18
* values from nsIWebNavigation.
19
*/
20
# define LOAD_FLAGS_ERROR_PAGE 0x0001U
21
22
# define MAKE_LOAD_TYPE(type, flags) ((type) | ((flags) << 16))
23
# define LOAD_TYPE_HAS_FLAGS(type, flags) ((type) & ((flags) << 16))
24
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.
30
*/
31
# define EXTRA_LOAD_FLAGS \
32
(nsIWebNavigation::LOAD_FLAGS_FIRST_LOAD | \
33
nsIWebNavigation::LOAD_FLAGS_ALLOW_POPUPS | 0xffff0000)
34
35
/* load types are legal combinations of load commands and flags
36
*
37
* NOTE:
38
* Remember to update the IsValidLoadType function below if you change this
39
* enum to ensure bad flag combinations will be rejected.
40
*/
41
enum LoadType : uint32_t {
42
LOAD_NORMAL = MAKE_LOAD_TYPE(nsIDocShell::LOAD_CMD_NORMAL,
43
nsIWebNavigation::LOAD_FLAGS_NONE),
44
LOAD_NORMAL_REPLACE =
45
MAKE_LOAD_TYPE(nsIDocShell::LOAD_CMD_NORMAL,
46
nsIWebNavigation::LOAD_FLAGS_REPLACE_HISTORY),
47
LOAD_NORMAL_EXTERNAL = MAKE_LOAD_TYPE(
48
nsIDocShell::LOAD_CMD_NORMAL, nsIWebNavigation::LOAD_FLAGS_FROM_EXTERNAL),
49
LOAD_HISTORY = MAKE_LOAD_TYPE(nsIDocShell::LOAD_CMD_HISTORY,
50
nsIWebNavigation::LOAD_FLAGS_NONE),
51
LOAD_NORMAL_BYPASS_CACHE = MAKE_LOAD_TYPE(
52
nsIDocShell::LOAD_CMD_NORMAL, nsIWebNavigation::LOAD_FLAGS_BYPASS_CACHE),
53
LOAD_NORMAL_BYPASS_PROXY = MAKE_LOAD_TYPE(
54
nsIDocShell::LOAD_CMD_NORMAL, nsIWebNavigation::LOAD_FLAGS_BYPASS_PROXY),
55
LOAD_NORMAL_BYPASS_PROXY_AND_CACHE =
56
MAKE_LOAD_TYPE(nsIDocShell::LOAD_CMD_NORMAL,
57
nsIWebNavigation::LOAD_FLAGS_BYPASS_CACHE |
58
nsIWebNavigation::LOAD_FLAGS_BYPASS_PROXY),
59
LOAD_NORMAL_ALLOW_MIXED_CONTENT =
60
MAKE_LOAD_TYPE(nsIDocShell::LOAD_CMD_NORMAL,
61
nsIWebNavigation::LOAD_FLAGS_ALLOW_MIXED_CONTENT |
62
nsIWebNavigation::LOAD_FLAGS_BYPASS_CACHE),
63
LOAD_RELOAD_NORMAL = MAKE_LOAD_TYPE(nsIDocShell::LOAD_CMD_RELOAD,
64
nsIWebNavigation::LOAD_FLAGS_NONE),
65
LOAD_RELOAD_BYPASS_CACHE = MAKE_LOAD_TYPE(
66
nsIDocShell::LOAD_CMD_RELOAD, nsIWebNavigation::LOAD_FLAGS_BYPASS_CACHE),
67
LOAD_RELOAD_BYPASS_PROXY = MAKE_LOAD_TYPE(
68
nsIDocShell::LOAD_CMD_RELOAD, nsIWebNavigation::LOAD_FLAGS_BYPASS_PROXY),
69
LOAD_RELOAD_ALLOW_MIXED_CONTENT =
70
MAKE_LOAD_TYPE(nsIDocShell::LOAD_CMD_RELOAD,
71
nsIWebNavigation::LOAD_FLAGS_ALLOW_MIXED_CONTENT |
72
nsIWebNavigation::LOAD_FLAGS_BYPASS_CACHE),
73
LOAD_RELOAD_BYPASS_PROXY_AND_CACHE =
74
MAKE_LOAD_TYPE(nsIDocShell::LOAD_CMD_RELOAD,
75
nsIWebNavigation::LOAD_FLAGS_BYPASS_CACHE |
76
nsIWebNavigation::LOAD_FLAGS_BYPASS_PROXY),
77
LOAD_LINK = MAKE_LOAD_TYPE(nsIDocShell::LOAD_CMD_NORMAL,
78
nsIWebNavigation::LOAD_FLAGS_IS_LINK),
79
LOAD_REFRESH = MAKE_LOAD_TYPE(nsIDocShell::LOAD_CMD_NORMAL,
80
nsIWebNavigation::LOAD_FLAGS_IS_REFRESH),
81
LOAD_RELOAD_CHARSET_CHANGE =
82
MAKE_LOAD_TYPE(nsIDocShell::LOAD_CMD_RELOAD,
83
nsIWebNavigation::LOAD_FLAGS_CHARSET_CHANGE),
84
LOAD_RELOAD_CHARSET_CHANGE_BYPASS_PROXY_AND_CACHE =
85
MAKE_LOAD_TYPE(nsIDocShell::LOAD_CMD_RELOAD,
86
nsIWebNavigation::LOAD_FLAGS_CHARSET_CHANGE |
87
nsIWebNavigation::LOAD_FLAGS_BYPASS_CACHE |
88
nsIWebNavigation::LOAD_FLAGS_BYPASS_PROXY),
89
LOAD_RELOAD_CHARSET_CHANGE_BYPASS_CACHE =
90
MAKE_LOAD_TYPE(nsIDocShell::LOAD_CMD_RELOAD,
91
nsIWebNavigation::LOAD_FLAGS_CHARSET_CHANGE |
92
nsIWebNavigation::LOAD_FLAGS_BYPASS_CACHE),
93
LOAD_BYPASS_HISTORY =
94
MAKE_LOAD_TYPE(nsIDocShell::LOAD_CMD_NORMAL,
95
nsIWebNavigation::LOAD_FLAGS_BYPASS_HISTORY),
96
LOAD_STOP_CONTENT = MAKE_LOAD_TYPE(nsIDocShell::LOAD_CMD_NORMAL,
97
nsIWebNavigation::LOAD_FLAGS_STOP_CONTENT),
98
LOAD_STOP_CONTENT_AND_REPLACE =
99
MAKE_LOAD_TYPE(nsIDocShell::LOAD_CMD_NORMAL,
100
nsIWebNavigation::LOAD_FLAGS_STOP_CONTENT |
101
nsIWebNavigation::LOAD_FLAGS_REPLACE_HISTORY),
102
LOAD_PUSHSTATE = MAKE_LOAD_TYPE(nsIDocShell::LOAD_CMD_PUSHSTATE,
103
nsIWebNavigation::LOAD_FLAGS_NONE),
104
LOAD_REPLACE_BYPASS_CACHE =
105
MAKE_LOAD_TYPE(nsIDocShell::LOAD_CMD_NORMAL,
106
nsIWebNavigation::LOAD_FLAGS_REPLACE_HISTORY |
107
nsIWebNavigation::LOAD_FLAGS_BYPASS_CACHE),
108
/**
109
* Load type for an error page. These loads are never triggered by users of
110
* Docshell. Instead, Docshell triggers the load itself when a
111
* consumer-triggered load failed.
112
*/
113
LOAD_ERROR_PAGE =
114
MAKE_LOAD_TYPE(nsIDocShell::LOAD_CMD_NORMAL, LOAD_FLAGS_ERROR_PAGE)
115
116
// NOTE: Adding a new value? Remember to update IsValidLoadType!
117
};
118
119
static inline bool IsForceReloadType(uint32_t aLoadType) {
120
switch (aLoadType) {
121
case LOAD_RELOAD_BYPASS_CACHE:
122
case LOAD_RELOAD_BYPASS_PROXY:
123
case LOAD_RELOAD_BYPASS_PROXY_AND_CACHE:
124
case LOAD_RELOAD_ALLOW_MIXED_CONTENT:
125
return true;
126
}
127
return false;
128
}
129
130
static inline bool IsValidLoadType(uint32_t aLoadType) {
131
switch (aLoadType) {
132
case LOAD_NORMAL:
133
case LOAD_NORMAL_REPLACE:
134
case LOAD_NORMAL_EXTERNAL:
135
case LOAD_NORMAL_BYPASS_CACHE:
136
case LOAD_NORMAL_BYPASS_PROXY:
137
case LOAD_NORMAL_BYPASS_PROXY_AND_CACHE:
138
case LOAD_NORMAL_ALLOW_MIXED_CONTENT:
139
case LOAD_HISTORY:
140
case LOAD_RELOAD_NORMAL:
141
case LOAD_RELOAD_BYPASS_CACHE:
142
case LOAD_RELOAD_BYPASS_PROXY:
143
case LOAD_RELOAD_BYPASS_PROXY_AND_CACHE:
144
case LOAD_RELOAD_ALLOW_MIXED_CONTENT:
145
case LOAD_LINK:
146
case LOAD_REFRESH:
147
case LOAD_RELOAD_CHARSET_CHANGE:
148
case LOAD_RELOAD_CHARSET_CHANGE_BYPASS_PROXY_AND_CACHE:
149
case LOAD_RELOAD_CHARSET_CHANGE_BYPASS_CACHE:
150
case LOAD_BYPASS_HISTORY:
151
case LOAD_STOP_CONTENT:
152
case LOAD_STOP_CONTENT_AND_REPLACE:
153
case LOAD_PUSHSTATE:
154
case LOAD_REPLACE_BYPASS_CACHE:
155
case LOAD_ERROR_PAGE:
156
return true;
157
}
158
return false;
159
}
160
161
static inline nsDOMNavigationTiming::Type ConvertLoadTypeToNavigationType(
162
uint32_t aLoadType) {
163
// Not initialized, assume it's normal load.
164
if (aLoadType == 0) {
165
aLoadType = LOAD_NORMAL;
166
}
167
168
auto result = nsDOMNavigationTiming::TYPE_RESERVED;
169
switch (aLoadType) {
170
case LOAD_NORMAL:
171
case LOAD_NORMAL_EXTERNAL:
172
case LOAD_NORMAL_BYPASS_CACHE:
173
case LOAD_NORMAL_BYPASS_PROXY:
174
case LOAD_NORMAL_BYPASS_PROXY_AND_CACHE:
175
case LOAD_NORMAL_REPLACE:
176
case LOAD_NORMAL_ALLOW_MIXED_CONTENT:
177
case LOAD_LINK:
178
case LOAD_STOP_CONTENT:
179
case LOAD_REPLACE_BYPASS_CACHE:
180
result = nsDOMNavigationTiming::TYPE_NAVIGATE;
181
break;
182
case LOAD_HISTORY:
183
result = nsDOMNavigationTiming::TYPE_BACK_FORWARD;
184
break;
185
case LOAD_RELOAD_NORMAL:
186
case LOAD_RELOAD_CHARSET_CHANGE:
187
case LOAD_RELOAD_CHARSET_CHANGE_BYPASS_PROXY_AND_CACHE:
188
case LOAD_RELOAD_CHARSET_CHANGE_BYPASS_CACHE:
189
case LOAD_RELOAD_BYPASS_CACHE:
190
case LOAD_RELOAD_BYPASS_PROXY:
191
case LOAD_RELOAD_BYPASS_PROXY_AND_CACHE:
192
case LOAD_RELOAD_ALLOW_MIXED_CONTENT:
193
result = nsDOMNavigationTiming::TYPE_RELOAD;
194
break;
195
case LOAD_STOP_CONTENT_AND_REPLACE:
196
case LOAD_REFRESH:
197
case LOAD_BYPASS_HISTORY:
198
case LOAD_ERROR_PAGE:
199
case LOAD_PUSHSTATE:
200
result = nsDOMNavigationTiming::TYPE_RESERVED;
201
break;
202
default:
203
result = nsDOMNavigationTiming::TYPE_RESERVED;
204
break;
205
}
206
207
return result;
208
}
209
210
#endif // MOZILLA_INTERNAL_API
211
#endif