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

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: Fix indendation problems (added by meld?) Created 6 years, 4 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/Node.cpp » ('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 2191 matching lines...) Expand 10 before | Expand all | Expand 10 after
2202 m_hoverNode = nullptr; 2202 m_hoverNode = nullptr;
2203 m_focusedElement = nullptr; 2203 m_focusedElement = nullptr;
2204 m_activeHoverElement = nullptr; 2204 m_activeHoverElement = nullptr;
2205 m_autofocusElement = nullptr; 2205 m_autofocusElement = nullptr;
2206 2206
2207 m_renderView = 0; 2207 m_renderView = 0;
2208 ContainerNode::detach(context); 2208 ContainerNode::detach(context);
2209 2209
2210 m_styleEngine->didDetach(); 2210 m_styleEngine->didDetach();
2211 2211
2212 if (Document* parentDoc = parentDocument())
2213 parentDoc->didClearTouchEventHandlers(this);
2214 frameHost()->eventHandlerRegistry().documentDetached(*this); 2212 frameHost()->eventHandlerRegistry().documentDetached(*this);
2215 2213
2216 // This is required, as our LocalFrame might delete itself as soon as it det aches 2214 // This is required, as our LocalFrame might delete itself as soon as it det aches
2217 // us. However, this violates Node::detach() semantics, as it's never 2215 // us. However, this violates Node::detach() semantics, as it's never
2218 // possible to re-attach. Eventually Document::detach() should be renamed, 2216 // possible to re-attach. Eventually Document::detach() should be renamed,
2219 // or this setting of the frame to 0 could be made explicit in each of the 2217 // or this setting of the frame to 0 could be made explicit in each of the
2220 // callers of Document::detach(). 2218 // callers of Document::detach().
2221 m_frame = 0; 2219 m_frame = 0;
2222 2220
2223 if (m_mediaQueryMatcher) 2221 if (m_mediaQueryMatcher)
2224 m_mediaQueryMatcher->documentDetached(); 2222 m_mediaQueryMatcher->documentDetached();
2225 2223
2226 lifecycleNotifier().notifyDocumentWasDetached(); 2224 lifecycleNotifier().notifyDocumentWasDetached();
2227 m_lifecycle.advanceTo(DocumentLifecycle::Stopped); 2225 m_lifecycle.advanceTo(DocumentLifecycle::Stopped);
2228 #if ENABLE(OILPAN) 2226 #if ENABLE(OILPAN)
2229 // This mirrors the clearing of the document object's touch
2230 // handlers that happens when the LocalDOMWindow is destructed in a
2231 // non-Oilpan setting (LocalDOMWindow::removeAllEventListeners()),
2232 // except that it is now done during detach instead.
2233 didClearTouchEventHandlers(this);
2234
2235 // Done with the window, explicitly clear to hasten its 2227 // Done with the window, explicitly clear to hasten its
2236 // destruction. 2228 // destruction.
2237 clearDOMWindow(); 2229 clearDOMWindow();
2238 #endif 2230 #endif
2239 } 2231 }
2240 2232
2241 void Document::prepareForDestruction() 2233 void Document::prepareForDestruction()
2242 { 2234 {
2243 m_markers->prepareForDestruction(); 2235 m_markers->prepareForDestruction();
2244 disconnectDescendantFrames(); 2236 disconnectDescendantFrames();
(...skipping 2996 matching lines...) Expand 10 before | Expand all | Expand 10 after
5241 // and implement them here. See https://bugs.webkit.org/show_bug.cgi?id=4781 9 5233 // and implement them here. See https://bugs.webkit.org/show_bug.cgi?id=4781 9
5242 LocalFrame* frame = window ? window->frame() : this->frame(); 5234 LocalFrame* frame = window ? window->frame() : this->frame();
5243 return Touch::create(frame, target, identifier, FloatPoint(screenX, screenY) , FloatPoint(pageX, pageY), FloatSize(radiusX, radiusY), rotationAngle, force); 5235 return Touch::create(frame, target, identifier, FloatPoint(screenX, screenY) , FloatPoint(pageX, pageY), FloatSize(radiusX, radiusY), rotationAngle, force);
5244 } 5236 }
5245 5237
5246 PassRefPtrWillBeRawPtr<TouchList> Document::createTouchList(WillBeHeapVector<Ref PtrWillBeMember<Touch> >& touches) const 5238 PassRefPtrWillBeRawPtr<TouchList> Document::createTouchList(WillBeHeapVector<Ref PtrWillBeMember<Touch> >& touches) const
5247 { 5239 {
5248 return TouchList::create(touches); 5240 return TouchList::create(touches);
5249 } 5241 }
5250 5242
5251 void Document::didAddTouchEventHandler(Node* handler)
5252 {
5253 // The node should either be in this document, or be the Document node of a child
5254 // of this document.
5255 ASSERT(&handler->document() == this
5256 || (handler->isDocumentNode() && toDocument(handler)->parentDocument() = = this));
5257 if (!m_touchEventTargets.get())
5258 m_touchEventTargets = adoptPtr(new TouchEventTargetSet);
5259 bool isFirstHandler = m_touchEventTargets->isEmpty();
5260
5261 if (!m_touchEventTargets->add(handler).isNewEntry) {
5262 // Just incremented refcount, no real change.
5263 // If this is a child document node, then the count should never go abov e 1.
5264 ASSERT(!handler->isDocumentNode() || &handler->document() == this);
5265 return;
5266 }
5267
5268 if (isFirstHandler) {
5269 if (Document* parent = parentDocument()) {
5270 parent->didAddTouchEventHandler(this);
5271 } else {
5272 // This is the first touch handler on the whole page.
5273 if (FrameHost* frameHost = this->frameHost())
5274 frameHost->chrome().client().needTouchEvents(true);
5275 }
5276 }
5277
5278 // When we're all done with all frames, ensure touch hit rects are marked as dirty.
5279 if (!handler->isDocumentNode() || handler == this) {
5280 if (Page* page = this->page()) {
5281 if (ScrollingCoordinator* scrollingCoordinator = page->scrollingCoor dinator())
5282 scrollingCoordinator->touchEventTargetRectsDidChange();
5283 }
5284 }
5285 }
5286
5287 void Document::didRemoveTouchEventHandler(Node* handler, bool clearAll)
5288 {
5289 // Note that we can't assert that |handler| is in this document because it m ight be in
5290 // the process of moving out of it.
5291 ASSERT(clearAll || m_touchEventTargets->contains(handler));
5292 if (!m_touchEventTargets.get())
5293 return;
5294
5295 if (clearAll) {
5296 if (!m_touchEventTargets->contains(handler))
5297 return;
5298 m_touchEventTargets->removeAll(handler);
5299 } else {
5300 if (!m_touchEventTargets->remove(handler))
5301 // Just decremented refcount, no real update.
5302 return;
5303 }
5304
5305 if (m_touchEventTargets->isEmpty()) {
5306 if (Document* parent = parentDocument()) {
5307 // This was the last handler in this document, update the parent doc ument too.
5308 parent->didRemoveTouchEventHandler(this, clearAll);
5309 } else {
5310 // We just removed the last touch handler on the whole page.
5311 if (FrameHost* frameHost = this->frameHost())
5312 frameHost->chrome().client().needTouchEvents(false);
5313 }
5314 }
5315
5316 // When we're all done with all frames, ensure touch hit rects are marked as dirty.
5317 if (!handler->isDocumentNode() || handler == this) {
5318 if (Page* page = this->page()) {
5319 if (ScrollingCoordinator* scrollingCoordinator = page->scrollingCoor dinator())
5320 scrollingCoordinator->touchEventTargetRectsDidChange();
5321 }
5322 }
5323 }
5324
5325 DocumentLoader* Document::loader() const 5243 DocumentLoader* Document::loader() const
5326 { 5244 {
5327 if (!m_frame) 5245 if (!m_frame)
5328 return 0; 5246 return 0;
5329 5247
5330 DocumentLoader* loader = m_frame->loader().documentLoader(); 5248 DocumentLoader* loader = m_frame->loader().documentLoader();
5331 if (!loader) 5249 if (!loader)
5332 return 0; 5250 return 0;
5333 5251
5334 if (m_frame->document() != this) 5252 if (m_frame->document() != this)
(...skipping 464 matching lines...) Expand 10 before | Expand all | Expand 10 after
5799 { 5717 {
5800 WillBeHeapHashSet<RawPtrWillBeWeakMember<const LiveNodeListBase> >::const_it erator end = m_listsInvalidatedAtDocument.end(); 5718 WillBeHeapHashSet<RawPtrWillBeWeakMember<const LiveNodeListBase> >::const_it erator end = m_listsInvalidatedAtDocument.end();
5801 for (WillBeHeapHashSet<RawPtrWillBeWeakMember<const LiveNodeListBase> >::con st_iterator it = m_listsInvalidatedAtDocument.begin(); it != end; ++it) 5719 for (WillBeHeapHashSet<RawPtrWillBeWeakMember<const LiveNodeListBase> >::con st_iterator it = m_listsInvalidatedAtDocument.begin(); it != end; ++it)
5802 (*it)->invalidateCacheForAttribute(attrName); 5720 (*it)->invalidateCacheForAttribute(attrName);
5803 } 5721 }
5804 5722
5805 void Document::clearWeakMembers(Visitor* visitor) 5723 void Document::clearWeakMembers(Visitor* visitor)
5806 { 5724 {
5807 if (m_axObjectCache) 5725 if (m_axObjectCache)
5808 m_axObjectCache->clearWeakMembers(visitor); 5726 m_axObjectCache->clearWeakMembers(visitor);
5809
5810 // FIXME: Oilpan: Use a weak counted set instead.
5811 if (m_touchEventTargets) {
5812 Vector<Node*> deadNodes;
5813 for (TouchEventTargetSet::iterator it = m_touchEventTargets->begin(); it != m_touchEventTargets->end(); ++it) {
5814 if (!visitor->isAlive(it->key))
5815 deadNodes.append(it->key);
5816 }
5817 for (unsigned i = 0; i < deadNodes.size(); ++i)
5818 didClearTouchEventHandlers(deadNodes[i]);
5819 }
5820 } 5727 }
5821 5728
5822 void Document::trace(Visitor* visitor) 5729 void Document::trace(Visitor* visitor)
5823 { 5730 {
5824 #if ENABLE(OILPAN) 5731 #if ENABLE(OILPAN)
5825 visitor->trace(m_importsController); 5732 visitor->trace(m_importsController);
5826 visitor->trace(m_docType); 5733 visitor->trace(m_docType);
5827 visitor->trace(m_implementation); 5734 visitor->trace(m_implementation);
5828 visitor->trace(m_autofocusElement); 5735 visitor->trace(m_autofocusElement);
5829 visitor->trace(m_focusedElement); 5736 visitor->trace(m_focusedElement);
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
5883 using namespace blink; 5790 using namespace blink;
5884 void showLiveDocumentInstances() 5791 void showLiveDocumentInstances()
5885 { 5792 {
5886 WeakDocumentSet& set = liveDocumentSet(); 5793 WeakDocumentSet& set = liveDocumentSet();
5887 fprintf(stderr, "There are %u documents currently alive:\n", set.size()); 5794 fprintf(stderr, "There are %u documents currently alive:\n", set.size());
5888 for (WeakDocumentSet::const_iterator it = set.begin(); it != set.end(); ++it ) { 5795 for (WeakDocumentSet::const_iterator it = set.begin(); it != set.end(); ++it ) {
5889 fprintf(stderr, "- Document %p URL: %s\n", *it, (*it)->url().string().ut f8().data()); 5796 fprintf(stderr, "- Document %p URL: %s\n", *it, (*it)->url().string().ut f8().data());
5890 } 5797 }
5891 } 5798 }
5892 #endif 5799 #endif
OLDNEW
« no previous file with comments | « Source/core/dom/Document.h ('k') | Source/core/dom/Node.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698