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 2316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2327 m_loadEventProgress = LoadEventInProgress; | 2327 m_loadEventProgress = LoadEventInProgress; |
2328 | 2328 |
2329 ScriptableDocumentParser* parser = scriptableDocumentParser(); | 2329 ScriptableDocumentParser* parser = scriptableDocumentParser(); |
2330 m_wellFormed = parser && parser->wellFormed(); | 2330 m_wellFormed = parser && parser->wellFormed(); |
2331 | 2331 |
2332 // We have to clear the parser, in case someone document.write()s from the | 2332 // We have to clear the parser, in case someone document.write()s from the |
2333 // onLoad event handler, as in Radar 3206524. | 2333 // onLoad event handler, as in Radar 3206524. |
2334 detachParser(); | 2334 detachParser(); |
2335 | 2335 |
2336 Frame* f = frame(); | 2336 Frame* f = frame(); |
2337 if (f && f->script()->canExecuteScripts(NotAboutToExecuteScript)) { | 2337 if (f && f->script().canExecuteScripts(NotAboutToExecuteScript)) { |
2338 ImageLoader::dispatchPendingBeforeLoadEvents(); | 2338 ImageLoader::dispatchPendingBeforeLoadEvents(); |
2339 ImageLoader::dispatchPendingLoadEvents(); | 2339 ImageLoader::dispatchPendingLoadEvents(); |
2340 ImageLoader::dispatchPendingErrorEvents(); | 2340 ImageLoader::dispatchPendingErrorEvents(); |
2341 | 2341 |
2342 HTMLLinkElement::dispatchPendingLoadEvents(); | 2342 HTMLLinkElement::dispatchPendingLoadEvents(); |
2343 HTMLStyleElement::dispatchPendingLoadEvents(); | 2343 HTMLStyleElement::dispatchPendingLoadEvents(); |
2344 } | 2344 } |
2345 | 2345 |
2346 // To align the HTML load event and the SVGLoad event for the outermost <svg
> element, fire it from | 2346 // To align the HTML load event and the SVGLoad event for the outermost <svg
> element, fire it from |
2347 // here, instead of doing it from SVGElement::finishedParsingChildren (if ex
ternalResourcesRequired="false", | 2347 // here, instead of doing it from SVGElement::finishedParsingChildren (if ex
ternalResourcesRequired="false", |
(...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2706 String Document::userAgent(const KURL& url) const | 2706 String Document::userAgent(const KURL& url) const |
2707 { | 2707 { |
2708 return frame() ? frame()->loader()->userAgent(url) : String(); | 2708 return frame() ? frame()->loader()->userAgent(url) : String(); |
2709 } | 2709 } |
2710 | 2710 |
2711 void Document::disableEval(const String& errorMessage) | 2711 void Document::disableEval(const String& errorMessage) |
2712 { | 2712 { |
2713 if (!frame()) | 2713 if (!frame()) |
2714 return; | 2714 return; |
2715 | 2715 |
2716 frame()->script()->disableEval(errorMessage); | 2716 frame()->script().disableEval(errorMessage); |
2717 } | 2717 } |
2718 | 2718 |
2719 bool Document::canNavigate(Frame* targetFrame) | 2719 bool Document::canNavigate(Frame* targetFrame) |
2720 { | 2720 { |
2721 if (!m_frame) | 2721 if (!m_frame) |
2722 return false; | 2722 return false; |
2723 | 2723 |
2724 // FIXME: We shouldn't call this function without a target frame, but | 2724 // FIXME: We shouldn't call this function without a target frame, but |
2725 // fast/forms/submit-to-blank-multiple-times.html depends on this function | 2725 // fast/forms/submit-to-blank-multiple-times.html depends on this function |
2726 // returning true when supplied with a 0 targetFrame. | 2726 // returning true when supplied with a 0 targetFrame. |
(...skipping 977 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3704 addListenerType(OVERFLOWCHANGED_LISTENER); | 3704 addListenerType(OVERFLOWCHANGED_LISTENER); |
3705 } else if (eventType == EventTypeNames::webkitAnimationStart || (RuntimeEnab
ledFeatures::cssAnimationUnprefixedEnabled() && eventType == EventTypeNames::ani
mationstart)) { | 3705 } else if (eventType == EventTypeNames::webkitAnimationStart || (RuntimeEnab
ledFeatures::cssAnimationUnprefixedEnabled() && eventType == EventTypeNames::ani
mationstart)) { |
3706 addListenerType(ANIMATIONSTART_LISTENER); | 3706 addListenerType(ANIMATIONSTART_LISTENER); |
3707 } else if (eventType == EventTypeNames::webkitAnimationEnd || (RuntimeEnable
dFeatures::cssAnimationUnprefixedEnabled() && eventType == EventTypeNames::anima
tionend)) { | 3707 } else if (eventType == EventTypeNames::webkitAnimationEnd || (RuntimeEnable
dFeatures::cssAnimationUnprefixedEnabled() && eventType == EventTypeNames::anima
tionend)) { |
3708 addListenerType(ANIMATIONEND_LISTENER); | 3708 addListenerType(ANIMATIONEND_LISTENER); |
3709 } else if (eventType == EventTypeNames::webkitAnimationIteration || (Runtime
EnabledFeatures::cssAnimationUnprefixedEnabled() && eventType == EventTypeNames:
:animationiteration)) { | 3709 } else if (eventType == EventTypeNames::webkitAnimationIteration || (Runtime
EnabledFeatures::cssAnimationUnprefixedEnabled() && eventType == EventTypeNames:
:animationiteration)) { |
3710 addListenerType(ANIMATIONITERATION_LISTENER); | 3710 addListenerType(ANIMATIONITERATION_LISTENER); |
3711 } else if (eventType == EventTypeNames::webkitTransitionEnd || eventType ==
EventTypeNames::transitionend) { | 3711 } else if (eventType == EventTypeNames::webkitTransitionEnd || eventType ==
EventTypeNames::transitionend) { |
3712 addListenerType(TRANSITIONEND_LISTENER); | 3712 addListenerType(TRANSITIONEND_LISTENER); |
3713 } else if (eventType == EventTypeNames::beforeload) { | 3713 } else if (eventType == EventTypeNames::beforeload) { |
3714 if (m_frame && m_frame->script()->shouldBypassMainWorldContentSecurityPo
licy()) { | 3714 if (m_frame && m_frame->script().shouldBypassMainWorldContentSecurityPol
icy()) { |
3715 UseCounter::count(*this, UseCounter::BeforeLoadEventInIsolatedWorld)
; | 3715 UseCounter::count(*this, UseCounter::BeforeLoadEventInIsolatedWorld)
; |
3716 } else { | 3716 } else { |
3717 UseCounter::count(*this, UseCounter::BeforeLoadEvent); | 3717 UseCounter::count(*this, UseCounter::BeforeLoadEvent); |
3718 } | 3718 } |
3719 addListenerType(BEFORELOAD_LISTENER); | 3719 addListenerType(BEFORELOAD_LISTENER); |
3720 } else if (eventType == EventTypeNames::scroll) { | 3720 } else if (eventType == EventTypeNames::scroll) { |
3721 addListenerType(SCROLL_LISTENER); | 3721 addListenerType(SCROLL_LISTENER); |
3722 } | 3722 } |
3723 } | 3723 } |
3724 | 3724 |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3812 | 3812 |
3813 // If the new domain is the same as the old domain, still call | 3813 // If the new domain is the same as the old domain, still call |
3814 // securityOrigin()->setDomainForDOM. This will change the | 3814 // securityOrigin()->setDomainForDOM. This will change the |
3815 // security check behavior. For example, if a page loaded on port 8000 | 3815 // security check behavior. For example, if a page loaded on port 8000 |
3816 // assigns its current domain using document.domain, the page will | 3816 // assigns its current domain using document.domain, the page will |
3817 // allow other pages loaded on different ports in the same domain that | 3817 // allow other pages loaded on different ports in the same domain that |
3818 // have also assigned to access this page. | 3818 // have also assigned to access this page. |
3819 if (equalIgnoringCase(domain(), newDomain)) { | 3819 if (equalIgnoringCase(domain(), newDomain)) { |
3820 securityOrigin()->setDomainFromDOM(newDomain); | 3820 securityOrigin()->setDomainFromDOM(newDomain); |
3821 if (m_frame) | 3821 if (m_frame) |
3822 m_frame->script()->updateSecurityOrigin(); | 3822 m_frame->script().updateSecurityOrigin(); |
3823 return; | 3823 return; |
3824 } | 3824 } |
3825 | 3825 |
3826 int oldLength = domain().length(); | 3826 int oldLength = domain().length(); |
3827 int newLength = newDomain.length(); | 3827 int newLength = newDomain.length(); |
3828 String exceptionMessage = ExceptionMessages::failedToSet("domain", "Documen
t", "'" + newDomain + "' is not a suffix of '" + domain() + "'."); | 3828 String exceptionMessage = ExceptionMessages::failedToSet("domain", "Documen
t", "'" + newDomain + "' is not a suffix of '" + domain() + "'."); |
3829 // e.g. newDomain = subdomain.www.example.com (25) and domain() = www.exampl
e.com (15) | 3829 // e.g. newDomain = subdomain.www.example.com (25) and domain() = www.exampl
e.com (15) |
3830 if (newLength >= oldLength) { | 3830 if (newLength >= oldLength) { |
3831 es.throwSecurityError(exceptionMessage); | 3831 es.throwSecurityError(exceptionMessage); |
3832 return; | 3832 return; |
3833 } | 3833 } |
3834 | 3834 |
3835 String test = domain(); | 3835 String test = domain(); |
3836 // Check that it's a complete suffix, not e.g. "ample.com" | 3836 // Check that it's a complete suffix, not e.g. "ample.com" |
3837 if (test[oldLength - newLength - 1] != '.') { | 3837 if (test[oldLength - newLength - 1] != '.') { |
3838 es.throwSecurityError(exceptionMessage); | 3838 es.throwSecurityError(exceptionMessage); |
3839 return; | 3839 return; |
3840 } | 3840 } |
3841 | 3841 |
3842 // Now test is "example.com" from domain() | 3842 // Now test is "example.com" from domain() |
3843 // and we check that it's the same thing as newDomain | 3843 // and we check that it's the same thing as newDomain |
3844 test.remove(0, oldLength - newLength); | 3844 test.remove(0, oldLength - newLength); |
3845 if (test != newDomain) { | 3845 if (test != newDomain) { |
3846 es.throwSecurityError(exceptionMessage); | 3846 es.throwSecurityError(exceptionMessage); |
3847 return; | 3847 return; |
3848 } | 3848 } |
3849 | 3849 |
3850 securityOrigin()->setDomainFromDOM(newDomain); | 3850 securityOrigin()->setDomainFromDOM(newDomain); |
3851 if (m_frame) | 3851 if (m_frame) |
3852 m_frame->script()->updateSecurityOrigin(); | 3852 m_frame->script().updateSecurityOrigin(); |
3853 } | 3853 } |
3854 | 3854 |
3855 // http://www.whatwg.org/specs/web-apps/current-work/#dom-document-lastmodified | 3855 // http://www.whatwg.org/specs/web-apps/current-work/#dom-document-lastmodified |
3856 String Document::lastModified() const | 3856 String Document::lastModified() const |
3857 { | 3857 { |
3858 DateComponents date; | 3858 DateComponents date; |
3859 bool foundDate = false; | 3859 bool foundDate = false; |
3860 if (m_frame) { | 3860 if (m_frame) { |
3861 String httpLastModified; | 3861 String httpLastModified; |
3862 if (DocumentLoader* documentLoader = loader()) | 3862 if (DocumentLoader* documentLoader = loader()) |
(...skipping 682 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4545 { | 4545 { |
4546 if (!contentSecurityPolicy()->allowInlineEventHandlers(contextURL, contextLi
ne)) | 4546 if (!contentSecurityPolicy()->allowInlineEventHandlers(contextURL, contextLi
ne)) |
4547 return false; | 4547 return false; |
4548 | 4548 |
4549 // HTML says that inline script needs browsing context to create its executi
on environment. | 4549 // HTML says that inline script needs browsing context to create its executi
on environment. |
4550 // http://www.whatwg.org/specs/web-apps/current-work/multipage/webappapis.ht
ml#event-handler-attributes | 4550 // http://www.whatwg.org/specs/web-apps/current-work/multipage/webappapis.ht
ml#event-handler-attributes |
4551 // Also, if the listening node came from other document, which happens on co
ntext-less event dispatching, | 4551 // Also, if the listening node came from other document, which happens on co
ntext-less event dispatching, |
4552 // we also need to ask the owner document of the node. | 4552 // we also need to ask the owner document of the node. |
4553 if (!m_frame) | 4553 if (!m_frame) |
4554 return false; | 4554 return false; |
4555 if (!m_frame->script()->canExecuteScripts(NotAboutToExecuteScript)) | 4555 if (!m_frame->script().canExecuteScripts(NotAboutToExecuteScript)) |
4556 return false; | 4556 return false; |
4557 if (node && node->document() != this && !node->document().allowInlineEventHa
ndlers(node, listener, contextURL, contextLine)) | 4557 if (node && node->document() != this && !node->document().allowInlineEventHa
ndlers(node, listener, contextURL, contextLine)) |
4558 return false; | 4558 return false; |
4559 | 4559 |
4560 return true; | 4560 return true; |
4561 } | 4561 } |
4562 | 4562 |
4563 bool Document::allowExecutingScripts(Node* node) | 4563 bool Document::allowExecutingScripts(Node* node) |
4564 { | 4564 { |
4565 // FIXME: Eventually we'd like to evaluate scripts which are inserted into a | 4565 // FIXME: Eventually we'd like to evaluate scripts which are inserted into a |
4566 // viewless document but this'll do for now. | 4566 // viewless document but this'll do for now. |
4567 // See http://bugs.webkit.org/show_bug.cgi?id=5727 | 4567 // See http://bugs.webkit.org/show_bug.cgi?id=5727 |
4568 if (!frame() && !import()) | 4568 if (!frame() && !import()) |
4569 return false; | 4569 return false; |
4570 if (!node->document().frame() && !node->document().import()) | 4570 if (!node->document().frame() && !node->document().import()) |
4571 return false; | 4571 return false; |
4572 if (!contextDocument().get()->frame()->script()->canExecuteScripts(AboutToEx
ecuteScript)) | 4572 if (!contextDocument().get()->frame()->script().canExecuteScripts(AboutToExe
cuteScript)) |
4573 return false; | 4573 return false; |
4574 return true; | 4574 return true; |
4575 } | 4575 } |
4576 | 4576 |
4577 void Document::didUpdateSecurityOrigin() | 4577 void Document::didUpdateSecurityOrigin() |
4578 { | 4578 { |
4579 if (!m_frame) | 4579 if (!m_frame) |
4580 return; | 4580 return; |
4581 m_frame->script()->updateSecurityOrigin(); | 4581 m_frame->script().updateSecurityOrigin(); |
4582 } | 4582 } |
4583 | 4583 |
4584 bool Document::isContextThread() const | 4584 bool Document::isContextThread() const |
4585 { | 4585 { |
4586 return isMainThread(); | 4586 return isMainThread(); |
4587 } | 4587 } |
4588 | 4588 |
4589 void Document::statePopped(PassRefPtr<SerializedScriptValue> stateObject) | 4589 void Document::statePopped(PassRefPtr<SerializedScriptValue> stateObject) |
4590 { | 4590 { |
4591 if (!frame()) | 4591 if (!frame()) |
(...skipping 756 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5348 void Document::modifiedStyleSheet(StyleSheet* sheet, RecalcStyleTime when, Style
ResolverUpdateMode updateMode) | 5348 void Document::modifiedStyleSheet(StyleSheet* sheet, RecalcStyleTime when, Style
ResolverUpdateMode updateMode) |
5349 { | 5349 { |
5350 if (!isActive()) | 5350 if (!isActive()) |
5351 return; | 5351 return; |
5352 | 5352 |
5353 styleEngine()->modifiedStyleSheet(sheet); | 5353 styleEngine()->modifiedStyleSheet(sheet); |
5354 styleResolverChanged(when, updateMode); | 5354 styleResolverChanged(when, updateMode); |
5355 } | 5355 } |
5356 | 5356 |
5357 } // namespace WebCore | 5357 } // namespace WebCore |
OLD | NEW |