This source file includes following definitions.
- m_wheelEventHandlerCount
- supplementName
- from
- wheelEventHandlerCountChanged
- didAddWheelEventHandler
- didRemoveWheelEventHandler
- didAddEventListener
- didRemoveEventListener
#include "config.h"
#include "core/dom/WheelController.h"
#include "core/dom/Document.h"
#include "core/events/WheelEvent.h"
#include "core/frame/LocalFrame.h"
#include "core/page/Page.h"
#include "core/page/scrolling/ScrollingCoordinator.h"
namespace WebCore {
WheelController::WheelController(Document& document)
: DOMWindowLifecycleObserver(document.domWindow())
, m_wheelEventHandlerCount(0)
{
}
WheelController::~WheelController()
{
}
const char* WheelController::supplementName()
{
return "WheelController";
}
WheelController* WheelController::from(Document& document)
{
WheelController* controller = static_cast<WheelController*>(DocumentSupplement::from(document, supplementName()));
if (!controller) {
controller = new WheelController(document);
DocumentSupplement::provideTo(document, supplementName(), adoptPtr(controller));
}
return controller;
}
static void wheelEventHandlerCountChanged(Document& document)
{
Page* page = document.page();
if (!page)
return;
ScrollingCoordinator* scrollingCoordinator = page->scrollingCoordinator();
if (!scrollingCoordinator)
return;
FrameView* frameView = document.view();
if (!frameView)
return;
scrollingCoordinator->frameViewWheelEventHandlerCountChanged(frameView);
}
void WheelController::didAddWheelEventHandler(Document& document)
{
++m_wheelEventHandlerCount;
Page* page = document.page();
LocalFrame* mainFrame = page ? page->mainFrame() : 0;
if (mainFrame)
mainFrame->notifyChromeClientWheelEventHandlerCountChanged();
wheelEventHandlerCountChanged(document);
}
void WheelController::didRemoveWheelEventHandler(Document& document)
{
ASSERT(m_wheelEventHandlerCount > 0);
--m_wheelEventHandlerCount;
Page* page = document.page();
LocalFrame* mainFrame = page ? page->mainFrame() : 0;
if (mainFrame)
mainFrame->notifyChromeClientWheelEventHandlerCountChanged();
wheelEventHandlerCountChanged(document);
}
void WheelController::didAddEventListener(DOMWindow* window, const AtomicString& eventType)
{
if (eventType != EventTypeNames::wheel && eventType != EventTypeNames::mousewheel)
return;
Document* document = window->document();
ASSERT(document);
didAddWheelEventHandler(*document);
}
void WheelController::didRemoveEventListener(DOMWindow* window, const AtomicString& eventType)
{
if (eventType != EventTypeNames::wheel && eventType != EventTypeNames::mousewheel)
return;
Document* document = window->document();
ASSERT(document);
didRemoveWheelEventHandler(*document);
}
}