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

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

Issue 159853004: Ensure that every Document has a single, distinct template content ownerDocument (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Suppress expected w3c test failures Created 6 years, 10 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 | Annotate | Revision Log
« no previous file with comments | « Source/core/dom/Document.h ('k') | no next file » | 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 503 matching lines...) Expand 10 before | Expand all | Expand 10 after
514 514
515 Document::~Document() 515 Document::~Document()
516 { 516 {
517 ASSERT(!renderView()); 517 ASSERT(!renderView());
518 ASSERT(m_ranges.isEmpty()); 518 ASSERT(m_ranges.isEmpty());
519 ASSERT(!parentTreeScope()); 519 ASSERT(!parentTreeScope());
520 ASSERT(!hasGuardRefCount()); 520 ASSERT(!hasGuardRefCount());
521 ASSERT(m_visibilityObservers.isEmpty()); 521 ASSERT(m_visibilityObservers.isEmpty());
522 522
523 if (m_templateDocument) 523 if (m_templateDocument)
524 m_templateDocument->setTemplateDocumentHost(0); // balanced in templateD ocument(). 524 m_templateDocument->m_templateDocumentHost = 0; // balanced in ensureTem plateDocument().
525 525
526 m_scriptRunner.clear(); 526 m_scriptRunner.clear();
527 527
528 removeAllEventListeners(); 528 removeAllEventListeners();
529 529
530 // Currently we believe that Document can never outlive the parser. 530 // Currently we believe that Document can never outlive the parser.
531 // Although the Document may be replaced synchronously, DocumentParsers 531 // Although the Document may be replaced synchronously, DocumentParsers
532 // generally keep at least one reference to an Element which would in turn 532 // generally keep at least one reference to an Element which would in turn
533 // has a reference to the Document. If you hit this ASSERT, then that 533 // has a reference to the Document. If you hit this ASSERT, then that
534 // assumption is wrong. DocumentParser::detach() should ensure that even 534 // assumption is wrong. DocumentParser::detach() should ensure that even
(...skipping 4780 matching lines...) Expand 10 before | Expand all | Expand 10 after
5315 if (locale.isEmpty() || !RuntimeEnabledFeatures::langAttributeAwareFormContr olUIEnabled()) 5315 if (locale.isEmpty() || !RuntimeEnabledFeatures::langAttributeAwareFormContr olUIEnabled())
5316 return Locale::defaultLocale(); 5316 return Locale::defaultLocale();
5317 LocaleIdentifierToLocaleMap::AddResult result = m_localeCache.add(localeKey, nullptr); 5317 LocaleIdentifierToLocaleMap::AddResult result = m_localeCache.add(localeKey, nullptr);
5318 if (result.isNewEntry) 5318 if (result.isNewEntry)
5319 result.iterator->value = Locale::create(localeKey); 5319 result.iterator->value = Locale::create(localeKey);
5320 return *(result.iterator->value); 5320 return *(result.iterator->value);
5321 } 5321 }
5322 5322
5323 Document& Document::ensureTemplateDocument() 5323 Document& Document::ensureTemplateDocument()
5324 { 5324 {
5325 if (const Document* document = templateDocument()) 5325 if (isTemplateDocument())
5326 return *const_cast<Document*>(document); 5326 return *this;
5327
5328 if (m_templateDocument)
5329 return *m_templateDocument;
5327 5330
5328 if (isHTMLDocument()) { 5331 if (isHTMLDocument()) {
5329 DocumentInit init = DocumentInit::fromContext(contextDocument(), blankUR L()).withNewRegistrationContext(); 5332 DocumentInit init = DocumentInit::fromContext(contextDocument(), blankUR L()).withNewRegistrationContext();
5330 m_templateDocument = HTMLDocument::create(init); 5333 m_templateDocument = HTMLDocument::create(init);
5331 } else { 5334 } else {
5332 m_templateDocument = Document::create(DocumentInit(blankURL())); 5335 m_templateDocument = Document::create(DocumentInit(blankURL()));
5333 } 5336 }
5334 5337
5335 m_templateDocument->setTemplateDocumentHost(this); // balanced in dtor. 5338 m_templateDocument->m_templateDocumentHost = this; // balanced in dtor.
5336 5339
5337 return *m_templateDocument.get(); 5340 return *m_templateDocument.get();
5338 } 5341 }
5339 5342
5340 void Document::didAssociateFormControl(Element* element) 5343 void Document::didAssociateFormControl(Element* element)
5341 { 5344 {
5342 if (!frame() || !frame()->page()) 5345 if (!frame() || !frame()->page())
5343 return; 5346 return;
5344 m_associatedFormControls.add(element); 5347 m_associatedFormControls.add(element);
5345 if (!m_didAssociateFormControlsTimer.isActive()) 5348 if (!m_didAssociateFormControlsTimer.isActive())
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
5448 void Document::defaultEventHandler(Event* event) 5451 void Document::defaultEventHandler(Event* event)
5449 { 5452 {
5450 if (frame() && frame()->remotePlatformLayer()) { 5453 if (frame() && frame()->remotePlatformLayer()) {
5451 frame()->chromeClient().forwardInputEvent(this, event); 5454 frame()->chromeClient().forwardInputEvent(this, event);
5452 return; 5455 return;
5453 } 5456 }
5454 Node::defaultEventHandler(event); 5457 Node::defaultEventHandler(event);
5455 } 5458 }
5456 5459
5457 } // namespace WebCore 5460 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/dom/Document.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698