Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(23)

Side by Side Diff: Source/core/frame/Location.cpp

Issue 334283004: Rename DOMWindow to LocalDOMWindow (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebase Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/core/frame/Location.h ('k') | Source/core/frame/SmartClip.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2008, 2010 Apple Inc. All rights reserved. 2 * Copyright (C) 2008, 2010 Apple Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 15 matching lines...) Expand all
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */ 27 */
28 28
29 #include "config.h" 29 #include "config.h"
30 #include "core/frame/Location.h" 30 #include "core/frame/Location.h"
31 31
32 #include "bindings/v8/ExceptionState.h" 32 #include "bindings/v8/ExceptionState.h"
33 #include "core/dom/DOMURLUtilsReadOnly.h" 33 #include "core/dom/DOMURLUtilsReadOnly.h"
34 #include "core/dom/Document.h" 34 #include "core/dom/Document.h"
35 #include "core/dom/ExceptionCode.h" 35 #include "core/dom/ExceptionCode.h"
36 #include "core/frame/DOMWindow.h" 36 #include "core/frame/LocalDOMWindow.h"
37 #include "core/frame/LocalFrame.h" 37 #include "core/frame/LocalFrame.h"
38 #include "core/loader/FrameLoader.h" 38 #include "core/loader/FrameLoader.h"
39 #include "platform/weborigin/KURL.h" 39 #include "platform/weborigin/KURL.h"
40 #include "platform/weborigin/SecurityOrigin.h" 40 #include "platform/weborigin/SecurityOrigin.h"
41 41
42 namespace WebCore { 42 namespace WebCore {
43 43
44 Location::Location(LocalFrame* frame) 44 Location::Location(LocalFrame* frame)
45 : DOMWindowProperty(frame) 45 : DOMWindowProperty(frame)
46 { 46 {
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 } 129 }
130 130
131 String Location::hash() const 131 String Location::hash() const
132 { 132 {
133 if (!m_frame) 133 if (!m_frame)
134 return String(); 134 return String();
135 135
136 return DOMURLUtilsReadOnly::hash(url()); 136 return DOMURLUtilsReadOnly::hash(url());
137 } 137 }
138 138
139 void Location::setHref(DOMWindow* callingWindow, DOMWindow* enteredWindow, const String& url) 139 void Location::setHref(LocalDOMWindow* callingWindow, LocalDOMWindow* enteredWin dow, const String& url)
140 { 140 {
141 if (!m_frame) 141 if (!m_frame)
142 return; 142 return;
143 setLocation(url, callingWindow, enteredWindow); 143 setLocation(url, callingWindow, enteredWindow);
144 } 144 }
145 145
146 void Location::setProtocol(DOMWindow* callingWindow, DOMWindow* enteredWindow, c onst String& protocol, ExceptionState& exceptionState) 146 void Location::setProtocol(LocalDOMWindow* callingWindow, LocalDOMWindow* entere dWindow, const String& protocol, ExceptionState& exceptionState)
147 { 147 {
148 if (!m_frame) 148 if (!m_frame)
149 return; 149 return;
150 KURL url = m_frame->document()->url(); 150 KURL url = m_frame->document()->url();
151 if (!url.setProtocol(protocol)) { 151 if (!url.setProtocol(protocol)) {
152 exceptionState.throwDOMException(SyntaxError, "'" + protocol + "' is an invalid protocol."); 152 exceptionState.throwDOMException(SyntaxError, "'" + protocol + "' is an invalid protocol.");
153 return; 153 return;
154 } 154 }
155 setLocation(url.string(), callingWindow, enteredWindow); 155 setLocation(url.string(), callingWindow, enteredWindow);
156 } 156 }
157 157
158 void Location::setHost(DOMWindow* callingWindow, DOMWindow* enteredWindow, const String& host) 158 void Location::setHost(LocalDOMWindow* callingWindow, LocalDOMWindow* enteredWin dow, const String& host)
159 { 159 {
160 if (!m_frame) 160 if (!m_frame)
161 return; 161 return;
162 KURL url = m_frame->document()->url(); 162 KURL url = m_frame->document()->url();
163 url.setHostAndPort(host); 163 url.setHostAndPort(host);
164 setLocation(url.string(), callingWindow, enteredWindow); 164 setLocation(url.string(), callingWindow, enteredWindow);
165 } 165 }
166 166
167 void Location::setHostname(DOMWindow* callingWindow, DOMWindow* enteredWindow, c onst String& hostname) 167 void Location::setHostname(LocalDOMWindow* callingWindow, LocalDOMWindow* entere dWindow, const String& hostname)
168 { 168 {
169 if (!m_frame) 169 if (!m_frame)
170 return; 170 return;
171 KURL url = m_frame->document()->url(); 171 KURL url = m_frame->document()->url();
172 url.setHost(hostname); 172 url.setHost(hostname);
173 setLocation(url.string(), callingWindow, enteredWindow); 173 setLocation(url.string(), callingWindow, enteredWindow);
174 } 174 }
175 175
176 void Location::setPort(DOMWindow* callingWindow, DOMWindow* enteredWindow, const String& portString) 176 void Location::setPort(LocalDOMWindow* callingWindow, LocalDOMWindow* enteredWin dow, const String& portString)
177 { 177 {
178 if (!m_frame) 178 if (!m_frame)
179 return; 179 return;
180 KURL url = m_frame->document()->url(); 180 KURL url = m_frame->document()->url();
181 url.setPort(portString); 181 url.setPort(portString);
182 setLocation(url.string(), callingWindow, enteredWindow); 182 setLocation(url.string(), callingWindow, enteredWindow);
183 } 183 }
184 184
185 void Location::setPathname(DOMWindow* callingWindow, DOMWindow* enteredWindow, c onst String& pathname) 185 void Location::setPathname(LocalDOMWindow* callingWindow, LocalDOMWindow* entere dWindow, const String& pathname)
186 { 186 {
187 if (!m_frame) 187 if (!m_frame)
188 return; 188 return;
189 KURL url = m_frame->document()->url(); 189 KURL url = m_frame->document()->url();
190 url.setPath(pathname); 190 url.setPath(pathname);
191 setLocation(url.string(), callingWindow, enteredWindow); 191 setLocation(url.string(), callingWindow, enteredWindow);
192 } 192 }
193 193
194 void Location::setSearch(DOMWindow* callingWindow, DOMWindow* enteredWindow, con st String& search) 194 void Location::setSearch(LocalDOMWindow* callingWindow, LocalDOMWindow* enteredW indow, const String& search)
195 { 195 {
196 if (!m_frame) 196 if (!m_frame)
197 return; 197 return;
198 KURL url = m_frame->document()->url(); 198 KURL url = m_frame->document()->url();
199 url.setQuery(search); 199 url.setQuery(search);
200 setLocation(url.string(), callingWindow, enteredWindow); 200 setLocation(url.string(), callingWindow, enteredWindow);
201 } 201 }
202 202
203 void Location::setHash(DOMWindow* callingWindow, DOMWindow* enteredWindow, const String& hash) 203 void Location::setHash(LocalDOMWindow* callingWindow, LocalDOMWindow* enteredWin dow, const String& hash)
204 { 204 {
205 if (!m_frame) 205 if (!m_frame)
206 return; 206 return;
207 KURL url = m_frame->document()->url(); 207 KURL url = m_frame->document()->url();
208 String oldFragmentIdentifier = url.fragmentIdentifier(); 208 String oldFragmentIdentifier = url.fragmentIdentifier();
209 String newFragmentIdentifier = hash; 209 String newFragmentIdentifier = hash;
210 if (hash[0] == '#') 210 if (hash[0] == '#')
211 newFragmentIdentifier = hash.substring(1); 211 newFragmentIdentifier = hash.substring(1);
212 url.setFragmentIdentifier(newFragmentIdentifier); 212 url.setFragmentIdentifier(newFragmentIdentifier);
213 // Note that by parsing the URL and *then* comparing fragments, we are 213 // Note that by parsing the URL and *then* comparing fragments, we are
214 // comparing fragments post-canonicalization, and so this handles the 214 // comparing fragments post-canonicalization, and so this handles the
215 // cases where fragment identifiers are ignored or invalid. 215 // cases where fragment identifiers are ignored or invalid.
216 if (equalIgnoringNullity(oldFragmentIdentifier, url.fragmentIdentifier())) 216 if (equalIgnoringNullity(oldFragmentIdentifier, url.fragmentIdentifier()))
217 return; 217 return;
218 setLocation(url.string(), callingWindow, enteredWindow); 218 setLocation(url.string(), callingWindow, enteredWindow);
219 } 219 }
220 220
221 void Location::assign(DOMWindow* callingWindow, DOMWindow* enteredWindow, const String& url) 221 void Location::assign(LocalDOMWindow* callingWindow, LocalDOMWindow* enteredWind ow, const String& url)
222 { 222 {
223 if (!m_frame) 223 if (!m_frame)
224 return; 224 return;
225 setLocation(url, callingWindow, enteredWindow); 225 setLocation(url, callingWindow, enteredWindow);
226 } 226 }
227 227
228 void Location::replace(DOMWindow* callingWindow, DOMWindow* enteredWindow, const String& url) 228 void Location::replace(LocalDOMWindow* callingWindow, LocalDOMWindow* enteredWin dow, const String& url)
229 { 229 {
230 if (!m_frame) 230 if (!m_frame)
231 return; 231 return;
232 // Note: We call DOMWindow::setLocation directly here because replace() alwa ys operates on the current frame. 232 // Note: We call LocalDOMWindow::setLocation directly here because replace() always operates on the current frame.
233 m_frame->domWindow()->setLocation(url, callingWindow, enteredWindow, LockHis toryAndBackForwardList); 233 m_frame->domWindow()->setLocation(url, callingWindow, enteredWindow, LockHis toryAndBackForwardList);
234 } 234 }
235 235
236 void Location::reload(DOMWindow* callingWindow) 236 void Location::reload(LocalDOMWindow* callingWindow)
237 { 237 {
238 if (!m_frame) 238 if (!m_frame)
239 return; 239 return;
240 if (protocolIsJavaScript(m_frame->document()->url())) 240 if (protocolIsJavaScript(m_frame->document()->url()))
241 return; 241 return;
242 m_frame->navigationScheduler().scheduleRefresh(); 242 m_frame->navigationScheduler().scheduleRefresh();
243 } 243 }
244 244
245 void Location::setLocation(const String& url, DOMWindow* callingWindow, DOMWindo w* enteredWindow) 245 void Location::setLocation(const String& url, LocalDOMWindow* callingWindow, Loc alDOMWindow* enteredWindow)
246 { 246 {
247 ASSERT(m_frame); 247 ASSERT(m_frame);
248 LocalFrame* frame = m_frame->loader().findFrameForNavigation(nullAtom, calli ngWindow->document()); 248 LocalFrame* frame = m_frame->loader().findFrameForNavigation(nullAtom, calli ngWindow->document());
249 if (!frame) 249 if (!frame)
250 return; 250 return;
251 frame->domWindow()->setLocation(url, callingWindow, enteredWindow); 251 frame->domWindow()->setLocation(url, callingWindow, enteredWindow);
252 } 252 }
253 253
254 } // namespace WebCore 254 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/frame/Location.h ('k') | Source/core/frame/SmartClip.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698