Title: [171246] trunk/Source/WebCore
- Revision
- 171246
- Author
- [email protected]
- Date
- 2014-07-18 15:24:36 -0700 (Fri, 18 Jul 2014)
Log Message
Fixed position elements are misplaced when a WK1 view has contentInsets set
https://bugs.webkit.org/show_bug.cgi?id=135031
-and corresponding-
<rdar://problem/17682335>
Reviewed by Tim Horton.
[NSScrollView documentVisibleRect] includes content that is within the inset-area
of a view, but WebCore is interested in the content that is fully visible, so we
need to factor the inset sizes out of this rect.
Implement contract() to avoid the awkwardness of calling expand() with negative
values.
* platform/graphics/IntSize.h:
(WebCore::IntSize::contract):
Factor out insets
* platform/mac/ScrollViewMac.mm:
(WebCore::ScrollView::platformVisibleContentRect):
(WebCore::ScrollView::platformVisibleContentSize):
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (171245 => 171246)
--- trunk/Source/WebCore/ChangeLog 2014-07-18 22:08:19 UTC (rev 171245)
+++ trunk/Source/WebCore/ChangeLog 2014-07-18 22:24:36 UTC (rev 171246)
@@ -1,3 +1,26 @@
+2014-07-18 Beth Dakin <[email protected]>
+
+ Fixed position elements are misplaced when a WK1 view has contentInsets set
+ https://bugs.webkit.org/show_bug.cgi?id=135031
+ -and corresponding-
+ <rdar://problem/17682335>
+
+ Reviewed by Tim Horton.
+
+ [NSScrollView documentVisibleRect] includes content that is within the inset-area
+ of a view, but WebCore is interested in the content that is fully visible, so we
+ need to factor the inset sizes out of this rect.
+
+ Implement contract() to avoid the awkwardness of calling expand() with negative
+ values.
+ * platform/graphics/IntSize.h:
+ (WebCore::IntSize::contract):
+
+ Factor out insets
+ * platform/mac/ScrollViewMac.mm:
+ (WebCore::ScrollView::platformVisibleContentRect):
+ (WebCore::ScrollView::platformVisibleContentSize):
+
2014-07-18 Tim Horton <[email protected]>
Take navigation snapshots whenever the current back-forward item is going to change
Modified: trunk/Source/WebCore/platform/graphics/IntSize.h (171245 => 171246)
--- trunk/Source/WebCore/platform/graphics/IntSize.h 2014-07-18 22:08:19 UTC (rev 171245)
+++ trunk/Source/WebCore/platform/graphics/IntSize.h 2014-07-18 22:24:36 UTC (rev 171246)
@@ -81,6 +81,12 @@
m_height += height;
}
+ void contract(int width, int height)
+ {
+ m_width -= width;
+ m_height -= height;
+ }
+
void scale(float widthScale, float heightScale)
{
m_width = static_cast<int>(static_cast<float>(m_width) * widthScale);
Modified: trunk/Source/WebCore/platform/mac/ScrollViewMac.mm (171245 => 171246)
--- trunk/Source/WebCore/platform/mac/ScrollViewMac.mm 2014-07-18 22:08:19 UTC (rev 171245)
+++ trunk/Source/WebCore/platform/mac/ScrollViewMac.mm 2014-07-18 22:24:36 UTC (rev 171246)
@@ -34,6 +34,10 @@
#import "NotImplemented.h"
#import "WebCoreFrameView.h"
+@interface NSScrollView (Details)
+- (NSEdgeInsets)contentInsets;
+@end
+
@interface NSWindow (WebWindowDetails)
- (BOOL)_needsToResetDragMargins;
- (void)_setNeedsToResetDragMargins:(BOOL)needs;
@@ -107,23 +111,30 @@
IntRect ScrollView::platformVisibleContentRect(bool includeScrollbars) const
{
BEGIN_BLOCK_OBJC_EXCEPTIONS;
- IntRect result = enclosingIntRect([scrollView() documentVisibleRect]);
- if (includeScrollbars)
- result.setSize(IntSize([scrollView() frame].size));
- return result;
+
+ IntRect visibleContentRect = enclosingIntRect([scrollView() documentVisibleRect]);
+#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 10100
+ visibleContentRect.move(scrollView().contentInsets.left, scrollView().contentInsets.top);
+ visibleContentRect.contract(scrollView().contentInsets.left + scrollView().contentInsets.right, scrollView().contentInsets.top + scrollView().contentInsets.bottom);
+#endif
+
+ if (includeScrollbars) {
+ IntSize frameSize = IntSize([scrollView() frame].size);
+#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 10100
+ frameSize.contract(scrollView().contentInsets.left + scrollView().contentInsets.right, scrollView().contentInsets.top + scrollView().contentInsets.bottom);
+#endif
+ visibleContentRect.setSize(frameSize);
+ }
+
+ return visibleContentRect;
END_BLOCK_OBJC_EXCEPTIONS;
+
return IntRect();
}
IntSize ScrollView::platformVisibleContentSize(bool includeScrollbars) const
{
- BEGIN_BLOCK_OBJC_EXCEPTIONS;
- if (includeScrollbars)
- return IntSize([scrollView() frame].size);
-
- return expandedIntSize(FloatSize([scrollView() documentVisibleRect].size));
- END_BLOCK_OBJC_EXCEPTIONS;
- return IntSize();
+ return platformVisibleContentRect(includeScrollbars).size();
}
void ScrollView::platformSetContentsSize()
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes