Changeset 183510 in webkit
- Timestamp:
- Apr 28, 2015, 2:51:04 PM (10 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r183509 r183510 1 2015-04-28 Simon Fraser <simon.fraser@apple.com> 2 3 Provide contentsToView() and viewToContents() functions on ScrollView, and use them 4 https://bugs.webkit.org/show_bug.cgi?id=144357 5 6 Reviewed by Tim Horton. 7 8 Too much code was consulting topContentInset() and headerHeight() directly. Replace 9 with calls to new contentsToView() and viewToContents() functions, which wrap the 10 exisiting documentScrollOffsetRelativeToViewOrigin(). 11 12 Use the new functions in FrameView and ScrollView coordinate mapping functions. 13 14 No behavior change. 15 16 * page/FrameView.cpp: 17 (WebCore::FrameView::convertFromRendererToContainingView): 18 (WebCore::FrameView::convertFromContainingViewToRenderer): 19 * platform/ScrollView.cpp: 20 (WebCore::ScrollView::viewToContents): 21 (WebCore::ScrollView::contentsToView): 22 (WebCore::ScrollView::rootViewToContents): 23 (WebCore::ScrollView::contentsToRootView): 24 (WebCore::ScrollView::rootViewToTotalContents): 25 (WebCore::ScrollView::windowToContents): 26 (WebCore::ScrollView::contentsToWindow): 27 * platform/ScrollView.h: 28 1 29 2015-04-28 Eric Carlson <eric.carlson@apple.com> 2 30 -
trunk/Source/WebCore/page/FrameView.cpp
r183173 r183510 4200 4200 IntRect rect = snappedIntRect(enclosingLayoutRect(renderer->localToAbsoluteQuad(FloatRect(rendererRect)).boundingBox())); 4201 4201 4202 // Convert from page ("absolute") to FrameView coordinates.4203 4202 if (!delegatesScrolling()) 4204 rect .moveBy(-scrollPosition() + IntPoint(0, headerHeight() + topContentInset(TopContentInsetType::WebCoreOrPlatformContentInset)));4203 rect = contentsToView(rect); 4205 4204 4206 4205 return rect; … … 4213 4212 // Convert from FrameView coords into page ("absolute") coordinates. 4214 4213 if (!delegatesScrolling()) 4215 rect .moveBy(documentScrollPositionRelativeToViewOrigin());4214 rect = viewToContents(rect); 4216 4215 4217 4216 // FIXME: we don't have a way to map an absolute rect down to a local quad, so just … … 4227 4226 // Convert from page ("absolute") to FrameView coordinates. 4228 4227 if (!delegatesScrolling()) 4229 point.moveBy(-scrollPosition() + IntPoint(0, headerHeight() + topContentInset(TopContentInsetType::WebCoreOrPlatformContentInset))); 4228 point = contentsToView(point); 4229 4230 4230 return point; 4231 4231 } … … 4237 4237 // Convert from FrameView coords into page ("absolute") coordinates. 4238 4238 if (!delegatesScrolling()) 4239 point = point + documentScrollPositionRelativeToViewOrigin();4239 point = viewToContents(point); 4240 4240 4241 4241 return roundedIntPoint(renderer->absoluteToLocal(point, UseTransforms)); -
trunk/Source/WebCore/platform/ScrollView.cpp
r182364 r183510 865 865 } 866 866 867 IntPoint ScrollView::viewToContents(const IntPoint& point) const 868 { 869 return point + documentScrollOffsetRelativeToViewOrigin(); 870 } 871 872 IntPoint ScrollView::contentsToView(const IntPoint& point) const 873 { 874 return point - documentScrollOffsetRelativeToViewOrigin(); 875 } 876 877 IntRect ScrollView::viewToContents(IntRect rect) const 878 { 879 rect.move(documentScrollOffsetRelativeToViewOrigin()); 880 return rect; 881 } 882 883 IntRect ScrollView::contentsToView(IntRect rect) const 884 { 885 rect.move(-documentScrollOffsetRelativeToViewOrigin()); 886 return rect; 887 } 888 867 889 IntPoint ScrollView::rootViewToContents(const IntPoint& rootViewPoint) const 868 890 { … … 870 892 return convertFromRootView(rootViewPoint); 871 893 872 IntPoint viewPoint = convertFromRootView(rootViewPoint); 873 return viewPoint + documentScrollOffsetRelativeToViewOrigin(); 894 return viewToContents(convertFromRootView(rootViewPoint)); 874 895 } 875 896 … … 879 900 return convertToRootView(contentsPoint); 880 901 881 IntPoint viewPoint = contentsPoint + IntSize(0, headerHeight() + topContentInset(TopContentInsetType::WebCoreOrPlatformContentInset)) - scrollOffset(); 882 return convertToRootView(viewPoint); 902 return convertToRootView(contentsToView(contentsPoint)); 883 903 } 884 904 … … 888 908 return convertFromRootView(rootViewRect); 889 909 890 IntRect viewRect = convertFromRootView(rootViewRect); 891 viewRect.move(documentScrollOffsetRelativeToViewOrigin()); 892 return viewRect; 910 return viewToContents(convertFromRootView(rootViewRect)); 911 } 912 913 IntPoint ScrollView::rootViewToTotalContents(const IntPoint& rootViewPoint) const 914 { 915 if (delegatesScrolling()) 916 return convertFromRootView(rootViewPoint); 917 918 IntPoint viewPoint = convertFromRootView(rootViewPoint); 919 // Like rootViewToContents(), but ignores headerHeight. 920 return viewPoint + scrollOffset() - IntSize(0, topContentInset(TopContentInsetType::WebCoreOrPlatformContentInset)); 893 921 } 894 922 … … 898 926 return convertToRootView(contentsRect); 899 927 900 IntRect viewRect = contentsRect; 901 viewRect.move(-scrollOffset() + IntSize(0, headerHeight() + topContentInset(TopContentInsetType::WebCoreOrPlatformContentInset))); 902 return convertToRootView(viewRect); 903 } 904 905 IntPoint ScrollView::rootViewToTotalContents(const IntPoint& rootViewPoint) const 906 { 907 if (delegatesScrolling()) 908 return convertFromRootView(rootViewPoint); 909 910 IntPoint viewPoint = convertFromRootView(rootViewPoint); 911 return viewPoint + scrollOffset() - IntSize(0, topContentInset(TopContentInsetType::WebCoreOrPlatformContentInset)); 928 return convertToRootView(contentsToView(contentsRect)); 912 929 } 913 930 … … 917 934 return convertFromContainingWindow(windowPoint); 918 935 919 IntPoint viewPoint = convertFromContainingWindow(windowPoint); 920 return viewPoint + documentScrollOffsetRelativeToViewOrigin(); 936 return viewToContents(convertFromContainingWindow(windowPoint)); 921 937 } 922 938 … … 926 942 return convertToContainingWindow(contentsPoint); 927 943 928 IntPoint viewPoint = contentsPoint + IntSize(0, headerHeight() + topContentInset(TopContentInsetType::WebCoreOrPlatformContentInset)) - scrollOffset(); 929 return convertToContainingWindow(viewPoint); 944 return convertToContainingWindow(contentsToView(contentsPoint)); 930 945 } 931 946 … … 935 950 return convertFromContainingWindow(windowRect); 936 951 937 IntRect viewRect = convertFromContainingWindow(windowRect); 938 viewRect.move(documentScrollOffsetRelativeToViewOrigin()); 939 return viewRect; 952 return viewToContents(convertFromContainingWindow(windowRect)); 940 953 } 941 954 … … 945 958 return convertToContainingWindow(contentsRect); 946 959 947 IntRect viewRect = contentsRect; 948 viewRect.move(-scrollOffset() + IntSize(0, headerHeight() + topContentInset(TopContentInsetType::WebCoreOrPlatformContentInset))); 949 return convertToContainingWindow(viewRect); 960 return convertToContainingWindow(contentsToView(contentsRect)); 950 961 } 951 962 -
trunk/Source/WebCore/platform/ScrollView.h
r180615 r183510 293 293 WEBCORE_EXPORT IntRect contentsToRootView(const IntRect&) const; 294 294 295 IntPoint viewToContents(const IntPoint&) const; 296 IntPoint contentsToView(const IntPoint&) const; 297 298 IntRect viewToContents(IntRect) const; 299 IntRect contentsToView(IntRect) const; 300 295 301 WEBCORE_EXPORT IntPoint rootViewToTotalContents(const IntPoint&) const; 296 302
Note:
See TracChangeset
for help on using the changeset viewer.