- Revision
- 167503
- Author
- simon.fra...@apple.com
- Date
- 2014-04-18 13:31:35 -0700 (Fri, 18 Apr 2014)
Log Message
[iOS WK2] Make window.scroll() and window.scrollBy() work
https://bugs.webkit.org/show_bug.cgi?id=131848
<rdar://problem/16638319>
Reviewed by Beth Dakin.
The scrolling-related functions in DOMWindow were #ifdeffed for iOS
to use the hacky WK1-specific "actual scroll" functions, which do nothing
in WK2.
Fix by adding a scroll position wrapper (contentsScrollPosition) which does
the right thing on WK1 and WK2, and change almost all the places that used "actualScrollPosition"
to us it (with the exception of contentsScrollOffset() in MouseRelatedEvent.cpp, which has
confusing scaling behavior).
* dom/MouseRelatedEvent.cpp:
(WebCore::MouseRelatedEvent::MouseRelatedEvent):
* dom/TreeScope.cpp:
(WebCore::nodeFromPoint): Remove #ifdefs.
* html/HTMLBodyElement.cpp:
(WebCore::HTMLBodyElement::scrollLeft):
(WebCore::HTMLBodyElement::scrollTop):
* page/DOMWindow.cpp:
(WebCore::DOMWindow::scrollX):
(WebCore::DOMWindow::scrollY):
(WebCore::DOMWindow::scrollBy):
(WebCore::DOMWindow::scrollTo):
* platform/ScrollView.cpp:
(WebCore::ScrollView::contentsScrollPosition):
(WebCore::ScrollView::setContentsScrollPosition):
* platform/ScrollView.h:
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (167502 => 167503)
--- trunk/Source/WebCore/ChangeLog 2014-04-18 20:17:59 UTC (rev 167502)
+++ trunk/Source/WebCore/ChangeLog 2014-04-18 20:31:35 UTC (rev 167503)
@@ -1,5 +1,39 @@
2014-04-18 Simon Fraser <simon.fra...@apple.com>
+ [iOS WK2] Make window.scroll() and window.scrollBy() work
+ https://bugs.webkit.org/show_bug.cgi?id=131848
+ <rdar://problem/16638319>
+
+ Reviewed by Beth Dakin.
+
+ The scrolling-related functions in DOMWindow were #ifdeffed for iOS
+ to use the hacky WK1-specific "actual scroll" functions, which do nothing
+ in WK2.
+
+ Fix by adding a scroll position wrapper (contentsScrollPosition) which does
+ the right thing on WK1 and WK2, and change almost all the places that used "actualScrollPosition"
+ to us it (with the exception of contentsScrollOffset() in MouseRelatedEvent.cpp, which has
+ confusing scaling behavior).
+
+ * dom/MouseRelatedEvent.cpp:
+ (WebCore::MouseRelatedEvent::MouseRelatedEvent):
+ * dom/TreeScope.cpp:
+ (WebCore::nodeFromPoint): Remove #ifdefs.
+ * html/HTMLBodyElement.cpp:
+ (WebCore::HTMLBodyElement::scrollLeft):
+ (WebCore::HTMLBodyElement::scrollTop):
+ * page/DOMWindow.cpp:
+ (WebCore::DOMWindow::scrollX):
+ (WebCore::DOMWindow::scrollY):
+ (WebCore::DOMWindow::scrollBy):
+ (WebCore::DOMWindow::scrollTo):
+ * platform/ScrollView.cpp:
+ (WebCore::ScrollView::contentsScrollPosition):
+ (WebCore::ScrollView::setContentsScrollPosition):
+ * platform/ScrollView.h:
+
+2014-04-18 Simon Fraser <simon.fra...@apple.com>
+
Worse animation performance on pages with 3D transforms
https://bugs.webkit.org/show_bug.cgi?id=131838
<rdar://problem/16428630&15705876>
Modified: trunk/Source/WebCore/dom/MouseRelatedEvent.cpp (167502 => 167503)
--- trunk/Source/WebCore/dom/MouseRelatedEvent.cpp 2014-04-18 20:17:59 UTC (rev 167502)
+++ trunk/Source/WebCore/dom/MouseRelatedEvent.cpp 2014-04-18 20:31:35 UTC (rev 167503)
@@ -74,11 +74,7 @@
Frame* frame = view() ? view()->frame() : 0;
if (frame && !isSimulated) {
if (FrameView* frameView = frame->view()) {
-#if !PLATFORM(IOS)
- scrollPosition = frameView->scrollPosition();
-#else
- scrollPosition = frameView->actualScrollPosition();
-#endif
+ scrollPosition = frameView->contentsScrollPosition();
adjustedPageLocation = frameView->windowToContents(windowLocation);
float scaleFactor = 1 / (frame->pageZoomFactor() * frame->frameScaleFactor());
if (scaleFactor != 1.0f) {
Modified: trunk/Source/WebCore/dom/TreeScope.cpp (167502 => 167503)
--- trunk/Source/WebCore/dom/TreeScope.cpp 2014-04-18 20:17:59 UTC (rev 167502)
+++ trunk/Source/WebCore/dom/TreeScope.cpp 2014-04-18 20:31:35 UTC (rev 167503)
@@ -227,17 +227,19 @@
return nullptr;
float scaleFactor = frame->pageZoomFactor() * frame->frameScaleFactor();
-#if !PLATFORM(IOS)
- IntPoint point = roundedIntPoint(FloatPoint(x * scaleFactor + frameView->scrollX(), y * scaleFactor + frameView->scrollY()));
- if (!frameView->visibleContentRect().contains(point))
+ IntPoint scrollPosition = frameView->contentsScrollPosition();
+ IntPoint point = roundedIntPoint(FloatPoint(x * scaleFactor + scrollPosition.x(), y * scaleFactor + scrollPosition.y()));
+
+ IntRect visibleRect;
+#if PLATFORM(IOS)
+ visibleRect = frameView->unobscuredContentRect();
+#else
+ visibleRect = frameView->visibleContentRect();
+#endif
+ if (!visibleRect.contains(point))
return nullptr;
-#else
- IntPoint point = roundedIntPoint(FloatPoint(x * scaleFactor + frameView->actualScrollX(), y * scaleFactor + frameView->actualScrollY()));
- if (!frameView->unobscuredContentRect().contains(point))
- return nullptr;
-#endif
HitTestRequest request(HitTestRequest::ReadOnly | HitTestRequest::Active | HitTestRequest::DisallowShadowContent);
HitTestResult result(point);
document->renderView()->hitTest(request, result);
Modified: trunk/Source/WebCore/html/HTMLBodyElement.cpp (167502 => 167503)
--- trunk/Source/WebCore/html/HTMLBodyElement.cpp 2014-04-18 20:17:59 UTC (rev 167502)
+++ trunk/Source/WebCore/html/HTMLBodyElement.cpp 2014-04-18 20:31:35 UTC (rev 167503)
@@ -218,11 +218,7 @@
FrameView* view = frame->view();
if (!view)
return 0;
-#if PLATFORM(IOS)
- return adjustForZoom(view->actualScrollX(), *frame);
-#else
- return adjustForZoom(view->scrollX(), *frame);
-#endif
+ return adjustForZoom(view->contentsScrollPosition().x(), *frame);
}
void HTMLBodyElement::setScrollLeft(int scrollLeft)
@@ -246,11 +242,7 @@
FrameView* view = frame->view();
if (!view)
return 0;
-#if PLATFORM(IOS)
- return adjustForZoom(view->actualScrollY(), *frame);
-#else
- return adjustForZoom(view->scrollY(), *frame);
-#endif
+ return adjustForZoom(view->contentsScrollPosition().y(), *frame);
}
void HTMLBodyElement::setScrollTop(int scrollTop)
Modified: trunk/Source/WebCore/page/DOMWindow.cpp (167502 => 167503)
--- trunk/Source/WebCore/page/DOMWindow.cpp 2014-04-18 20:17:59 UTC (rev 167502)
+++ trunk/Source/WebCore/page/DOMWindow.cpp 2014-04-18 20:31:35 UTC (rev 167503)
@@ -1192,22 +1192,13 @@
if (!view)
return 0;
- int scrollX;
-#if PLATFORM(IOS)
- scrollX = view->actualScrollX();
-#else
- scrollX = view->scrollX();
-#endif
+ int scrollX = view->contentsScrollPosition().x();
if (!scrollX)
return 0;
m_frame->document()->updateLayoutIgnorePendingStylesheets();
-#if PLATFORM(IOS)
- return view->mapFromLayoutToCSSUnits(view->actualScrollX());
-#else
- return view->mapFromLayoutToCSSUnits(view->scrollX());
-#endif
+ return view->mapFromLayoutToCSSUnits(view->contentsScrollPosition().x());
}
int DOMWindow::scrollY() const
@@ -1219,22 +1210,13 @@
if (!view)
return 0;
- int scrollY;
-#if PLATFORM(IOS)
- scrollY = view->actualScrollY();
-#else
- scrollY = view->scrollY();
-#endif
+ int scrollY = view->contentsScrollPosition().y();
if (!scrollY)
return 0;
m_frame->document()->updateLayoutIgnorePendingStylesheets();
-#if PLATFORM(IOS)
- return view->mapFromLayoutToCSSUnits(view->actualScrollY());
-#else
- return view->mapFromLayoutToCSSUnits(view->scrollY());
-#endif
+ return view->mapFromLayoutToCSSUnits(view->contentsScrollPosition().y());
}
bool DOMWindow::closed() const
@@ -1446,11 +1428,7 @@
return;
IntSize scaledOffset(view->mapFromCSSToLayoutUnits(x), view->mapFromCSSToLayoutUnits(y));
-#if PLATFORM(IOS)
- view->setActualScrollPosition(view->actualScrollPosition() + scaledOffset);
-#else
- view->scrollBy(scaledOffset);
-#endif
+ view->setContentsScrollPosition(view->contentsScrollPosition() + scaledOffset);
}
void DOMWindow::scrollTo(int x, int y) const
@@ -1464,15 +1442,8 @@
if (!view)
return;
-
-#if PLATFORM(IOS)
- int zoomedX = static_cast<int>(x * m_frame->pageZoomFactor() * m_frame->frameScaleFactor());
- int zoomedY = static_cast<int>(y * m_frame->pageZoomFactor() * m_frame->frameScaleFactor());
- view->setActualScrollPosition(IntPoint(zoomedX, zoomedY));
-#else
IntPoint layoutPos(view->mapFromCSSToLayoutUnits(x), view->mapFromCSSToLayoutUnits(y));
- view->setScrollPosition(layoutPos);
-#endif
+ view->setContentsScrollPosition(layoutPos);
}
bool DOMWindow::allowedToChangeWindowGeometry() const
Modified: trunk/Source/WebCore/platform/ScrollView.cpp (167502 => 167503)
--- trunk/Source/WebCore/platform/ScrollView.cpp 2014-04-18 20:17:59 UTC (rev 167502)
+++ trunk/Source/WebCore/platform/ScrollView.cpp 2014-04-18 20:31:35 UTC (rev 167503)
@@ -236,6 +236,24 @@
delegatesScrollingDidChange();
}
+IntPoint ScrollView::contentsScrollPosition() const
+{
+#if PLATFORM(IOS)
+ if (platformWidget())
+ return actualScrollPosition();
+#endif
+ return scrollPosition();
+}
+
+void ScrollView::setContentsScrollPosition(const IntPoint& position)
+{
+#if PLATFORM(IOS)
+ if (platformWidget())
+ setActualScrollPosition(position);
+#endif
+ setScrollPosition(position);
+}
+
#if !PLATFORM(IOS)
IntRect ScrollView::unobscuredContentRect(VisibleContentRectIncludesScrollbars scrollbarInclusion) const
{
Modified: trunk/Source/WebCore/platform/ScrollView.h (167502 => 167503)
--- trunk/Source/WebCore/platform/ScrollView.h 2014-04-18 20:17:59 UTC (rev 167502)
+++ trunk/Source/WebCore/platform/ScrollView.h 2014-04-18 20:31:35 UTC (rev 167503)
@@ -229,6 +229,10 @@
int scrollX() const { return scrollPosition().x(); }
int scrollY() const { return scrollPosition().y(); }
+ // Scroll position used by web-exposed features (has legacy iOS behavior).
+ IntPoint contentsScrollPosition() const;
+ void setContentsScrollPosition(const IntPoint&);
+
#if PLATFORM(IOS)
int actualScrollX() const { return unobscuredContentRect().x(); }
int actualScrollY() const { return unobscuredContentRect().y(); }