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

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

Issue 225903009: Migrate touch events to EventHandlerRegistry (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Fixed HTMLInputElement adding handler at document destruction and removed dead oilpan code. Created 6 years, 5 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
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 2161 matching lines...) Expand 10 before | Expand all | Expand 10 after
2172 m_hoverNode = nullptr; 2172 m_hoverNode = nullptr;
2173 m_focusedElement = nullptr; 2173 m_focusedElement = nullptr;
2174 m_activeHoverElement = nullptr; 2174 m_activeHoverElement = nullptr;
2175 m_autofocusElement = nullptr; 2175 m_autofocusElement = nullptr;
2176 2176
2177 m_renderView = 0; 2177 m_renderView = 0;
2178 ContainerNode::detach(context); 2178 ContainerNode::detach(context);
2179 2179
2180 m_styleEngine->didDetach(); 2180 m_styleEngine->didDetach();
2181 2181
2182 if (Document* parentDoc = parentDocument())
2183 parentDoc->didClearTouchEventHandlers(this);
2184
2185 // This is required, as our LocalFrame might delete itself as soon as it det aches 2182 // This is required, as our LocalFrame might delete itself as soon as it det aches
2186 // us. However, this violates Node::detach() semantics, as it's never 2183 // us. However, this violates Node::detach() semantics, as it's never
2187 // possible to re-attach. Eventually Document::detach() should be renamed, 2184 // possible to re-attach. Eventually Document::detach() should be renamed,
2188 // or this setting of the frame to 0 could be made explicit in each of the 2185 // or this setting of the frame to 0 could be made explicit in each of the
2189 // callers of Document::detach(). 2186 // callers of Document::detach().
2190 m_frame = 0; 2187 m_frame = 0;
2191 2188
2192 if (m_mediaQueryMatcher) 2189 if (m_mediaQueryMatcher)
2193 m_mediaQueryMatcher->documentDetached(); 2190 m_mediaQueryMatcher->documentDetached();
2194 2191
2195 lifecycleNotifier().notifyDocumentWasDetached(); 2192 lifecycleNotifier().notifyDocumentWasDetached();
2196 m_lifecycle.advanceTo(DocumentLifecycle::Stopped); 2193 m_lifecycle.advanceTo(DocumentLifecycle::Stopped);
2197 #if ENABLE(OILPAN) 2194 #if ENABLE(OILPAN)
2198 // This mirrors the clearing of the document object's touch
2199 // handlers that happens when the LocalDOMWindow is destructed in a
2200 // non-Oilpan setting (LocalDOMWindow::removeAllEventListeners()),
2201 // except that it is now done during detach instead.
2202 didClearTouchEventHandlers(this);
2203
2204 // Done with the window, explicitly clear to hasten its 2195 // Done with the window, explicitly clear to hasten its
2205 // destruction. 2196 // destruction.
2206 clearDOMWindow(); 2197 clearDOMWindow();
2207 #endif 2198 #endif
2208 } 2199 }
2209 2200
2210 void Document::prepareForDestruction() 2201 void Document::prepareForDestruction()
2211 { 2202 {
2212 m_markers->prepareForDestruction(); 2203 m_markers->prepareForDestruction();
2213 disconnectDescendantFrames(); 2204 disconnectDescendantFrames();
(...skipping 3015 matching lines...) Expand 10 before | Expand all | Expand 10 after
5229 // and implement them here. See https://bugs.webkit.org/show_bug.cgi?id=4781 9 5220 // and implement them here. See https://bugs.webkit.org/show_bug.cgi?id=4781 9
5230 LocalFrame* frame = window ? window->frame() : this->frame(); 5221 LocalFrame* frame = window ? window->frame() : this->frame();
5231 return Touch::create(frame, target, identifier, FloatPoint(screenX, screenY) , FloatPoint(pageX, pageY), FloatSize(radiusX, radiusY), rotationAngle, force); 5222 return Touch::create(frame, target, identifier, FloatPoint(screenX, screenY) , FloatPoint(pageX, pageY), FloatSize(radiusX, radiusY), rotationAngle, force);
5232 } 5223 }
5233 5224
5234 PassRefPtrWillBeRawPtr<TouchList> Document::createTouchList(WillBeHeapVector<Ref PtrWillBeMember<Touch> >& touches) const 5225 PassRefPtrWillBeRawPtr<TouchList> Document::createTouchList(WillBeHeapVector<Ref PtrWillBeMember<Touch> >& touches) const
5235 { 5226 {
5236 return TouchList::create(touches); 5227 return TouchList::create(touches);
5237 } 5228 }
5238 5229
5239 void Document::didAddTouchEventHandler(Node* handler)
5240 {
5241 // The node should either be in this document, or be the Document node of a child
5242 // of this document.
5243 ASSERT(&handler->document() == this
5244 || (handler->isDocumentNode() && toDocument(handler)->parentDocument() = = this));
5245 if (!m_touchEventTargets.get())
5246 m_touchEventTargets = adoptPtr(new TouchEventTargetSet);
5247 bool isFirstHandler = m_touchEventTargets->isEmpty();
5248
5249 if (!m_touchEventTargets->add(handler).isNewEntry) {
5250 // Just incremented refcount, no real change.
5251 // If this is a child document node, then the count should never go abov e 1.
5252 ASSERT(!handler->isDocumentNode() || &handler->document() == this);
5253 return;
5254 }
5255
5256 if (isFirstHandler) {
5257 if (Document* parent = parentDocument()) {
5258 parent->didAddTouchEventHandler(this);
5259 } else {
5260 // This is the first touch handler on the whole page.
5261 if (FrameHost* frameHost = this->frameHost())
5262 frameHost->chrome().client().needTouchEvents(true);
5263 }
5264 }
5265
5266 // When we're all done with all frames, ensure touch hit rects are marked as dirty.
5267 if (!handler->isDocumentNode() || handler == this) {
5268 if (Page* page = this->page()) {
5269 if (ScrollingCoordinator* scrollingCoordinator = page->scrollingCoor dinator())
5270 scrollingCoordinator->touchEventTargetRectsDidChange();
5271 }
5272 }
5273 }
5274
5275 void Document::didRemoveTouchEventHandler(Node* handler, bool clearAll)
5276 {
5277 // Note that we can't assert that |handler| is in this document because it m ight be in
5278 // the process of moving out of it.
5279 ASSERT(clearAll || m_touchEventTargets->contains(handler));
5280 if (!m_touchEventTargets.get())
5281 return;
5282
5283 if (clearAll) {
5284 if (!m_touchEventTargets->contains(handler))
5285 return;
5286 m_touchEventTargets->removeAll(handler);
5287 } else {
5288 if (!m_touchEventTargets->remove(handler))
5289 // Just decremented refcount, no real update.
5290 return;
5291 }
5292
5293 if (m_touchEventTargets->isEmpty()) {
5294 if (Document* parent = parentDocument()) {
5295 // This was the last handler in this document, update the parent doc ument too.
5296 parent->didRemoveTouchEventHandler(this, clearAll);
5297 } else {
5298 // We just removed the last touch handler on the whole page.
5299 if (FrameHost* frameHost = this->frameHost())
5300 frameHost->chrome().client().needTouchEvents(false);
5301 }
5302 }
5303
5304 // When we're all done with all frames, ensure touch hit rects are marked as dirty.
5305 if (!handler->isDocumentNode() || handler == this) {
5306 if (Page* page = this->page()) {
5307 if (ScrollingCoordinator* scrollingCoordinator = page->scrollingCoor dinator())
5308 scrollingCoordinator->touchEventTargetRectsDidChange();
5309 }
5310 }
5311 }
5312
5313 DocumentLoader* Document::loader() const 5230 DocumentLoader* Document::loader() const
5314 { 5231 {
5315 if (!m_frame) 5232 if (!m_frame)
5316 return 0; 5233 return 0;
5317 5234
5318 DocumentLoader* loader = m_frame->loader().documentLoader(); 5235 DocumentLoader* loader = m_frame->loader().documentLoader();
5319 if (!loader) 5236 if (!loader)
5320 return 0; 5237 return 0;
5321 5238
5322 if (m_frame->document() != this) 5239 if (m_frame->document() != this)
(...skipping 424 matching lines...) Expand 10 before | Expand all | Expand 10 after
5747 { 5664 {
5748 WillBeHeapHashSet<RawPtrWillBeWeakMember<const LiveNodeListBase> >::const_it erator end = m_listsInvalidatedAtDocument.end(); 5665 WillBeHeapHashSet<RawPtrWillBeWeakMember<const LiveNodeListBase> >::const_it erator end = m_listsInvalidatedAtDocument.end();
5749 for (WillBeHeapHashSet<RawPtrWillBeWeakMember<const LiveNodeListBase> >::con st_iterator it = m_listsInvalidatedAtDocument.begin(); it != end; ++it) 5666 for (WillBeHeapHashSet<RawPtrWillBeWeakMember<const LiveNodeListBase> >::con st_iterator it = m_listsInvalidatedAtDocument.begin(); it != end; ++it)
5750 (*it)->invalidateCacheForAttribute(attrName); 5667 (*it)->invalidateCacheForAttribute(attrName);
5751 } 5668 }
5752 5669
5753 void Document::clearWeakMembers(Visitor* visitor) 5670 void Document::clearWeakMembers(Visitor* visitor)
5754 { 5671 {
5755 if (m_axObjectCache) 5672 if (m_axObjectCache)
5756 m_axObjectCache->clearWeakMembers(visitor); 5673 m_axObjectCache->clearWeakMembers(visitor);
5757
5758 // FIXME: Oilpan: Use a weak counted set instead.
5759 if (m_touchEventTargets) {
5760 Vector<Node*> deadNodes;
5761 for (TouchEventTargetSet::iterator it = m_touchEventTargets->begin(); it != m_touchEventTargets->end(); ++it) {
5762 if (!visitor->isAlive(it->key))
5763 deadNodes.append(it->key);
5764 }
5765 for (unsigned i = 0; i < deadNodes.size(); ++i)
5766 didClearTouchEventHandlers(deadNodes[i]);
5767 }
5768 } 5674 }
5769 5675
5770 void Document::trace(Visitor* visitor) 5676 void Document::trace(Visitor* visitor)
5771 { 5677 {
5772 visitor->trace(m_importsController); 5678 visitor->trace(m_importsController);
5773 visitor->trace(m_docType); 5679 visitor->trace(m_docType);
5774 visitor->trace(m_implementation); 5680 visitor->trace(m_implementation);
5775 visitor->trace(m_autofocusElement); 5681 visitor->trace(m_autofocusElement);
5776 visitor->trace(m_focusedElement); 5682 visitor->trace(m_focusedElement);
5777 visitor->trace(m_hoverNode); 5683 visitor->trace(m_hoverNode);
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
5816 visitor->trace(m_compositorPendingAnimations); 5722 visitor->trace(m_compositorPendingAnimations);
5817 visitor->trace(m_contextDocument); 5723 visitor->trace(m_contextDocument);
5818 visitor->registerWeakMembers<Document, &Document::clearWeakMembers>(this); 5724 visitor->registerWeakMembers<Document, &Document::clearWeakMembers>(this);
5819 DocumentSupplementable::trace(visitor); 5725 DocumentSupplementable::trace(visitor);
5820 TreeScope::trace(visitor); 5726 TreeScope::trace(visitor);
5821 ContainerNode::trace(visitor); 5727 ContainerNode::trace(visitor);
5822 ExecutionContext::trace(visitor); 5728 ExecutionContext::trace(visitor);
5823 } 5729 }
5824 5730
5825 } // namespace WebCore 5731 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698