Title: [171207] trunk/Source/WebCore
Revision
171207
Author
[email protected]
Date
2014-07-17 16:49:21 -0700 (Thu, 17 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] is not the rect that we are looking for when 
this function is called. WebCore is interested in the rect that does not include 
content that is within the inset region.

Implement contract() to avoid the awkwardness of calling expand() with negative 
values.
* platform/graphics/IntSize.h:
(WebCore::IntSize::contract):

Use _insetBounds instead of documentVisibleRect, and when it’s necessary to use 
the frame’s dimensions, extract the inset from that size.
* platform/mac/ScrollViewMac.mm:
(WebCore::ScrollView::platformVisibleContentRect):
(WebCore::ScrollView::platformVisibleContentSize):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (171206 => 171207)


--- trunk/Source/WebCore/ChangeLog	2014-07-17 23:39:18 UTC (rev 171206)
+++ trunk/Source/WebCore/ChangeLog	2014-07-17 23:49:21 UTC (rev 171207)
@@ -1,3 +1,27 @@
+2014-07-17  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] is not the rect that we are looking for when 
+        this function is called. WebCore is interested in the rect that does not include 
+        content that is within the inset region.
+
+        Implement contract() to avoid the awkwardness of calling expand() with negative 
+        values.
+        * platform/graphics/IntSize.h:
+        (WebCore::IntSize::contract):
+
+        Use _insetBounds instead of documentVisibleRect, and when it’s necessary to use 
+        the frame’s dimensions, extract the inset from that size.
+        * platform/mac/ScrollViewMac.mm:
+        (WebCore::ScrollView::platformVisibleContentRect):
+        (WebCore::ScrollView::platformVisibleContentSize):
+
 2014-07-17  Enrica Casucci  <[email protected]>
 
         [REGRESSION WK2]The menu bar does not show up when tapping on the caret.

Modified: trunk/Source/WebCore/platform/graphics/IntSize.h (171206 => 171207)


--- trunk/Source/WebCore/platform/graphics/IntSize.h	2014-07-17 23:39:18 UTC (rev 171206)
+++ trunk/Source/WebCore/platform/graphics/IntSize.h	2014-07-17 23:49:21 UTC (rev 171207)
@@ -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 (171206 => 171207)


--- trunk/Source/WebCore/platform/mac/ScrollViewMac.mm	2014-07-17 23:39:18 UTC (rev 171206)
+++ trunk/Source/WebCore/platform/mac/ScrollViewMac.mm	2014-07-17 23:49:21 UTC (rev 171207)
@@ -34,6 +34,14 @@
 #import "NotImplemented.h"
 #import "WebCoreFrameView.h"
 
+@interface NSClipView (Details)
+- (NSRect)_insetBounds;
+@end
+
+@interface NSScrollView (Details)
+- (NSEdgeInsets)contentInsets;
+@end
+
 @interface NSWindow (WebWindowDetails)
 - (BOOL)_needsToResetDragMargins;
 - (void)_setNeedsToResetDragMargins:(BOOL)needs;
@@ -107,23 +115,31 @@
 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;
+#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 10100
+    visibleContentRect = enclosingIntRect([[scrollView() contentView] _insetBounds]);
+#else
+    visibleContentRect = enclosingIntRect([scrollView() documentVisibleRect]);
+#endif
+
+    if (includeScrollbars) {
+        IntSize frameSize([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

Reply via email to