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

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

Issue 12518022: Merge 143840 (Closed) Base URL: http://svn.webkit.org/repository/webkit/branches/chromium/1410/
Patch Set: Created 7 years, 9 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/WebCore/dom/Document.h ('k') | Source/WebCore/dom/DocumentFragment.cpp » ('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 391 matching lines...) Expand 10 before | Expand all | Expand 10 after
402 frame->document()->domWindow()->printErrorMessage(message); 402 frame->document()->domWindow()->printErrorMessage(message);
403 } 403 }
404 404
405 static HashSet<Document*>* documentsThatNeedStyleRecalc = 0; 405 static HashSet<Document*>* documentsThatNeedStyleRecalc = 0;
406 406
407 uint64_t Document::s_globalTreeVersion = 0; 407 uint64_t Document::s_globalTreeVersion = 0;
408 408
409 Document::Document(Frame* frame, const KURL& url, bool isXHTML, bool isHTML) 409 Document::Document(Frame* frame, const KURL& url, bool isXHTML, bool isHTML)
410 : ContainerNode(0, CreateDocument) 410 : ContainerNode(0, CreateDocument)
411 , TreeScope(this) 411 , TreeScope(this)
412 , m_guardRefCount(0)
413 , m_styleResolverThrowawayTimer(this, &Document::styleResolverThrowawayTimer Fired) 412 , m_styleResolverThrowawayTimer(this, &Document::styleResolverThrowawayTimer Fired)
414 , m_lastStyleResolverAccessTime(0) 413 , m_lastStyleResolverAccessTime(0)
415 , m_activeParserCount(0) 414 , m_activeParserCount(0)
416 , m_contextFeatures(ContextFeatures::defaultSwitch()) 415 , m_contextFeatures(ContextFeatures::defaultSwitch())
417 , m_compatibilityMode(NoQuirksMode) 416 , m_compatibilityMode(NoQuirksMode)
418 , m_compatibilityModeLocked(false) 417 , m_compatibilityModeLocked(false)
419 , m_domTreeVersion(++s_globalTreeVersion) 418 , m_domTreeVersion(++s_globalTreeVersion)
420 , m_mutationObserverTypes(0) 419 , m_mutationObserverTypes(0)
421 , m_styleSheetCollection(DocumentStyleSheetCollection::create(this)) 420 , m_styleSheetCollection(DocumentStyleSheetCollection::create(this))
422 , m_visitedLinkState(VisitedLinkState::create(this)) 421 , m_visitedLinkState(VisitedLinkState::create(this))
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
474 , m_visualUpdatesAllowed(true) 473 , m_visualUpdatesAllowed(true)
475 , m_visualUpdatesSuppressionTimer(this, &Document::visualUpdatesSuppressionT imerFired) 474 , m_visualUpdatesSuppressionTimer(this, &Document::visualUpdatesSuppressionT imerFired)
476 , m_sharedObjectPoolClearTimer(this, &Document::sharedObjectPoolClearTimerFi red) 475 , m_sharedObjectPoolClearTimer(this, &Document::sharedObjectPoolClearTimerFi red)
477 #ifndef NDEBUG 476 #ifndef NDEBUG
478 , m_didDispatchViewportPropertiesChanged(false) 477 , m_didDispatchViewportPropertiesChanged(false)
479 #endif 478 #endif
480 #if ENABLE(TEMPLATE_ELEMENT) 479 #if ENABLE(TEMPLATE_ELEMENT)
481 , m_templateDocumentHost(0) 480 , m_templateDocumentHost(0)
482 #endif 481 #endif
483 { 482 {
484 setTreeScope(this);
485
486 m_printing = false; 483 m_printing = false;
487 m_paginatedForScreen = false; 484 m_paginatedForScreen = false;
488 485
489 m_ignoreAutofocus = false; 486 m_ignoreAutofocus = false;
490 487
491 m_frame = frame; 488 m_frame = frame;
492 if (m_frame) 489 if (m_frame)
493 provideContextFeaturesToDocumentFrom(this, m_frame->page()); 490 provideContextFeaturesToDocumentFrom(this, m_frame->page());
494 491
495 // We depend on the url getting immediately set in subframes, but we 492 // We depend on the url getting immediately set in subframes, but we
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
575 #endif 572 #endif
576 573
577 Document::~Document() 574 Document::~Document()
578 { 575 {
579 ASSERT(!renderer()); 576 ASSERT(!renderer());
580 ASSERT(!m_inPageCache); 577 ASSERT(!m_inPageCache);
581 ASSERT(!m_savedRenderer); 578 ASSERT(!m_savedRenderer);
582 ASSERT(m_ranges.isEmpty()); 579 ASSERT(m_ranges.isEmpty());
583 ASSERT(!m_styleRecalcTimer.isActive()); 580 ASSERT(!m_styleRecalcTimer.isActive());
584 ASSERT(!m_parentTreeScope); 581 ASSERT(!m_parentTreeScope);
585 ASSERT(!m_guardRefCount); 582 ASSERT(!hasGuardRefCount());
586 583
587 #if ENABLE(TEMPLATE_ELEMENT) 584 #if ENABLE(TEMPLATE_ELEMENT)
588 if (m_templateDocument) 585 if (m_templateDocument)
589 m_templateDocument->setTemplateDocumentHost(0); // balanced in templateD ocument(). 586 m_templateDocument->setTemplateDocumentHost(0); // balanced in templateD ocument().
590 #endif 587 #endif
591 588
592 #if ENABLE(TOUCH_EVENT_TRACKING) 589 #if ENABLE(TOUCH_EVENT_TRACKING)
593 if (Document* ownerDocument = this->ownerDocument()) 590 if (Document* ownerDocument = this->ownerDocument())
594 ownerDocument->didRemoveEventTargetNode(this); 591 ownerDocument->didRemoveEventTargetNode(this);
595 #endif 592 #endif
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
642 ASSERT(!m_listsInvalidatedAtDocument.size()); 639 ASSERT(!m_listsInvalidatedAtDocument.size());
643 640
644 for (unsigned i = 0; i < WTF_ARRAY_LENGTH(m_nodeListCounts); i++) 641 for (unsigned i = 0; i < WTF_ARRAY_LENGTH(m_nodeListCounts); i++)
645 ASSERT(!m_nodeListCounts[i]); 642 ASSERT(!m_nodeListCounts[i]);
646 643
647 clearDocumentScope(); 644 clearDocumentScope();
648 645
649 InspectorCounters::decrementCounter(InspectorCounters::DocumentCounter); 646 InspectorCounters::decrementCounter(InspectorCounters::DocumentCounter);
650 } 647 }
651 648
652 void Document::removedLastRef() 649 void Document::dispose()
653 { 650 {
654 ASSERT(!m_deletionHasBegun); 651 // We must make sure not to be retaining any of our children through
655 if (m_guardRefCount) { 652 // these extra pointers or we will create a reference cycle.
656 // If removing a child removes the last self-only ref, we don't 653 m_docType = 0;
657 // want the scope to be destructed until after 654 m_focusedNode = 0;
658 // removeDetachedChildren returns, so we guard ourselves with an 655 m_hoverNode = 0;
659 // extra self-only ref. 656 m_activeElement = 0;
660 guardRef(); 657 m_titleElement = 0;
661 658 m_documentElement = 0;
662 // We must make sure not to be retaining any of our children through 659 m_contextFeatures = ContextFeatures::defaultSwitch();
663 // these extra pointers or we will create a reference cycle. 660 m_userActionElements.documentDidRemoveLastRef();
664 m_docType = 0;
665 m_focusedNode = 0;
666 m_hoverNode = 0;
667 m_activeElement = 0;
668 m_titleElement = 0;
669 m_documentElement = 0;
670 m_contextFeatures = ContextFeatures::defaultSwitch();
671 m_userActionElements.documentDidRemoveLastRef();
672 #if ENABLE(FULLSCREEN_API) 661 #if ENABLE(FULLSCREEN_API)
673 m_fullScreenElement = 0; 662 m_fullScreenElement = 0;
674 m_fullScreenElementStack.clear(); 663 m_fullScreenElementStack.clear();
675 #endif 664 #endif
676 665
677 detachParser(); 666 detachParser();
678 667
679 // removeDetachedChildren() doesn't always unregister IDs, 668 // removeDetachedChildren() doesn't always unregister IDs,
680 // so tear down scope information upfront to avoid having stale referenc es in the map. 669 // so tear down scope information upfront to avoid having stale references i n the map.
681 destroyTreeScopeData(); 670 destroyTreeScopeData();
682 removeDetachedChildren(); 671 removeDetachedChildren();
683 672
684 m_markers->detach(); 673 m_markers->detach();
685 674
686 m_cssCanvasElements.clear(); 675 m_cssCanvasElements.clear();
687 676
688 #if ENABLE(REQUEST_ANIMATION_FRAME) 677 #if ENABLE(REQUEST_ANIMATION_FRAME)
689 // FIXME: consider using ActiveDOMObject. 678 // FIXME: consider using ActiveDOMObject.
690 if (m_scriptedAnimationController) 679 if (m_scriptedAnimationController)
691 m_scriptedAnimationController->clearDocumentPointer(); 680 m_scriptedAnimationController->clearDocumentPointer();
692 m_scriptedAnimationController.clear(); 681 m_scriptedAnimationController.clear();
693 #endif 682 #endif
694
695 #ifndef NDEBUG
696 m_inRemovedLastRefFunction = false;
697 #endif
698
699 guardDeref();
700 } else {
701 #ifndef NDEBUG
702 m_deletionHasBegun = true;
703 #endif
704 delete this;
705 }
706 } 683 }
707 684
708 Element* Document::getElementById(const AtomicString& id) const 685 Element* Document::getElementById(const AtomicString& id) const
709 { 686 {
710 return TreeScope::getElementById(id); 687 return TreeScope::getElementById(id);
711 } 688 }
712 689
713 Element* Document::getElementByAccessKey(const String& key) 690 Element* Document::getElementByAccessKey(const String& key)
714 { 691 {
715 if (key.isEmpty()) 692 if (key.isEmpty())
(...skipping 5329 matching lines...) Expand 10 before | Expand all | Expand 10 after
6045 else 6022 else
6046 m_templateDocument = Document::create(0, blankURL()); 6023 m_templateDocument = Document::create(0, blankURL());
6047 6024
6048 m_templateDocument->setTemplateDocumentHost(this); // balanced in dtor. 6025 m_templateDocument->setTemplateDocumentHost(this); // balanced in dtor.
6049 6026
6050 return m_templateDocument.get(); 6027 return m_templateDocument.get();
6051 } 6028 }
6052 #endif 6029 #endif
6053 6030
6054 } // namespace WebCore 6031 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/WebCore/dom/Document.h ('k') | Source/WebCore/dom/DocumentFragment.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698