This source file includes following definitions.
- mainFrameView
- animate
- layout
- paint
- handleInputEvent
- handleMouseMove
- handleMouseLeave
- handleMouseDown
- handleMouseUp
- handleMouseWheel
- handleTouchEvent
#include "config.h"
#include "PageWidgetDelegate.h"
#include "PageOverlayList.h"
#include "WebInputEvent.h"
#include "WebInputEventConversion.h"
#include "core/frame/FrameView.h"
#include "core/frame/LocalFrame.h"
#include "core/page/AutoscrollController.h"
#include "core/page/EventHandler.h"
#include "core/rendering/RenderView.h"
#include "core/rendering/compositing/RenderLayerCompositor.h"
#include "platform/graphics/GraphicsContext.h"
#include "wtf/CurrentTime.h"
using namespace WebCore;
namespace blink {
static inline FrameView* mainFrameView(Page* page)
{
if (!page)
return 0;
if (!page->mainFrame())
return 0;
return page->mainFrame()->view();
}
void PageWidgetDelegate::animate(Page* page, double monotonicFrameBeginTime)
{
RefPtr<FrameView> view = mainFrameView(page);
if (!view)
return;
page->autoscrollController().animate(monotonicFrameBeginTime);
page->animator().serviceScriptedAnimations(monotonicFrameBeginTime);
}
void PageWidgetDelegate::layout(Page* page)
{
if (!page || !page->mainFrame())
return;
page->animator().updateLayoutAndStyleForPainting();
}
void PageWidgetDelegate::paint(Page* page, PageOverlayList* overlays, WebCanvas* canvas, const WebRect& rect, CanvasBackground background)
{
if (rect.isEmpty())
return;
GraphicsContext gc(canvas);
gc.setCertainlyOpaque(background == Opaque);
gc.applyDeviceScaleFactor(page->deviceScaleFactor());
gc.setUseHighResMarkers(page->deviceScaleFactor() > 1.5f);
IntRect dirtyRect(rect);
gc.save();
FrameView* view = mainFrameView(page);
if (view && page->mainFrame()->document()) {
gc.clip(dirtyRect);
view->paint(&gc, dirtyRect);
if (overlays)
overlays->paintWebFrame(gc);
} else {
gc.fillRect(dirtyRect, Color::white);
}
gc.restore();
}
bool PageWidgetDelegate::handleInputEvent(Page* page, PageWidgetEventHandler& handler, const WebInputEvent& event)
{
LocalFrame* frame = page ? page->mainFrame() : 0;
switch (event.type) {
case WebInputEvent::MouseMove:
if (!frame || !frame->view())
return true;
handler.handleMouseMove(*frame, *static_cast<const WebMouseEvent*>(&event));
return true;
case WebInputEvent::MouseLeave:
if (!frame || !frame->view())
return true;
handler.handleMouseLeave(*frame, *static_cast<const WebMouseEvent*>(&event));
return true;
case WebInputEvent::MouseDown:
if (!frame || !frame->view())
return true;
handler.handleMouseDown(*frame, *static_cast<const WebMouseEvent*>(&event));
return true;
case WebInputEvent::MouseUp:
if (!frame || !frame->view())
return true;
handler.handleMouseUp(*frame, *static_cast<const WebMouseEvent*>(&event));
return true;
case WebInputEvent::MouseWheel:
if (!frame || !frame->view())
return false;
return handler.handleMouseWheel(*frame, *static_cast<const WebMouseWheelEvent*>(&event));
case WebInputEvent::RawKeyDown:
case WebInputEvent::KeyDown:
case WebInputEvent::KeyUp:
return handler.handleKeyEvent(*static_cast<const WebKeyboardEvent*>(&event));
case WebInputEvent::Char:
return handler.handleCharEvent(*static_cast<const WebKeyboardEvent*>(&event));
case WebInputEvent::GestureScrollBegin:
case WebInputEvent::GestureScrollEnd:
case WebInputEvent::GestureScrollUpdate:
case WebInputEvent::GestureScrollUpdateWithoutPropagation:
case WebInputEvent::GestureFlingStart:
case WebInputEvent::GestureFlingCancel:
case WebInputEvent::GestureTap:
case WebInputEvent::GestureTapUnconfirmed:
case WebInputEvent::GestureTapDown:
case WebInputEvent::GestureShowPress:
case WebInputEvent::GestureTapCancel:
case WebInputEvent::GestureDoubleTap:
case WebInputEvent::GestureTwoFingerTap:
case WebInputEvent::GestureLongPress:
case WebInputEvent::GestureLongTap:
return handler.handleGestureEvent(*static_cast<const WebGestureEvent*>(&event));
case WebInputEvent::TouchStart:
case WebInputEvent::TouchMove:
case WebInputEvent::TouchEnd:
case WebInputEvent::TouchCancel:
if (!frame || !frame->view())
return false;
return handler.handleTouchEvent(*frame, *static_cast<const WebTouchEvent*>(&event));
case WebInputEvent::GesturePinchBegin:
case WebInputEvent::GesturePinchEnd:
case WebInputEvent::GesturePinchUpdate:
return false;
default:
return false;
}
}
void PageWidgetEventHandler::handleMouseMove(LocalFrame& mainFrame, const WebMouseEvent& event)
{
mainFrame.eventHandler().handleMouseMoveEvent(PlatformMouseEventBuilder(mainFrame.view(), event));
}
void PageWidgetEventHandler::handleMouseLeave(LocalFrame& mainFrame, const WebMouseEvent& event)
{
mainFrame.eventHandler().handleMouseLeaveEvent(PlatformMouseEventBuilder(mainFrame.view(), event));
}
void PageWidgetEventHandler::handleMouseDown(LocalFrame& mainFrame, const WebMouseEvent& event)
{
mainFrame.eventHandler().handleMousePressEvent(PlatformMouseEventBuilder(mainFrame.view(), event));
}
void PageWidgetEventHandler::handleMouseUp(LocalFrame& mainFrame, const WebMouseEvent& event)
{
mainFrame.eventHandler().handleMouseReleaseEvent(PlatformMouseEventBuilder(mainFrame.view(), event));
}
bool PageWidgetEventHandler::handleMouseWheel(LocalFrame& mainFrame, const WebMouseWheelEvent& event)
{
return mainFrame.eventHandler().handleWheelEvent(PlatformWheelEventBuilder(mainFrame.view(), event));
}
bool PageWidgetEventHandler::handleTouchEvent(LocalFrame& mainFrame, const WebTouchEvent& event)
{
return mainFrame.eventHandler().handleTouchEvent(PlatformTouchEventBuilder(mainFrame.view(), event));
}
}