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

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: Rebased. 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
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 2218 matching lines...) Expand 10 before | Expand all | Expand 10 after
2229 m_hoverNode = nullptr; 2229 m_hoverNode = nullptr;
2230 m_focusedElement = nullptr; 2230 m_focusedElement = nullptr;
2231 m_activeHoverElement = nullptr; 2231 m_activeHoverElement = nullptr;
2232 m_autofocusElement = nullptr; 2232 m_autofocusElement = nullptr;
2233 2233
2234 m_renderView = 0; 2234 m_renderView = 0;
2235 ContainerNode::detach(context); 2235 ContainerNode::detach(context);
2236 2236
2237 m_styleEngine->didDetach(); 2237 m_styleEngine->didDetach();
2238 2238
2239 if (Document* parentDoc = parentDocument())
2240 parentDoc->didClearTouchEventHandlers(this);
2241
2242 // This is required, as our LocalFrame might delete itself as soon as it det aches 2239 // This is required, as our LocalFrame might delete itself as soon as it det aches
2243 // us. However, this violates Node::detach() semantics, as it's never 2240 // us. However, this violates Node::detach() semantics, as it's never
2244 // possible to re-attach. Eventually Document::detach() should be renamed, 2241 // possible to re-attach. Eventually Document::detach() should be renamed,
2245 // or this setting of the frame to 0 could be made explicit in each of the 2242 // or this setting of the frame to 0 could be made explicit in each of the
2246 // callers of Document::detach(). 2243 // callers of Document::detach().
2247 m_frame = 0; 2244 m_frame = 0;
2248 2245
2249 if (m_mediaQueryMatcher) 2246 if (m_mediaQueryMatcher)
2250 m_mediaQueryMatcher->documentDestroyed(); 2247 m_mediaQueryMatcher->documentDestroyed();
2251 2248
(...skipping 3017 matching lines...) Expand 10 before | Expand all | Expand 10 after
5269 // and implement them here. See https://bugs.webkit.org/show_bug.cgi?id=4781 9 5266 // and implement them here. See https://bugs.webkit.org/show_bug.cgi?id=4781 9
5270 LocalFrame* frame = window ? window->frame() : this->frame(); 5267 LocalFrame* frame = window ? window->frame() : this->frame();
5271 return Touch::create(frame, target, identifier, FloatPoint(screenX, screenY) , FloatPoint(pageX, pageY), FloatSize(radiusX, radiusY), rotationAngle, force); 5268 return Touch::create(frame, target, identifier, FloatPoint(screenX, screenY) , FloatPoint(pageX, pageY), FloatSize(radiusX, radiusY), rotationAngle, force);
5272 } 5269 }
5273 5270
5274 PassRefPtrWillBeRawPtr<TouchList> Document::createTouchList(WillBeHeapVector<Ref PtrWillBeMember<Touch> >& touches) const 5271 PassRefPtrWillBeRawPtr<TouchList> Document::createTouchList(WillBeHeapVector<Ref PtrWillBeMember<Touch> >& touches) const
5275 { 5272 {
5276 return TouchList::create(touches); 5273 return TouchList::create(touches);
5277 } 5274 }
5278 5275
5279 void Document::didAddTouchEventHandler(Node* handler)
5280 {
5281 // The node should either be in this document, or be the Document node of a child
5282 // of this document.
5283 ASSERT(&handler->document() == this
5284 || (handler->isDocumentNode() && toDocument(handler)->parentDocument() = = this));
5285 if (!m_touchEventTargets.get())
5286 m_touchEventTargets = adoptPtr(new TouchEventTargetSet);
5287 bool isFirstHandler = m_touchEventTargets->isEmpty();
5288
5289 if (!m_touchEventTargets->add(handler).isNewEntry) {
5290 // Just incremented refcount, no real change.
5291 // If this is a child document node, then the count should never go abov e 1.
5292 ASSERT(!handler->isDocumentNode() || &handler->document() == this);
5293 return;
5294 }
5295
5296 if (isFirstHandler) {
5297 if (Document* parent = parentDocument()) {
5298 parent->didAddTouchEventHandler(this);
5299 } else {
5300 // This is the first touch handler on the whole page.
5301 if (FrameHost* frameHost = this->frameHost())
5302 frameHost->chrome().client().needTouchEvents(true);
5303 }
5304 }
5305
5306 // When we're all done with all frames, ensure touch hit rects are marked as dirty.
5307 if (!handler->isDocumentNode() || handler == this) {
5308 if (Page* page = this->page()) {
5309 if (ScrollingCoordinator* scrollingCoordinator = page->scrollingCoor dinator())
5310 scrollingCoordinator->touchEventTargetRectsDidChange();
5311 }
5312 }
5313 }
5314
5315 void Document::didRemoveTouchEventHandler(Node* handler, bool clearAll)
5316 {
5317 // Note that we can't assert that |handler| is in this document because it m ight be in
5318 // the process of moving out of it.
5319 ASSERT(clearAll || m_touchEventTargets->contains(handler));
5320 if (!m_touchEventTargets.get())
5321 return;
5322
5323 if (clearAll) {
5324 if (!m_touchEventTargets->contains(handler))
5325 return;
5326 m_touchEventTargets->removeAll(handler);
5327 } else {
5328 if (!m_touchEventTargets->remove(handler))
5329 // Just decremented refcount, no real update.
5330 return;
5331 }
5332
5333 if (m_touchEventTargets->isEmpty()) {
5334 if (Document* parent = parentDocument()) {
5335 // This was the last handler in this document, update the parent doc ument too.
5336 parent->didRemoveTouchEventHandler(this, clearAll);
5337 } else {
5338 // We just removed the last touch handler on the whole page.
5339 if (FrameHost* frameHost = this->frameHost())
5340 frameHost->chrome().client().needTouchEvents(false);
5341 }
5342 }
5343
5344 // When we're all done with all frames, ensure touch hit rects are marked as dirty.
5345 if (!handler->isDocumentNode() || handler == this) {
5346 if (Page* page = this->page()) {
5347 if (ScrollingCoordinator* scrollingCoordinator = page->scrollingCoor dinator())
5348 scrollingCoordinator->touchEventTargetRectsDidChange();
5349 }
5350 }
5351 }
5352
5353 DocumentLoader* Document::loader() const 5276 DocumentLoader* Document::loader() const
5354 { 5277 {
5355 if (!m_frame) 5278 if (!m_frame)
5356 return 0; 5279 return 0;
5357 5280
5358 DocumentLoader* loader = m_frame->loader().documentLoader(); 5281 DocumentLoader* loader = m_frame->loader().documentLoader();
5359 if (!loader) 5282 if (!loader)
5360 return 0; 5283 return 0;
5361 5284
5362 if (m_frame->document() != this) 5285 if (m_frame->document() != this)
(...skipping 424 matching lines...) Expand 10 before | Expand all | Expand 10 after
5787 { 5710 {
5788 WillBeHeapHashSet<RawPtrWillBeWeakMember<const LiveNodeListBase> >::const_it erator end = m_listsInvalidatedAtDocument.end(); 5711 WillBeHeapHashSet<RawPtrWillBeWeakMember<const LiveNodeListBase> >::const_it erator end = m_listsInvalidatedAtDocument.end();
5789 for (WillBeHeapHashSet<RawPtrWillBeWeakMember<const LiveNodeListBase> >::con st_iterator it = m_listsInvalidatedAtDocument.begin(); it != end; ++it) 5712 for (WillBeHeapHashSet<RawPtrWillBeWeakMember<const LiveNodeListBase> >::con st_iterator it = m_listsInvalidatedAtDocument.begin(); it != end; ++it)
5790 (*it)->invalidateCacheForAttribute(attrName); 5713 (*it)->invalidateCacheForAttribute(attrName);
5791 } 5714 }
5792 5715
5793 void Document::clearWeakMembers(Visitor* visitor) 5716 void Document::clearWeakMembers(Visitor* visitor)
5794 { 5717 {
5795 if (m_axObjectCache) 5718 if (m_axObjectCache)
5796 m_axObjectCache->clearWeakMembers(visitor); 5719 m_axObjectCache->clearWeakMembers(visitor);
5797
5798 // FIXME: Oilpan: Use a weak counted set instead.
5799 if (m_touchEventTargets) {
5800 Vector<Node*> deadNodes;
5801 for (TouchEventTargetSet::iterator it = m_touchEventTargets->begin(); it != m_touchEventTargets->end(); ++it) {
5802 if (!visitor->isAlive(it->key))
5803 deadNodes.append(it->key);
5804 }
5805 for (unsigned i = 0; i < deadNodes.size(); ++i)
5806 didClearTouchEventHandlers(deadNodes[i]);
5807 }
5808 } 5720 }
5809 5721
5810 void Document::trace(Visitor* visitor) 5722 void Document::trace(Visitor* visitor)
5811 { 5723 {
5812 visitor->trace(m_importsController); 5724 visitor->trace(m_importsController);
5813 visitor->trace(m_docType); 5725 visitor->trace(m_docType);
5814 visitor->trace(m_implementation); 5726 visitor->trace(m_implementation);
5815 visitor->trace(m_autofocusElement); 5727 visitor->trace(m_autofocusElement);
5816 visitor->trace(m_focusedElement); 5728 visitor->trace(m_focusedElement);
5817 visitor->trace(m_hoverNode); 5729 visitor->trace(m_hoverNode);
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
5855 visitor->trace(m_compositorPendingAnimations); 5767 visitor->trace(m_compositorPendingAnimations);
5856 visitor->trace(m_contextDocument); 5768 visitor->trace(m_contextDocument);
5857 visitor->registerWeakMembers<Document, &Document::clearWeakMembers>(this); 5769 visitor->registerWeakMembers<Document, &Document::clearWeakMembers>(this);
5858 DocumentSupplementable::trace(visitor); 5770 DocumentSupplementable::trace(visitor);
5859 TreeScope::trace(visitor); 5771 TreeScope::trace(visitor);
5860 ContainerNode::trace(visitor); 5772 ContainerNode::trace(visitor);
5861 ExecutionContext::trace(visitor); 5773 ExecutionContext::trace(visitor);
5862 } 5774 }
5863 5775
5864 } // namespace WebCore 5776 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698