| Index: Source/WebCore/dom/Document.cpp
|
| ===================================================================
|
| --- Source/WebCore/dom/Document.cpp (revision 138187)
|
| +++ Source/WebCore/dom/Document.cpp (working copy)
|
| @@ -498,9 +498,6 @@
|
| , m_writeRecursionIsTooDeep(false)
|
| , m_writeRecursionDepth(0)
|
| , m_wheelEventHandlerCount(0)
|
| -#if ENABLE(TOUCH_EVENTS)
|
| - , m_touchEventHandlerCount(0)
|
| -#endif
|
| , m_pendingTasksTimer(this, &Document::pendingTasksTimerFired)
|
| , m_scheduledTasksAreSuspended(false)
|
| , m_visualUpdatesAllowed(true)
|
| @@ -613,6 +610,10 @@
|
| ASSERT(!m_parentTreeScope);
|
| ASSERT(!m_guardRefCount);
|
|
|
| +#if ENABLE(TOUCH_EVENT_TRACKING)
|
| + if (Document* ownerDocument = this->ownerDocument())
|
| + ownerDocument->didRemoveEventTargetNode(this);
|
| +#endif
|
| // FIXME: Should we reset m_domWindow when we detach from the Frame?
|
| if (m_domWindow)
|
| m_domWindow->resetUnlessSuspendedForPageCache();
|
| @@ -5599,36 +5600,68 @@
|
| wheelEventHandlerCountChanged(this);
|
| }
|
|
|
| -void Document::didAddTouchEventHandler()
|
| +void Document::didAddTouchEventHandler(Node* handler)
|
| {
|
| #if ENABLE(TOUCH_EVENTS)
|
| - ++m_touchEventHandlerCount;
|
| - if (m_touchEventHandlerCount > 1)
|
| + if (!m_touchEventTargets.get())
|
| + m_touchEventTargets = adoptPtr(new TouchEventTargetSet);
|
| + m_touchEventTargets->add(handler);
|
| + if (Document* parent = parentDocument()) {
|
| + parent->didAddTouchEventHandler(this);
|
| return;
|
| - if (Page* page = this->page())
|
| - page->chrome()->client()->needTouchEvents(true);
|
| + }
|
| + if (Page* page = this->page()) {
|
| +#if ENABLE(TOUCH_EVENT_TRACKING)
|
| + if (ScrollingCoordinator* scrollingCoordinator = page->scrollingCoordinator())
|
| + scrollingCoordinator->touchEventTargetRectsDidChange(this);
|
| #endif
|
| + if (m_touchEventTargets->size() == 1)
|
| + page->chrome()->client()->needTouchEvents(true);
|
| + }
|
| +#else
|
| + UNUSED_PARAM(handler);
|
| +#endif
|
| }
|
|
|
| -void Document::didRemoveTouchEventHandler()
|
| +void Document::didRemoveTouchEventHandler(Node* handler)
|
| {
|
| #if ENABLE(TOUCH_EVENTS)
|
| - ASSERT(m_touchEventHandlerCount);
|
| - --m_touchEventHandlerCount;
|
| - if (m_touchEventHandlerCount)
|
| + if (!m_touchEventTargets.get())
|
| return;
|
| + ASSERT(m_touchEventTargets->contains(handler));
|
| + m_touchEventTargets->remove(handler);
|
| + if (Document* parent = parentDocument()) {
|
| + parent->didRemoveTouchEventHandler(this);
|
| + return;
|
| + }
|
|
|
| Page* page = this->page();
|
| if (!page)
|
| return;
|
| +#if ENABLE(TOUCH_EVENT_TRACKING)
|
| + if (ScrollingCoordinator* scrollingCoordinator = page->scrollingCoordinator())
|
| + scrollingCoordinator->touchEventTargetRectsDidChange(this);
|
| +#endif
|
| + if (m_touchEventTargets->size())
|
| + return;
|
| for (const Frame* frame = page->mainFrame(); frame; frame = frame->tree()->traverseNext()) {
|
| - if (frame->document() && frame->document()->touchEventHandlerCount())
|
| + if (frame->document() && frame->document()->hasTouchEventHandlers())
|
| return;
|
| }
|
| page->chrome()->client()->needTouchEvents(false);
|
| +#else
|
| + UNUSED_PARAM(handler);
|
| #endif
|
| }
|
|
|
| +#if ENABLE(TOUCH_EVENT_TRACKING)
|
| +void Document::didRemoveEventTargetNode(Node* handler)
|
| +{
|
| + if (m_touchEventTargets.get())
|
| + m_touchEventTargets->removeAll(handler);
|
| +}
|
| +#endif
|
| +
|
| HTMLIFrameElement* Document::seamlessParentIFrame() const
|
| {
|
| if (!shouldDisplaySeamlesslyWithParent())
|
|
|