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