Index: Source/core/frame/LocalDOMWindow.cpp |
diff --git a/Source/core/frame/LocalDOMWindow.cpp b/Source/core/frame/LocalDOMWindow.cpp |
index 545e4b81f5107fea8467f0524dc5730ce70decb9..cc98d95270ac8dec2fd4f38a03ca6d8766efe932 100644 |
--- a/Source/core/frame/LocalDOMWindow.cpp |
+++ b/Source/core/frame/LocalDOMWindow.cpp |
@@ -1152,13 +1152,21 @@ int LocalDOMWindow::innerHeight() const |
if (!view) |
return 0; |
+ FrameHost* host = frame()->host(); |
+ if (!host) |
+ return 0; |
+ |
// FIXME: This is potentially too much work. We really only need to know the dimensions of the parent frame's renderer. |
if (Frame* parent = frame()->tree().parent()) { |
if (parent && parent->isLocalFrame()) |
toLocalFrame(parent)->document()->updateLayoutIgnorePendingStylesheets(); |
} |
- return adjustForAbsoluteZoom(view->visibleContentRect(IncludeScrollbars).height(), frame()->pageZoomFactor()); |
+ FloatSize viewportSize = host->settings().pinchVirtualViewportEnabled() && frame()->isMainFrame() |
+ ? host->pinchViewport().visibleRect().size() |
+ : view->visibleContentRect(IncludeScrollbars).size(); |
+ |
+ return adjustForAbsoluteZoom(expandedIntSize(viewportSize).height(), frame()->pageZoomFactor()); |
} |
int LocalDOMWindow::innerWidth() const |
@@ -1170,13 +1178,21 @@ int LocalDOMWindow::innerWidth() const |
if (!view) |
return 0; |
+ FrameHost* host = frame()->host(); |
+ if (!host) |
+ return 0; |
+ |
// FIXME: This is potentially too much work. We really only need to know the dimensions of the parent frame's renderer. |
if (Frame* parent = frame()->tree().parent()) { |
if (parent && parent->isLocalFrame()) |
toLocalFrame(parent)->document()->updateLayoutIgnorePendingStylesheets(); |
} |
- return adjustForAbsoluteZoom(view->visibleContentRect(IncludeScrollbars).width(), frame()->pageZoomFactor()); |
+ FloatSize viewportSize = host->settings().pinchVirtualViewportEnabled() && frame()->isMainFrame() |
+ ? host->pinchViewport().visibleRect().size() |
+ : view->visibleContentRect(IncludeScrollbars).size(); |
+ |
+ return adjustForAbsoluteZoom(expandedIntSize(viewportSize).width(), frame()->pageZoomFactor()); |
} |
int LocalDOMWindow::screenX() const |
@@ -1216,9 +1232,18 @@ double LocalDOMWindow::scrollX() const |
if (!view) |
return 0; |
+ FrameHost* host = frame()->host(); |
+ if (!host) |
+ return 0; |
+ |
frame()->document()->updateLayoutIgnorePendingStylesheets(); |
- return adjustScrollForAbsoluteZoom(view->scrollX(), frame()->pageZoomFactor()); |
+ double viewportX = view->scrollX(); |
+ |
+ if (host->settings().pinchVirtualViewportEnabled() && frame()->isMainFrame()) |
+ viewportX += host->pinchViewport().location().x(); |
+ |
+ return adjustScrollForAbsoluteZoom(viewportX, frame()->pageZoomFactor()); |
} |
double LocalDOMWindow::scrollY() const |
@@ -1230,9 +1255,18 @@ double LocalDOMWindow::scrollY() const |
if (!view) |
return 0; |
+ FrameHost* host = frame()->host(); |
+ if (!host) |
+ return 0; |
+ |
frame()->document()->updateLayoutIgnorePendingStylesheets(); |
- return adjustScrollForAbsoluteZoom(view->scrollY(), frame()->pageZoomFactor()); |
+ double viewportY = view->scrollY(); |
+ |
+ if (host->settings().pinchVirtualViewportEnabled() && frame()->isMainFrame()) |
+ viewportY += host->pinchViewport().location().y(); |
+ |
+ return adjustScrollForAbsoluteZoom(viewportY, frame()->pageZoomFactor()); |
} |
bool LocalDOMWindow::closed() const |
@@ -1397,6 +1431,25 @@ static bool scrollBehaviorFromScrollOptions(const ScrollOptions& scrollOptions, |
return false; |
} |
+static void scrollViewportTo(LocalFrame* frame, DoublePoint offset, ScrollBehavior scrollBehavior) |
+{ |
+ FrameView* view = frame->view(); |
+ if (!view) |
+ return; |
+ |
+ FrameHost* host = frame->host(); |
+ if (!host) |
+ return; |
+ |
+ view->setScrollPosition(offset, scrollBehavior); |
+ |
+ if (host->settings().pinchVirtualViewportEnabled() && frame->isMainFrame()) { |
+ PinchViewport& pinchViewport = frame->host()->pinchViewport(); |
+ DoubleSize excessDelta = offset - DoublePoint(pinchViewport.visibleRectInDocument().location()); |
+ pinchViewport.move(FloatPoint(excessDelta.width(), excessDelta.height())); |
Rick Byers
2014/11/18 20:53:31
How does this interact with smooth scrolling? It
bokan
2014/11/18 23:21:50
This is a change, though is ScrollBehavior gone li
Rick Byers
2014/11/20 19:23:31
Oh right, it is. CSSOMSmoothScroll is still marke
|
+ } |
+} |
+ |
void LocalDOMWindow::scrollBy(double x, double y, ScrollBehavior scrollBehavior) const |
{ |
if (!isCurrentlyDisplayedInFrame()) |
@@ -1408,11 +1461,19 @@ void LocalDOMWindow::scrollBy(double x, double y, ScrollBehavior scrollBehavior) |
if (!view) |
return; |
+ FrameHost* host = frame()->host(); |
+ if (!host) |
+ return; |
+ |
if (std::isnan(x) || std::isnan(y)) |
return; |
+ DoublePoint currentOffset = host->settings().pinchVirtualViewportEnabled() && frame()->isMainFrame() |
+ ? DoublePoint(host->pinchViewport().visibleRectInDocument().location()) |
+ : view->scrollPositionDouble(); |
+ |
DoubleSize scaledOffset(x * frame()->pageZoomFactor(), y * frame()->pageZoomFactor()); |
- view->scrollBy(scaledOffset, scrollBehavior); |
Rick Byers
2014/11/18 20:53:31
There are a couple other places in the code that c
bokan
2014/11/18 23:21:50
Technically yes, but they're only used from Spacia
Rick Byers
2014/11/20 19:23:30
SGTM, thanks.
|
+ scrollViewportTo(frame(), currentOffset + scaledOffset, scrollBehavior); |
} |
void LocalDOMWindow::scrollBy(double x, double y, const ScrollOptions& scrollOptions, ExceptionState &exceptionState) const |
@@ -1430,15 +1491,11 @@ void LocalDOMWindow::scrollTo(double x, double y, ScrollBehavior scrollBehavior) |
document()->updateLayoutIgnorePendingStylesheets(); |
- RefPtrWillBeRawPtr<FrameView> view = frame()->view(); |
- if (!view) |
- return; |
- |
if (std::isnan(x) || std::isnan(y)) |
return; |
DoublePoint layoutPos(x * frame()->pageZoomFactor(), y * frame()->pageZoomFactor()); |
- view->setScrollPosition(layoutPos, scrollBehavior); |
+ scrollViewportTo(frame(), layoutPos, scrollBehavior); |
} |
void LocalDOMWindow::scrollTo(double x, double y, const ScrollOptions& scrollOptions, ExceptionState& exceptionState) const |