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

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

Issue 330383004: Oilpan: Introduce TempRangeScope to avoid needless Range attaches on Document. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Address review comments. Created 6 years, 6 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 | « no previous file | Source/core/dom/Range.h » ('j') | Source/core/dom/Range.h » ('J')
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 3745 matching lines...) Expand 10 before | Expand all | Expand 10 after
3756 for (WillBeHeapHashSet<RawPtrWillBeWeakMember<NodeIterator> >::const_iterato r it = nodeIteratorsList.begin(); it != nodeIteratorsEnd; ++it) { 3756 for (WillBeHeapHashSet<RawPtrWillBeWeakMember<NodeIterator> >::const_iterato r it = nodeIteratorsList.begin(); it != nodeIteratorsEnd; ++it) {
3757 if ((*it)->root() == node) { 3757 if ((*it)->root() == node) {
3758 detachNodeIterator(*it); 3758 detachNodeIterator(*it);
3759 newDocument.attachNodeIterator(*it); 3759 newDocument.attachNodeIterator(*it);
3760 } 3760 }
3761 } 3761 }
3762 } 3762 }
3763 3763
3764 void Document::updateRangesAfterChildrenChanged(ContainerNode* container) 3764 void Document::updateRangesAfterChildrenChanged(ContainerNode* container)
3765 { 3765 {
3766 ASSERT(!TemporaryRangeScope::active());
3766 if (!m_ranges.isEmpty()) { 3767 if (!m_ranges.isEmpty()) {
3767 AttachedRangeSet::const_iterator end = m_ranges.end(); 3768 AttachedRangeSet::const_iterator end = m_ranges.end();
3768 for (AttachedRangeSet::const_iterator it = m_ranges.begin(); it != end; ++it) 3769 for (AttachedRangeSet::const_iterator it = m_ranges.begin(); it != end; ++it)
3769 (*it)->nodeChildrenChanged(container); 3770 (*it)->nodeChildrenChanged(container);
3770 } 3771 }
3771 } 3772 }
3772 3773
3773 void Document::updateRangesAfterNodeMovedToAnotherDocument(const Node& node) 3774 void Document::updateRangesAfterNodeMovedToAnotherDocument(const Node& node)
3774 { 3775 {
3776 ASSERT(!TemporaryRangeScope::active());
3775 ASSERT(node.document() != this); 3777 ASSERT(node.document() != this);
3776 if (m_ranges.isEmpty()) 3778 if (m_ranges.isEmpty())
3777 return; 3779 return;
3778 AttachedRangeSet ranges = m_ranges; 3780 AttachedRangeSet ranges = m_ranges;
3779 AttachedRangeSet::const_iterator end = ranges.end(); 3781 AttachedRangeSet::const_iterator end = ranges.end();
3780 for (AttachedRangeSet::const_iterator it = ranges.begin(); it != end; ++it) 3782 for (AttachedRangeSet::const_iterator it = ranges.begin(); it != end; ++it)
3781 (*it)->updateOwnerDocumentIfNeeded(); 3783 (*it)->updateOwnerDocumentIfNeeded();
3782 } 3784 }
3783 3785
3784 void Document::nodeChildrenWillBeRemoved(ContainerNode& container) 3786 void Document::nodeChildrenWillBeRemoved(ContainerNode& container)
3785 { 3787 {
3788 ASSERT(!TemporaryRangeScope::active());
3786 NoEventDispatchAssertion assertNoEventDispatch; 3789 NoEventDispatchAssertion assertNoEventDispatch;
3787 if (!m_ranges.isEmpty()) { 3790 if (!m_ranges.isEmpty()) {
3788 AttachedRangeSet::const_iterator end = m_ranges.end(); 3791 AttachedRangeSet::const_iterator end = m_ranges.end();
3789 for (AttachedRangeSet::const_iterator it = m_ranges.begin(); it != end; ++it) 3792 for (AttachedRangeSet::const_iterator it = m_ranges.begin(); it != end; ++it)
3790 (*it)->nodeChildrenWillBeRemoved(container); 3793 (*it)->nodeChildrenWillBeRemoved(container);
3791 } 3794 }
3792 3795
3793 WillBeHeapHashSet<RawPtrWillBeWeakMember<NodeIterator> >::const_iterator nod eIteratorsEnd = m_nodeIterators.end(); 3796 WillBeHeapHashSet<RawPtrWillBeWeakMember<NodeIterator> >::const_iterator nod eIteratorsEnd = m_nodeIterators.end();
3794 for (WillBeHeapHashSet<RawPtrWillBeWeakMember<NodeIterator> >::const_iterato r it = m_nodeIterators.begin(); it != nodeIteratorsEnd; ++it) { 3797 for (WillBeHeapHashSet<RawPtrWillBeWeakMember<NodeIterator> >::const_iterato r it = m_nodeIterators.begin(); it != nodeIteratorsEnd; ++it) {
3795 for (Node* n = container.firstChild(); n; n = n->nextSibling()) 3798 for (Node* n = container.firstChild(); n; n = n->nextSibling())
3796 (*it)->nodeWillBeRemoved(*n); 3799 (*it)->nodeWillBeRemoved(*n);
3797 } 3800 }
3798 3801
3799 if (LocalFrame* frame = this->frame()) { 3802 if (LocalFrame* frame = this->frame()) {
3800 for (Node* n = container.firstChild(); n; n = n->nextSibling()) { 3803 for (Node* n = container.firstChild(); n; n = n->nextSibling()) {
3801 frame->eventHandler().nodeWillBeRemoved(*n); 3804 frame->eventHandler().nodeWillBeRemoved(*n);
3802 frame->selection().nodeWillBeRemoved(*n); 3805 frame->selection().nodeWillBeRemoved(*n);
3803 frame->page()->dragCaretController().nodeWillBeRemoved(*n); 3806 frame->page()->dragCaretController().nodeWillBeRemoved(*n);
3804 } 3807 }
3805 } 3808 }
3806 } 3809 }
3807 3810
3808 void Document::nodeWillBeRemoved(Node& n) 3811 void Document::nodeWillBeRemoved(Node& n)
3809 { 3812 {
3813 ASSERT(!TemporaryRangeScope::active());
3810 WillBeHeapHashSet<RawPtrWillBeWeakMember<NodeIterator> >::const_iterator nod eIteratorsEnd = m_nodeIterators.end(); 3814 WillBeHeapHashSet<RawPtrWillBeWeakMember<NodeIterator> >::const_iterator nod eIteratorsEnd = m_nodeIterators.end();
3811 for (WillBeHeapHashSet<RawPtrWillBeWeakMember<NodeIterator> >::const_iterato r it = m_nodeIterators.begin(); it != nodeIteratorsEnd; ++it) 3815 for (WillBeHeapHashSet<RawPtrWillBeWeakMember<NodeIterator> >::const_iterato r it = m_nodeIterators.begin(); it != nodeIteratorsEnd; ++it)
3812 (*it)->nodeWillBeRemoved(n); 3816 (*it)->nodeWillBeRemoved(n);
3813 3817
3814 if (!m_ranges.isEmpty()) { 3818 if (!m_ranges.isEmpty()) {
3815 AttachedRangeSet::const_iterator rangesEnd = m_ranges.end(); 3819 AttachedRangeSet::const_iterator rangesEnd = m_ranges.end();
3816 for (AttachedRangeSet::const_iterator it = m_ranges.begin(); it != range sEnd; ++it) 3820 for (AttachedRangeSet::const_iterator it = m_ranges.begin(); it != range sEnd; ++it)
3817 (*it)->nodeWillBeRemoved(n); 3821 (*it)->nodeWillBeRemoved(n);
3818 } 3822 }
3819 3823
3820 if (LocalFrame* frame = this->frame()) { 3824 if (LocalFrame* frame = this->frame()) {
3821 frame->eventHandler().nodeWillBeRemoved(n); 3825 frame->eventHandler().nodeWillBeRemoved(n);
3822 frame->selection().nodeWillBeRemoved(n); 3826 frame->selection().nodeWillBeRemoved(n);
3823 frame->page()->dragCaretController().nodeWillBeRemoved(n); 3827 frame->page()->dragCaretController().nodeWillBeRemoved(n);
3824 } 3828 }
3825 } 3829 }
3826 3830
3827 void Document::didInsertText(Node* text, unsigned offset, unsigned length) 3831 void Document::didInsertText(Node* text, unsigned offset, unsigned length)
3828 { 3832 {
3833 ASSERT(!TemporaryRangeScope::active());
3829 if (!m_ranges.isEmpty()) { 3834 if (!m_ranges.isEmpty()) {
3830 AttachedRangeSet::const_iterator end = m_ranges.end(); 3835 AttachedRangeSet::const_iterator end = m_ranges.end();
3831 for (AttachedRangeSet::const_iterator it = m_ranges.begin(); it != end; ++it) 3836 for (AttachedRangeSet::const_iterator it = m_ranges.begin(); it != end; ++it)
3832 (*it)->didInsertText(text, offset, length); 3837 (*it)->didInsertText(text, offset, length);
3833 } 3838 }
3834 3839
3835 // Update the markers for spelling and grammar checking. 3840 // Update the markers for spelling and grammar checking.
3836 m_markers->shiftMarkers(text, offset, length); 3841 m_markers->shiftMarkers(text, offset, length);
3837 } 3842 }
3838 3843
3839 void Document::didRemoveText(Node* text, unsigned offset, unsigned length) 3844 void Document::didRemoveText(Node* text, unsigned offset, unsigned length)
3840 { 3845 {
3846 ASSERT(!TemporaryRangeScope::active());
3841 if (!m_ranges.isEmpty()) { 3847 if (!m_ranges.isEmpty()) {
3842 AttachedRangeSet::const_iterator end = m_ranges.end(); 3848 AttachedRangeSet::const_iterator end = m_ranges.end();
3843 for (AttachedRangeSet::const_iterator it = m_ranges.begin(); it != end; ++it) 3849 for (AttachedRangeSet::const_iterator it = m_ranges.begin(); it != end; ++it)
3844 (*it)->didRemoveText(text, offset, length); 3850 (*it)->didRemoveText(text, offset, length);
3845 } 3851 }
3846 3852
3847 // Update the markers for spelling and grammar checking. 3853 // Update the markers for spelling and grammar checking.
3848 m_markers->removeMarkers(text, offset, length); 3854 m_markers->removeMarkers(text, offset, length);
3849 m_markers->shiftMarkers(text, offset + length, 0 - length); 3855 m_markers->shiftMarkers(text, offset + length, 0 - length);
3850 } 3856 }
3851 3857
3852 void Document::didMergeTextNodes(Text& oldNode, unsigned offset) 3858 void Document::didMergeTextNodes(Text& oldNode, unsigned offset)
3853 { 3859 {
3860 ASSERT(!TemporaryRangeScope::active());
3854 if (!m_ranges.isEmpty()) { 3861 if (!m_ranges.isEmpty()) {
3855 NodeWithIndex oldNodeWithIndex(oldNode); 3862 NodeWithIndex oldNodeWithIndex(oldNode);
3856 AttachedRangeSet::const_iterator end = m_ranges.end(); 3863 AttachedRangeSet::const_iterator end = m_ranges.end();
3857 for (AttachedRangeSet::const_iterator it = m_ranges.begin(); it != end; ++it) 3864 for (AttachedRangeSet::const_iterator it = m_ranges.begin(); it != end; ++it)
3858 (*it)->didMergeTextNodes(oldNodeWithIndex, offset); 3865 (*it)->didMergeTextNodes(oldNodeWithIndex, offset);
3859 } 3866 }
3860 3867
3861 if (m_frame) 3868 if (m_frame)
3862 m_frame->selection().didMergeTextNodes(oldNode, offset); 3869 m_frame->selection().didMergeTextNodes(oldNode, offset);
3863 3870
3864 // FIXME: This should update markers for spelling and grammar checking. 3871 // FIXME: This should update markers for spelling and grammar checking.
3865 } 3872 }
3866 3873
3867 void Document::didSplitTextNode(Text& oldNode) 3874 void Document::didSplitTextNode(Text& oldNode)
3868 { 3875 {
3876 ASSERT(!TemporaryRangeScope::active());
3869 if (!m_ranges.isEmpty()) { 3877 if (!m_ranges.isEmpty()) {
3870 AttachedRangeSet::const_iterator end = m_ranges.end(); 3878 AttachedRangeSet::const_iterator end = m_ranges.end();
3871 for (AttachedRangeSet::const_iterator it = m_ranges.begin(); it != end; ++it) 3879 for (AttachedRangeSet::const_iterator it = m_ranges.begin(); it != end; ++it)
3872 (*it)->didSplitTextNode(oldNode); 3880 (*it)->didSplitTextNode(oldNode);
3873 } 3881 }
3874 3882
3875 if (m_frame) 3883 if (m_frame)
3876 m_frame->selection().didSplitTextNode(oldNode); 3884 m_frame->selection().didSplitTextNode(oldNode);
3877 3885
3878 // FIXME: This should update markers for spelling and grammar checking. 3886 // FIXME: This should update markers for spelling and grammar checking.
(...skipping 1992 matching lines...) Expand 10 before | Expand all | Expand 10 after
5871 visitor->trace(m_compositorPendingAnimations); 5879 visitor->trace(m_compositorPendingAnimations);
5872 visitor->trace(m_contextDocument); 5880 visitor->trace(m_contextDocument);
5873 visitor->registerWeakMembers<Document, &Document::clearWeakMembers>(this); 5881 visitor->registerWeakMembers<Document, &Document::clearWeakMembers>(this);
5874 DocumentSupplementable::trace(visitor); 5882 DocumentSupplementable::trace(visitor);
5875 TreeScope::trace(visitor); 5883 TreeScope::trace(visitor);
5876 ContainerNode::trace(visitor); 5884 ContainerNode::trace(visitor);
5877 ExecutionContext::trace(visitor); 5885 ExecutionContext::trace(visitor);
5878 } 5886 }
5879 5887
5880 } // namespace WebCore 5888 } // namespace WebCore
OLDNEW
« no previous file with comments | « no previous file | Source/core/dom/Range.h » ('j') | Source/core/dom/Range.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698