Changeset 194410 in webkit
- Timestamp:
- Dec 23, 2015, 7:43:23 PM (11 years ago)
- Location:
- trunk/Source
- Files:
-
- 11 edited
-
WebCore/ChangeLog (modified) (1 diff)
-
WebCore/page/scrolling/ScrollingTreeFrameScrollingNode.cpp (modified) (1 diff)
-
WebCore/page/scrolling/ScrollingTreeScrollingNode.cpp (modified) (1 diff)
-
WebCore/platform/ScrollView.cpp (modified) (1 diff)
-
WebCore/platform/graphics/FloatPoint.cpp (modified) (1 diff)
-
WebCore/platform/graphics/FloatPoint.h (modified) (1 diff)
-
WebCore/platform/graphics/IntPoint.cpp (modified) (1 diff)
-
WebCore/platform/graphics/LayoutPoint.cpp (modified) (1 diff)
-
WebCore/platform/graphics/LayoutPoint.h (modified) (2 diffs)
-
WebKit2/ChangeLog (modified) (1 diff)
-
WebKit2/UIProcess/API/Cocoa/WKWebView.mm (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r194405 r194410 1 2015-12-23 Simon Fraser <simon.fraser@apple.com> 2 3 Use "constrainedBetween" in more places 4 https://bugs.webkit.org/show_bug.cgi?id=152543 5 6 Reviewed by Zalan Bujtas. 7 8 Replace code that contrains points via shrunkTo/expandedTo() with calls 9 to constrainedBetween(), and implement constrainedBetween() on IntPoint, 10 FloatPoint and LayoutPoint. 11 12 Convert some functions that return points to more modern syntax. 13 14 * page/scrolling/ScrollingTreeFrameScrollingNode.cpp: 15 (WebCore::ScrollingTreeFrameScrollingNode::setScrollPosition): 16 * page/scrolling/ScrollingTreeScrollingNode.cpp: 17 (WebCore::ScrollingTreeScrollingNode::setScrollPosition): 18 * platform/ScrollView.cpp: 19 (WebCore::ScrollView::adjustScrollPositionWithinRange): 20 * platform/graphics/FloatPoint.cpp: 21 (WebCore::FloatPoint::constrainedBetween): 22 * platform/graphics/FloatPoint.h: 23 (WebCore::FloatPoint::shrunkTo): 24 (WebCore::FloatPoint::expandedTo): 25 (WebCore::FloatPoint::transposedPoint): 26 * platform/graphics/IntPoint.cpp: 27 * platform/graphics/LayoutPoint.cpp: 28 (WebCore::LayoutPoint::constrainedBetween): 29 * platform/graphics/LayoutPoint.h: 30 (WebCore::LayoutPoint::expandedTo): 31 (WebCore::LayoutPoint::shrunkTo): 32 (WebCore::LayoutPoint::transposedPoint): 33 (WebCore::LayoutPoint::fraction): 34 (WebCore::LayoutPoint::operator FloatPoint): 35 1 36 2015-12-23 Simon Fraser <simon.fraser@apple.com> 2 37 -
trunk/Source/WebCore/page/scrolling/ScrollingTreeFrameScrollingNode.cpp
r194004 r194410 83 83 void ScrollingTreeFrameScrollingNode::setScrollPosition(const FloatPoint& scrollPosition) 84 84 { 85 FloatPoint newScrollPosition = scrollPosition; 86 newScrollPosition = newScrollPosition.shrunkTo(maximumScrollPosition()); 87 newScrollPosition = newScrollPosition.expandedTo(minimumScrollPosition()); 88 85 FloatPoint newScrollPosition = scrollPosition.constrainedBetween(minimumScrollPosition(), maximumScrollPosition()); 89 86 setScrollPositionWithoutContentEdgeConstraints(newScrollPosition); 90 87 } -
trunk/Source/WebCore/page/scrolling/ScrollingTreeScrollingNode.cpp
r185762 r194410 104 104 void ScrollingTreeScrollingNode::setScrollPosition(const FloatPoint& scrollPosition) 105 105 { 106 FloatPoint newScrollPosition = scrollPosition; 107 newScrollPosition = newScrollPosition.shrunkTo(maximumScrollPosition()); 108 newScrollPosition = newScrollPosition.expandedTo(minimumScrollPosition()); 109 106 FloatPoint newScrollPosition = scrollPosition.constrainedBetween(minimumScrollPosition(), maximumScrollPosition()); 110 107 setScrollPositionWithoutContentEdgeConstraints(newScrollPosition); 111 108 } -
trunk/Source/WebCore/platform/ScrollView.cpp
r194405 r194410 404 404 return scrollPoint; 405 405 406 IntPoint newScrollPosition = scrollPoint.shrunkTo(maximumScrollPosition()); 407 newScrollPosition = newScrollPosition.expandedTo(minimumScrollPosition()); 408 return newScrollPosition; 406 return scrollPoint.constrainedBetween(minimumScrollPosition(), maximumScrollPosition()); 409 407 } 410 408 -
trunk/Source/WebCore/platform/graphics/FloatPoint.cpp
r191216 r194410 40 40 FloatPoint::FloatPoint(const IntPoint& p) : m_x(p.x()), m_y(p.y()) 41 41 { 42 } 43 44 FloatPoint FloatPoint::constrainedBetween(const FloatPoint& min, const FloatPoint& max) const 45 { 46 return { 47 std::max(min.x(), std::min(max.x(), m_x)), 48 std::max(min.y(), std::min(max.y(), m_y)) 49 }; 42 50 } 43 51 -
trunk/Source/WebCore/platform/graphics/FloatPoint.h
r191216 r194410 122 122 } 123 123 124 WEBCORE_EXPORT FloatPoint constrainedBetween(const FloatPoint& min, const FloatPoint& max) const; 125 124 126 FloatPoint shrunkTo(const FloatPoint& other) const 125 127 { 126 return FloatPoint(std::min(m_x, other.m_x), std::min(m_y, other.m_y));128 return { std::min(m_x, other.m_x), std::min(m_y, other.m_y) }; 127 129 } 128 130 129 131 FloatPoint expandedTo(const FloatPoint& other) const 130 132 { 131 return FloatPoint(std::max(m_x, other.m_x), std::max(m_y, other.m_y));133 return { std::max(m_x, other.m_x), std::max(m_y, other.m_y) }; 132 134 } 133 135 134 136 FloatPoint transposedPoint() const 135 137 { 136 return FloatPoint(m_y, m_x);138 return { m_y, m_x }; 137 139 } 138 140 -
trunk/Source/WebCore/platform/graphics/IntPoint.cpp
r194405 r194410 46 46 } 47 47 48 49 48 TextStream& operator<<(TextStream& ts, const IntPoint& p) 50 49 { -
trunk/Source/WebCore/platform/graphics/LayoutPoint.cpp
r191216 r194410 31 31 namespace WebCore { 32 32 33 LayoutPoint LayoutPoint::constrainedBetween(const LayoutPoint& min, const LayoutPoint& max) const 34 { 35 return { 36 std::max(min.x(), std::min(max.x(), m_x)), 37 std::max(min.y(), std::min(max.y(), m_y)) 38 }; 39 } 40 33 41 TextStream& operator<<(TextStream& ts, const LayoutPoint& p) 34 42 { -
trunk/Source/WebCore/platform/graphics/LayoutPoint.h
r191216 r194410 61 61 m_y *= sy; 62 62 } 63 63 64 LayoutPoint constrainedBetween(const LayoutPoint& min, const LayoutPoint& max) const; 65 64 66 LayoutPoint expandedTo(const LayoutPoint& other) const 65 67 { 66 return LayoutPoint(std::max(m_x, other.m_x), std::max(m_y, other.m_y));68 return { std::max(m_x, other.m_x), std::max(m_y, other.m_y) }; 67 69 } 68 70 69 71 LayoutPoint shrunkTo(const LayoutPoint& other) const 70 72 { 71 return LayoutPoint(std::min(m_x, other.m_x), std::min(m_y, other.m_y));73 return { std::min(m_x, other.m_x), std::min(m_y, other.m_y) }; 72 74 } 73 75 … … 79 81 LayoutPoint transposedPoint() const 80 82 { 81 return LayoutPoint(m_y, m_x);83 return { m_y, m_x }; 82 84 } 83 85 84 86 LayoutPoint fraction() const 85 87 { 86 return LayoutPoint(m_x.fraction(), m_y.fraction());87 } 88 89 operator FloatPoint() const { return FloatPoint(m_x, m_y); }88 return { m_x.fraction(), m_y.fraction() }; 89 } 90 91 operator FloatPoint() const { return { m_x, m_y }; } 90 92 91 93 private: -
trunk/Source/WebKit2/ChangeLog
r194384 r194410 1 2015-12-23 Simon Fraser <simon.fraser@apple.com> 2 3 Use "constrainedBetween" in more places 4 https://bugs.webkit.org/show_bug.cgi?id=152543 5 6 Reviewed by Zalan Bujtas. 7 8 Replace code that contrains points via shrunkTo/expandedTo() with calls 9 to constrainedBetween(), and implement constrainedBetween() on IntPoint, 10 FloatPoint and LayoutPoint. 11 12 Convert some functions that return points to more modern syntax. 13 14 * UIProcess/API/Cocoa/WKWebView.mm: 15 (constrainContentOffset): 16 1 17 2015-12-22 Hunseop Jeong <hs85.jeong@samsung.com> 2 18 -
trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm
r194318 r194410 1260 1260 { 1261 1261 WebCore::FloatSize maximumContentOffset = contentSize - unobscuredContentSize; 1262 contentOffset = contentOffset.shrunkTo(WebCore::FloatPoint(maximumContentOffset.width(), maximumContentOffset.height())); 1263 contentOffset = contentOffset.expandedTo(WebCore::FloatPoint()); 1264 return contentOffset; 1262 return contentOffset.constrainedBetween(WebCore::FloatPoint(), WebCore::FloatPoint(maximumContentOffset)); 1265 1263 } 1266 1264
Note:
See TracChangeset
for help on using the changeset viewer.