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

Side by Side Diff: sky/engine/core/frame/Location.cpp

Issue 922893002: Merge the Sky Engine changes from the SkyDart branch (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 10 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
« no previous file with comments | « sky/engine/core/frame/Location.h ('k') | sky/engine/core/frame/Location.idl » ('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 11 matching lines...) Expand all
22 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
24 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
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 "sky/engine/config.h" 29 #include "sky/engine/config.h"
30 #include "sky/engine/core/frame/Location.h" 30 #include "sky/engine/core/frame/Location.h"
31 31
32 #include "sky/engine/bindings/core/v8/ExceptionState.h" 32 #include "sky/engine/bindings2/exception_state.h"
33 #include "sky/engine/core/dom/DOMURLUtilsReadOnly.h" 33 #include "sky/engine/core/dom/DOMURLUtilsReadOnly.h"
34 #include "sky/engine/core/dom/Document.h" 34 #include "sky/engine/core/dom/Document.h"
35 #include "sky/engine/core/dom/ExceptionCode.h" 35 #include "sky/engine/core/dom/ExceptionCode.h"
36 #include "sky/engine/core/frame/LocalDOMWindow.h" 36 #include "sky/engine/core/frame/LocalDOMWindow.h"
37 #include "sky/engine/core/frame/LocalFrame.h" 37 #include "sky/engine/core/frame/LocalFrame.h"
38 #include "sky/engine/platform/weborigin/KURL.h" 38 #include "sky/engine/platform/weborigin/KURL.h"
39 39
40 namespace blink { 40 namespace blink {
41 41
42 Location::Location(LocalFrame* frame) 42 Location::Location(LocalFrame* frame)
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 } 113 }
114 114
115 String Location::hash() const 115 String Location::hash() const
116 { 116 {
117 if (!m_frame) 117 if (!m_frame)
118 return String(); 118 return String();
119 119
120 return DOMURLUtilsReadOnly::hash(url()); 120 return DOMURLUtilsReadOnly::hash(url());
121 } 121 }
122 122
123 void Location::setHref(LocalDOMWindow* callingWindow, LocalDOMWindow* enteredWin dow, const String& url) 123 void Location::setHref(const String& url)
124 { 124 {
125 if (!m_frame) 125 if (!m_frame)
126 return; 126 return;
127 setLocation(url, callingWindow, enteredWindow); 127 setLocation(url);
128 } 128 }
129 129
130 void Location::setProtocol(LocalDOMWindow* callingWindow, LocalDOMWindow* entere dWindow, const String& protocol, ExceptionState& exceptionState) 130 void Location::setProtocol(const String& protocol, ExceptionState& exceptionStat e)
131 { 131 {
132 if (!m_frame) 132 if (!m_frame)
133 return; 133 return;
134 KURL url = m_frame->document()->url(); 134 KURL url = m_frame->document()->url();
135 if (!url.setProtocol(protocol)) { 135 if (!url.setProtocol(protocol)) {
136 exceptionState.throwDOMException(SyntaxError, "'" + protocol + "' is an invalid protocol."); 136 exceptionState.ThrowDOMException(SyntaxError, "'" + protocol + "' is an invalid protocol.");
137 return; 137 return;
138 } 138 }
139 setLocation(url.string(), callingWindow, enteredWindow); 139 setLocation(url.string());
140 } 140 }
141 141
142 void Location::setHost(LocalDOMWindow* callingWindow, LocalDOMWindow* enteredWin dow, const String& host) 142 void Location::setHost(const String& host)
143 { 143 {
144 if (!m_frame) 144 if (!m_frame)
145 return; 145 return;
146 KURL url = m_frame->document()->url(); 146 KURL url = m_frame->document()->url();
147 url.setHostAndPort(host); 147 url.setHostAndPort(host);
148 setLocation(url.string(), callingWindow, enteredWindow); 148 setLocation(url.string());
149 } 149 }
150 150
151 void Location::setHostname(LocalDOMWindow* callingWindow, LocalDOMWindow* entere dWindow, const String& hostname) 151 void Location::setHostname(const String& hostname)
152 { 152 {
153 if (!m_frame) 153 if (!m_frame)
154 return; 154 return;
155 KURL url = m_frame->document()->url(); 155 KURL url = m_frame->document()->url();
156 url.setHost(hostname); 156 url.setHost(hostname);
157 setLocation(url.string(), callingWindow, enteredWindow); 157 setLocation(url.string());
158 } 158 }
159 159
160 void Location::setPort(LocalDOMWindow* callingWindow, LocalDOMWindow* enteredWin dow, const String& portString) 160 void Location::setPort(const String& portString)
161 { 161 {
162 if (!m_frame) 162 if (!m_frame)
163 return; 163 return;
164 KURL url = m_frame->document()->url(); 164 KURL url = m_frame->document()->url();
165 url.setPort(portString); 165 url.setPort(portString);
166 setLocation(url.string(), callingWindow, enteredWindow); 166 setLocation(url.string());
167 } 167 }
168 168
169 void Location::setPathname(LocalDOMWindow* callingWindow, LocalDOMWindow* entere dWindow, const String& pathname) 169 void Location::setPathname(const String& pathname)
170 { 170 {
171 if (!m_frame) 171 if (!m_frame)
172 return; 172 return;
173 KURL url = m_frame->document()->url(); 173 KURL url = m_frame->document()->url();
174 url.setPath(pathname); 174 url.setPath(pathname);
175 setLocation(url.string(), callingWindow, enteredWindow); 175 setLocation(url.string());
176 } 176 }
177 177
178 void Location::setSearch(LocalDOMWindow* callingWindow, LocalDOMWindow* enteredW indow, const String& search) 178 void Location::setSearch(const String& search)
179 { 179 {
180 if (!m_frame) 180 if (!m_frame)
181 return; 181 return;
182 KURL url = m_frame->document()->url(); 182 KURL url = m_frame->document()->url();
183 url.setQuery(search); 183 url.setQuery(search);
184 setLocation(url.string(), callingWindow, enteredWindow); 184 setLocation(url.string());
185 } 185 }
186 186
187 void Location::setHash(LocalDOMWindow* callingWindow, LocalDOMWindow* enteredWin dow, const String& hash) 187 void Location::setHash(const String& hash)
188 { 188 {
189 if (!m_frame) 189 if (!m_frame)
190 return; 190 return;
191 KURL url = m_frame->document()->url(); 191 KURL url = m_frame->document()->url();
192 String oldFragmentIdentifier = url.fragmentIdentifier(); 192 String oldFragmentIdentifier = url.fragmentIdentifier();
193 String newFragmentIdentifier = hash; 193 String newFragmentIdentifier = hash;
194 if (hash[0] == '#') 194 if (hash[0] == '#')
195 newFragmentIdentifier = hash.substring(1); 195 newFragmentIdentifier = hash.substring(1);
196 url.setFragmentIdentifier(newFragmentIdentifier); 196 url.setFragmentIdentifier(newFragmentIdentifier);
197 // Note that by parsing the URL and *then* comparing fragments, we are 197 // Note that by parsing the URL and *then* comparing fragments, we are
198 // comparing fragments post-canonicalization, and so this handles the 198 // comparing fragments post-canonicalization, and so this handles the
199 // cases where fragment identifiers are ignored or invalid. 199 // cases where fragment identifiers are ignored or invalid.
200 if (equalIgnoringNullity(oldFragmentIdentifier, url.fragmentIdentifier())) 200 if (equalIgnoringNullity(oldFragmentIdentifier, url.fragmentIdentifier()))
201 return; 201 return;
202 setLocation(url.string(), callingWindow, enteredWindow); 202 setLocation(url.string());
203 } 203 }
204 204
205 void Location::assign(LocalDOMWindow* callingWindow, LocalDOMWindow* enteredWind ow, const String& url) 205 void Location::assign(const String& url)
206 { 206 {
207 if (!m_frame) 207 if (!m_frame)
208 return; 208 return;
209 setLocation(url, callingWindow, enteredWindow); 209 setLocation(url);
210 } 210 }
211 211
212 void Location::replace(LocalDOMWindow* callingWindow, LocalDOMWindow* enteredWin dow, const String& url) 212 void Location::replace(const String& url)
213 { 213 {
214 if (!m_frame) 214 if (!m_frame)
215 return; 215 return;
216 // Note: We call LocalDOMWindow::setLocation directly here because replace() always operates on the current frame. 216 // Note: We call LocalDOMWindow::setLocation directly here because replace() always operates on the current frame.
217 m_frame->domWindow()->setLocation(url, callingWindow, enteredWindow, LockHis toryAndBackForwardList); 217 m_frame->domWindow()->setLocation(url, LockHistoryAndBackForwardList);
218 } 218 }
219 219
220 void Location::reload(LocalDOMWindow* callingWindow) 220 void Location::reload()
221 { 221 {
222 // FIXME(sky): remove. 222 // FIXME(sky): remove.
223 } 223 }
224 224
225 void Location::setLocation(const String& url, LocalDOMWindow* callingWindow, Loc alDOMWindow* enteredWindow) 225 void Location::setLocation(const String& url)
226 { 226 {
227 ASSERT(m_frame); 227 ASSERT(m_frame);
228 m_frame->domWindow()->setLocation(url, callingWindow, enteredWindow); 228 m_frame->domWindow()->setLocation(url);
229 } 229 }
230 230
231 } // namespace blink 231 } // namespace blink
OLDNEW
« no previous file with comments | « sky/engine/core/frame/Location.h ('k') | sky/engine/core/frame/Location.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698