Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(830)

Side by Side Diff: Source/core/dom/Document.cpp

Issue 1176013002: Move attributes and methods from HTMLDocument to Document (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Updated to latest master Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « Source/core/dom/Document.h ('k') | Source/core/dom/Document.idl » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 2334 matching lines...) Expand 10 before | Expand all | Expand 10 after
2345 return parser() ? parser()->asScriptableDocumentParser() : 0; 2345 return parser() ? parser()->asScriptableDocumentParser() : 0;
2346 } 2346 }
2347 2347
2348 void Document::open(Document* ownerDocument, ExceptionState& exceptionState) 2348 void Document::open(Document* ownerDocument, ExceptionState& exceptionState)
2349 { 2349 {
2350 if (importLoader()) { 2350 if (importLoader()) {
2351 exceptionState.throwDOMException(InvalidStateError, "Imported document d oesn't support open()."); 2351 exceptionState.throwDOMException(InvalidStateError, "Imported document d oesn't support open().");
2352 return; 2352 return;
2353 } 2353 }
2354 2354
2355 if (!isHTMLDocument()) {
2356 exceptionState.throwDOMException(InvalidStateError, "Only HTML documents support open().");
2357 return;
2358 }
2359
2355 if (ownerDocument) { 2360 if (ownerDocument) {
2356 setURL(ownerDocument->url()); 2361 setURL(ownerDocument->url());
2357 m_cookieURL = ownerDocument->cookieURL(); 2362 m_cookieURL = ownerDocument->cookieURL();
2358 setSecurityOrigin(ownerDocument->securityOrigin()); 2363 setSecurityOrigin(ownerDocument->securityOrigin());
2359 } 2364 }
2360 2365
2366 open();
2367 }
2368
2369 void Document::open()
2370 {
2371 ASSERT(!importLoader());
2372
2361 if (m_frame) { 2373 if (m_frame) {
2362 if (ScriptableDocumentParser* parser = scriptableDocumentParser()) { 2374 if (ScriptableDocumentParser* parser = scriptableDocumentParser()) {
2363 if (parser->isParsing()) { 2375 if (parser->isParsing()) {
2364 // FIXME: HTML5 doesn't tell us to check this, it might not be c orrect. 2376 // FIXME: HTML5 doesn't tell us to check this, it might not be c orrect.
2365 if (parser->isExecutingScript()) 2377 if (parser->isExecutingScript())
2366 return; 2378 return;
2367 2379
2368 if (!parser->wasCreatedByScript() && parser->hasInsertionPoint() ) 2380 if (!parser->wasCreatedByScript() && parser->hasInsertionPoint() )
2369 return; 2381 return;
2370 } 2382 }
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
2511 void Document::close(ExceptionState& exceptionState) 2523 void Document::close(ExceptionState& exceptionState)
2512 { 2524 {
2513 // FIXME: We should follow the specification more closely: 2525 // FIXME: We should follow the specification more closely:
2514 // http://www.whatwg.org/specs/web-apps/current-work/#dom-document-cl ose 2526 // http://www.whatwg.org/specs/web-apps/current-work/#dom-document-cl ose
2515 2527
2516 if (importLoader()) { 2528 if (importLoader()) {
2517 exceptionState.throwDOMException(InvalidStateError, "Imported document d oesn't support close()."); 2529 exceptionState.throwDOMException(InvalidStateError, "Imported document d oesn't support close().");
2518 return; 2530 return;
2519 } 2531 }
2520 2532
2533 if (!isHTMLDocument()) {
2534 exceptionState.throwDOMException(InvalidStateError, "Only HTML documents support close().");
2535 return;
2536 }
2537
2538 close();
2539 }
2540
2541 void Document::close()
2542 {
2521 if (!scriptableDocumentParser() || !scriptableDocumentParser()->wasCreatedBy Script() || !scriptableDocumentParser()->isParsing()) 2543 if (!scriptableDocumentParser() || !scriptableDocumentParser()->wasCreatedBy Script() || !scriptableDocumentParser()->isParsing())
2522 return; 2544 return;
2523 2545
2524 explicitClose(); 2546 explicitClose();
2525 } 2547 }
2526 2548
2527 void Document::explicitClose() 2549 void Document::explicitClose()
2528 { 2550 {
2529 if (RefPtrWillBeRawPtr<DocumentParser> parser = m_parser) 2551 if (RefPtrWillBeRawPtr<DocumentParser> parser = m_parser)
2530 parser->finish(); 2552 parser->finish();
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
2757 return static_cast<int>((currentTime() - m_startTime) * 1000); 2779 return static_cast<int>((currentTime() - m_startTime) * 1000);
2758 } 2780 }
2759 2781
2760 void Document::write(const SegmentedString& text, Document* ownerDocument, Excep tionState& exceptionState) 2782 void Document::write(const SegmentedString& text, Document* ownerDocument, Excep tionState& exceptionState)
2761 { 2783 {
2762 if (importLoader()) { 2784 if (importLoader()) {
2763 exceptionState.throwDOMException(InvalidStateError, "Imported document d oesn't support write()."); 2785 exceptionState.throwDOMException(InvalidStateError, "Imported document d oesn't support write().");
2764 return; 2786 return;
2765 } 2787 }
2766 2788
2789 if (!isHTMLDocument()) {
2790 exceptionState.throwDOMException(InvalidStateError, "Only HTML documents support write().");
2791 return;
2792 }
2793
2767 NestingLevelIncrementer nestingLevelIncrementer(m_writeRecursionDepth); 2794 NestingLevelIncrementer nestingLevelIncrementer(m_writeRecursionDepth);
2768 2795
2769 m_writeRecursionIsTooDeep = (m_writeRecursionDepth > 1) && m_writeRecursionI sTooDeep; 2796 m_writeRecursionIsTooDeep = (m_writeRecursionDepth > 1) && m_writeRecursionI sTooDeep;
2770 m_writeRecursionIsTooDeep = (m_writeRecursionDepth > cMaxWriteRecursionDepth ) || m_writeRecursionIsTooDeep; 2797 m_writeRecursionIsTooDeep = (m_writeRecursionDepth > cMaxWriteRecursionDepth ) || m_writeRecursionIsTooDeep;
2771 2798
2772 if (m_writeRecursionIsTooDeep) 2799 if (m_writeRecursionIsTooDeep)
2773 return; 2800 return;
2774 2801
2775 bool hasInsertionPoint = m_parser && m_parser->hasInsertionPoint(); 2802 bool hasInsertionPoint = m_parser && m_parser->hasInsertionPoint();
2776 2803
2777 if (!hasInsertionPoint && m_ignoreDestructiveWriteCount) { 2804 if (!hasInsertionPoint && m_ignoreDestructiveWriteCount) {
2778 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."))); 2805 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.")));
2779 return; 2806 return;
2780 } 2807 }
2781 2808
2782 if (!hasInsertionPoint) 2809 if (!hasInsertionPoint)
2783 open(ownerDocument); 2810 open(ownerDocument, ASSERT_NO_EXCEPTION);
2784 2811
2785 ASSERT(m_parser); 2812 ASSERT(m_parser);
2786 m_parser->insert(text); 2813 m_parser->insert(text);
2787 } 2814 }
2788 2815
2789 void Document::write(const String& text, Document* ownerDocument, ExceptionState & exceptionState) 2816 void Document::write(const String& text, Document* ownerDocument, ExceptionState & exceptionState)
2790 { 2817 {
2791 write(SegmentedString(text), ownerDocument, exceptionState); 2818 write(SegmentedString(text), ownerDocument, exceptionState);
2792 } 2819 }
2793 2820
2794 void Document::writeln(const String& text, Document* ownerDocument, ExceptionSta te& exceptionState) 2821 void Document::writeln(const String& text, Document* ownerDocument, ExceptionSta te& exceptionState)
2795 { 2822 {
2796 write(text, ownerDocument, exceptionState); 2823 write(text, ownerDocument, exceptionState);
2797 if (exceptionState.hadException()) 2824 if (exceptionState.hadException())
2798 return; 2825 return;
2799 write("\n", ownerDocument); 2826 write("\n", ownerDocument);
2800 } 2827 }
2801 2828
2829 void Document::write(LocalDOMWindow* callingWindow, const Vector<String>& text, ExceptionState& exceptionState)
2830 {
2831 ASSERT(callingWindow);
2832 StringBuilder builder;
2833 for (const String& string : text)
2834 builder.append(string);
2835 write(builder.toString(), callingWindow->document(), exceptionState);
2836 }
2837
2838 void Document::writeln(LocalDOMWindow* callingWindow, const Vector<String>& text , ExceptionState& exceptionState)
2839 {
2840 ASSERT(callingWindow);
2841 StringBuilder builder;
2842 for (const String& string : text)
2843 builder.append(string);
2844 writeln(builder.toString(), callingWindow->document(), exceptionState);
2845 }
2846
2802 const KURL& Document::virtualURL() const 2847 const KURL& Document::virtualURL() const
2803 { 2848 {
2804 return m_url; 2849 return m_url;
2805 } 2850 }
2806 2851
2807 KURL Document::virtualCompleteURL(const String& url) const 2852 KURL Document::virtualCompleteURL(const String& url) const
2808 { 2853 {
2809 return completeURL(url); 2854 return completeURL(url);
2810 } 2855 }
2811 2856
(...skipping 2998 matching lines...) Expand 10 before | Expand all | Expand 10 after
5810 #ifndef NDEBUG 5855 #ifndef NDEBUG
5811 using namespace blink; 5856 using namespace blink;
5812 void showLiveDocumentInstances() 5857 void showLiveDocumentInstances()
5813 { 5858 {
5814 WeakDocumentSet& set = liveDocumentSet(); 5859 WeakDocumentSet& set = liveDocumentSet();
5815 fprintf(stderr, "There are %u documents currently alive:\n", set.size()); 5860 fprintf(stderr, "There are %u documents currently alive:\n", set.size());
5816 for (Document* document : set) 5861 for (Document* document : set)
5817 fprintf(stderr, "- Document %p URL: %s\n", document, document->url().str ing().utf8().data()); 5862 fprintf(stderr, "- Document %p URL: %s\n", document, document->url().str ing().utf8().data());
5818 } 5863 }
5819 #endif 5864 #endif
OLDNEW
« no previous file with comments | « Source/core/dom/Document.h ('k') | Source/core/dom/Document.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698