Diff
Modified: trunk/Source/WebCore/ChangeLog (194409 => 194410)
--- trunk/Source/WebCore/ChangeLog 2015-12-24 02:17:03 UTC (rev 194409)
+++ trunk/Source/WebCore/ChangeLog 2015-12-24 03:43:23 UTC (rev 194410)
@@ -1,5 +1,40 @@
2015-12-23 Simon Fraser <[email protected]>
+ Use "constrainedBetween" in more places
+ https://bugs.webkit.org/show_bug.cgi?id=152543
+
+ Reviewed by Zalan Bujtas.
+
+ Replace code that contrains points via shrunkTo/expandedTo() with calls
+ to constrainedBetween(), and implement constrainedBetween() on IntPoint,
+ FloatPoint and LayoutPoint.
+
+ Convert some functions that return points to more modern syntax.
+
+ * page/scrolling/ScrollingTreeFrameScrollingNode.cpp:
+ (WebCore::ScrollingTreeFrameScrollingNode::setScrollPosition):
+ * page/scrolling/ScrollingTreeScrollingNode.cpp:
+ (WebCore::ScrollingTreeScrollingNode::setScrollPosition):
+ * platform/ScrollView.cpp:
+ (WebCore::ScrollView::adjustScrollPositionWithinRange):
+ * platform/graphics/FloatPoint.cpp:
+ (WebCore::FloatPoint::constrainedBetween):
+ * platform/graphics/FloatPoint.h:
+ (WebCore::FloatPoint::shrunkTo):
+ (WebCore::FloatPoint::expandedTo):
+ (WebCore::FloatPoint::transposedPoint):
+ * platform/graphics/IntPoint.cpp:
+ * platform/graphics/LayoutPoint.cpp:
+ (WebCore::LayoutPoint::constrainedBetween):
+ * platform/graphics/LayoutPoint.h:
+ (WebCore::LayoutPoint::expandedTo):
+ (WebCore::LayoutPoint::shrunkTo):
+ (WebCore::LayoutPoint::transposedPoint):
+ (WebCore::LayoutPoint::fraction):
+ (WebCore::LayoutPoint::operator FloatPoint):
+
+2015-12-23 Simon Fraser <[email protected]>
+
REGRESSION (r187593): Scroll position jumps when selecting text in an iframe
https://bugs.webkit.org/show_bug.cgi?id=152541
rdar://problem/23886181
Modified: trunk/Source/WebCore/page/scrolling/ScrollingTreeFrameScrollingNode.cpp (194409 => 194410)
--- trunk/Source/WebCore/page/scrolling/ScrollingTreeFrameScrollingNode.cpp 2015-12-24 02:17:03 UTC (rev 194409)
+++ trunk/Source/WebCore/page/scrolling/ScrollingTreeFrameScrollingNode.cpp 2015-12-24 03:43:23 UTC (rev 194410)
@@ -82,10 +82,7 @@
void ScrollingTreeFrameScrollingNode::setScrollPosition(const FloatPoint& scrollPosition)
{
- FloatPoint newScrollPosition = scrollPosition;
- newScrollPosition = newScrollPosition.shrunkTo(maximumScrollPosition());
- newScrollPosition = newScrollPosition.expandedTo(minimumScrollPosition());
-
+ FloatPoint newScrollPosition = scrollPosition.constrainedBetween(minimumScrollPosition(), maximumScrollPosition());
setScrollPositionWithoutContentEdgeConstraints(newScrollPosition);
}
Modified: trunk/Source/WebCore/page/scrolling/ScrollingTreeScrollingNode.cpp (194409 => 194410)
--- trunk/Source/WebCore/page/scrolling/ScrollingTreeScrollingNode.cpp 2015-12-24 02:17:03 UTC (rev 194409)
+++ trunk/Source/WebCore/page/scrolling/ScrollingTreeScrollingNode.cpp 2015-12-24 03:43:23 UTC (rev 194410)
@@ -103,10 +103,7 @@
void ScrollingTreeScrollingNode::setScrollPosition(const FloatPoint& scrollPosition)
{
- FloatPoint newScrollPosition = scrollPosition;
- newScrollPosition = newScrollPosition.shrunkTo(maximumScrollPosition());
- newScrollPosition = newScrollPosition.expandedTo(minimumScrollPosition());
-
+ FloatPoint newScrollPosition = scrollPosition.constrainedBetween(minimumScrollPosition(), maximumScrollPosition());
setScrollPositionWithoutContentEdgeConstraints(newScrollPosition);
}
Modified: trunk/Source/WebCore/platform/ScrollView.cpp (194409 => 194410)
--- trunk/Source/WebCore/platform/ScrollView.cpp 2015-12-24 02:17:03 UTC (rev 194409)
+++ trunk/Source/WebCore/platform/ScrollView.cpp 2015-12-24 03:43:23 UTC (rev 194410)
@@ -403,9 +403,7 @@
if (!constrainsScrollingToContentEdge())
return scrollPoint;
- IntPoint newScrollPosition = scrollPoint.shrunkTo(maximumScrollPosition());
- newScrollPosition = newScrollPosition.expandedTo(minimumScrollPosition());
- return newScrollPosition;
+ return scrollPoint.constrainedBetween(minimumScrollPosition(), maximumScrollPosition());
}
IntSize ScrollView::documentScrollOffsetRelativeToViewOrigin() const
Modified: trunk/Source/WebCore/platform/graphics/FloatPoint.cpp (194409 => 194410)
--- trunk/Source/WebCore/platform/graphics/FloatPoint.cpp 2015-12-24 02:17:03 UTC (rev 194409)
+++ trunk/Source/WebCore/platform/graphics/FloatPoint.cpp 2015-12-24 03:43:23 UTC (rev 194410)
@@ -41,6 +41,14 @@
{
}
+FloatPoint FloatPoint::constrainedBetween(const FloatPoint& min, const FloatPoint& max) const
+{
+ return {
+ std::max(min.x(), std::min(max.x(), m_x)),
+ std::max(min.y(), std::min(max.y(), m_y))
+ };
+}
+
void FloatPoint::normalize()
{
float tempLength = length();
Modified: trunk/Source/WebCore/platform/graphics/FloatPoint.h (194409 => 194410)
--- trunk/Source/WebCore/platform/graphics/FloatPoint.h 2015-12-24 02:17:03 UTC (rev 194409)
+++ trunk/Source/WebCore/platform/graphics/FloatPoint.h 2015-12-24 03:43:23 UTC (rev 194410)
@@ -121,19 +121,21 @@
return m_x * m_x + m_y * m_y;
}
+ WEBCORE_EXPORT FloatPoint constrainedBetween(const FloatPoint& min, const FloatPoint& max) const;
+
FloatPoint shrunkTo(const FloatPoint& other) const
{
- return FloatPoint(std::min(m_x, other.m_x), std::min(m_y, other.m_y));
+ return { std::min(m_x, other.m_x), std::min(m_y, other.m_y) };
}
FloatPoint expandedTo(const FloatPoint& other) const
{
- return FloatPoint(std::max(m_x, other.m_x), std::max(m_y, other.m_y));
+ return { std::max(m_x, other.m_x), std::max(m_y, other.m_y) };
}
FloatPoint transposedPoint() const
{
- return FloatPoint(m_y, m_x);
+ return { m_y, m_x };
}
#if USE(CG)
Modified: trunk/Source/WebCore/platform/graphics/IntPoint.cpp (194409 => 194410)
--- trunk/Source/WebCore/platform/graphics/IntPoint.cpp 2015-12-24 02:17:03 UTC (rev 194409)
+++ trunk/Source/WebCore/platform/graphics/IntPoint.cpp 2015-12-24 03:43:23 UTC (rev 194410)
@@ -45,7 +45,6 @@
};
}
-
TextStream& operator<<(TextStream& ts, const IntPoint& p)
{
return ts << "(" << p.x() << "," << p.y() << ")";
Modified: trunk/Source/WebCore/platform/graphics/LayoutPoint.cpp (194409 => 194410)
--- trunk/Source/WebCore/platform/graphics/LayoutPoint.cpp 2015-12-24 02:17:03 UTC (rev 194409)
+++ trunk/Source/WebCore/platform/graphics/LayoutPoint.cpp 2015-12-24 03:43:23 UTC (rev 194410)
@@ -30,6 +30,14 @@
namespace WebCore {
+LayoutPoint LayoutPoint::constrainedBetween(const LayoutPoint& min, const LayoutPoint& max) const
+{
+ return {
+ std::max(min.x(), std::min(max.x(), m_x)),
+ std::max(min.y(), std::min(max.y(), m_y))
+ };
+}
+
TextStream& operator<<(TextStream& ts, const LayoutPoint& p)
{
// FIXME: These should be printed as floats. Keeping them ints for consistency with pervious test expectations.
Modified: trunk/Source/WebCore/platform/graphics/LayoutPoint.h (194409 => 194410)
--- trunk/Source/WebCore/platform/graphics/LayoutPoint.h 2015-12-24 02:17:03 UTC (rev 194409)
+++ trunk/Source/WebCore/platform/graphics/LayoutPoint.h 2015-12-24 03:43:23 UTC (rev 194410)
@@ -60,15 +60,17 @@
m_x *= sx;
m_y *= sy;
}
-
+
+ LayoutPoint constrainedBetween(const LayoutPoint& min, const LayoutPoint& max) const;
+
LayoutPoint expandedTo(const LayoutPoint& other) const
{
- return LayoutPoint(std::max(m_x, other.m_x), std::max(m_y, other.m_y));
+ return { std::max(m_x, other.m_x), std::max(m_y, other.m_y) };
}
LayoutPoint shrunkTo(const LayoutPoint& other) const
{
- return LayoutPoint(std::min(m_x, other.m_x), std::min(m_y, other.m_y));
+ return { std::min(m_x, other.m_x), std::min(m_y, other.m_y) };
}
void clampNegativeToZero()
@@ -78,15 +80,15 @@
LayoutPoint transposedPoint() const
{
- return LayoutPoint(m_y, m_x);
+ return { m_y, m_x };
}
LayoutPoint fraction() const
{
- return LayoutPoint(m_x.fraction(), m_y.fraction());
+ return { m_x.fraction(), m_y.fraction() };
}
- operator FloatPoint() const { return FloatPoint(m_x, m_y); }
+ operator FloatPoint() const { return { m_x, m_y }; }
private:
LayoutUnit m_x, m_y;
Modified: trunk/Source/WebKit2/ChangeLog (194409 => 194410)
--- trunk/Source/WebKit2/ChangeLog 2015-12-24 02:17:03 UTC (rev 194409)
+++ trunk/Source/WebKit2/ChangeLog 2015-12-24 03:43:23 UTC (rev 194410)
@@ -1,3 +1,19 @@
+2015-12-23 Simon Fraser <[email protected]>
+
+ Use "constrainedBetween" in more places
+ https://bugs.webkit.org/show_bug.cgi?id=152543
+
+ Reviewed by Zalan Bujtas.
+
+ Replace code that contrains points via shrunkTo/expandedTo() with calls
+ to constrainedBetween(), and implement constrainedBetween() on IntPoint,
+ FloatPoint and LayoutPoint.
+
+ Convert some functions that return points to more modern syntax.
+
+ * UIProcess/API/Cocoa/WKWebView.mm:
+ (constrainContentOffset):
+
2015-12-22 Hunseop Jeong <[email protected]>
[EFL] ewk_application_cache_manager test failed after r193812
Modified: trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm (194409 => 194410)
--- trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm 2015-12-24 02:17:03 UTC (rev 194409)
+++ trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm 2015-12-24 03:43:23 UTC (rev 194410)
@@ -1259,9 +1259,7 @@
static WebCore::FloatPoint constrainContentOffset(WebCore::FloatPoint contentOffset, WebCore::FloatSize contentSize, WebCore::FloatSize unobscuredContentSize)
{
WebCore::FloatSize maximumContentOffset = contentSize - unobscuredContentSize;
- contentOffset = contentOffset.shrunkTo(WebCore::FloatPoint(maximumContentOffset.width(), maximumContentOffset.height()));
- contentOffset = contentOffset.expandedTo(WebCore::FloatPoint());
- return contentOffset;
+ return contentOffset.constrainedBetween(WebCore::FloatPoint(), WebCore::FloatPoint(maximumContentOffset));
}
- (void)_scrollToContentOffset:(WebCore::FloatPoint)contentOffsetInPageCoordinates scrollOrigin:(WebCore::IntPoint)scrollOrigin