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 2398 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2409 if (!isHTMLDocument()) | 2409 if (!isHTMLDocument()) |
2410 return false; | 2410 return false; |
2411 return isHTMLFrameSetElement(body()); | 2411 return isHTMLFrameSetElement(body()); |
2412 } | 2412 } |
2413 | 2413 |
2414 ScriptableDocumentParser* Document::scriptableDocumentParser() const | 2414 ScriptableDocumentParser* Document::scriptableDocumentParser() const |
2415 { | 2415 { |
2416 return parser() ? parser()->asScriptableDocumentParser() : 0; | 2416 return parser() ? parser()->asScriptableDocumentParser() : 0; |
2417 } | 2417 } |
2418 | 2418 |
2419 void Document::open(Document* ownerDocument, ExceptionState& exceptionState) | 2419 void Document::open(Document* enteredDocument, ExceptionState& exceptionState) |
2420 { | 2420 { |
2421 if (importLoader()) { | 2421 if (importLoader()) { |
2422 exceptionState.throwDOMException(InvalidStateError, "Imported document d oesn't support open()."); | 2422 exceptionState.throwDOMException(InvalidStateError, "Imported document d oesn't support open()."); |
2423 return; | 2423 return; |
2424 } | 2424 } |
2425 | 2425 |
2426 if (!isHTMLDocument()) { | 2426 if (!isHTMLDocument()) { |
2427 exceptionState.throwDOMException(InvalidStateError, "Only HTML documents support open()."); | 2427 exceptionState.throwDOMException(InvalidStateError, "Only HTML documents support open()."); |
2428 return; | 2428 return; |
2429 } | 2429 } |
2430 | 2430 |
2431 if (ownerDocument) { | 2431 if (enteredDocument) { |
2432 setURL(ownerDocument->url()); | 2432 if (!securityOrigin()->canAccess(enteredDocument->securityOrigin())) { |
2433 m_cookieURL = ownerDocument->cookieURL(); | 2433 exceptionState.throwSecurityError("Can only call open() on same-orig in documents."); |
2434 setSecurityOrigin(ownerDocument->securityOrigin()); | 2434 return; |
2435 } | |
2436 setSecurityOrigin(enteredDocument->securityOrigin()); | |
2437 setURL(enteredDocument->url()); | |
2438 m_cookieURL = enteredDocument->cookieURL(); | |
2435 } | 2439 } |
2436 | 2440 |
2437 open(); | 2441 open(); |
2438 } | 2442 } |
2439 | 2443 |
2440 void Document::open() | 2444 void Document::open() |
2441 { | 2445 { |
2442 ASSERT(!importLoader()); | 2446 ASSERT(!importLoader()); |
2443 | 2447 |
2444 if (m_frame) { | 2448 if (m_frame) { |
(...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2836 return true; | 2840 return true; |
2837 | 2841 |
2838 return false; | 2842 return false; |
2839 } | 2843 } |
2840 | 2844 |
2841 int Document::elapsedTime() const | 2845 int Document::elapsedTime() const |
2842 { | 2846 { |
2843 return static_cast<int>((currentTime() - m_startTime) * 1000); | 2847 return static_cast<int>((currentTime() - m_startTime) * 1000); |
2844 } | 2848 } |
2845 | 2849 |
2846 void Document::write(const SegmentedString& text, Document* ownerDocument, Excep tionState& exceptionState) | 2850 void Document::write(const SegmentedString& text, Document* enteredDocument, Exc eptionState& exceptionState) |
2847 { | 2851 { |
2848 if (importLoader()) { | 2852 if (importLoader()) { |
2849 exceptionState.throwDOMException(InvalidStateError, "Imported document d oesn't support write()."); | 2853 exceptionState.throwDOMException(InvalidStateError, "Imported document d oesn't support write()."); |
2850 return; | 2854 return; |
2851 } | 2855 } |
2852 | 2856 |
2853 if (!isHTMLDocument()) { | 2857 if (!isHTMLDocument()) { |
2854 exceptionState.throwDOMException(InvalidStateError, "Only HTML documents support write()."); | 2858 exceptionState.throwDOMException(InvalidStateError, "Only HTML documents support write()."); |
2855 return; | 2859 return; |
2856 } | 2860 } |
2857 | 2861 |
2862 if (enteredDocument && !securityOrigin()->canAccess(enteredDocument->securit yOrigin())) { | |
jochen (gone - plz use gerrit)
2016/01/29 08:01:37
without this, the ASSERT(m_parser) below will fail
| |
2863 exceptionState.throwSecurityError("Can only call write() on same-origin documents."); | |
2864 return; | |
2865 } | |
2866 | |
2858 NestingLevelIncrementer nestingLevelIncrementer(m_writeRecursionDepth); | 2867 NestingLevelIncrementer nestingLevelIncrementer(m_writeRecursionDepth); |
2859 | 2868 |
2860 m_writeRecursionIsTooDeep = (m_writeRecursionDepth > 1) && m_writeRecursionI sTooDeep; | 2869 m_writeRecursionIsTooDeep = (m_writeRecursionDepth > 1) && m_writeRecursionI sTooDeep; |
2861 m_writeRecursionIsTooDeep = (m_writeRecursionDepth > cMaxWriteRecursionDepth ) || m_writeRecursionIsTooDeep; | 2870 m_writeRecursionIsTooDeep = (m_writeRecursionDepth > cMaxWriteRecursionDepth ) || m_writeRecursionIsTooDeep; |
2862 | 2871 |
2863 if (m_writeRecursionIsTooDeep) | 2872 if (m_writeRecursionIsTooDeep) |
2864 return; | 2873 return; |
2865 | 2874 |
2866 bool hasInsertionPoint = m_parser && m_parser->hasInsertionPoint(); | 2875 bool hasInsertionPoint = m_parser && m_parser->hasInsertionPoint(); |
2867 | 2876 |
2868 if (!hasInsertionPoint && m_ignoreDestructiveWriteCount) { | 2877 if (!hasInsertionPoint && m_ignoreDestructiveWriteCount) { |
2869 addConsoleMessage(ConsoleMessage::create(JSMessageSource, WarningMessage Level, ExceptionMessages::failedToExecute("write", "Document", "It isn't possibl e to write into a document from an asynchronously-loaded external script unless it is explicitly opened."))); | 2878 addConsoleMessage(ConsoleMessage::create(JSMessageSource, WarningMessage Level, ExceptionMessages::failedToExecute("write", "Document", "It isn't possibl e to write into a document from an asynchronously-loaded external script unless it is explicitly opened."))); |
2870 return; | 2879 return; |
2871 } | 2880 } |
2872 | 2881 |
2873 if (!hasInsertionPoint) | 2882 if (!hasInsertionPoint) |
2874 open(ownerDocument, ASSERT_NO_EXCEPTION); | 2883 open(enteredDocument, ASSERT_NO_EXCEPTION); |
2875 | 2884 |
2876 ASSERT(m_parser); | 2885 ASSERT(m_parser); |
2877 m_parser->insert(text); | 2886 m_parser->insert(text); |
2878 } | 2887 } |
2879 | 2888 |
2880 void Document::write(const String& text, Document* ownerDocument, ExceptionState & exceptionState) | 2889 void Document::write(const String& text, Document* enteredDocument, ExceptionSta te& exceptionState) |
2881 { | 2890 { |
2882 write(SegmentedString(text), ownerDocument, exceptionState); | 2891 write(SegmentedString(text), enteredDocument, exceptionState); |
2883 } | 2892 } |
2884 | 2893 |
2885 void Document::writeln(const String& text, Document* ownerDocument, ExceptionSta te& exceptionState) | 2894 void Document::writeln(const String& text, Document* enteredDocument, ExceptionS tate& exceptionState) |
2886 { | 2895 { |
2887 write(text, ownerDocument, exceptionState); | 2896 write(text, enteredDocument, exceptionState); |
2888 if (exceptionState.hadException()) | 2897 if (exceptionState.hadException()) |
2889 return; | 2898 return; |
2890 write("\n", ownerDocument); | 2899 write("\n", enteredDocument); |
2891 } | 2900 } |
2892 | 2901 |
2893 void Document::write(LocalDOMWindow* callingWindow, const Vector<String>& text, ExceptionState& exceptionState) | 2902 void Document::write(LocalDOMWindow* callingWindow, const Vector<String>& text, ExceptionState& exceptionState) |
2894 { | 2903 { |
2895 ASSERT(callingWindow); | 2904 ASSERT(callingWindow); |
2896 StringBuilder builder; | 2905 StringBuilder builder; |
2897 for (const String& string : text) | 2906 for (const String& string : text) |
2898 builder.append(string); | 2907 builder.append(string); |
2899 write(builder.toString(), callingWindow->document(), exceptionState); | 2908 write(builder.toString(), callingWindow->document(), exceptionState); |
2900 } | 2909 } |
(...skipping 3023 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5924 #ifndef NDEBUG | 5933 #ifndef NDEBUG |
5925 using namespace blink; | 5934 using namespace blink; |
5926 void showLiveDocumentInstances() | 5935 void showLiveDocumentInstances() |
5927 { | 5936 { |
5928 Document::WeakDocumentSet& set = Document::liveDocumentSet(); | 5937 Document::WeakDocumentSet& set = Document::liveDocumentSet(); |
5929 fprintf(stderr, "There are %u documents currently alive:\n", set.size()); | 5938 fprintf(stderr, "There are %u documents currently alive:\n", set.size()); |
5930 for (Document* document : set) | 5939 for (Document* document : set) |
5931 fprintf(stderr, "- Document %p URL: %s\n", document, document->url().str ing().utf8().data()); | 5940 fprintf(stderr, "- Document %p URL: %s\n", document, document->url().str ing().utf8().data()); |
5932 } | 5941 } |
5933 #endif | 5942 #endif |
OLD | NEW |