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

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

Issue 2369853002: HTML parser: implementing throw-on-dynamic-markup-insertion counter (Closed)
Patch Set: copyright comment update Created 4 years, 2 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
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 414 matching lines...) Expand 10 before | Expand all | Expand 10 after
425 , m_mutationObserverTypes(0) 425 , m_mutationObserverTypes(0)
426 , m_visitedLinkState(VisitedLinkState::create(*this)) 426 , m_visitedLinkState(VisitedLinkState::create(*this))
427 , m_visuallyOrdered(false) 427 , m_visuallyOrdered(false)
428 , m_readyState(Complete) 428 , m_readyState(Complete)
429 , m_parsingState(FinishedParsing) 429 , m_parsingState(FinishedParsing)
430 , m_gotoAnchorNeededAfterStylesheetsLoad(false) 430 , m_gotoAnchorNeededAfterStylesheetsLoad(false)
431 , m_containsValidityStyleRules(false) 431 , m_containsValidityStyleRules(false)
432 , m_containsPlugins(false) 432 , m_containsPlugins(false)
433 , m_updateFocusAppearanceSelectionBahavior(SelectionBehaviorOnFocus::Reset) 433 , m_updateFocusAppearanceSelectionBahavior(SelectionBehaviorOnFocus::Reset)
434 , m_ignoreDestructiveWriteCount(0) 434 , m_ignoreDestructiveWriteCount(0)
435 , m_throwOnDynamicMarkupInsertionCount(0)
435 , m_markers(new DocumentMarkerController(*this)) 436 , m_markers(new DocumentMarkerController(*this))
436 , m_updateFocusAppearanceTimer(this, &Document::updateFocusAppearanceTimerFi red) 437 , m_updateFocusAppearanceTimer(this, &Document::updateFocusAppearanceTimerFi red)
437 , m_cssTarget(nullptr) 438 , m_cssTarget(nullptr)
438 , m_loadEventProgress(LoadEventNotRun) 439 , m_loadEventProgress(LoadEventNotRun)
439 , m_startTime(currentTime()) 440 , m_startTime(currentTime())
440 , m_scriptRunner(ScriptRunner::create(this)) 441 , m_scriptRunner(ScriptRunner::create(this))
441 , m_xmlVersion("1.0") 442 , m_xmlVersion("1.0")
442 , m_xmlStandalone(StandaloneUnspecified) 443 , m_xmlStandalone(StandaloneUnspecified)
443 , m_hasXMLDeclaration(0) 444 , m_hasXMLDeclaration(0)
444 , m_designMode(false) 445 , m_designMode(false)
(...skipping 1941 matching lines...) Expand 10 before | Expand all | Expand 10 after
2386 if (importLoader()) { 2387 if (importLoader()) {
2387 exceptionState.throwDOMException(InvalidStateError, "Imported document d oesn't support open()."); 2388 exceptionState.throwDOMException(InvalidStateError, "Imported document d oesn't support open().");
2388 return; 2389 return;
2389 } 2390 }
2390 2391
2391 if (!isHTMLDocument()) { 2392 if (!isHTMLDocument()) {
2392 exceptionState.throwDOMException(InvalidStateError, "Only HTML documents support open()."); 2393 exceptionState.throwDOMException(InvalidStateError, "Only HTML documents support open().");
2393 return; 2394 return;
2394 } 2395 }
2395 2396
2397 if (m_throwOnDynamicMarkupInsertionCount) {
2398 exceptionState.throwDOMException(InvalidStateError, "Custom Element cons tructor should not use open().");
2399 return;
2400 }
2401
2396 if (enteredDocument) { 2402 if (enteredDocument) {
2397 if (!getSecurityOrigin()->canAccess(enteredDocument->getSecurityOrigin() )) { 2403 if (!getSecurityOrigin()->canAccess(enteredDocument->getSecurityOrigin() )) {
2398 exceptionState.throwSecurityError("Can only call open() on same-orig in documents."); 2404 exceptionState.throwSecurityError("Can only call open() on same-orig in documents.");
2399 return; 2405 return;
2400 } 2406 }
2401 setSecurityOrigin(enteredDocument->getSecurityOrigin()); 2407 setSecurityOrigin(enteredDocument->getSecurityOrigin());
2402 setURL(enteredDocument->url()); 2408 setURL(enteredDocument->url());
2403 m_cookieURL = enteredDocument->cookieURL(); 2409 m_cookieURL = enteredDocument->cookieURL();
2404 } 2410 }
2405 2411
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
2583 if (importLoader()) { 2589 if (importLoader()) {
2584 exceptionState.throwDOMException(InvalidStateError, "Imported document d oesn't support close()."); 2590 exceptionState.throwDOMException(InvalidStateError, "Imported document d oesn't support close().");
2585 return; 2591 return;
2586 } 2592 }
2587 2593
2588 if (!isHTMLDocument()) { 2594 if (!isHTMLDocument()) {
2589 exceptionState.throwDOMException(InvalidStateError, "Only HTML documents support close()."); 2595 exceptionState.throwDOMException(InvalidStateError, "Only HTML documents support close().");
2590 return; 2596 return;
2591 } 2597 }
2592 2598
2599 if (m_throwOnDynamicMarkupInsertionCount) {
2600 exceptionState.throwDOMException(InvalidStateError, "Custom Element cons tructor should not use close().");
2601 return;
2602 }
2603
2593 close(); 2604 close();
2594 } 2605 }
2595 2606
2596 void Document::close() 2607 void Document::close()
2597 { 2608 {
2598 if (!scriptableDocumentParser() || !scriptableDocumentParser()->wasCreatedBy Script() || !scriptableDocumentParser()->isParsing()) 2609 if (!scriptableDocumentParser() || !scriptableDocumentParser()->wasCreatedBy Script() || !scriptableDocumentParser()->isParsing())
2599 return; 2610 return;
2600 2611
2601 if (DocumentParser* parser = m_parser) 2612 if (DocumentParser* parser = m_parser)
2602 parser->finish(); 2613 parser->finish();
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after
2846 if (importLoader()) { 2857 if (importLoader()) {
2847 exceptionState.throwDOMException(InvalidStateError, "Imported document d oesn't support write()."); 2858 exceptionState.throwDOMException(InvalidStateError, "Imported document d oesn't support write().");
2848 return; 2859 return;
2849 } 2860 }
2850 2861
2851 if (!isHTMLDocument()) { 2862 if (!isHTMLDocument()) {
2852 exceptionState.throwDOMException(InvalidStateError, "Only HTML documents support write()."); 2863 exceptionState.throwDOMException(InvalidStateError, "Only HTML documents support write().");
2853 return; 2864 return;
2854 } 2865 }
2855 2866
2867 if (m_throwOnDynamicMarkupInsertionCount) {
2868 exceptionState.throwDOMException(InvalidStateError, "Custom Element cons tructor should not use write().");
2869 return;
2870 }
2871
2856 if (enteredDocument && !getSecurityOrigin()->canAccess(enteredDocument->getS ecurityOrigin())) { 2872 if (enteredDocument && !getSecurityOrigin()->canAccess(enteredDocument->getS ecurityOrigin())) {
2857 exceptionState.throwSecurityError("Can only call write() on same-origin documents."); 2873 exceptionState.throwSecurityError("Can only call write() on same-origin documents.");
2858 return; 2874 return;
2859 } 2875 }
2860 2876
2861 NestingLevelIncrementer nestingLevelIncrementer(m_writeRecursionDepth); 2877 NestingLevelIncrementer nestingLevelIncrementer(m_writeRecursionDepth);
2862 2878
2863 m_writeRecursionIsTooDeep = (m_writeRecursionDepth > 1) && m_writeRecursionI sTooDeep; 2879 m_writeRecursionIsTooDeep = (m_writeRecursionDepth > 1) && m_writeRecursionI sTooDeep;
2864 m_writeRecursionIsTooDeep = (m_writeRecursionDepth > cMaxWriteRecursionDepth ) || m_writeRecursionIsTooDeep; 2880 m_writeRecursionIsTooDeep = (m_writeRecursionDepth > cMaxWriteRecursionDepth ) || m_writeRecursionIsTooDeep;
2865 2881
(...skipping 3219 matching lines...) Expand 10 before | Expand all | Expand 10 after
6085 } 6101 }
6086 6102
6087 void showLiveDocumentInstances() 6103 void showLiveDocumentInstances()
6088 { 6104 {
6089 WeakDocumentSet& set = liveDocumentSet(); 6105 WeakDocumentSet& set = liveDocumentSet();
6090 fprintf(stderr, "There are %u documents currently alive:\n", set.size()); 6106 fprintf(stderr, "There are %u documents currently alive:\n", set.size());
6091 for (Document* document : set) 6107 for (Document* document : set)
6092 fprintf(stderr, "- Document %p URL: %s\n", document, document->url().get String().utf8().data()); 6108 fprintf(stderr, "- Document %p URL: %s\n", document, document->url().get String().utf8().data());
6093 } 6109 }
6094 #endif 6110 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698