| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
| 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) | 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) |
| 4 * (C) 2001 Dirk Mueller (mueller@kde.org) | 4 * (C) 2001 Dirk Mueller (mueller@kde.org) |
| 5 * (C) 2006 Alexey Proskuryakov (ap@webkit.org) | 5 * (C) 2006 Alexey Proskuryakov (ap@webkit.org) |
| 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2011, 2012 Apple Inc. All | 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2011, 2012 Apple Inc. All |
| 7 * rights reserved. | 7 * rights reserved. |
| 8 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. | 8 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. |
| 9 * (http://www.torchmobile.com/) | 9 * (http://www.torchmobile.com/) |
| 10 * Copyright (C) 2008, 2009, 2011, 2012 Google Inc. All rights reserved. | 10 * Copyright (C) 2008, 2009, 2011, 2012 Google Inc. All rights reserved. |
| (...skipping 3269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3280 anchor.invalidateCachedVisitedLinkHash(); | 3280 anchor.invalidateCachedVisitedLinkHash(); |
| 3281 } | 3281 } |
| 3282 } | 3282 } |
| 3283 | 3283 |
| 3284 void Document::setBaseURLOverride(const KURL& url) { | 3284 void Document::setBaseURLOverride(const KURL& url) { |
| 3285 m_baseURLOverride = url; | 3285 m_baseURLOverride = url; |
| 3286 updateBaseURL(); | 3286 updateBaseURL(); |
| 3287 } | 3287 } |
| 3288 | 3288 |
| 3289 void Document::processBaseElement() { | 3289 void Document::processBaseElement() { |
| 3290 UseCounter::count(*this, UseCounter::BaseElement); |
| 3291 |
| 3290 // Find the first href attribute in a base element and the first target | 3292 // Find the first href attribute in a base element and the first target |
| 3291 // attribute in a base element. | 3293 // attribute in a base element. |
| 3292 const AtomicString* href = 0; | 3294 const AtomicString* href = 0; |
| 3293 const AtomicString* target = 0; | 3295 const AtomicString* target = 0; |
| 3294 for (HTMLBaseElement* base = Traversal<HTMLBaseElement>::firstWithin(*this); | 3296 for (HTMLBaseElement* base = Traversal<HTMLBaseElement>::firstWithin(*this); |
| 3295 base && (!href || !target); | 3297 base && (!href || !target); |
| 3296 base = Traversal<HTMLBaseElement>::next(*base)) { | 3298 base = Traversal<HTMLBaseElement>::next(*base)) { |
| 3297 if (!href) { | 3299 if (!href) { |
| 3298 const AtomicString& value = base->fastGetAttribute(hrefAttr); | 3300 const AtomicString& value = base->fastGetAttribute(hrefAttr); |
| 3299 if (!value.isNull()) | 3301 if (!value.isNull()) |
| 3300 href = &value; | 3302 href = &value; |
| 3301 } | 3303 } |
| 3302 if (!target) { | 3304 if (!target) { |
| 3303 const AtomicString& value = base->fastGetAttribute(targetAttr); | 3305 const AtomicString& value = base->fastGetAttribute(targetAttr); |
| 3304 if (!value.isNull()) | 3306 if (!value.isNull()) |
| 3305 target = &value; | 3307 target = &value; |
| 3306 } | 3308 } |
| 3307 if (contentSecurityPolicy()->isActive()) | 3309 if (contentSecurityPolicy()->isActive()) { |
| 3308 UseCounter::count(*this, | 3310 UseCounter::count(*this, |
| 3309 UseCounter::ContentSecurityPolicyWithBaseElement); | 3311 UseCounter::ContentSecurityPolicyWithBaseElement); |
| 3312 } |
| 3310 } | 3313 } |
| 3311 | 3314 |
| 3312 // FIXME: Since this doesn't share code with completeURL it may not handle | 3315 // FIXME: Since this doesn't share code with completeURL it may not handle |
| 3313 // encodings correctly. | 3316 // encodings correctly. |
| 3314 KURL baseElementURL; | 3317 KURL baseElementURL; |
| 3315 if (href) { | 3318 if (href) { |
| 3316 String strippedHref = stripLeadingAndTrailingHTMLSpaces(*href); | 3319 String strippedHref = stripLeadingAndTrailingHTMLSpaces(*href); |
| 3317 if (!strippedHref.isEmpty()) | 3320 if (!strippedHref.isEmpty()) |
| 3318 baseElementURL = KURL(url(), strippedHref); | 3321 baseElementURL = KURL(url(), strippedHref); |
| 3319 } | 3322 } |
| 3323 |
| 3324 if (!baseElementURL.isEmpty()) { |
| 3325 if (baseElementURL.protocolIsData()) |
| 3326 UseCounter::count(*this, UseCounter::BaseWithDataHref); |
| 3327 if (!this->getSecurityOrigin()->canRequest(baseElementURL)) |
| 3328 UseCounter::count(*this, UseCounter::BaseWithCrossOriginHref); |
| 3329 } |
| 3330 |
| 3320 if (m_baseElementURL != baseElementURL && | 3331 if (m_baseElementURL != baseElementURL && |
| 3321 contentSecurityPolicy()->allowBaseURI(baseElementURL)) { | 3332 contentSecurityPolicy()->allowBaseURI(baseElementURL)) { |
| 3322 m_baseElementURL = baseElementURL; | 3333 m_baseElementURL = baseElementURL; |
| 3323 updateBaseURL(); | 3334 updateBaseURL(); |
| 3324 } | 3335 } |
| 3325 | 3336 |
| 3326 m_baseTarget = target ? *target : nullAtom; | 3337 if (target) { |
| 3338 if (target->contains('\n') || target->contains('\r')) |
| 3339 UseCounter::count(*this, UseCounter::BaseWithNewlinesInTarget); |
| 3340 if (target->contains('<')) |
| 3341 UseCounter::count(*this, UseCounter::BaseWithOpenBracketInTarget); |
| 3342 m_baseTarget = *target; |
| 3343 } else { |
| 3344 m_baseTarget = nullAtom; |
| 3345 } |
| 3327 } | 3346 } |
| 3328 | 3347 |
| 3329 String Document::userAgent() const { | 3348 String Document::userAgent() const { |
| 3330 return frame() ? frame()->loader().userAgent() : String(); | 3349 return frame() ? frame()->loader().userAgent() : String(); |
| 3331 } | 3350 } |
| 3332 | 3351 |
| 3333 void Document::disableEval(const String& errorMessage) { | 3352 void Document::disableEval(const String& errorMessage) { |
| 3334 if (!frame()) | 3353 if (!frame()) |
| 3335 return; | 3354 return; |
| 3336 | 3355 |
| (...skipping 3138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6475 } | 6494 } |
| 6476 | 6495 |
| 6477 void showLiveDocumentInstances() { | 6496 void showLiveDocumentInstances() { |
| 6478 WeakDocumentSet& set = liveDocumentSet(); | 6497 WeakDocumentSet& set = liveDocumentSet(); |
| 6479 fprintf(stderr, "There are %u documents currently alive:\n", set.size()); | 6498 fprintf(stderr, "There are %u documents currently alive:\n", set.size()); |
| 6480 for (Document* document : set) | 6499 for (Document* document : set) |
| 6481 fprintf(stderr, "- Document %p URL: %s\n", document, | 6500 fprintf(stderr, "- Document %p URL: %s\n", document, |
| 6482 document->url().getString().utf8().data()); | 6501 document->url().getString().utf8().data()); |
| 6483 } | 6502 } |
| 6484 #endif | 6503 #endif |
| OLD | NEW |