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

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

Issue 285213003: Oilpan: move Node traversal objects to the heap. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Add virtual to NodeIteratorBase::trace Created 6 years, 7 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 1519 matching lines...) Expand 10 before | Expand all | Expand 10 after
1530 Settings* Document::settings() const 1530 Settings* Document::settings() const
1531 { 1531 {
1532 return m_frame ? m_frame->settings() : 0; 1532 return m_frame ? m_frame->settings() : 0;
1533 } 1533 }
1534 1534
1535 PassRefPtrWillBeRawPtr<Range> Document::createRange() 1535 PassRefPtrWillBeRawPtr<Range> Document::createRange()
1536 { 1536 {
1537 return Range::create(*this); 1537 return Range::create(*this);
1538 } 1538 }
1539 1539
1540 PassRefPtr<NodeIterator> Document::createNodeIterator(Node* root, ExceptionState & exceptionState) 1540 PassRefPtrWillBeRawPtr<NodeIterator> Document::createNodeIterator(Node* root, Ex ceptionState& exceptionState)
1541 { 1541 {
1542 // FIXME: Probably this should be handled within the bindings layer and Type Error should be thrown. 1542 // FIXME: Probably this should be handled within the bindings layer and Type Error should be thrown.
1543 if (!root) { 1543 if (!root) {
1544 exceptionState.throwDOMException(NotSupportedError, ExceptionMessages::a rgumentNullOrIncorrectType(1, "Node")); 1544 exceptionState.throwDOMException(NotSupportedError, ExceptionMessages::a rgumentNullOrIncorrectType(1, "Node"));
1545 return nullptr; 1545 return nullptr;
1546 } 1546 }
1547 return NodeIterator::create(root, NodeFilter::SHOW_ALL, PassRefPtr<NodeFilte r>()); 1547 return NodeIterator::create(root, NodeFilter::SHOW_ALL, PassRefPtrWillBeRawP tr<NodeFilter>(nullptr));
haraken 2014/05/18 08:45:48 Doesn't just 'nullptr' work? The same comment for
sof 2014/05/18 17:19:24 Yes, the compiler doesn't need our explicit guidan
1548 } 1548 }
1549 1549
1550 PassRefPtr<NodeIterator> Document::createNodeIterator(Node* root, unsigned whatT oShow, ExceptionState& exceptionState) 1550 PassRefPtrWillBeRawPtr<NodeIterator> Document::createNodeIterator(Node* root, un signed whatToShow, ExceptionState& exceptionState)
1551 { 1551 {
1552 if (!root) { 1552 if (!root) {
1553 exceptionState.throwDOMException(NotSupportedError, ExceptionMessages::a rgumentNullOrIncorrectType(1, "Node")); 1553 exceptionState.throwDOMException(NotSupportedError, ExceptionMessages::a rgumentNullOrIncorrectType(1, "Node"));
1554 return nullptr; 1554 return nullptr;
1555 } 1555 }
1556 // FIXME: It might be a good idea to emit a warning if |whatToShow| contains a bit that is not defined in 1556 // FIXME: It might be a good idea to emit a warning if |whatToShow| contains a bit that is not defined in
1557 // NodeFilter. 1557 // NodeFilter.
1558 return NodeIterator::create(root, whatToShow, PassRefPtr<NodeFilter>()); 1558 return NodeIterator::create(root, whatToShow, PassRefPtrWillBeRawPtr<NodeFil ter>(nullptr));
1559 } 1559 }
1560 1560
1561 PassRefPtr<NodeIterator> Document::createNodeIterator(Node* root, unsigned whatT oShow, PassRefPtr<NodeFilter> filter, ExceptionState& exceptionState) 1561 PassRefPtrWillBeRawPtr<NodeIterator> Document::createNodeIterator(Node* root, un signed whatToShow, PassRefPtrWillBeRawPtr<NodeFilter> filter, ExceptionState& ex ceptionState)
1562 { 1562 {
1563 if (!root) { 1563 if (!root) {
1564 exceptionState.throwDOMException(NotSupportedError, ExceptionMessages::a rgumentNullOrIncorrectType(1, "Node")); 1564 exceptionState.throwDOMException(NotSupportedError, ExceptionMessages::a rgumentNullOrIncorrectType(1, "Node"));
1565 return nullptr; 1565 return nullptr;
1566 } 1566 }
1567 // FIXME: Ditto. 1567 // FIXME: Ditto.
1568 return NodeIterator::create(root, whatToShow, filter); 1568 return NodeIterator::create(root, whatToShow, filter);
1569 } 1569 }
1570 1570
1571 PassRefPtr<TreeWalker> Document::createTreeWalker(Node* root, ExceptionState& ex ceptionState) 1571 PassRefPtrWillBeRawPtr<TreeWalker> Document::createTreeWalker(Node* root, Except ionState& exceptionState)
1572 { 1572 {
1573 if (!root) { 1573 if (!root) {
1574 exceptionState.throwDOMException(NotSupportedError, ExceptionMessages::a rgumentNullOrIncorrectType(1, "Node")); 1574 exceptionState.throwDOMException(NotSupportedError, ExceptionMessages::a rgumentNullOrIncorrectType(1, "Node"));
1575 return nullptr; 1575 return nullptr;
1576 } 1576 }
1577 return TreeWalker::create(root, NodeFilter::SHOW_ALL, PassRefPtr<NodeFilter> ()); 1577 return TreeWalker::create(root, NodeFilter::SHOW_ALL, PassRefPtrWillBeRawPtr <NodeFilter>(nullptr));
1578 } 1578 }
1579 1579
1580 PassRefPtr<TreeWalker> Document::createTreeWalker(Node* root, unsigned whatToSho w, ExceptionState& exceptionState) 1580 PassRefPtrWillBeRawPtr<TreeWalker> Document::createTreeWalker(Node* root, unsign ed whatToShow, ExceptionState& exceptionState)
1581 { 1581 {
1582 if (!root) { 1582 if (!root) {
1583 exceptionState.throwDOMException(NotSupportedError, ExceptionMessages::a rgumentNullOrIncorrectType(1, "Node")); 1583 exceptionState.throwDOMException(NotSupportedError, ExceptionMessages::a rgumentNullOrIncorrectType(1, "Node"));
1584 return nullptr; 1584 return nullptr;
1585 } 1585 }
1586 return TreeWalker::create(root, whatToShow, PassRefPtr<NodeFilter>()); 1586 return TreeWalker::create(root, whatToShow, PassRefPtrWillBeRawPtr<NodeFilte r>(nullptr));
1587 } 1587 }
1588 1588
1589 PassRefPtr<TreeWalker> Document::createTreeWalker(Node* root, unsigned whatToSho w, PassRefPtr<NodeFilter> filter, ExceptionState& exceptionState) 1589 PassRefPtrWillBeRawPtr<TreeWalker> Document::createTreeWalker(Node* root, unsign ed whatToShow, PassRefPtrWillBeRawPtr<NodeFilter> filter, ExceptionState& except ionState)
1590 { 1590 {
1591 if (!root) { 1591 if (!root) {
1592 exceptionState.throwDOMException(NotSupportedError, ExceptionMessages::a rgumentNullOrIncorrectType(1, "Node")); 1592 exceptionState.throwDOMException(NotSupportedError, ExceptionMessages::a rgumentNullOrIncorrectType(1, "Node"));
1593 return nullptr; 1593 return nullptr;
1594 } 1594 }
1595 return TreeWalker::create(root, whatToShow, filter); 1595 return TreeWalker::create(root, whatToShow, filter);
1596 } 1596 }
1597 1597
1598 bool Document::needsRenderTreeUpdate() const 1598 bool Document::needsRenderTreeUpdate() const
1599 { 1599 {
(...skipping 2120 matching lines...) Expand 10 before | Expand all | Expand 10 after
3720 3720
3721 void Document::detachNodeIterator(NodeIterator* ni) 3721 void Document::detachNodeIterator(NodeIterator* ni)
3722 { 3722 {
3723 // The node iterator can be detached without having been attached if its roo t node didn't have a document 3723 // The node iterator can be detached without having been attached if its roo t node didn't have a document
3724 // when the iterator was created, but has it now. 3724 // when the iterator was created, but has it now.
3725 m_nodeIterators.remove(ni); 3725 m_nodeIterators.remove(ni);
3726 } 3726 }
3727 3727
3728 void Document::moveNodeIteratorsToNewDocument(Node& node, Document& newDocument) 3728 void Document::moveNodeIteratorsToNewDocument(Node& node, Document& newDocument)
3729 { 3729 {
3730 HashSet<NodeIterator*> nodeIteratorsList = m_nodeIterators; 3730 WillBeHeapHashSet<RawPtrWillBeWeakMember<NodeIterator> > nodeIteratorsList = m_nodeIterators;
3731 HashSet<NodeIterator*>::const_iterator nodeIteratorsEnd = nodeIteratorsList. end(); 3731 WillBeHeapHashSet<RawPtrWillBeWeakMember<NodeIterator> >::const_iterator nod eIteratorsEnd = nodeIteratorsList.end();
3732 for (HashSet<NodeIterator*>::const_iterator it = nodeIteratorsList.begin(); it != nodeIteratorsEnd; ++it) { 3732 for (WillBeHeapHashSet<RawPtrWillBeWeakMember<NodeIterator> >::const_iterato r it = nodeIteratorsList.begin(); it != nodeIteratorsEnd; ++it) {
3733 if ((*it)->root() == node) { 3733 if ((*it)->root() == node) {
3734 detachNodeIterator(*it); 3734 detachNodeIterator(*it);
3735 newDocument.attachNodeIterator(*it); 3735 newDocument.attachNodeIterator(*it);
3736 } 3736 }
3737 } 3737 }
3738 } 3738 }
3739 3739
3740 void Document::updateRangesAfterChildrenChanged(ContainerNode* container) 3740 void Document::updateRangesAfterChildrenChanged(ContainerNode* container)
3741 { 3741 {
3742 if (!m_ranges.isEmpty()) { 3742 if (!m_ranges.isEmpty()) {
3743 HashSet<Range*>::const_iterator end = m_ranges.end(); 3743 HashSet<Range*>::const_iterator end = m_ranges.end();
3744 for (HashSet<Range*>::const_iterator it = m_ranges.begin(); it != end; + +it) 3744 for (HashSet<Range*>::const_iterator it = m_ranges.begin(); it != end; + +it)
3745 (*it)->nodeChildrenChanged(container); 3745 (*it)->nodeChildrenChanged(container);
3746 } 3746 }
3747 } 3747 }
3748 3748
3749 void Document::nodeChildrenWillBeRemoved(ContainerNode& container) 3749 void Document::nodeChildrenWillBeRemoved(ContainerNode& container)
3750 { 3750 {
3751 NoEventDispatchAssertion assertNoEventDispatch; 3751 NoEventDispatchAssertion assertNoEventDispatch;
3752 if (!m_ranges.isEmpty()) { 3752 if (!m_ranges.isEmpty()) {
3753 HashSet<Range*>::const_iterator end = m_ranges.end(); 3753 HashSet<Range*>::const_iterator end = m_ranges.end();
3754 for (HashSet<Range*>::const_iterator it = m_ranges.begin(); it != end; + +it) 3754 for (HashSet<Range*>::const_iterator it = m_ranges.begin(); it != end; + +it)
3755 (*it)->nodeChildrenWillBeRemoved(container); 3755 (*it)->nodeChildrenWillBeRemoved(container);
3756 } 3756 }
3757 3757
3758 HashSet<NodeIterator*>::const_iterator nodeIteratorsEnd = m_nodeIterators.en d(); 3758 WillBeHeapHashSet<RawPtrWillBeWeakMember<NodeIterator> >::const_iterator nod eIteratorsEnd = m_nodeIterators.end();
3759 for (HashSet<NodeIterator*>::const_iterator it = m_nodeIterators.begin(); it != nodeIteratorsEnd; ++it) { 3759 for (WillBeHeapHashSet<RawPtrWillBeWeakMember<NodeIterator> >::const_iterato r it = m_nodeIterators.begin(); it != nodeIteratorsEnd; ++it) {
3760 for (Node* n = container.firstChild(); n; n = n->nextSibling()) 3760 for (Node* n = container.firstChild(); n; n = n->nextSibling())
3761 (*it)->nodeWillBeRemoved(*n); 3761 (*it)->nodeWillBeRemoved(*n);
3762 } 3762 }
3763 3763
3764 if (LocalFrame* frame = this->frame()) { 3764 if (LocalFrame* frame = this->frame()) {
3765 for (Node* n = container.firstChild(); n; n = n->nextSibling()) { 3765 for (Node* n = container.firstChild(); n; n = n->nextSibling()) {
3766 frame->eventHandler().nodeWillBeRemoved(*n); 3766 frame->eventHandler().nodeWillBeRemoved(*n);
3767 frame->selection().nodeWillBeRemoved(*n); 3767 frame->selection().nodeWillBeRemoved(*n);
3768 frame->page()->dragCaretController().nodeWillBeRemoved(*n); 3768 frame->page()->dragCaretController().nodeWillBeRemoved(*n);
3769 } 3769 }
3770 } 3770 }
3771 } 3771 }
3772 3772
3773 void Document::nodeWillBeRemoved(Node& n) 3773 void Document::nodeWillBeRemoved(Node& n)
3774 { 3774 {
3775 HashSet<NodeIterator*>::const_iterator nodeIteratorsEnd = m_nodeIterators.en d(); 3775 WillBeHeapHashSet<RawPtrWillBeWeakMember<NodeIterator> >::const_iterator nod eIteratorsEnd = m_nodeIterators.end();
3776 for (HashSet<NodeIterator*>::const_iterator it = m_nodeIterators.begin(); it != nodeIteratorsEnd; ++it) 3776 for (WillBeHeapHashSet<RawPtrWillBeWeakMember<NodeIterator> >::const_iterato r it = m_nodeIterators.begin(); it != nodeIteratorsEnd; ++it)
3777 (*it)->nodeWillBeRemoved(n); 3777 (*it)->nodeWillBeRemoved(n);
3778 3778
3779 if (!m_ranges.isEmpty()) { 3779 if (!m_ranges.isEmpty()) {
3780 HashSet<Range*>::const_iterator rangesEnd = m_ranges.end(); 3780 HashSet<Range*>::const_iterator rangesEnd = m_ranges.end();
3781 for (HashSet<Range*>::const_iterator it = m_ranges.begin(); it != ranges End; ++it) 3781 for (HashSet<Range*>::const_iterator it = m_ranges.begin(); it != ranges End; ++it)
3782 (*it)->nodeWillBeRemoved(n); 3782 (*it)->nodeWillBeRemoved(n);
3783 } 3783 }
3784 3784
3785 if (LocalFrame* frame = this->frame()) { 3785 if (LocalFrame* frame = this->frame()) {
3786 frame->eventHandler().nodeWillBeRemoved(n); 3786 frame->eventHandler().nodeWillBeRemoved(n);
(...skipping 1923 matching lines...) Expand 10 before | Expand all | Expand 10 after
5710 visitor->trace(m_hoverNode); 5710 visitor->trace(m_hoverNode);
5711 visitor->trace(m_activeHoverElement); 5711 visitor->trace(m_activeHoverElement);
5712 visitor->trace(m_documentElement); 5712 visitor->trace(m_documentElement);
5713 visitor->trace(m_titleElement); 5713 visitor->trace(m_titleElement);
5714 visitor->trace(m_markers); 5714 visitor->trace(m_markers);
5715 visitor->trace(m_currentScriptStack); 5715 visitor->trace(m_currentScriptStack);
5716 visitor->trace(m_transformSourceDocument); 5716 visitor->trace(m_transformSourceDocument);
5717 visitor->trace(m_cssCanvasElements); 5717 visitor->trace(m_cssCanvasElements);
5718 visitor->trace(m_topLayerElements); 5718 visitor->trace(m_topLayerElements);
5719 visitor->trace(m_elemSheet); 5719 visitor->trace(m_elemSheet);
5720 visitor->trace(m_nodeIterators);
5720 visitor->trace(m_styleEngine); 5721 visitor->trace(m_styleEngine);
5721 visitor->trace(m_formController); 5722 visitor->trace(m_formController);
5722 visitor->trace(m_fetcher); 5723 visitor->trace(m_fetcher);
5723 visitor->trace(m_contextFeatures); 5724 visitor->trace(m_contextFeatures);
5724 visitor->trace(m_styleSheetList); 5725 visitor->trace(m_styleSheetList);
5725 visitor->trace(m_mediaQueryMatcher); 5726 visitor->trace(m_mediaQueryMatcher);
5726 visitor->trace(m_associatedFormControls); 5727 visitor->trace(m_associatedFormControls);
5727 visitor->trace(m_templateDocument); 5728 visitor->trace(m_templateDocument);
5728 visitor->trace(m_templateDocumentHost); 5729 visitor->trace(m_templateDocumentHost);
5729 visitor->trace(m_visibilityObservers); 5730 visitor->trace(m_visibilityObservers);
5730 visitor->trace(m_userActionElements); 5731 visitor->trace(m_userActionElements);
5731 visitor->trace(m_svgExtensions); 5732 visitor->trace(m_svgExtensions);
5732 visitor->registerWeakMembers<Document, &Document::clearWeakMembers>(this); 5733 visitor->registerWeakMembers<Document, &Document::clearWeakMembers>(this);
5733 DocumentSupplementable::trace(visitor); 5734 DocumentSupplementable::trace(visitor);
5734 TreeScope::trace(visitor); 5735 TreeScope::trace(visitor);
5735 ContainerNode::trace(visitor); 5736 ContainerNode::trace(visitor);
5736 ExecutionContext::trace(visitor); 5737 ExecutionContext::trace(visitor);
5737 } 5738 }
5738 5739
5739 } // namespace WebCore 5740 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698