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

Side by Side Diff: Source/WebCore/platform/KURLGoogle.cpp

Issue 8856006: WebKit changes needed for supporting filesystem URLs natively in GURL/KURL. (Closed) Base URL: http://svn.webkit.org/repository/webkit/trunk
Patch Set: Remove dead constructor code. Created 9 years 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 | « Source/WebCore/platform/KURL.h ('k') | Source/WebCore/platform/KURLGooglePrivate.h » ('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) 2004, 2007, 2008, 2009 Apple Inc. All rights reserved. 2 * Copyright (C) 2004, 2007, 2008, 2009 Apple Inc. All rights reserved.
3 * Copyright (C) 2008, 2009, 2011 Google Inc. All rights reserved. 3 * Copyright (C) 2008, 2009, 2011 Google Inc. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are 6 * modification, are permitted provided that the following conditions are
7 * met: 7 * met:
8 * 8 *
9 * * Redistributions of source code must retain the above copyright 9 * * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 , m_utf8IsASCII(true) 167 , m_utf8IsASCII(true)
168 , m_stringIsValid(false) 168 , m_stringIsValid(false)
169 { 169 {
170 } 170 }
171 171
172 KURLGooglePrivate::KURLGooglePrivate(WTF::HashTableDeletedValueType) 172 KURLGooglePrivate::KURLGooglePrivate(WTF::HashTableDeletedValueType)
173 : m_string(WTF::HashTableDeletedValue) 173 : m_string(WTF::HashTableDeletedValue)
174 { 174 {
175 } 175 }
176 176
177 KURLGooglePrivate::KURLGooglePrivate(const KURLGooglePrivate& o)
178 : m_isValid(o.m_isValid)
179 , m_protocolIsInHTTPFamily(o.m_protocolIsInHTTPFamily)
180 , m_parsed(o.m_parsed)
181 , m_utf8(o.m_utf8)
182 , m_utf8IsASCII(o.m_utf8IsASCII)
183 , m_stringIsValid(o.m_stringIsValid)
184 , m_string(o.m_string)
185 {
186 if (o.m_innerURL.get())
187 m_innerURL = adoptPtr(new KURL(o.m_innerURL->copy()));
188 }
189
190 KURLGooglePrivate& KURLGooglePrivate::operator=(const KURLGooglePrivate& o)
191 {
192 m_isValid = o.m_isValid;
193 m_protocolIsInHTTPFamily = o.m_protocolIsInHTTPFamily;
194 m_parsed = o.m_parsed;
195 m_utf8 = o.m_utf8;
196 m_utf8IsASCII = o.m_utf8IsASCII;
197 m_stringIsValid = o.m_stringIsValid;
198 m_string = o.m_string;
199 if (o.m_innerURL.get())
200 m_innerURL = adoptPtr(new KURL(o.m_innerURL->copy()));
201 else
202 m_innerURL.clear();
203 return *this;
204 }
205
177 // Setters for the data. Using the ASCII version when you know the 206 // Setters for the data. Using the ASCII version when you know the
178 // data is ASCII will be slightly more efficient. The UTF-8 version 207 // data is ASCII will be slightly more efficient. The UTF-8 version
179 // will always be correct if the caller is unsure. 208 // will always be correct if the caller is unsure.
180 void KURLGooglePrivate::setUtf8(const CString& str) 209 void KURLGooglePrivate::setUtf8(const CString& str)
181 { 210 {
182 const char* data = str.data(); 211 const char* data = str.data();
183 unsigned dataLength = str.length(); 212 unsigned dataLength = str.length();
184 213
185 // The m_utf8IsASCII must always be correct since the DeprecatedString 214 // The m_utf8IsASCII must always be correct since the DeprecatedString
186 // getter must create it with the proper constructor. This test can be 215 // getter must create it with the proper constructor. This test can be
187 // removed when DeprecatedString is gone, but it still might be a 216 // removed when DeprecatedString is gone, but it still might be a
188 // performance win. 217 // performance win.
189 m_utf8IsASCII = true; 218 m_utf8IsASCII = true;
190 for (unsigned i = 0; i < dataLength; i++) { 219 for (unsigned i = 0; i < dataLength; i++) {
191 if (static_cast<unsigned char>(data[i]) >= 0x80) { 220 if (static_cast<unsigned char>(data[i]) >= 0x80) {
192 m_utf8IsASCII = false; 221 m_utf8IsASCII = false;
193 break; 222 break;
194 } 223 }
195 } 224 }
196 225
197 m_utf8 = str; 226 m_utf8 = str;
198 m_stringIsValid = false; 227 m_stringIsValid = false;
199 initProtocolIsInHTTPFamily(); 228 initProtocolIsInHTTPFamily();
229 initInnerURL();
200 } 230 }
201 231
202 void KURLGooglePrivate::setAscii(const CString& str) 232 void KURLGooglePrivate::setAscii(const CString& str)
203 { 233 {
204 m_utf8 = str; 234 m_utf8 = str;
205 m_utf8IsASCII = true; 235 m_utf8IsASCII = true;
206 m_stringIsValid = false; 236 m_stringIsValid = false;
207 initProtocolIsInHTTPFamily(); 237 initProtocolIsInHTTPFamily();
238 initInnerURL();
208 } 239 }
209 240
210 void KURLGooglePrivate::init(const KURL& base, 241 void KURLGooglePrivate::init(const KURL& base,
211 const String& relative, 242 const String& relative,
212 const TextEncoding* queryEncoding) 243 const TextEncoding* queryEncoding)
213 { 244 {
214 init(base, relative.characters(), relative.length(), queryEncoding); 245 init(base, relative.characters(), relative.length(), queryEncoding);
215 } 246 }
216 247
217 template <typename CHAR> 248 template <typename CHAR>
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
251 if (m_parsed.ref.is_nonempty()) 282 if (m_parsed.ref.is_nonempty())
252 setUtf8(CString(output.data(), output.length())); 283 setUtf8(CString(output.data(), output.length()));
253 else 284 else
254 setAscii(CString(output.data(), output.length())); 285 setAscii(CString(output.data(), output.length()));
255 } else { 286 } else {
256 // WebCore expects resolved URLs to be empty rather than null. 287 // WebCore expects resolved URLs to be empty rather than null.
257 setUtf8(CString("", 0)); 288 setUtf8(CString("", 0));
258 } 289 }
259 } 290 }
260 291
292 void KURLGooglePrivate::initInnerURL() {
293 if (!m_isValid) {
294 m_innerURL.clear();
295 return;
296 }
297 url_parse::Parsed* innerParsed = m_parsed.inner_parsed();
298 if (innerParsed)
299 m_innerURL = adoptPtr(new KURL(
300 ParsedURLString,
301 String(m_utf8.data() + innerParsed->scheme.begin, innerParsed->Lengt h() - innerParsed->scheme.begin)));
302 else
303 m_innerURL.clear();
304 }
305
261 void KURLGooglePrivate::initProtocolIsInHTTPFamily() 306 void KURLGooglePrivate::initProtocolIsInHTTPFamily()
262 { 307 {
263 if (!m_isValid) { 308 if (!m_isValid) {
264 m_protocolIsInHTTPFamily = false; 309 m_protocolIsInHTTPFamily = false;
265 return; 310 return;
266 } 311 }
267 312
268 const char* scheme = m_utf8.data() + m_parsed.scheme.begin; 313 const char* scheme = m_utf8.data() + m_parsed.scheme.begin;
269 if (m_parsed.scheme.len == 4) 314 if (m_parsed.scheme.len == 4)
270 m_protocolIsInHTTPFamily = lowerCaseEqualsASCII(scheme, scheme + 4, "htt p"); 315 m_protocolIsInHTTPFamily = lowerCaseEqualsASCII(scheme, scheme + 4, "htt p");
271 else if (m_parsed.scheme.len == 5) 316 else if (m_parsed.scheme.len == 5)
272 m_protocolIsInHTTPFamily = lowerCaseEqualsASCII(scheme, scheme + 5, "htt ps"); 317 m_protocolIsInHTTPFamily = lowerCaseEqualsASCII(scheme, scheme + 5, "htt ps");
273 else 318 else
274 m_protocolIsInHTTPFamily = false; 319 m_protocolIsInHTTPFamily = false;
275 } 320 }
276 321
277 void KURLGooglePrivate::copyTo(KURLGooglePrivate* dest) const 322 void KURLGooglePrivate::copyTo(KURLGooglePrivate* dest) const
278 { 323 {
279 dest->m_isValid = m_isValid; 324 dest->m_isValid = m_isValid;
280 dest->m_protocolIsInHTTPFamily = m_protocolIsInHTTPFamily; 325 dest->m_protocolIsInHTTPFamily = m_protocolIsInHTTPFamily;
281 dest->m_parsed = m_parsed; 326 dest->m_parsed = m_parsed;
282 327
283 // Don't copy the 16-bit string since that will be regenerated as needed. 328 // Don't copy the 16-bit string since that will be regenerated as needed.
284 dest->m_utf8 = CString(m_utf8.data(), m_utf8.length()); 329 dest->m_utf8 = CString(m_utf8.data(), m_utf8.length());
285 dest->m_utf8IsASCII = m_utf8IsASCII; 330 dest->m_utf8IsASCII = m_utf8IsASCII;
286 dest->m_stringIsValid = false; 331 dest->m_stringIsValid = false;
287 dest->m_string = String(); // Clear the invalid string to avoid cross thread ref counting. 332 dest->m_string = String(); // Clear the invalid string to avoid cross thread ref counting.
333 if (m_innerURL) {
334 dest->m_innerURL = adoptPtr(new KURL(m_innerURL->copy()));
335 }
336 else
337 dest->m_innerURL.clear();
288 } 338 }
289 339
290 String KURLGooglePrivate::componentString(const url_parse::Component& comp) cons t 340 String KURLGooglePrivate::componentString(const url_parse::Component& comp) cons t
291 { 341 {
292 if (!m_isValid || comp.len <= 0) { 342 if (!m_isValid || comp.len <= 0) {
293 // KURL returns a null string if the URL is itself a null string, and an 343 // KURL returns a null string if the URL is itself a null string, and an
294 // empty string for other nonexistent entities. 344 // empty string for other nonexistent entities.
295 if (utf8String().isNull()) 345 if (utf8String().isNull())
296 return String(); 346 return String();
297 return String("", 0); 347 return String("", 0);
(...skipping 522 matching lines...) Expand 10 before | Expand all | Expand 10 after
820 reinterpret_cast<const UChar*>(notEncodedString.characters()), 870 reinterpret_cast<const UChar*>(notEncodedString.characters()),
821 notEncodedString.length(), 871 notEncodedString.length(),
822 URLEncodedEntitiesForUnencodables); 872 URLEncodedEntitiesForUnencodables);
823 const char* input = utf8.data(); 873 const char* input = utf8.data();
824 int inputLength = utf8.length(); 874 int inputLength = utf8.length();
825 url_canon::RawCanonOutputT<char> buffer; 875 url_canon::RawCanonOutputT<char> buffer;
826 if (buffer.length() < inputLength * 3) 876 if (buffer.length() < inputLength * 3)
827 buffer.Resize(inputLength * 3); 877 buffer.Resize(inputLength * 3);
828 878
829 url_util::EncodeURIComponent(input, inputLength, &buffer); 879 url_util::EncodeURIComponent(input, inputLength, &buffer);
830 return String(buffer.data(), buffer.length()); 880 String escaped(buffer.data(), buffer.length());
881 // Unescape '/'; it's safe and much prettier.
882 escaped.replace("%2F", "/");
883 return escaped;
831 } 884 }
832 885
833 bool KURL::isHierarchical() const 886 bool KURL::isHierarchical() const
834 { 887 {
835 if (!m_url.m_parsed.scheme.is_nonempty()) 888 if (!m_url.m_parsed.scheme.is_nonempty())
836 return false; 889 return false;
837 return url_util::IsStandard( 890 return url_util::IsStandard(
838 &m_url.utf8String().data()[m_url.m_parsed.scheme.begin], 891 &m_url.utf8String().data()[m_url.m_parsed.scheme.begin],
839 m_url.m_parsed.scheme); 892 m_url.m_parsed.scheme);
840 } 893 }
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
943 996
944 if (a.port() != b.port()) 997 if (a.port() != b.port())
945 return false; 998 return false;
946 999
947 return true; 1000 return true;
948 } 1001 }
949 1002
950 } // namespace WebCore 1003 } // namespace WebCore
951 1004
952 #endif // USE(GOOGLEURL) 1005 #endif // USE(GOOGLEURL)
OLDNEW
« no previous file with comments | « Source/WebCore/platform/KURL.h ('k') | Source/WebCore/platform/KURLGooglePrivate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698