Skip to content

Commit

Permalink
Revert of Remove default args to several PageWidgetDelegate members. …
Browse files Browse the repository at this point in the history
…(patchset #2 id:20001 of https://codereview.chromium.org/603883002/)

Reason for revert:
Broke several cross-site iframe tests.

Original issue's description:
> Remove default args to several PageWidgetDelegate members.
> 
> No one passes the correct local root here yet; eventually, something....
> 
> BUG=411993
> 
> Committed: https://src.chromium.org/viewvc/blink?view=rev&revision=182705

TBR=japhet@chromium.org,kenrb@chromium.org
NOTREECHECKS=true
NOTRY=true
BUG=411993

Review URL: https://codereview.chromium.org/600823005

git-svn-id: svn://svn.chromium.org/blink/trunk@182716 bbb929c8-8fbe-4397-9dbb-9b2b20218538
  • Loading branch information
zetafunction committed Sep 25, 2014
1 parent e7ac366 commit f1db071
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 33 deletions.
60 changes: 39 additions & 21 deletions Source/web/PageWidgetDelegate.cpp
Expand Up @@ -47,24 +47,41 @@

namespace blink {

void PageWidgetDelegate::animate(Page* page, double monotonicFrameBeginTime, LocalFrame* root)
static inline FrameView* rootFrameView(Page* page, LocalFrame* rootFrame)
{
RefPtr<FrameView> view = root->view();
if (rootFrame)
return rootFrame->view();
if (!page)
return 0;
if (!page->mainFrame()->isLocalFrame())
return 0;
return toLocalFrame(page->mainFrame())->view();
}

void PageWidgetDelegate::animate(Page* page, double monotonicFrameBeginTime, LocalFrame* rootFrame)
{
RefPtr<FrameView> view = rootFrameView(page, rootFrame);
if (!view)
return;
page->autoscrollController().animate(monotonicFrameBeginTime);
page->animator().serviceScriptedAnimations(monotonicFrameBeginTime);
}

void PageWidgetDelegate::layout(Page* page, LocalFrame* root)
void PageWidgetDelegate::layout(Page* page, LocalFrame* rootFrame)
{
if (!page)
return;

page->animator().updateLayoutAndStyleForPainting(root);
if (!rootFrame) {
if (!page->mainFrame() || !page->mainFrame()->isLocalFrame())
return;
rootFrame = toLocalFrame(page->mainFrame());
}

page->animator().updateLayoutAndStyleForPainting(rootFrame);
}

void PageWidgetDelegate::paint(Page* page, PageOverlayList* overlays, WebCanvas* canvas, const WebRect& rect, CanvasBackground background, LocalFrame* root)
void PageWidgetDelegate::paint(Page* page, PageOverlayList* overlays, WebCanvas* canvas, const WebRect& rect, CanvasBackground background, LocalFrame* rootFrame)
{
if (rect.isEmpty())
return;
Expand All @@ -74,7 +91,7 @@ void PageWidgetDelegate::paint(Page* page, PageOverlayList* overlays, WebCanvas*
gc.setDeviceScaleFactor(page->deviceScaleFactor());
IntRect dirtyRect(rect);
gc.save(); // Needed to save the canvas, not the GraphicsContext.
FrameView* view = root->view();
FrameView* view = rootFrameView(page, rootFrame);
if (view) {
gc.clip(dirtyRect);
view->paint(&gc, dirtyRect);
Expand All @@ -86,40 +103,41 @@ void PageWidgetDelegate::paint(Page* page, PageOverlayList* overlays, WebCanvas*
gc.restore();
}

bool PageWidgetDelegate::handleInputEvent(Page* page, PageWidgetEventHandler& handler, const WebInputEvent& event, LocalFrame* root)
bool PageWidgetDelegate::handleInputEvent(Page* page, PageWidgetEventHandler& handler, const WebInputEvent& event, LocalFrame* rootFrame)
{
LocalFrame* frame = rootFrame;
if (!frame)
frame = page && page->mainFrame()->isLocalFrame() ? toLocalFrame(page->mainFrame()) : 0;
switch (event.type) {

// FIXME: WebKit seems to always return false on mouse events processing
// methods. For now we'll assume it has processed them (as we are only
// interested in whether keyboard events are processed).
// FIXME: Why do we return true when there is no root or the root is
// detached?
case WebInputEvent::MouseMove:
if (!root || !root->view())
if (!frame || !frame->view())
return true;
handler.handleMouseMove(*root, static_cast<const WebMouseEvent&>(event));
handler.handleMouseMove(*frame, static_cast<const WebMouseEvent&>(event));
return true;
case WebInputEvent::MouseLeave:
if (!root || !root->view())
if (!frame || !frame->view())
return true;
handler.handleMouseLeave(*root, static_cast<const WebMouseEvent&>(event));
handler.handleMouseLeave(*frame, static_cast<const WebMouseEvent&>(event));
return true;
case WebInputEvent::MouseDown:
if (!root || !root->view())
if (!frame || !frame->view())
return true;
handler.handleMouseDown(*root, static_cast<const WebMouseEvent&>(event));
handler.handleMouseDown(*frame, static_cast<const WebMouseEvent&>(event));
return true;
case WebInputEvent::MouseUp:
if (!root || !root->view())
if (!frame || !frame->view())
return true;
handler.handleMouseUp(*root, static_cast<const WebMouseEvent&>(event));
handler.handleMouseUp(*frame, static_cast<const WebMouseEvent&>(event));
return true;

case WebInputEvent::MouseWheel:
if (!root || !root->view())
if (!frame || !frame->view())
return false;
return handler.handleMouseWheel(*root, static_cast<const WebMouseWheelEvent&>(event));
return handler.handleMouseWheel(*frame, static_cast<const WebMouseWheelEvent&>(event));

case WebInputEvent::RawKeyDown:
case WebInputEvent::KeyDown:
Expand Down Expand Up @@ -149,9 +167,9 @@ bool PageWidgetDelegate::handleInputEvent(Page* page, PageWidgetEventHandler& ha
case WebInputEvent::TouchMove:
case WebInputEvent::TouchEnd:
case WebInputEvent::TouchCancel:
if (!root || !root->view())
if (!frame || !frame->view())
return false;
return handler.handleTouchEvent(*root, static_cast<const WebTouchEvent&>(event));
return handler.handleTouchEvent(*frame, static_cast<const WebTouchEvent&>(event));

case WebInputEvent::GesturePinchBegin:
case WebInputEvent::GesturePinchEnd:
Expand Down
8 changes: 4 additions & 4 deletions Source/web/PageWidgetDelegate.h
Expand Up @@ -72,10 +72,10 @@ class PageWidgetDelegate {
// rootFrame arguments indicate a root localFrame from which to start performing the
// specified operation. If rootFrame is 0, these methods will attempt to use the
// Page's mainFrame(), if it is a LocalFrame.
static void animate(Page*, double monotonicFrameBeginTime, LocalFrame* root);
static void layout(Page*, LocalFrame* root);
static void paint(Page*, PageOverlayList*, WebCanvas*, const WebRect&, CanvasBackground, LocalFrame* root);
static bool handleInputEvent(Page*, PageWidgetEventHandler&, const WebInputEvent&, LocalFrame* root);
static void animate(Page*, double monotonicFrameBeginTime, LocalFrame* rootFrame = 0);
static void layout(Page*, LocalFrame* rootFrame = 0);
static void paint(Page*, PageOverlayList*, WebCanvas*, const WebRect&, CanvasBackground, LocalFrame* rootFrame = 0);
static bool handleInputEvent(Page*, PageWidgetEventHandler&, const WebInputEvent&, LocalFrame* rootFrame = 0);

private:
PageWidgetDelegate() { }
Expand Down
8 changes: 4 additions & 4 deletions Source/web/WebPagePopupImpl.cpp
Expand Up @@ -323,7 +323,7 @@ void WebPagePopupImpl::beginFrame(const WebBeginFrameArgs& frameTime)
{
// FIXME: This should use frameTime.lastFrameTimeMonotonic but doing so
// breaks tests.
PageWidgetDelegate::animate(m_page.get(), monotonicallyIncreasingTime(), m_page->deprecatedLocalMainFrame());
PageWidgetDelegate::animate(m_page.get(), monotonicallyIncreasingTime());
}

void WebPagePopupImpl::willCloseLayerTreeView()
Expand All @@ -334,13 +334,13 @@ void WebPagePopupImpl::willCloseLayerTreeView()

void WebPagePopupImpl::layout()
{
PageWidgetDelegate::layout(m_page.get(), m_page->deprecatedLocalMainFrame());
PageWidgetDelegate::layout(m_page.get());
}

void WebPagePopupImpl::paint(WebCanvas* canvas, const WebRect& rect)
{
if (!m_closing)
PageWidgetDelegate::paint(m_page.get(), 0, canvas, rect, PageWidgetDelegate::Opaque, m_page->deprecatedLocalMainFrame());
PageWidgetDelegate::paint(m_page.get(), 0, canvas, rect, PageWidgetDelegate::Opaque);
}

void WebPagePopupImpl::resize(const WebSize& newSize)
Expand Down Expand Up @@ -379,7 +379,7 @@ bool WebPagePopupImpl::handleInputEvent(const WebInputEvent& event)
{
if (m_closing)
return false;
return PageWidgetDelegate::handleInputEvent(m_page.get(), *this, event, m_page->deprecatedLocalMainFrame());
return PageWidgetDelegate::handleInputEvent(m_page.get(), *this, event);
}

bool WebPagePopupImpl::handleKeyEvent(const PlatformKeyboardEvent& event)
Expand Down
8 changes: 4 additions & 4 deletions Source/web/WebViewImpl.cpp
Expand Up @@ -1819,7 +1819,7 @@ void WebViewImpl::beginFrame(const WebBeginFrameArgs& frameTime)
if (!m_page)
return;

PageWidgetDelegate::animate(m_page.get(), validFrameTime.lastFrameTimeMonotonic, m_page->deprecatedLocalMainFrame());
PageWidgetDelegate::animate(m_page.get(), validFrameTime.lastFrameTimeMonotonic);

if (m_continuousPaintingEnabled) {
ContinuousPainter::setNeedsDisplayRecursive(m_rootGraphicsLayer, m_pageOverlays.get());
Expand Down Expand Up @@ -1855,7 +1855,7 @@ void WebViewImpl::paint(WebCanvas* canvas, const WebRect& rect)
ASSERT(!isAcceleratedCompositingActive());

double paintStart = currentTime();
PageWidgetDelegate::paint(m_page.get(), pageOverlays(), canvas, rect, isTransparent() ? PageWidgetDelegate::Translucent : PageWidgetDelegate::Opaque, m_page->deprecatedLocalMainFrame());
PageWidgetDelegate::paint(m_page.get(), pageOverlays(), canvas, rect, isTransparent() ? PageWidgetDelegate::Translucent : PageWidgetDelegate::Opaque);
double paintEnd = currentTime();
double pixelsPerSec = (rect.width * rect.height) / (paintEnd - paintStart);
Platform::current()->histogramCustomCounts("Renderer4.SoftwarePaintDurationMS", (paintEnd - paintStart) * 1000, 0, 120, 30);
Expand All @@ -1874,7 +1874,7 @@ void WebViewImpl::paintCompositedDeprecated(WebCanvas* canvas, const WebRect& re
PaintBehavior oldPaintBehavior = view->paintBehavior();
view->setPaintBehavior(oldPaintBehavior | PaintBehaviorFlattenCompositingLayers);

PageWidgetDelegate::paint(m_page.get(), pageOverlays(), canvas, rect, isTransparent() ? PageWidgetDelegate::Translucent : PageWidgetDelegate::Opaque, m_page->deprecatedLocalMainFrame());
PageWidgetDelegate::paint(m_page.get(), pageOverlays(), canvas, rect, isTransparent() ? PageWidgetDelegate::Translucent : PageWidgetDelegate::Opaque);

view->setPaintBehavior(oldPaintBehavior);
}
Expand Down Expand Up @@ -2065,7 +2065,7 @@ bool WebViewImpl::handleInputEvent(const WebInputEvent& inputEvent)
return true;
}

return PageWidgetDelegate::handleInputEvent(m_page.get(), *this, inputEvent, m_page->deprecatedLocalMainFrame());
return PageWidgetDelegate::handleInputEvent(m_page.get(), *this, inputEvent);
}

void WebViewImpl::setCursorVisibilityState(bool isVisible)
Expand Down

0 comments on commit f1db071

Please sign in to comment.