Source/WebKit2/ChangeLog

 12014-02-18 Simon Fraser <simon.fraser@apple.com>
 2
 3 Clean up WKContentView initialization
 4 https://bugs.webkit.org/show_bug.cgi?id=129016
 5
 6 Reviewed by NOBODY (OOPS!).
 7
 8 WKContentView had too many initializers and duplicated init
 9 code. Clean up by removing all but one initializer and and
 10 doing all the setup in it.
 11
 12 * UIProcess/API/ios/WKContentView.h:
 13 * UIProcess/API/ios/WKContentView.mm:
 14 * UIProcess/API/ios/WKViewIOS.mm:
 15 (-[WKView _commonInitializationWithContextRef:pageGroupRef:relatedToPage:]):
 16
1172014-02-18 Tim Horton <timothy_horton@apple.com>
218
319 Can't use #if inside a macro, so we'll duplicate the macro for now.

Source/WebKit2/UIProcess/API/ios/WKContentView.h

@@WK_API_CLASS
6060
6161- (instancetype)initWithFrame:(CGRect)frame context:(WebKit::WebContext&)context configuration:(WebKit::WebPageConfiguration)webPageConfiguration;
6262
63 - (id)initWithFrame:(CGRect)frame contextRef:(WKContextRef)contextRef pageGroupRef:(WKPageGroupRef)pageGroupRef;
64 - (id)initWithFrame:(CGRect)frame contextRef:(WKContextRef)contextRef pageGroupRef:(WKPageGroupRef)pageGroupRef relatedToPage:(WKPageRef)relatedPage;
65 - (id)initWithFrame:(CGRect)frame processGroup:(WKProcessGroup *)processGroup browsingContextGroup:(WKBrowsingContextGroup *)browsingContextGroup;
66 
6763- (void)setMinimumSize:(CGSize)size;
6864- (void)setViewportSize:(CGSize)size;
6965- (void)setMinimumLayoutSize:(CGSize)size;

Source/WebKit2/UIProcess/API/ios/WKContentView.mm

@@@implementation WKContentView {
7272 WebCore::FloatPoint _currentExposedRectPosition;
7373}
7474
75 - (id)initWithFrame:(CGRect)frame contextRef:(WKContextRef)contextRef pageGroupRef:(WKPageGroupRef)pageGroupRef
76 {
77  return [self initWithFrame:frame contextRef:contextRef pageGroupRef:pageGroupRef relatedToPage:nullptr];
78 }
79 
80 - (id)initWithFrame:(CGRect)frame contextRef:(WKContextRef)contextRef pageGroupRef:(WKPageGroupRef)pageGroupRef relatedToPage:(WKPageRef)relatedPage
81 {
82  if (!(self = [super initWithFrame:frame]))
83  return nil;
84 
85  [self _commonInitializationWithContextRef:contextRef pageGroupRef:pageGroupRef relatedToPage:relatedPage];
86  return self;
87 }
88 
89 - (id)initWithFrame:(CGRect)frame processGroup:(WKProcessGroup *)processGroup browsingContextGroup:(WKBrowsingContextGroup *)browsingContextGroup
90 {
91  if (!(self = [super initWithFrame:frame]))
92  return nil;
93 
94  [self _commonInitializationWithContextRef:processGroup._contextRef pageGroupRef:browsingContextGroup._pageGroupRef relatedToPage:nullptr];
95  return self;
96 }
97 
9875- (instancetype)initWithFrame:(CGRect)frame context:(WebKit::WebContext&)context configuration:(WebKit::WebPageConfiguration)webPageConfiguration
9976{
10077 if (!(self = [super initWithFrame:frame]))

@@- (void)didZoomToScale:(CGFloat)scale
252229
253230#pragma mark Internal
254231
255 - (void)_commonInitializationWithContextRef:(WKContextRef)contextRef pageGroupRef:(WKPageGroupRef)pageGroupRef relatedToPage:(WKPageRef)relatedPage
256 {
257  InitializeWebKit2();
258 
259  _pageClient = std::make_unique<PageClientImpl>(self);
260 
261  WebPageConfiguration webPageConfiguration;
262  webPageConfiguration.pageGroup = toImpl(pageGroupRef);
263  webPageConfiguration.relatedPage = toImpl(relatedPage);
264 
265  _page = toImpl(contextRef)->createWebPage(*_pageClient, std::move(webPageConfiguration));
266  _page->initializeWebPage();
267  _page->setIntrinsicDeviceScaleFactor([UIScreen mainScreen].scale);
268  _page->setUseFixedLayout(true);
269  _page->setDelegatesScrolling(true);
270 
271  WebContext::statistics().wkViewCount++;
272 
273  _rootContentView = adoptNS([[UIView alloc] init]);
274  [[_rootContentView layer] setMasksToBounds:NO];
275  [_rootContentView setUserInteractionEnabled:NO];
276 
277  [self addSubview:_rootContentView.get()];
278 
279  _interactionView = adoptNS([[WKInteractionView alloc] init]);
280  [_interactionView setPage:_page];
281  [self addSubview:_interactionView.get()];
282 
283  self.layer.hitTestsAsOpaque = YES;
284 }
285 
286232- (void)_windowDidMoveToScreenNotification:(NSNotification *)notification
287233{
288234 ASSERT(notification.object == self.window);

Source/WebKit2/UIProcess/API/ios/WKViewIOS.mm

@@- (void)_commonInitializationWithContextRef:(WKContextRef)contextRef pageGroupRe
239239
240240 [self addSubview:_scrollView.get()];
241241
242  _contentView = adoptNS([[WKContentView alloc] initWithFrame:bounds contextRef:contextRef pageGroupRef:pageGroupRef relatedToPage:relatedPage]);
 242 WebKit::WebPageConfiguration webPageConfiguration;
 243 webPageConfiguration.pageGroup = toImpl(pageGroupRef);
 244 webPageConfiguration.relatedPage = toImpl(relatedPage);
 245
 246 _contentView = adoptNS([[WKContentView alloc] initWithFrame:bounds context:*toImpl(contextRef) configuration:std::move(webPageConfiguration)]);
 247
243248 [_contentView setDelegate:self];
244249 [[_contentView layer] setAnchorPoint:CGPointZero];
245250 [_contentView setFrame:bounds];