REGRESSION (r170361): In landscape with UI hidden, fixed position elements at top...
authorsimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 22 Jul 2014 00:58:40 +0000 (00:58 +0000)
committersimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 22 Jul 2014 00:58:40 +0000 (00:58 +0000)
https://bugs.webkit.org/show_bug.cgi?id=135141
<rdar://problem/17627525>

Reviewed by Benjamin Poulain.

We can't use the WKWebView's UIScrollView contentInsets to determine the unobscured rect
in MobileSafari, because contentInsets can't be changed dynamically while scrolling.
To get around this, MobileSafari sets obscured insets instead (but also sets a fixed
contentInset).

So if the client calls _setObscuredInsets:, always use _obscuredInsets to compute the
content insets.

* UIProcess/API/Cocoa/WKWebView.mm:
(-[WKWebView _computedContentInset]):
(-[WKWebView _setObscuredInsets:]):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@171329 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebKit2/ChangeLog
Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm

index bb7d6eec2bdb791daf2938f805a7cdf618c6d1d1..cf975f4c8f29acb0f5c59ca203790f3c6ca8303c 100644 (file)
@@ -1,3 +1,23 @@
+2014-07-21  Simon Fraser  <simon.fraser@apple.com>
+
+        REGRESSION (r170361): In landscape with UI hidden, fixed position elements at top of screen are too low
+        https://bugs.webkit.org/show_bug.cgi?id=135141
+        <rdar://problem/17627525>
+
+        Reviewed by Benjamin Poulain.
+        
+        We can't use the WKWebView's UIScrollView contentInsets to determine the unobscured rect
+        in MobileSafari, because contentInsets can't be changed dynamically while scrolling.
+        To get around this, MobileSafari sets obscured insets instead (but also sets a fixed
+        contentInset).
+        
+        So if the client calls _setObscuredInsets:, always use _obscuredInsets to compute the 
+        content insets.
+
+        * UIProcess/API/Cocoa/WKWebView.mm:
+        (-[WKWebView _computedContentInset]):
+        (-[WKWebView _setObscuredInsets:]):
+
 2014-07-21  Oliver Hunt  <oliver@apple.com>
 
         Remove global cookie workaround from sandbox profiles
index bbe9995fc443195d69510f8229f11a4790fb0f69..ff1a3d13fa106f9d10ca712601e3e9804ba53502 100644 (file)
@@ -168,7 +168,8 @@ WKWebView* fromWebPageProxy(WebKit::WebPageProxy& page)
     CGFloat _viewportMetaTagWidth;
 
     UIEdgeInsets _obscuredInsets;
-    bool _isChangingObscuredInsetsInteractively;
+    BOOL _haveSetObscuredInsets;
+    BOOL _isChangingObscuredInsetsInteractively;
 
     UIInterfaceOrientation _interfaceOrientationOverride;
     BOOL _overridesInterfaceOrientation;
@@ -740,7 +741,7 @@ static WebCore::Color scrollViewBackgroundColor(WKWebView *webView)
 
 - (UIEdgeInsets)_computedContentInset
 {
-    if (!UIEdgeInsetsEqualToEdgeInsets(_obscuredInsets, UIEdgeInsetsZero))
+    if (_haveSetObscuredInsets)
         return _obscuredInsets;
 
     return [_scrollView contentInset];
@@ -2076,6 +2077,8 @@ static inline WebKit::FindOptions toFindOptions(_WKFindOptions wkFindOptions)
     ASSERT(obscuredInsets.left >= 0);
     ASSERT(obscuredInsets.bottom >= 0);
     ASSERT(obscuredInsets.right >= 0);
+    
+    _haveSetObscuredInsets = YES;
 
     if (UIEdgeInsetsEqualToEdgeInsets(_obscuredInsets, obscuredInsets))
         return;