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

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

Issue 645443003: Move parts of core/dom to C++11 (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 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 | Annotate | Revision Log
« no previous file with comments | « Source/core/dom/Document.h ('k') | Source/core/dom/DocumentLifecycleNotifier.h » ('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 350 matching lines...) Expand 10 before | Expand all | Expand 10 after
361 { 361 {
362 String message = "Unsafe JavaScript attempt to initiate navigation for frame with URL '" + frame.document()->url().string() + "' from frame with URL '" + ac tiveURL.string() + "'. " + reason + "\n"; 362 String message = "Unsafe JavaScript attempt to initiate navigation for frame with URL '" + frame.document()->url().string() + "' from frame with URL '" + ac tiveURL.string() + "'. " + reason + "\n";
363 363
364 // FIXME: should we print to the console of the document performing the navi gation instead? 364 // FIXME: should we print to the console of the document performing the navi gation instead?
365 frame.domWindow()->printErrorMessage(message); 365 frame.domWindow()->printErrorMessage(message);
366 } 366 }
367 367
368 uint64_t Document::s_globalTreeVersion = 0; 368 uint64_t Document::s_globalTreeVersion = 0;
369 369
370 #ifndef NDEBUG 370 #ifndef NDEBUG
371 typedef WillBeHeapHashSet<RawPtrWillBeWeakMember<Document> > WeakDocumentSet; 371 using WeakDocumentSet = WillBeHeapHashSet<RawPtrWillBeWeakMember<Document>>;
372 static WeakDocumentSet& liveDocumentSet() 372 static WeakDocumentSet& liveDocumentSet()
373 { 373 {
374 DEFINE_STATIC_LOCAL(OwnPtrWillBePersistent<WeakDocumentSet>, set, (adoptPtrW illBeNoop(new WeakDocumentSet()))); 374 DEFINE_STATIC_LOCAL(OwnPtrWillBePersistent<WeakDocumentSet>, set, (adoptPtrW illBeNoop(new WeakDocumentSet())));
375 return *set; 375 return *set;
376 } 376 }
377 #endif 377 #endif
378 378
379 // This class doesn't work with non-Document ExecutionContext. 379 // This class doesn't work with non-Document ExecutionContext.
380 class AutofocusTask final : public ExecutionContextTask { 380 class AutofocusTask final : public ExecutionContextTask {
381 public: 381 public:
(...skipping 1075 matching lines...) Expand 10 before | Expand all | Expand 10 after
1457 return pageVisibilityState() != PageVisibilityStateVisible; 1457 return pageVisibilityState() != PageVisibilityStateVisible;
1458 } 1458 }
1459 1459
1460 void Document::didChangeVisibilityState() 1460 void Document::didChangeVisibilityState()
1461 { 1461 {
1462 dispatchEvent(Event::create(EventTypeNames::visibilitychange)); 1462 dispatchEvent(Event::create(EventTypeNames::visibilitychange));
1463 // Also send out the deprecated version until it can be removed. 1463 // Also send out the deprecated version until it can be removed.
1464 dispatchEvent(Event::create(EventTypeNames::webkitvisibilitychange)); 1464 dispatchEvent(Event::create(EventTypeNames::webkitvisibilitychange));
1465 1465
1466 PageVisibilityState state = pageVisibilityState(); 1466 PageVisibilityState state = pageVisibilityState();
1467 DocumentVisibilityObserverSet::const_iterator observerEnd = m_visibilityObse rvers.end(); 1467 for (DocumentVisibilityObserver* observer : m_visibilityObservers)
1468 for (DocumentVisibilityObserverSet::const_iterator it = m_visibilityObserver s.begin(); it != observerEnd; ++it) 1468 observer->didChangeVisibilityState(state);
1469 (*it)->didChangeVisibilityState(state);
1470 } 1469 }
1471 1470
1472 void Document::registerVisibilityObserver(DocumentVisibilityObserver* observer) 1471 void Document::registerVisibilityObserver(DocumentVisibilityObserver* observer)
1473 { 1472 {
1474 ASSERT(!m_visibilityObservers.contains(observer)); 1473 ASSERT(!m_visibilityObservers.contains(observer));
1475 m_visibilityObservers.add(observer); 1474 m_visibilityObservers.add(observer);
1476 } 1475 }
1477 1476
1478 void Document::unregisterVisibilityObserver(DocumentVisibilityObserver* observer ) 1477 void Document::unregisterVisibilityObserver(DocumentVisibilityObserver* observer )
1479 { 1478 {
(...skipping 576 matching lines...) Expand 10 before | Expand all | Expand 10 after
2056 2055
2057 setSecurityOrigin(SecurityOrigin::createUnique()); 2056 setSecurityOrigin(SecurityOrigin::createUnique());
2058 didUpdateSecurityOrigin(); 2057 didUpdateSecurityOrigin();
2059 } 2058 }
2060 2059
2061 bool Document::dirtyElementsForLayerUpdate() 2060 bool Document::dirtyElementsForLayerUpdate()
2062 { 2061 {
2063 if (m_layerUpdateSVGFilterElements.isEmpty()) 2062 if (m_layerUpdateSVGFilterElements.isEmpty())
2064 return false; 2063 return false;
2065 2064
2066 for (WillBeHeapHashSet<RawPtrWillBeMember<Element> >::iterator it = m_layerU pdateSVGFilterElements.begin(), end = m_layerUpdateSVGFilterElements.end(); it ! = end; ++it) 2065 for (Element* element : m_layerUpdateSVGFilterElements)
2067 (*it)->setNeedsStyleRecalc(LocalStyleChange, StyleChangeReasonForTracing ::create(StyleChangeReason::SVGFilterLayerUpdate)); 2066 element->setNeedsStyleRecalc(LocalStyleChange, StyleChangeReasonForTraci ng::create(StyleChangeReason::SVGFilterLayerUpdate));
2068 m_layerUpdateSVGFilterElements.clear(); 2067 m_layerUpdateSVGFilterElements.clear();
2069 return true; 2068 return true;
2070 } 2069 }
2071 2070
2072 void Document::scheduleSVGFilterLayerUpdateHack(Element& element) 2071 void Document::scheduleSVGFilterLayerUpdateHack(Element& element)
2073 { 2072 {
2074 if (element.styleChangeType() == NeedsReattachStyleChange) 2073 if (element.styleChangeType() == NeedsReattachStyleChange)
2075 return; 2074 return;
2076 element.setSVGFilterNeedsLayerUpdate(); 2075 element.setSVGFilterNeedsLayerUpdate();
2077 m_layerUpdateSVGFilterElements.add(&element); 2076 m_layerUpdateSVGFilterElements.add(&element);
(...skipping 17 matching lines...) Expand all
2095 m_useElementsNeedingUpdate.remove(&element); 2094 m_useElementsNeedingUpdate.remove(&element);
2096 } 2095 }
2097 2096
2098 void Document::updateUseShadowTreesIfNeeded() 2097 void Document::updateUseShadowTreesIfNeeded()
2099 { 2098 {
2100 ScriptForbiddenScope forbidScript; 2099 ScriptForbiddenScope forbidScript;
2101 2100
2102 if (m_useElementsNeedingUpdate.isEmpty()) 2101 if (m_useElementsNeedingUpdate.isEmpty())
2103 return; 2102 return;
2104 2103
2105 WillBeHeapVector<RawPtrWillBeMember<SVGUseElement> > elements; 2104 WillBeHeapVector<RawPtrWillBeMember<SVGUseElement>> elements;
2106 copyToVector(m_useElementsNeedingUpdate, elements); 2105 copyToVector(m_useElementsNeedingUpdate, elements);
2107 m_useElementsNeedingUpdate.clear(); 2106 m_useElementsNeedingUpdate.clear();
2108 2107
2109 for (WillBeHeapVector<RawPtrWillBeMember<SVGUseElement> >::iterator it = ele ments.begin(), end = elements.end(); it != end; ++it) 2108 for (SVGUseElement* element : elements)
2110 (*it)->buildPendingResource(); 2109 element->buildPendingResource();
2111 } 2110 }
2112 2111
2113 StyleResolver* Document::styleResolver() const 2112 StyleResolver* Document::styleResolver() const
2114 { 2113 {
2115 return m_styleEngine->resolver(); 2114 return m_styleEngine->resolver();
2116 } 2115 }
2117 2116
2118 StyleResolver& Document::ensureStyleResolver() const 2117 StyleResolver& Document::ensureStyleResolver() const
2119 { 2118 {
2120 return m_styleEngine->ensureResolver(); 2119 return m_styleEngine->ensureResolver();
(...skipping 1590 matching lines...) Expand 10 before | Expand all | Expand 10 after
3711 3710
3712 void Document::detachNodeIterator(NodeIterator* ni) 3711 void Document::detachNodeIterator(NodeIterator* ni)
3713 { 3712 {
3714 // The node iterator can be detached without having been attached if its roo t node didn't have a document 3713 // The node iterator can be detached without having been attached if its roo t node didn't have a document
3715 // when the iterator was created, but has it now. 3714 // when the iterator was created, but has it now.
3716 m_nodeIterators.remove(ni); 3715 m_nodeIterators.remove(ni);
3717 } 3716 }
3718 3717
3719 void Document::moveNodeIteratorsToNewDocument(Node& node, Document& newDocument) 3718 void Document::moveNodeIteratorsToNewDocument(Node& node, Document& newDocument)
3720 { 3719 {
3721 WillBeHeapHashSet<RawPtrWillBeWeakMember<NodeIterator> > nodeIteratorsList = m_nodeIterators; 3720 WillBeHeapHashSet<RawPtrWillBeWeakMember<NodeIterator>> nodeIteratorsList = m_nodeIterators;
3722 WillBeHeapHashSet<RawPtrWillBeWeakMember<NodeIterator> >::const_iterator nod eIteratorsEnd = nodeIteratorsList.end(); 3721 for (NodeIterator* ni : nodeIteratorsList) {
3723 for (WillBeHeapHashSet<RawPtrWillBeWeakMember<NodeIterator> >::const_iterato r it = nodeIteratorsList.begin(); it != nodeIteratorsEnd; ++it) { 3722 if (ni->root() == node) {
3724 if ((*it)->root() == node) { 3723 detachNodeIterator(ni);
3725 detachNodeIterator(*it); 3724 newDocument.attachNodeIterator(ni);
3726 newDocument.attachNodeIterator(*it);
3727 } 3725 }
3728 } 3726 }
3729 } 3727 }
3730 3728
3731 void Document::updateRangesAfterChildrenChanged(ContainerNode* container) 3729 void Document::updateRangesAfterChildrenChanged(ContainerNode* container)
3732 { 3730 {
3733 if (!m_ranges.isEmpty()) { 3731 if (m_ranges.isEmpty())
3734 AttachedRangeSet::const_iterator end = m_ranges.end(); 3732 return;
3735 for (AttachedRangeSet::const_iterator it = m_ranges.begin(); it != end; ++it) 3733
3736 (*it)->nodeChildrenChanged(container); 3734 for (Range* range : m_ranges)
3737 } 3735 range->nodeChildrenChanged(container);
3738 } 3736 }
3739 3737
3740 void Document::updateRangesAfterNodeMovedToAnotherDocument(const Node& node) 3738 void Document::updateRangesAfterNodeMovedToAnotherDocument(const Node& node)
3741 { 3739 {
3742 ASSERT(node.document() != this); 3740 ASSERT(node.document() != this);
3743 if (m_ranges.isEmpty()) 3741 if (m_ranges.isEmpty())
3744 return; 3742 return;
3743
3745 AttachedRangeSet ranges = m_ranges; 3744 AttachedRangeSet ranges = m_ranges;
3746 AttachedRangeSet::const_iterator end = ranges.end(); 3745 for (Range* range : ranges)
3747 for (AttachedRangeSet::const_iterator it = ranges.begin(); it != end; ++it) 3746 range->updateOwnerDocumentIfNeeded();
3748 (*it)->updateOwnerDocumentIfNeeded();
3749 } 3747 }
3750 3748
3751 void Document::nodeChildrenWillBeRemoved(ContainerNode& container) 3749 void Document::nodeChildrenWillBeRemoved(ContainerNode& container)
3752 { 3750 {
3753 EventDispatchForbiddenScope assertNoEventDispatch; 3751 EventDispatchForbiddenScope assertNoEventDispatch;
3754 if (!m_ranges.isEmpty()) { 3752 if (!m_ranges.isEmpty()) {
3755 AttachedRangeSet::const_iterator end = m_ranges.end(); 3753 for (Range* range : m_ranges)
3756 for (AttachedRangeSet::const_iterator it = m_ranges.begin(); it != end; ++it) 3754 range->nodeChildrenWillBeRemoved(container);
3757 (*it)->nodeChildrenWillBeRemoved(container);
3758 } 3755 }
3759 3756
3760 WillBeHeapHashSet<RawPtrWillBeWeakMember<NodeIterator> >::const_iterator nod eIteratorsEnd = m_nodeIterators.end(); 3757 for (NodeIterator* ni : m_nodeIterators) {
3761 for (WillBeHeapHashSet<RawPtrWillBeWeakMember<NodeIterator> >::const_iterato r it = m_nodeIterators.begin(); it != nodeIteratorsEnd; ++it) {
3762 for (Node& n : NodeTraversal::childrenOf(container)) 3758 for (Node& n : NodeTraversal::childrenOf(container))
3763 (*it)->nodeWillBeRemoved(n); 3759 ni->nodeWillBeRemoved(n);
3764 } 3760 }
3765 3761
3766 if (LocalFrame* frame = this->frame()) { 3762 if (LocalFrame* frame = this->frame()) {
3767 for (Node& n : NodeTraversal::childrenOf(container)) { 3763 for (Node& n : NodeTraversal::childrenOf(container)) {
3768 frame->eventHandler().nodeWillBeRemoved(n); 3764 frame->eventHandler().nodeWillBeRemoved(n);
3769 frame->selection().nodeWillBeRemoved(n); 3765 frame->selection().nodeWillBeRemoved(n);
3770 frame->page()->dragCaretController().nodeWillBeRemoved(n); 3766 frame->page()->dragCaretController().nodeWillBeRemoved(n);
3771 } 3767 }
3772 } 3768 }
3773 } 3769 }
3774 3770
3775 void Document::nodeWillBeRemoved(Node& n) 3771 void Document::nodeWillBeRemoved(Node& n)
3776 { 3772 {
3777 WillBeHeapHashSet<RawPtrWillBeWeakMember<NodeIterator> >::const_iterator nod eIteratorsEnd = m_nodeIterators.end(); 3773 for (NodeIterator* ni : m_nodeIterators)
3778 for (WillBeHeapHashSet<RawPtrWillBeWeakMember<NodeIterator> >::const_iterato r it = m_nodeIterators.begin(); it != nodeIteratorsEnd; ++it) 3774 ni->nodeWillBeRemoved(n);
3779 (*it)->nodeWillBeRemoved(n);
3780 3775
3781 if (!m_ranges.isEmpty()) { 3776 if (!m_ranges.isEmpty()) {
Mike West 2014/10/21 18:51:10 Nit: Doesn't the new syntax make this irrelevant?
3782 AttachedRangeSet::const_iterator rangesEnd = m_ranges.end(); 3777 for (Range* range : m_ranges)
3783 for (AttachedRangeSet::const_iterator it = m_ranges.begin(); it != range sEnd; ++it) 3778 range->nodeWillBeRemoved(n);
3784 (*it)->nodeWillBeRemoved(n);
3785 } 3779 }
3786 3780
3787 if (LocalFrame* frame = this->frame()) { 3781 if (LocalFrame* frame = this->frame()) {
3788 frame->eventHandler().nodeWillBeRemoved(n); 3782 frame->eventHandler().nodeWillBeRemoved(n);
3789 frame->selection().nodeWillBeRemoved(n); 3783 frame->selection().nodeWillBeRemoved(n);
3790 frame->page()->dragCaretController().nodeWillBeRemoved(n); 3784 frame->page()->dragCaretController().nodeWillBeRemoved(n);
3791 } 3785 }
3792 } 3786 }
3793 3787
3794 void Document::didInsertText(Node* text, unsigned offset, unsigned length) 3788 void Document::didInsertText(Node* text, unsigned offset, unsigned length)
3795 { 3789 {
3796 if (!m_ranges.isEmpty()) { 3790 if (!m_ranges.isEmpty()) {
3797 AttachedRangeSet::const_iterator end = m_ranges.end(); 3791 for (Range* range : m_ranges)
3798 for (AttachedRangeSet::const_iterator it = m_ranges.begin(); it != end; ++it) 3792 range->didInsertText(text, offset, length);
3799 (*it)->didInsertText(text, offset, length);
3800 } 3793 }
3801 3794
3802 // Update the markers for spelling and grammar checking. 3795 // Update the markers for spelling and grammar checking.
3803 m_markers->shiftMarkers(text, offset, length); 3796 m_markers->shiftMarkers(text, offset, length);
3804 } 3797 }
3805 3798
3806 void Document::didRemoveText(Node* text, unsigned offset, unsigned length) 3799 void Document::didRemoveText(Node* text, unsigned offset, unsigned length)
3807 { 3800 {
3808 if (!m_ranges.isEmpty()) { 3801 if (!m_ranges.isEmpty()) {
3809 AttachedRangeSet::const_iterator end = m_ranges.end(); 3802 for (Range* range : m_ranges)
3810 for (AttachedRangeSet::const_iterator it = m_ranges.begin(); it != end; ++it) 3803 range->didRemoveText(text, offset, length);
3811 (*it)->didRemoveText(text, offset, length);
3812 } 3804 }
3813 3805
3814 // Update the markers for spelling and grammar checking. 3806 // Update the markers for spelling and grammar checking.
3815 m_markers->removeMarkers(text, offset, length); 3807 m_markers->removeMarkers(text, offset, length);
3816 m_markers->shiftMarkers(text, offset + length, 0 - length); 3808 m_markers->shiftMarkers(text, offset + length, 0 - length);
3817 } 3809 }
3818 3810
3819 void Document::didMergeTextNodes(Text& oldNode, unsigned offset) 3811 void Document::didMergeTextNodes(Text& oldNode, unsigned offset)
3820 { 3812 {
3821 if (!m_ranges.isEmpty()) { 3813 if (!m_ranges.isEmpty()) {
3822 NodeWithIndex oldNodeWithIndex(oldNode); 3814 NodeWithIndex oldNodeWithIndex(oldNode);
3823 AttachedRangeSet::const_iterator end = m_ranges.end(); 3815 for (Range* range : m_ranges)
3824 for (AttachedRangeSet::const_iterator it = m_ranges.begin(); it != end; ++it) 3816 range->didMergeTextNodes(oldNodeWithIndex, offset);
3825 (*it)->didMergeTextNodes(oldNodeWithIndex, offset);
3826 } 3817 }
3827 3818
3828 if (m_frame) 3819 if (m_frame)
3829 m_frame->selection().didMergeTextNodes(oldNode, offset); 3820 m_frame->selection().didMergeTextNodes(oldNode, offset);
3830 3821
3831 // FIXME: This should update markers for spelling and grammar checking. 3822 // FIXME: This should update markers for spelling and grammar checking.
3832 } 3823 }
3833 3824
3834 void Document::didSplitTextNode(Text& oldNode) 3825 void Document::didSplitTextNode(Text& oldNode)
3835 { 3826 {
3836 if (!m_ranges.isEmpty()) { 3827 if (!m_ranges.isEmpty()) {
3837 AttachedRangeSet::const_iterator end = m_ranges.end(); 3828 for (Range* range : m_ranges)
3838 for (AttachedRangeSet::const_iterator it = m_ranges.begin(); it != end; ++it) 3829 range->didSplitTextNode(oldNode);
3839 (*it)->didSplitTextNode(oldNode);
3840 } 3830 }
3841 3831
3842 if (m_frame) 3832 if (m_frame)
3843 m_frame->selection().didSplitTextNode(oldNode); 3833 m_frame->selection().didSplitTextNode(oldNode);
3844 3834
3845 // FIXME: This should update markers for spelling and grammar checking. 3835 // FIXME: This should update markers for spelling and grammar checking.
3846 } 3836 }
3847 3837
3848 void Document::setWindowAttributeEventListener(const AtomicString& eventType, Pa ssRefPtr<EventListener> listener) 3838 void Document::setWindowAttributeEventListener(const AtomicString& eventType, Pa ssRefPtr<EventListener> listener)
3849 { 3839 {
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
3886 ensureScriptedAnimationController().enqueuePerFrameEvent(scrollEvent.release ()); 3876 ensureScriptedAnimationController().enqueuePerFrameEvent(scrollEvent.release ());
3887 } 3877 }
3888 3878
3889 void Document::enqueueResizeEvent() 3879 void Document::enqueueResizeEvent()
3890 { 3880 {
3891 RefPtrWillBeRawPtr<Event> event = Event::create(EventTypeNames::resize); 3881 RefPtrWillBeRawPtr<Event> event = Event::create(EventTypeNames::resize);
3892 event->setTarget(domWindow()); 3882 event->setTarget(domWindow());
3893 ensureScriptedAnimationController().enqueuePerFrameEvent(event.release()); 3883 ensureScriptedAnimationController().enqueuePerFrameEvent(event.release());
3894 } 3884 }
3895 3885
3896 void Document::enqueueMediaQueryChangeListeners(WillBeHeapVector<RefPtrWillBeMem ber<MediaQueryListListener> >& listeners) 3886 void Document::enqueueMediaQueryChangeListeners(WillBeHeapVector<RefPtrWillBeMem ber<MediaQueryListListener>>& listeners)
3897 { 3887 {
3898 ensureScriptedAnimationController().enqueueMediaQueryChangeListeners(listene rs); 3888 ensureScriptedAnimationController().enqueueMediaQueryChangeListeners(listene rs);
3899 } 3889 }
3900 3890
3901 Document::EventFactorySet& Document::eventFactories() 3891 Document::EventFactorySet& Document::eventFactories()
3902 { 3892 {
3903 DEFINE_STATIC_LOCAL(EventFactorySet, s_eventFactory, ()); 3893 DEFINE_STATIC_LOCAL(EventFactorySet, s_eventFactory, ());
3904 return s_eventFactory; 3894 return s_eventFactory;
3905 } 3895 }
3906 3896
3907 void Document::registerEventFactory(PassOwnPtr<EventFactoryBase> eventFactory) 3897 void Document::registerEventFactory(PassOwnPtr<EventFactoryBase> eventFactory)
3908 { 3898 {
3909 ASSERT(!eventFactories().contains(eventFactory.get())); 3899 ASSERT(!eventFactories().contains(eventFactory.get()));
3910 eventFactories().add(eventFactory); 3900 eventFactories().add(eventFactory);
3911 } 3901 }
3912 3902
3913 PassRefPtrWillBeRawPtr<Event> Document::createEvent(const String& eventType, Exc eptionState& exceptionState) 3903 PassRefPtrWillBeRawPtr<Event> Document::createEvent(const String& eventType, Exc eptionState& exceptionState)
3914 { 3904 {
3915 RefPtrWillBeRawPtr<Event> event = nullptr; 3905 RefPtrWillBeRawPtr<Event> event = nullptr;
3916 for (EventFactorySet::const_iterator it = eventFactories().begin(); it != ev entFactories().end(); ++it) { 3906 for (const auto& factory : eventFactories()) {
3917 event = (*it)->create(eventType); 3907 event = factory->create(eventType);
3918 if (event) 3908 if (event)
3919 return event.release(); 3909 return event.release();
3920 } 3910 }
3921 exceptionState.throwDOMException(NotSupportedError, "The provided event type ('" + eventType + "') is invalid."); 3911 exceptionState.throwDOMException(NotSupportedError, "The provided event type ('" + eventType + "') is invalid.");
3922 return nullptr; 3912 return nullptr;
3923 } 3913 }
3924 3914
3925 void Document::addMutationEventListenerTypeIfEnabled(ListenerType listenerType) 3915 void Document::addMutationEventListenerTypeIfEnabled(ListenerType listenerType)
3926 { 3916 {
3927 if (ContextFeatures::mutationEventsEnabled(this)) 3917 if (ContextFeatures::mutationEventsEnabled(this))
(...skipping 1328 matching lines...) Expand 10 before | Expand all | Expand 10 after
5256 force = 0; 5246 force = 0;
5257 5247
5258 // FIXME: It's not clear from the documentation at 5248 // FIXME: It's not clear from the documentation at
5259 // http://developer.apple.com/library/safari/#documentation/UserExperience/R eference/DocumentAdditionsReference/DocumentAdditions/DocumentAdditions.html 5249 // http://developer.apple.com/library/safari/#documentation/UserExperience/R eference/DocumentAdditionsReference/DocumentAdditions/DocumentAdditions.html
5260 // when this method should throw and nor is it by inspection of iOS behavior . It would be nice to verify any cases where it throws under iOS 5250 // when this method should throw and nor is it by inspection of iOS behavior . It would be nice to verify any cases where it throws under iOS
5261 // and implement them here. See https://bugs.webkit.org/show_bug.cgi?id=4781 9 5251 // and implement them here. See https://bugs.webkit.org/show_bug.cgi?id=4781 9
5262 LocalFrame* frame = window ? window->frame() : this->frame(); 5252 LocalFrame* frame = window ? window->frame() : this->frame();
5263 return Touch::create(frame, target, identifier, FloatPoint(screenX, screenY) , FloatPoint(pageX, pageY), FloatSize(radiusX, radiusY), rotationAngle, force); 5253 return Touch::create(frame, target, identifier, FloatPoint(screenX, screenY) , FloatPoint(pageX, pageY), FloatSize(radiusX, radiusY), rotationAngle, force);
5264 } 5254 }
5265 5255
5266 PassRefPtrWillBeRawPtr<TouchList> Document::createTouchList(WillBeHeapVector<Ref PtrWillBeMember<Touch> >& touches) const 5256 PassRefPtrWillBeRawPtr<TouchList> Document::createTouchList(WillBeHeapVector<Ref PtrWillBeMember<Touch>>& touches) const
5267 { 5257 {
5268 return TouchList::adopt(touches); 5258 return TouchList::adopt(touches);
5269 } 5259 }
5270 5260
5271 DocumentLoader* Document::loader() const 5261 DocumentLoader* Document::loader() const
5272 { 5262 {
5273 if (!m_frame) 5263 if (!m_frame)
5274 return 0; 5264 return 0;
5275 5265
5276 DocumentLoader* loader = m_frame->loader().documentLoader(); 5266 DocumentLoader* loader = m_frame->loader().documentLoader();
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after
5545 if (!m_didAssociateFormControlsTimer.isActive()) 5535 if (!m_didAssociateFormControlsTimer.isActive())
5546 m_didAssociateFormControlsTimer.startOneShot(0, FROM_HERE); 5536 m_didAssociateFormControlsTimer.startOneShot(0, FROM_HERE);
5547 } 5537 }
5548 5538
5549 void Document::didAssociateFormControlsTimerFired(Timer<Document>* timer) 5539 void Document::didAssociateFormControlsTimerFired(Timer<Document>* timer)
5550 { 5540 {
5551 ASSERT_UNUSED(timer, timer == &m_didAssociateFormControlsTimer); 5541 ASSERT_UNUSED(timer, timer == &m_didAssociateFormControlsTimer);
5552 if (!frame() || !frame()->page()) 5542 if (!frame() || !frame()->page())
5553 return; 5543 return;
5554 5544
5555 WillBeHeapVector<RefPtrWillBeMember<Element> > associatedFormControls; 5545 WillBeHeapVector<RefPtrWillBeMember<Element>> associatedFormControls;
5556 copyToVector(m_associatedFormControls, associatedFormControls); 5546 copyToVector(m_associatedFormControls, associatedFormControls);
5557 5547
5558 frame()->page()->chrome().client().didAssociateFormControls(associatedFormCo ntrols); 5548 frame()->page()->chrome().client().didAssociateFormControls(associatedFormCo ntrols);
5559 m_associatedFormControls.clear(); 5549 m_associatedFormControls.clear();
5560 } 5550 }
5561 5551
5562 float Document::devicePixelRatio() const 5552 float Document::devicePixelRatio() const
5563 { 5553 {
5564 return m_frame ? m_frame->devicePixelRatio() : 1.0; 5554 return m_frame ? m_frame->devicePixelRatio() : 1.0;
5565 } 5555 }
5566 5556
5567 PassOwnPtr<LifecycleNotifier<Document> > Document::createLifecycleNotifier() 5557 PassOwnPtr<LifecycleNotifier<Document>> Document::createLifecycleNotifier()
5568 { 5558 {
5569 return DocumentLifecycleNotifier::create(this); 5559 return DocumentLifecycleNotifier::create(this);
5570 } 5560 }
5571 5561
5572 DocumentLifecycleNotifier& Document::lifecycleNotifier() 5562 DocumentLifecycleNotifier& Document::lifecycleNotifier()
5573 { 5563 {
5574 return static_cast<DocumentLifecycleNotifier&>(LifecycleContext<Document>::l ifecycleNotifier()); 5564 return static_cast<DocumentLifecycleNotifier&>(LifecycleContext<Document>::l ifecycleNotifier());
5575 } 5565 }
5576 5566
5577 void Document::removedStyleSheet(StyleSheet* sheet, StyleResolverUpdateMode upda teMode) 5567 void Document::removedStyleSheet(StyleSheet* sheet, StyleResolverUpdateMode upda teMode)
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
5684 Frame* focusedFrame = page->focusController().focusedFrame(); 5674 Frame* focusedFrame = page->focusController().focusedFrame();
5685 if (focusedFrame && focusedFrame->isLocalFrame()) { 5675 if (focusedFrame && focusedFrame->isLocalFrame()) {
5686 if (toLocalFrame(focusedFrame)->tree().isDescendantOf(frame())) 5676 if (toLocalFrame(focusedFrame)->tree().isDescendantOf(frame()))
5687 return true; 5677 return true;
5688 } 5678 }
5689 return false; 5679 return false;
5690 } 5680 }
5691 5681
5692 #if ENABLE(OILPAN) 5682 #if ENABLE(OILPAN)
5693 template<unsigned type> 5683 template<unsigned type>
5694 bool shouldInvalidateNodeListCachesForAttr(const HeapHashSet<WeakMember<const Li veNodeListBase> > nodeLists[], const QualifiedName& attrName) 5684 bool shouldInvalidateNodeListCachesForAttr(const HeapHashSet<WeakMember<const Li veNodeListBase>> nodeLists[], const QualifiedName& attrName)
5695 { 5685 {
5696 if (!nodeLists[type].isEmpty() && LiveNodeListBase::shouldInvalidateTypeOnAt tributeChange(static_cast<NodeListInvalidationType>(type), attrName)) 5686 if (!nodeLists[type].isEmpty() && LiveNodeListBase::shouldInvalidateTypeOnAt tributeChange(static_cast<NodeListInvalidationType>(type), attrName))
5697 return true; 5687 return true;
5698 return shouldInvalidateNodeListCachesForAttr<type + 1>(nodeLists, attrName); 5688 return shouldInvalidateNodeListCachesForAttr<type + 1>(nodeLists, attrName);
5699 } 5689 }
5700 5690
5701 template<> 5691 template<>
5702 bool shouldInvalidateNodeListCachesForAttr<numNodeListInvalidationTypes>(const H eapHashSet<WeakMember<const LiveNodeListBase> >[], const QualifiedName&) 5692 bool shouldInvalidateNodeListCachesForAttr<numNodeListInvalidationTypes>(const H eapHashSet<WeakMember<const LiveNodeListBase>>[], const QualifiedName&)
5703 { 5693 {
5704 return false; 5694 return false;
5705 } 5695 }
5706 #else 5696 #else
5707 template<unsigned type> 5697 template<unsigned type>
5708 bool shouldInvalidateNodeListCachesForAttr(const unsigned nodeListCounts[], cons t QualifiedName& attrName) 5698 bool shouldInvalidateNodeListCachesForAttr(const unsigned nodeListCounts[], cons t QualifiedName& attrName)
5709 { 5699 {
5710 if (nodeListCounts[type] && LiveNodeListBase::shouldInvalidateTypeOnAttribut eChange(static_cast<NodeListInvalidationType>(type), attrName)) 5700 if (nodeListCounts[type] && LiveNodeListBase::shouldInvalidateTypeOnAttribut eChange(static_cast<NodeListInvalidationType>(type), attrName))
5711 return true; 5701 return true;
5712 return shouldInvalidateNodeListCachesForAttr<type + 1>(nodeListCounts, attrN ame); 5702 return shouldInvalidateNodeListCachesForAttr<type + 1>(nodeListCounts, attrN ame);
(...skipping 23 matching lines...) Expand all
5736 if (m_nodeListCounts[type]) 5726 if (m_nodeListCounts[type])
5737 #endif 5727 #endif
5738 return true; 5728 return true;
5739 } 5729 }
5740 5730
5741 return false; 5731 return false;
5742 } 5732 }
5743 5733
5744 void Document::invalidateNodeListCaches(const QualifiedName* attrName) 5734 void Document::invalidateNodeListCaches(const QualifiedName* attrName)
5745 { 5735 {
5746 WillBeHeapHashSet<RawPtrWillBeWeakMember<const LiveNodeListBase> >::const_it erator end = m_listsInvalidatedAtDocument.end(); 5736 for (const LiveNodeListBase* list : m_listsInvalidatedAtDocument)
5747 for (WillBeHeapHashSet<RawPtrWillBeWeakMember<const LiveNodeListBase> >::con st_iterator it = m_listsInvalidatedAtDocument.begin(); it != end; ++it) 5737 list->invalidateCacheForAttribute(attrName);
5748 (*it)->invalidateCacheForAttribute(attrName);
5749 } 5738 }
5750 5739
5751 void Document::clearWeakMembers(Visitor* visitor) 5740 void Document::clearWeakMembers(Visitor* visitor)
5752 { 5741 {
5753 if (m_axObjectCache) 5742 if (m_axObjectCache)
5754 m_axObjectCache->clearWeakMembers(visitor); 5743 m_axObjectCache->clearWeakMembers(visitor);
5755 } 5744 }
5756 5745
5757 v8::Handle<v8::Object> Document::wrap(v8::Handle<v8::Object> creationContext, v8 ::Isolate* isolate) 5746 v8::Handle<v8::Object> Document::wrap(v8::Handle<v8::Object> creationContext, v8 ::Isolate* isolate)
5758 { 5747 {
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
5850 } 5839 }
5851 5840
5852 } // namespace blink 5841 } // namespace blink
5853 5842
5854 #ifndef NDEBUG 5843 #ifndef NDEBUG
5855 using namespace blink; 5844 using namespace blink;
5856 void showLiveDocumentInstances() 5845 void showLiveDocumentInstances()
5857 { 5846 {
5858 WeakDocumentSet& set = liveDocumentSet(); 5847 WeakDocumentSet& set = liveDocumentSet();
5859 fprintf(stderr, "There are %u documents currently alive:\n", set.size()); 5848 fprintf(stderr, "There are %u documents currently alive:\n", set.size());
5860 for (WeakDocumentSet::const_iterator it = set.begin(); it != set.end(); ++it ) { 5849 for (Document* document : set)
5861 fprintf(stderr, "- Document %p URL: %s\n", *it, (*it)->url().string().ut f8().data()); 5850 fprintf(stderr, "- Document %p URL: %s\n", document, document->url().str ing().utf8().data());
5862 }
5863 } 5851 }
5864 #endif 5852 #endif
OLDNEW
« no previous file with comments | « Source/core/dom/Document.h ('k') | Source/core/dom/DocumentLifecycleNotifier.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698