Changeset 170361 in webkit
- Timestamp:
- Jun 24, 2014 7:38:17 AM (10 years ago)
- Location:
- trunk/Source/WebKit2
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit2/ChangeLog
r170348 r170361 1 2014-06-24 Anders Carlsson <andersca@apple.com> 2 3 WKWebView doesn't respect -[UIScrollView contentInset] 4 https://bugs.webkit.org/show_bug.cgi?id=134230 5 <rdar://problem/17429107> 6 7 Reviewed by Tim Horton. 8 9 * UIProcess/API/Cocoa/WKWebView.mm: 10 (-[WKWebView _setHasCustomContentView:loadedMIMEType:WTF::]): 11 Call initWithFrame and pass the WKWebView along. 12 13 (-[WKWebView _adjustedContentOffset:]): 14 New helper method that takes a content offset as a CGPoint and offsets it by the computed content inset. 15 16 (-[WKWebView _computedContentInset]): 17 New helper method that returns the _obscuredInsets, or if it's zero, the scroll view's content inset. 18 19 (-[WKWebView _processDidExit]): 20 Use _computedContentInset. 21 22 (-[WKWebView _didCommitLayerTree:WebKit::]): 23 use _computedContentInset. 24 25 (-[WKWebView _dynamicViewportUpdateChangedTargetToScale:position:]): 26 Use _computedContentInset. 27 28 (-[WKWebView _scrollToContentOffset:WebCore::]): 29 Use _computedContentInset. 30 31 (-[WKWebView _updateVisibleContentRects]): 32 If we have a custom content view, call web_computedContentInsetDidChange. 33 34 (-[WKWebView _setObscuredInsets:]): 35 Don't call web_setObscuredInsets: if we have a custom content view. 36 37 * UIProcess/API/Cocoa/WKWebViewInternal.h: 38 Add new methods. 39 40 * UIProcess/Cocoa/WKWebViewContentProvider.h: 41 Add new methods. 42 43 * UIProcess/ios/WKPDFView.mm: 44 (-[WKPDFView web_initWithFrame:webView:]): 45 Set the _webView and _scrollView ivars. 46 47 (-[WKPDFView _offsetForPageNumberIndicator]): 48 Get the computed content offset from the WKWebView. 49 50 (-[WKPDFView web_computedContentInsetDidChange]): 51 Update the page indicator. 52 53 (-[WKPDFView initWithFrame:]): Deleted. 54 (-[WKPDFView web_setObscuredInsets:]): Deleted. 55 56 * UIProcess/ios/WKScrollView.mm: 57 (-[WKScrollView setContentInset:]): 58 Call _updateVisibleContentRects. 59 1 60 2014-06-23 Jaehun Lim <ljaehun.lim@samsung.com> 2 61 -
trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm
r170335 r170361 590 590 Class representationClass = [[_configuration _contentProviderRegistry] providerForMIMEType:mimeType]; 591 591 ASSERT(representationClass); 592 _customContentView = adoptNS([[representationClass alloc] init]);592 _customContentView = adoptNS([[representationClass alloc] web_initWithFrame:self.bounds webView:self]); 593 593 _customContentFixedOverlayView = adoptNS([[UIView alloc] initWithFrame:self.bounds]); 594 594 [_customContentFixedOverlayView setUserInteractionEnabled:NO]; … … 599 599 600 600 [_customContentView web_setMinimumSize:self.bounds.size]; 601 [_customContentView web_setScrollView:_scrollView.get()];602 [_customContentView web_setObscuredInsets:_obscuredInsets];603 601 [_customContentView web_setFixedOverlayView:_customContentFixedOverlayView.get()]; 604 602 } else if (_customContentView) { … … 690 688 } 691 689 690 - (CGPoint)_adjustedContentOffset:(CGPoint)point 691 { 692 CGPoint result = point; 693 UIEdgeInsets contentInset = [self _computedContentInset]; 694 695 result.x -= contentInset.left; 696 result.y -= contentInset.top; 697 698 return result; 699 } 700 701 - (UIEdgeInsets)_computedContentInset 702 { 703 if (!UIEdgeInsetsEqualToEdgeInsets(_obscuredInsets, UIEdgeInsetsZero)) 704 return _obscuredInsets; 705 706 return [_scrollView contentInset]; 707 } 708 692 709 - (void)_processDidExit 693 710 { … … 703 720 [_contentView setFrame:self.bounds]; 704 721 [_scrollView setBackgroundColor:[UIColor whiteColor]]; 705 [_scrollView setContentOffset: CGPointMake(-_obscuredInsets.left, -_obscuredInsets.top)];722 [_scrollView setContentOffset:[self _adjustedContentOffset:CGPointZero]]; 706 723 [_scrollView setZoomScale:1]; 707 724 … … 779 796 if (_needsResetViewStateAfterCommitLoadForMainFrame && layerTreeTransaction.transactionID() >= _firstPaintAfterCommitLoadTransactionID) { 780 797 _needsResetViewStateAfterCommitLoadForMainFrame = NO; 781 [_scrollView setContentOffset: CGPointMake(-_obscuredInsets.left, -_obscuredInsets.top)];798 [_scrollView setContentOffset:[self _adjustedContentOffset:CGPointZero]]; 782 799 [self _updateVisibleContentRects]; 783 800 } … … 820 837 _resizeAnimationTransformAdjustments = CATransform3DMakeScale(scale, scale, 0); 821 838 822 CGPoint newContentOffset = CGPointMake(newScrollPosition.x * newScale, newScrollPosition.y * newScale); 823 newContentOffset.x -= _obscuredInsets.left; 824 newContentOffset.y -= _obscuredInsets.top; 839 CGPoint newContentOffset = [self _adjustedContentOffset:CGPointMake(newScrollPosition.x * newScale, newScrollPosition.y * newScale)]; 825 840 CGPoint currentContentOffset = [_scrollView contentOffset]; 826 841 … … 943 958 scaledOffset.scale(zoomScale, zoomScale); 944 959 945 scaledOffset -= WebCore::FloatSize(_obscuredInsets.left, _obscuredInsets.top); 946 [_scrollView setContentOffset:scaledOffset]; 960 [_scrollView setContentOffset:[self _adjustedContentOffset:scaledOffset]]; 947 961 } 948 962 … … 1268 1282 - (void)_updateVisibleContentRects 1269 1283 { 1270 if (![self usesStandardContentView]) 1271 return; 1284 if (![self usesStandardContentView]) { 1285 [_customContentView web_computedContentInsetDidChange]; 1286 return 1287 } 1272 1288 1273 1289 if (_delayUpdateVisibleContentRects) { … … 1285 1301 CGRect visibleRectInContentCoordinates = [self convertRect:fullViewRect toView:_contentView.get()]; 1286 1302 1287 CGRect unobscuredRect = UIEdgeInsetsInsetRect(fullViewRect, _obscuredInsets);1303 CGRect unobscuredRect = UIEdgeInsetsInsetRect(fullViewRect, [self _computedContentInset]); 1288 1304 CGRect unobscuredRectInContentCoordinates = [self convertRect:unobscuredRect toView:_contentView.get()]; 1289 1305 … … 1924 1940 1925 1941 [self _updateVisibleContentRects]; 1926 [_customContentView web_setObscuredInsets:obscuredInsets];1927 1942 } 1928 1943 -
trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewInternal.h
r170325 r170361 89 89 - (void)_willInvokeUIScrollViewDelegateCallback; 90 90 - (void)_didInvokeUIScrollViewDelegateCallback; 91 92 - (void)_updateVisibleContentRects; 93 94 @property (nonatomic, readonly) UIEdgeInsets _computedContentInset; 95 91 96 #endif 92 97 @end -
trunk/Source/WebKit2/UIProcess/Cocoa/WKWebViewContentProvider.h
r169290 r170361 33 33 @class UIScrollView; 34 34 @class UIView; 35 @class WKWebView; 35 36 @protocol NSObject; 36 37 @protocol UIScrollViewDelegate; … … 41 42 @protocol WKWebViewContentProvider <NSObject, UIScrollViewDelegate> 42 43 44 - (instancetype)web_initWithFrame:(CGRect) frame webView:(WKWebView *)webView; 43 45 - (void)web_setContentProviderData:(NSData *)data suggestedFilename:(NSString *)filename; 44 46 - (void)web_setMinimumSize:(CGSize)size; 45 - (void)web_setScrollView:(UIScrollView *)scrollView;46 - (void)web_setObscuredInsets:(UIEdgeInsets)insets;47 47 - (void)web_setOverlaidAccessoryViewsInset:(CGSize)inset; 48 - (void)web_computedContentInsetDidChange; 48 49 - (void)web_setFixedOverlayView:(UIView *)fixedOverlayView; 49 50 -
trunk/Source/WebKit2/UIProcess/ios/WKPDFView.mm
r169290 r170361 30 30 31 31 #import "WKPDFPageNumberIndicator.h" 32 #import "WKWebViewInternal.h" 32 33 #import <CorePDF/UIPDFDocument.h> 34 #import <CorePDF/UIPDFPage.h> 33 35 #import <CorePDF/UIPDFPageView.h> 34 36 #import <WebCore/FloatRect.h> … … 61 63 CGSize _minimumSize; 62 64 CGSize _overlaidAccessoryViewsInset; 63 UIEdgeInsets _obscuredInsets;65 WKWebView *_webView; 64 66 UIScrollView *_scrollView; 65 67 UIView *_fixedOverlayView; 66 68 } 67 69 68 - (instancetype) initWithFrame:(CGRect)frame70 - (instancetype)web_initWithFrame:(CGRect)frame webView:(WKWebView *)webView 69 71 { 70 72 if (!(self = [super initWithFrame:frame])) … … 72 74 73 75 self.backgroundColor = [UIColor grayColor]; 76 77 _webView = webView; 78 79 _scrollView = webView.scrollView; 80 [_scrollView setMinimumZoomScale:pdfMinimumZoomScale]; 81 [_scrollView setMaximumZoomScale:pdfMaximumZoomScale]; 82 [_scrollView setContentSize:_documentFrame.size]; 83 [_scrollView setBackgroundColor:[UIColor grayColor]]; 74 84 75 85 return self; … … 176 186 - (CGPoint)_offsetForPageNumberIndicator 177 187 { 178 return CGPointMake(_obscuredInsets.left, _obscuredInsets.top + _overlaidAccessoryViewsInset.height); 188 UIEdgeInsets contentInset = [_webView _computedContentInset]; 189 return CGPointMake(contentInset.left, contentInset.top + _overlaidAccessoryViewsInset.height); 179 190 } 180 191 … … 190 201 } 191 202 192 - (void)web_setObscuredInsets:(UIEdgeInsets)insets193 {194 if (UIEdgeInsetsEqualToEdgeInsets(insets, _obscuredInsets))195 return;196 197 _obscuredInsets = insets;198 199 [self _updatePageNumberIndicator];200 }201 202 203 - (void)web_setOverlaidAccessoryViewsInset:(CGSize)inset 203 204 { 204 205 _overlaidAccessoryViewsInset = inset; 205 206 [_pageNumberIndicator moveToPoint:[self _offsetForPageNumberIndicator] animated:YES]; 207 } 208 209 - (void)web_computedContentInsetDidChange 210 { 211 [self _updatePageNumberIndicator]; 206 212 } 207 213 -
trunk/Source/WebKit2/UIProcess/ios/WKScrollView.mm
r168747 r170361 192 192 } 193 193 194 - (void)setContentInset:(UIEdgeInsets)contentInset 195 { 196 [super setContentInset:contentInset]; 197 198 [_internalDelegate _updateVisibleContentRects]; 199 } 200 194 201 @end 195 202
Note: See TracChangeset
for help on using the changeset viewer.