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 r
ights reserved. | 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2011, 2012 Apple Inc. All r
ights reserved. |
7 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t
orchmobile.com/) | 7 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t
orchmobile.com/) |
8 * Copyright (C) 2008, 2009, 2011, 2012 Google Inc. All rights reserved. | 8 * Copyright (C) 2008, 2009, 2011, 2012 Google Inc. All rights reserved. |
9 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) | 9 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) |
10 * Copyright (C) Research In Motion Limited 2010-2011. All rights reserved. | 10 * Copyright (C) Research In Motion Limited 2010-2011. All rights reserved. |
(...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
345 return toLayoutPart(layoutObject)->widget(); | 345 return toLayoutPart(layoutObject)->widget(); |
346 } | 346 } |
347 | 347 |
348 static bool acceptsEditingFocus(const Element& element) | 348 static bool acceptsEditingFocus(const Element& element) |
349 { | 349 { |
350 DCHECK(element.hasEditableStyle()); | 350 DCHECK(element.hasEditableStyle()); |
351 | 351 |
352 return element.document().frame() && element.rootEditableElement(); | 352 return element.document().frame() && element.rootEditableElement(); |
353 } | 353 } |
354 | 354 |
355 static bool isOriginPotentiallyTrustworthy(SecurityOrigin* origin, String* error
Message) | |
356 { | |
357 if (origin->isPotentiallyTrustworthy()) | |
358 return true; | |
359 if (errorMessage) | |
360 *errorMessage = origin->isPotentiallyTrustworthyErrorMessage(); | |
361 return false; | |
362 } | |
363 | |
364 uint64_t Document::s_globalTreeVersion = 0; | 355 uint64_t Document::s_globalTreeVersion = 0; |
365 | 356 |
366 static bool s_threadedParsingEnabledForTesting = true; | 357 static bool s_threadedParsingEnabledForTesting = true; |
367 | 358 |
368 Document::WeakDocumentSet& Document::liveDocumentSet() | 359 Document::WeakDocumentSet& Document::liveDocumentSet() |
369 { | 360 { |
370 DEFINE_STATIC_LOCAL(WeakDocumentSet, set, (new WeakDocumentSet)); | 361 DEFINE_STATIC_LOCAL(WeakDocumentSet, set, (new WeakDocumentSet)); |
371 return set; | 362 return set; |
372 } | 363 } |
373 | 364 |
(...skipping 2973 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3347 | 3338 |
3348 void Document::cloneDataFromDocument(const Document& other) | 3339 void Document::cloneDataFromDocument(const Document& other) |
3349 { | 3340 { |
3350 setCompatibilityMode(other.getCompatibilityMode()); | 3341 setCompatibilityMode(other.getCompatibilityMode()); |
3351 setEncodingData(other.m_encodingData); | 3342 setEncodingData(other.m_encodingData); |
3352 setContextFeatures(other.contextFeatures()); | 3343 setContextFeatures(other.contextFeatures()); |
3353 setSecurityOrigin(other.getSecurityOrigin()->isolatedCopy()); | 3344 setSecurityOrigin(other.getSecurityOrigin()->isolatedCopy()); |
3354 setMimeType(other.contentType()); | 3345 setMimeType(other.contentType()); |
3355 } | 3346 } |
3356 | 3347 |
3357 bool Document::isSecureContextImpl(String* errorMessage, const SecureContextChec
k privilegeContextCheck) const | 3348 bool Document::isSecureContextImpl(const SecureContextCheck privilegeContextChec
k) const |
3358 { | 3349 { |
3359 // There may be exceptions for the secure context check defined for certain | 3350 // There may be exceptions for the secure context check defined for certain |
3360 // schemes. The exceptions are applied only to the special scheme and to | 3351 // schemes. The exceptions are applied only to the special scheme and to |
3361 // sandboxed URLs from those origins, but *not* to any children. | 3352 // sandboxed URLs from those origins, but *not* to any children. |
3362 // | 3353 // |
3363 // For example: | 3354 // For example: |
3364 // <iframe src="http://host"> | 3355 // <iframe src="http://host"> |
3365 // <iframe src="scheme-has-exception://host"></iframe> | 3356 // <iframe src="scheme-has-exception://host"></iframe> |
3366 // <iframe sandbox src="scheme-has-exception://host"></iframe> | 3357 // <iframe sandbox src="scheme-has-exception://host"></iframe> |
3367 // </iframe> | 3358 // </iframe> |
3368 // both inner iframes pass this check, assuming that the scheme | 3359 // both inner iframes pass this check, assuming that the scheme |
3369 // "scheme-has-exception:" is granted an exception. | 3360 // "scheme-has-exception:" is granted an exception. |
3370 // | 3361 // |
3371 // However, | 3362 // However, |
3372 // <iframe src="http://host"> | 3363 // <iframe src="http://host"> |
3373 // <iframe sandbox src="http://host"></iframe> | 3364 // <iframe sandbox src="http://host"></iframe> |
3374 // </iframe> | 3365 // </iframe> |
3375 // would fail the check (that is, sandbox does not grant an exception itself
). | 3366 // would fail the check (that is, sandbox does not grant an exception itself
). |
3376 // | 3367 // |
3377 // Additionally, with | 3368 // Additionally, with |
3378 // <iframe src="scheme-has-exception://host"> | 3369 // <iframe src="scheme-has-exception://host"> |
3379 // <iframe src="http://host"></iframe> | 3370 // <iframe src="http://host"></iframe> |
3380 // <iframe sandbox src="http://host"></iframe> | 3371 // <iframe sandbox src="http://host"></iframe> |
3381 // </iframe> | 3372 // </iframe> |
3382 // both inner iframes would fail the check, even though the outermost iframe | 3373 // both inner iframes would fail the check, even though the outermost iframe |
3383 // passes. | 3374 // passes. |
3384 // | 3375 // |
3385 // In all cases, a frame must be potentially trustworthy in addition to | 3376 // In all cases, a frame must be potentially trustworthy in addition to |
3386 // having an exception listed in order for the exception to be granted. | 3377 // having an exception listed in order for the exception to be granted. |
3387 if (!isOriginPotentiallyTrustworthy(getSecurityOrigin(), errorMessage)) | 3378 if (!getSecurityOrigin()->isPotentiallyTrustworthy()) |
3388 return false; | 3379 return false; |
3389 | 3380 |
3390 if (SchemeRegistry::schemeShouldBypassSecureContextCheck(getSecurityOrigin()
->protocol())) | 3381 if (SchemeRegistry::schemeShouldBypassSecureContextCheck(getSecurityOrigin()
->protocol())) |
3391 return true; | 3382 return true; |
3392 | 3383 |
3393 if (privilegeContextCheck == StandardSecureContextCheck) { | 3384 if (privilegeContextCheck == StandardSecureContextCheck) { |
3394 if (!m_frame) | 3385 if (!m_frame) |
3395 return true; | 3386 return true; |
3396 Frame* parent = m_frame->tree().parent(); | 3387 Frame* parent = m_frame->tree().parent(); |
3397 while (parent) { | 3388 while (parent) { |
3398 if (!isOriginPotentiallyTrustworthy(parent->securityContext()->getSe
curityOrigin(), errorMessage)) | 3389 if (!parent->securityContext()->getSecurityOrigin()->isPotentiallyTr
ustworthy()) |
3399 return false; | 3390 return false; |
3400 parent = parent->tree().parent(); | 3391 parent = parent->tree().parent(); |
3401 } | 3392 } |
3402 } | 3393 } |
3403 return true; | 3394 return true; |
3404 } | 3395 } |
3405 | 3396 |
3406 StyleSheetList& Document::styleSheets() | 3397 StyleSheetList& Document::styleSheets() |
3407 { | 3398 { |
3408 if (!m_styleSheetList) | 3399 if (!m_styleSheetList) |
(...skipping 2448 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5857 { | 5848 { |
5858 wrapper = V8DOMWrapper::associateObjectWithWrapper(isolate, this, wrapperTyp
e, wrapper); | 5849 wrapper = V8DOMWrapper::associateObjectWithWrapper(isolate, this, wrapperTyp
e, wrapper); |
5859 DOMWrapperWorld& world = DOMWrapperWorld::current(isolate); | 5850 DOMWrapperWorld& world = DOMWrapperWorld::current(isolate); |
5860 if (world.isMainWorld() && frame()) | 5851 if (world.isMainWorld() && frame()) |
5861 frame()->script().windowProxy(world)->updateDocumentWrapper(wrapper); | 5852 frame()->script().windowProxy(world)->updateDocumentWrapper(wrapper); |
5862 return wrapper; | 5853 return wrapper; |
5863 } | 5854 } |
5864 | 5855 |
5865 bool Document::isSecureContext(String& errorMessage, const SecureContextCheck pr
ivilegeContextCheck) const | 5856 bool Document::isSecureContext(String& errorMessage, const SecureContextCheck pr
ivilegeContextCheck) const |
5866 { | 5857 { |
5867 return isSecureContextImpl(&errorMessage, privilegeContextCheck); | 5858 if (isSecureContextImpl(privilegeContextCheck)) |
| 5859 return true; |
| 5860 errorMessage = SecurityOrigin::isPotentiallyTrustworthyErrorMessage(); |
| 5861 return false; |
5868 } | 5862 } |
5869 | 5863 |
5870 bool Document::isSecureContext(const SecureContextCheck privilegeContextCheck) c
onst | 5864 bool Document::isSecureContext(const SecureContextCheck privilegeContextCheck) c
onst |
5871 { | 5865 { |
5872 return isSecureContextImpl(nullptr, privilegeContextCheck); | 5866 return isSecureContextImpl(privilegeContextCheck); |
5873 } | 5867 } |
5874 | 5868 |
5875 WebTaskRunner* Document::loadingTaskRunner() const | 5869 WebTaskRunner* Document::loadingTaskRunner() const |
5876 { | 5870 { |
5877 if (frame()) | 5871 if (frame()) |
5878 return frame()->frameScheduler()->loadingTaskRunner(); | 5872 return frame()->frameScheduler()->loadingTaskRunner(); |
5879 if (m_importsController) | 5873 if (m_importsController) |
5880 return m_importsController->master()->loadingTaskRunner(); | 5874 return m_importsController->master()->loadingTaskRunner(); |
5881 if (m_contextDocument) | 5875 if (m_contextDocument) |
5882 return m_contextDocument->loadingTaskRunner(); | 5876 return m_contextDocument->loadingTaskRunner(); |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6016 #ifndef NDEBUG | 6010 #ifndef NDEBUG |
6017 using namespace blink; | 6011 using namespace blink; |
6018 void showLiveDocumentInstances() | 6012 void showLiveDocumentInstances() |
6019 { | 6013 { |
6020 Document::WeakDocumentSet& set = Document::liveDocumentSet(); | 6014 Document::WeakDocumentSet& set = Document::liveDocumentSet(); |
6021 fprintf(stderr, "There are %u documents currently alive:\n", set.size()); | 6015 fprintf(stderr, "There are %u documents currently alive:\n", set.size()); |
6022 for (Document* document : set) | 6016 for (Document* document : set) |
6023 fprintf(stderr, "- Document %p URL: %s\n", document, document->url().get
String().utf8().data()); | 6017 fprintf(stderr, "- Document %p URL: %s\n", document, document->url().get
String().utf8().data()); |
6024 } | 6018 } |
6025 #endif | 6019 #endif |
OLD | NEW |