| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 #include "core/frame/LocalFrame.h" | 35 #include "core/frame/LocalFrame.h" |
| 36 #include "core/layout/LayoutView.h" | 36 #include "core/layout/LayoutView.h" |
| 37 #include "core/layout/compositing/DeprecatedPaintLayerCompositor.h" | 37 #include "core/layout/compositing/DeprecatedPaintLayerCompositor.h" |
| 38 #include "core/page/AutoscrollController.h" | 38 #include "core/page/AutoscrollController.h" |
| 39 #include "core/page/EventHandler.h" | 39 #include "core/page/EventHandler.h" |
| 40 #include "core/page/Page.h" | 40 #include "core/page/Page.h" |
| 41 #include "core/paint/TransformRecorder.h" | 41 #include "core/paint/TransformRecorder.h" |
| 42 #include "platform/Logging.h" | 42 #include "platform/Logging.h" |
| 43 #include "platform/graphics/GraphicsContext.h" | 43 #include "platform/graphics/GraphicsContext.h" |
| 44 #include "platform/graphics/paint/ClipRecorder.h" | 44 #include "platform/graphics/paint/ClipRecorder.h" |
| 45 #include "platform/graphics/paint/DisplayItemListContextRecorder.h" | |
| 46 #include "platform/graphics/paint/DrawingRecorder.h" | 45 #include "platform/graphics/paint/DrawingRecorder.h" |
| 46 #include "platform/graphics/paint/SkPictureBuilder.h" |
| 47 #include "platform/transforms/AffineTransform.h" | 47 #include "platform/transforms/AffineTransform.h" |
| 48 #include "public/web/WebInputEvent.h" | 48 #include "public/web/WebInputEvent.h" |
| 49 #include "web/PageOverlayList.h" | 49 #include "web/PageOverlayList.h" |
| 50 #include "web/WebInputEventConversion.h" | 50 #include "web/WebInputEventConversion.h" |
| 51 #include "wtf/CurrentTime.h" | 51 #include "wtf/CurrentTime.h" |
| 52 | 52 |
| 53 namespace blink { | 53 namespace blink { |
| 54 | 54 |
| 55 void PageWidgetDelegate::animate(Page& page, double monotonicFrameBeginTime, Loc
alFrame& root) | 55 void PageWidgetDelegate::animate(Page& page, double monotonicFrameBeginTime, Loc
alFrame& root) |
| 56 { | 56 { |
| 57 RefPtrWillBeRawPtr<FrameView> view = root.view(); | 57 RefPtrWillBeRawPtr<FrameView> view = root.view(); |
| 58 if (!view) | 58 if (!view) |
| 59 return; | 59 return; |
| 60 page.autoscrollController().animate(monotonicFrameBeginTime); | 60 page.autoscrollController().animate(monotonicFrameBeginTime); |
| 61 page.animator().serviceScriptedAnimations(monotonicFrameBeginTime); | 61 page.animator().serviceScriptedAnimations(monotonicFrameBeginTime); |
| 62 } | 62 } |
| 63 | 63 |
| 64 void PageWidgetDelegate::layout(Page& page, LocalFrame& root) | 64 void PageWidgetDelegate::layout(Page& page, LocalFrame& root) |
| 65 { | 65 { |
| 66 page.animator().updateLayoutAndStyleForPainting(&root); | 66 page.animator().updateLayoutAndStyleForPainting(&root); |
| 67 } | 67 } |
| 68 | 68 |
| 69 void PageWidgetDelegate::paint(Page& page, PageOverlayList* overlays, WebCanvas*
canvas, | 69 void PageWidgetDelegate::paint(Page& page, PageOverlayList* overlays, WebCanvas*
canvas, |
| 70 const WebRect& rect, LocalFrame& root) | 70 const WebRect& rect, LocalFrame& root) |
| 71 { | 71 { |
| 72 if (rect.isEmpty()) | 72 if (rect.isEmpty()) |
| 73 return; | 73 return; |
| 74 | 74 |
| 75 OwnPtr<GraphicsContext> context = GraphicsContext::deprecatedCreateWithCanva
s(canvas); | 75 IntRect intRect(rect); |
| 76 { | 76 SkPictureBuilder builder(intRect); |
| 77 DisplayItemListContextRecorder contextRecorder(*context); | 77 GraphicsContext* context = &builder.context(); |
| 78 GraphicsContext& paintContext = contextRecorder.context(); | |
| 79 | 78 |
| 80 // FIXME: device scale factor settings are layering violations and shoul
d not | 79 // FIXME: device scale factor settings are layering violations and should no
t |
| 81 // be used within Blink paint code. | 80 // be used within Blink paint code. |
| 82 float scaleFactor = page.deviceScaleFactor(); | 81 float scaleFactor = page.deviceScaleFactor(); |
| 83 paintContext.setDeviceScaleFactor(scaleFactor); | 82 context->setDeviceScaleFactor(scaleFactor); |
| 84 | 83 |
| 85 AffineTransform scale; | 84 AffineTransform scale; |
| 86 scale.scale(scaleFactor); | 85 scale.scale(scaleFactor); |
| 87 TransformRecorder scaleRecorder(paintContext, root, scale); | 86 TransformRecorder scaleRecorder(*context, root, scale); |
| 88 | 87 |
| 89 IntRect dirtyRect(rect); | 88 IntRect dirtyRect(rect); |
| 90 FrameView* view = root.view(); | 89 FrameView* view = root.view(); |
| 91 if (view) { | 90 if (view) { |
| 92 ClipRecorder clipRecorder(paintContext, root, DisplayItem::PageWidge
tDelegateClip, LayoutRect(dirtyRect)); | 91 ClipRecorder clipRecorder(*context, root, DisplayItem::PageWidgetDelegat
eClip, LayoutRect(dirtyRect)); |
| 93 | 92 |
| 94 view->paint(&paintContext, dirtyRect); | 93 view->paint(context, dirtyRect); |
| 95 if (overlays) | 94 if (overlays) |
| 96 overlays->paintWebFrame(paintContext); | 95 overlays->paintWebFrame(*context); |
| 97 } else { | 96 } else { |
| 98 DrawingRecorder drawingRecorder(paintContext, root, DisplayItem::Pag
eWidgetDelegateBackgroundFallback, dirtyRect); | 97 DrawingRecorder drawingRecorder(*context, root, DisplayItem::PageWidgetD
elegateBackgroundFallback, dirtyRect); |
| 99 if (!drawingRecorder.canUseCachedDrawing()) | 98 if (!drawingRecorder.canUseCachedDrawing()) |
| 100 paintContext.fillRect(dirtyRect, Color::white); | 99 context->fillRect(dirtyRect, Color::white); |
| 101 } | |
| 102 } | 100 } |
| 101 builder.endRecording()->playback(canvas); |
| 103 } | 102 } |
| 104 | 103 |
| 105 bool PageWidgetDelegate::handleInputEvent(PageWidgetEventHandler& handler, const
WebInputEvent& event, LocalFrame* root) | 104 bool PageWidgetDelegate::handleInputEvent(PageWidgetEventHandler& handler, const
WebInputEvent& event, LocalFrame* root) |
| 106 { | 105 { |
| 107 switch (event.type) { | 106 switch (event.type) { |
| 108 | 107 |
| 109 // FIXME: WebKit seems to always return false on mouse events processing | 108 // FIXME: WebKit seems to always return false on mouse events processing |
| 110 // methods. For now we'll assume it has processed them (as we are only | 109 // methods. For now we'll assume it has processed them (as we are only |
| 111 // interested in whether keyboard events are processed). | 110 // interested in whether keyboard events are processed). |
| 112 // FIXME: Why do we return true when there is no root or the root is | 111 // FIXME: Why do we return true when there is no root or the root is |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 205 { | 204 { |
| 206 return mainFrame.eventHandler().handleWheelEvent(PlatformWheelEventBuilder(m
ainFrame.view(), event)); | 205 return mainFrame.eventHandler().handleWheelEvent(PlatformWheelEventBuilder(m
ainFrame.view(), event)); |
| 207 } | 206 } |
| 208 | 207 |
| 209 bool PageWidgetEventHandler::handleTouchEvent(LocalFrame& mainFrame, const WebTo
uchEvent& event) | 208 bool PageWidgetEventHandler::handleTouchEvent(LocalFrame& mainFrame, const WebTo
uchEvent& event) |
| 210 { | 209 { |
| 211 return mainFrame.eventHandler().handleTouchEvent(PlatformTouchEventBuilder(m
ainFrame.view(), event)); | 210 return mainFrame.eventHandler().handleTouchEvent(PlatformTouchEventBuilder(m
ainFrame.view(), event)); |
| 212 } | 211 } |
| 213 | 212 |
| 214 } // namespace blink | 213 } // namespace blink |
| OLD | NEW |