研究4
在尋找WKWebView的畫面更新方法過程中發現- (void)_updateVisibleContentRects
只有- (void)_addUpdateVisibleContentRectPreCommitHandler
這有使用到,於是再往上追蹤到- (void)_scheduleVisibleContentRectUpdateAfterScrollInView:(UIScrollView *)scrollView
就有很多地方再使用了,來分類一下出現的地方。
WKWebView畫面大小改變:
- (void)setFrame:(CGRect)frame
{
CGRect oldFrame = self.frame;
[super setFrame:frame];
if (!CGSizeEqualToSize(oldFrame.size, frame.size))
[self _frameOrBoundsChanged];
}
- (void)setBounds:(CGRect)bounds
{
CGRect oldBounds = self.bounds;
[super setBounds:bounds];
[_customContentFixedOverlayView setFrame:self.bounds];
if (!CGSizeEqualToSize(oldBounds.size, bounds.size))
[self _frameOrBoundsChanged];
}
- (void)layoutSubviews
{
[super layoutSubviews];
[self _frameOrBoundsChanged];
}
最初就提及的地方。
WKScrollView滾動或縮放:
- (void)scrollViewDidScroll:(UIScrollView *)scrollView
{
if (![self usesStandardContentView])
[_customContentView scrollViewDidScroll:(UIScrollView *)scrollView];
[self _scheduleVisibleContentRectUpdateAfterScrollInView:scrollView];
if (WebKit::RemoteLayerTreeScrollingPerformanceData* scrollPerfData = _page->scrollingPerformanceData())
scrollPerfData->didScroll([self visibleRectInViewCoordinates]);
}
- (void)scrollViewDidZoom:(UIScrollView *)scrollView
{
[self _updateScrollViewBackground];
[self _scheduleVisibleContentRectUpdateAfterScrollInView:scrollView];
}
- (void)scrollViewDidEndZooming:(UIScrollView *)scrollView withView:(UIView *)view atScale:(CGFloat)scale
{
ASSERT(scrollView == _scrollView);
[self _scheduleVisibleContentRectUpdateAfterScrollInView:scrollView];
[_contentView didZoomToScale:scale];
}