OLD | NEW |
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 2183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2194 m_hoverNode = nullptr; | 2194 m_hoverNode = nullptr; |
2195 m_focusedElement = nullptr; | 2195 m_focusedElement = nullptr; |
2196 m_activeHoverElement = nullptr; | 2196 m_activeHoverElement = nullptr; |
2197 m_autofocusElement = nullptr; | 2197 m_autofocusElement = nullptr; |
2198 | 2198 |
2199 m_renderView = 0; | 2199 m_renderView = 0; |
2200 ContainerNode::detach(context); | 2200 ContainerNode::detach(context); |
2201 | 2201 |
2202 m_styleEngine->didDetach(); | 2202 m_styleEngine->didDetach(); |
2203 | 2203 |
| 2204 if (Document* parentDoc = parentDocument()) |
| 2205 parentDoc->didClearTouchEventHandlers(this); |
| 2206 |
2204 // This is required, as our LocalFrame might delete itself as soon as it det
aches | 2207 // This is required, as our LocalFrame might delete itself as soon as it det
aches |
2205 // us. However, this violates Node::detach() semantics, as it's never | 2208 // us. However, this violates Node::detach() semantics, as it's never |
2206 // possible to re-attach. Eventually Document::detach() should be renamed, | 2209 // possible to re-attach. Eventually Document::detach() should be renamed, |
2207 // or this setting of the frame to 0 could be made explicit in each of the | 2210 // or this setting of the frame to 0 could be made explicit in each of the |
2208 // callers of Document::detach(). | 2211 // callers of Document::detach(). |
2209 m_frame = 0; | 2212 m_frame = 0; |
2210 | 2213 |
2211 if (m_mediaQueryMatcher) | 2214 if (m_mediaQueryMatcher) |
2212 m_mediaQueryMatcher->documentDetached(); | 2215 m_mediaQueryMatcher->documentDetached(); |
2213 | 2216 |
2214 lifecycleNotifier().notifyDocumentWasDetached(); | 2217 lifecycleNotifier().notifyDocumentWasDetached(); |
2215 m_lifecycle.advanceTo(DocumentLifecycle::Stopped); | 2218 m_lifecycle.advanceTo(DocumentLifecycle::Stopped); |
2216 #if ENABLE(OILPAN) | 2219 #if ENABLE(OILPAN) |
| 2220 // This mirrors the clearing of the document object's touch |
| 2221 // handlers that happens when the LocalDOMWindow is destructed in a |
| 2222 // non-Oilpan setting (LocalDOMWindow::removeAllEventListeners()), |
| 2223 // except that it is now done during detach instead. |
| 2224 didClearTouchEventHandlers(this); |
| 2225 |
2217 // Done with the window, explicitly clear to hasten its | 2226 // Done with the window, explicitly clear to hasten its |
2218 // destruction. | 2227 // destruction. |
2219 clearDOMWindow(); | 2228 clearDOMWindow(); |
2220 #endif | 2229 #endif |
2221 } | 2230 } |
2222 | 2231 |
2223 void Document::prepareForDestruction() | 2232 void Document::prepareForDestruction() |
2224 { | 2233 { |
2225 m_markers->prepareForDestruction(); | 2234 m_markers->prepareForDestruction(); |
2226 disconnectDescendantFrames(); | 2235 disconnectDescendantFrames(); |
(...skipping 3020 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5247 // and implement them here. See https://bugs.webkit.org/show_bug.cgi?id=4781
9 | 5256 // and implement them here. See https://bugs.webkit.org/show_bug.cgi?id=4781
9 |
5248 LocalFrame* frame = window ? window->frame() : this->frame(); | 5257 LocalFrame* frame = window ? window->frame() : this->frame(); |
5249 return Touch::create(frame, target, identifier, FloatPoint(screenX, screenY)
, FloatPoint(pageX, pageY), FloatSize(radiusX, radiusY), rotationAngle, force); | 5258 return Touch::create(frame, target, identifier, FloatPoint(screenX, screenY)
, FloatPoint(pageX, pageY), FloatSize(radiusX, radiusY), rotationAngle, force); |
5250 } | 5259 } |
5251 | 5260 |
5252 PassRefPtrWillBeRawPtr<TouchList> Document::createTouchList(WillBeHeapVector<Ref
PtrWillBeMember<Touch> >& touches) const | 5261 PassRefPtrWillBeRawPtr<TouchList> Document::createTouchList(WillBeHeapVector<Ref
PtrWillBeMember<Touch> >& touches) const |
5253 { | 5262 { |
5254 return TouchList::create(touches); | 5263 return TouchList::create(touches); |
5255 } | 5264 } |
5256 | 5265 |
| 5266 void Document::didAddTouchEventHandler(Node* handler) |
| 5267 { |
| 5268 // The node should either be in this document, or be the Document node of a
child |
| 5269 // of this document. |
| 5270 ASSERT(&handler->document() == this |
| 5271 || (handler->isDocumentNode() && toDocument(handler)->parentDocument() =
= this)); |
| 5272 if (!m_touchEventTargets.get()) |
| 5273 m_touchEventTargets = adoptPtr(new TouchEventTargetSet); |
| 5274 bool isFirstHandler = m_touchEventTargets->isEmpty(); |
| 5275 |
| 5276 if (!m_touchEventTargets->add(handler).isNewEntry) { |
| 5277 // Just incremented refcount, no real change. |
| 5278 // If this is a child document node, then the count should never go abov
e 1. |
| 5279 ASSERT(!handler->isDocumentNode() || &handler->document() == this); |
| 5280 return; |
| 5281 } |
| 5282 |
| 5283 if (isFirstHandler) { |
| 5284 if (Document* parent = parentDocument()) { |
| 5285 parent->didAddTouchEventHandler(this); |
| 5286 } else { |
| 5287 // This is the first touch handler on the whole page. |
| 5288 if (FrameHost* frameHost = this->frameHost()) |
| 5289 frameHost->chrome().client().needTouchEvents(true); |
| 5290 } |
| 5291 } |
| 5292 |
| 5293 // When we're all done with all frames, ensure touch hit rects are marked as
dirty. |
| 5294 if (!handler->isDocumentNode() || handler == this) { |
| 5295 if (Page* page = this->page()) { |
| 5296 if (ScrollingCoordinator* scrollingCoordinator = page->scrollingCoor
dinator()) |
| 5297 scrollingCoordinator->touchEventTargetRectsDidChange(); |
| 5298 } |
| 5299 } |
| 5300 } |
| 5301 |
| 5302 void Document::didRemoveTouchEventHandler(Node* handler, bool clearAll) |
| 5303 { |
| 5304 // Note that we can't assert that |handler| is in this document because it m
ight be in |
| 5305 // the process of moving out of it. |
| 5306 ASSERT(clearAll || m_touchEventTargets->contains(handler)); |
| 5307 if (!m_touchEventTargets.get()) |
| 5308 return; |
| 5309 |
| 5310 if (clearAll) { |
| 5311 if (!m_touchEventTargets->contains(handler)) |
| 5312 return; |
| 5313 m_touchEventTargets->removeAll(handler); |
| 5314 } else { |
| 5315 if (!m_touchEventTargets->remove(handler)) |
| 5316 // Just decremented refcount, no real update. |
| 5317 return; |
| 5318 } |
| 5319 |
| 5320 if (m_touchEventTargets->isEmpty()) { |
| 5321 if (Document* parent = parentDocument()) { |
| 5322 // This was the last handler in this document, update the parent doc
ument too. |
| 5323 parent->didRemoveTouchEventHandler(this, clearAll); |
| 5324 } else { |
| 5325 // We just removed the last touch handler on the whole page. |
| 5326 if (FrameHost* frameHost = this->frameHost()) |
| 5327 frameHost->chrome().client().needTouchEvents(false); |
| 5328 } |
| 5329 } |
| 5330 |
| 5331 // When we're all done with all frames, ensure touch hit rects are marked as
dirty. |
| 5332 if (!handler->isDocumentNode() || handler == this) { |
| 5333 if (Page* page = this->page()) { |
| 5334 if (ScrollingCoordinator* scrollingCoordinator = page->scrollingCoor
dinator()) |
| 5335 scrollingCoordinator->touchEventTargetRectsDidChange(); |
| 5336 } |
| 5337 } |
| 5338 } |
| 5339 |
5257 DocumentLoader* Document::loader() const | 5340 DocumentLoader* Document::loader() const |
5258 { | 5341 { |
5259 if (!m_frame) | 5342 if (!m_frame) |
5260 return 0; | 5343 return 0; |
5261 | 5344 |
5262 DocumentLoader* loader = m_frame->loader().documentLoader(); | 5345 DocumentLoader* loader = m_frame->loader().documentLoader(); |
5263 if (!loader) | 5346 if (!loader) |
5264 return 0; | 5347 return 0; |
5265 | 5348 |
5266 if (m_frame->document() != this) | 5349 if (m_frame->document() != this) |
(...skipping 419 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5686 { | 5769 { |
5687 WillBeHeapHashSet<RawPtrWillBeWeakMember<const LiveNodeListBase> >::const_it
erator end = m_listsInvalidatedAtDocument.end(); | 5770 WillBeHeapHashSet<RawPtrWillBeWeakMember<const LiveNodeListBase> >::const_it
erator end = m_listsInvalidatedAtDocument.end(); |
5688 for (WillBeHeapHashSet<RawPtrWillBeWeakMember<const LiveNodeListBase> >::con
st_iterator it = m_listsInvalidatedAtDocument.begin(); it != end; ++it) | 5771 for (WillBeHeapHashSet<RawPtrWillBeWeakMember<const LiveNodeListBase> >::con
st_iterator it = m_listsInvalidatedAtDocument.begin(); it != end; ++it) |
5689 (*it)->invalidateCacheForAttribute(attrName); | 5772 (*it)->invalidateCacheForAttribute(attrName); |
5690 } | 5773 } |
5691 | 5774 |
5692 void Document::clearWeakMembers(Visitor* visitor) | 5775 void Document::clearWeakMembers(Visitor* visitor) |
5693 { | 5776 { |
5694 if (m_axObjectCache) | 5777 if (m_axObjectCache) |
5695 m_axObjectCache->clearWeakMembers(visitor); | 5778 m_axObjectCache->clearWeakMembers(visitor); |
| 5779 |
| 5780 // FIXME: Oilpan: Use a weak counted set instead. |
| 5781 if (m_touchEventTargets) { |
| 5782 Vector<Node*> deadNodes; |
| 5783 for (TouchEventTargetSet::iterator it = m_touchEventTargets->begin(); it
!= m_touchEventTargets->end(); ++it) { |
| 5784 if (!visitor->isAlive(it->key)) |
| 5785 deadNodes.append(it->key); |
| 5786 } |
| 5787 for (unsigned i = 0; i < deadNodes.size(); ++i) |
| 5788 didClearTouchEventHandlers(deadNodes[i]); |
| 5789 } |
5696 } | 5790 } |
5697 | 5791 |
5698 void Document::trace(Visitor* visitor) | 5792 void Document::trace(Visitor* visitor) |
5699 { | 5793 { |
5700 visitor->trace(m_importsController); | 5794 visitor->trace(m_importsController); |
5701 visitor->trace(m_docType); | 5795 visitor->trace(m_docType); |
5702 visitor->trace(m_implementation); | 5796 visitor->trace(m_implementation); |
5703 visitor->trace(m_autofocusElement); | 5797 visitor->trace(m_autofocusElement); |
5704 visitor->trace(m_focusedElement); | 5798 visitor->trace(m_focusedElement); |
5705 visitor->trace(m_hoverNode); | 5799 visitor->trace(m_hoverNode); |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5757 using namespace WebCore; | 5851 using namespace WebCore; |
5758 void showLiveDocumentInstances() | 5852 void showLiveDocumentInstances() |
5759 { | 5853 { |
5760 WeakDocumentSet& set = liveDocumentSet(); | 5854 WeakDocumentSet& set = liveDocumentSet(); |
5761 fprintf(stderr, "There are %u documents currently alive:\n", set.size()); | 5855 fprintf(stderr, "There are %u documents currently alive:\n", set.size()); |
5762 for (WeakDocumentSet::const_iterator it = set.begin(); it != set.end(); ++it
) { | 5856 for (WeakDocumentSet::const_iterator it = set.begin(); it != set.end(); ++it
) { |
5763 fprintf(stderr, "- Document %p URL: %s\n", *it, (*it)->url().string().ut
f8().data()); | 5857 fprintf(stderr, "- Document %p URL: %s\n", *it, (*it)->url().string().ut
f8().data()); |
5764 } | 5858 } |
5765 } | 5859 } |
5766 #endif | 5860 #endif |
OLD | NEW |