Changeset 181881 in webkit
- Timestamp:
- Mar 23, 2015, 4:42:40 PM (10 years ago)
- Location:
- trunk/Source/WebKit2
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit2/ChangeLog
r181874 r181881 1 2015-03-19 Timothy Hatcher <timothy@apple.com> 2 3 Web Inspector: Support attaching to another view other than the WKView 4 https://bugs.webkit.org/show_bug.cgi?id=142892 5 6 Reviewed by Tim Horton. 7 8 * UIProcess/API/C/WKInspector.cpp: 9 (WKInspectorAttach): Drive by fix so it used the last attachment side. 10 11 * UIProcess/API/Cocoa/WKViewPrivate.h: 12 * UIProcess/API/mac/WKView.mm: 13 (-[WKView _inspectorAttachmentView]): Added. 14 (-[WKView _setInspectorAttachmentView:]): Added. 15 16 * UIProcess/WebInspectorProxy.cpp: 17 (WebKit::WebInspectorProxy::createInspectorPage): 18 (WebKit::WebInspectorProxy::attachAvailabilityChanged): 19 Use platformCanAttach as a final check incase there is a different 20 attachment view that the platform knows about. 21 22 * UIProcess/WebInspectorProxy.h: 23 (WebKit::WebInspectorProxy::attachmentSide): Added. 24 (WebKit::WebInspectorProxy::platformCanAttach): Added. 25 26 * UIProcess/mac/WebInspectorProxyMac.mm: 27 (WebKit::WebInspectorProxy::attachmentViewDidChange): Added. 28 (WebKit::WebInspectorProxy::closeTimerFired): 29 (WebKit::WebInspectorProxy::platformCreateInspectorPage): 30 (WebKit::WebInspectorProxy::platformCanAttach): 31 (WebKit::WebInspectorProxy::inspectedViewFrameDidChange): 32 (WebKit::WebInspectorProxy::platformInspectedWindowHeight): 33 (WebKit::WebInspectorProxy::platformInspectedWindowWidth): 34 (WebKit::WebInspectorProxy::platformAttach): 35 (WebKit::WebInspectorProxy::platformDetach): 36 Use the _inspectorAttachmentView and change how the frame change notification 37 is observed and follow the attachment view as it changes. 38 1 39 2015-03-23 Tim Horton <timothy_horton@apple.com> 2 40 -
trunk/Source/WebKit2/UIProcess/API/C/WKInspector.cpp
r179705 r181881 102 102 void WKInspectorAttach(WKInspectorRef inspectorRef) 103 103 { 104 toImpl(inspectorRef)->attach(); 104 auto inspector = toImpl(inspectorRef); 105 inspector->attach(inspector->attachmentSide()); 105 106 } 106 107 -
trunk/Source/WebKit2/UIProcess/API/Cocoa/WKViewPrivate.h
r181039 r181881 98 98 99 99 @property (readonly) NSColor *_pageExtendedBackgroundColor; 100 @property(copy, nonatomic) NSColor *underlayColor; 100 @property (copy, nonatomic) NSColor *underlayColor; 101 102 @property (strong, nonatomic, setter=_setInspectorAttachmentView:) NSView *_inspectorAttachmentView WK_AVAILABLE(WK_MAC_TBA, NA); 101 103 102 104 - (NSView*)fullScreenPlaceholderView; -
trunk/Source/WebKit2/UIProcess/API/mac/WKView.mm
r181866 r181881 69 69 #import "WebBackForwardList.h" 70 70 #import "WebEventFactory.h" 71 #import "WebInspectorProxy.h" 71 72 #import "WebKit2Initialize.h" 72 73 #import "WebPage.h" … … 192 193 193 194 RetainPtr<id> _remoteAccessibilityChild; 194 195 196 RetainPtr<NSView> _inspectorAttachmentView; 197 195 198 // For asynchronous validation. 196 199 ValidationMap _validationMap; … … 4133 4136 } 4134 4137 4138 - (NSView *)_inspectorAttachmentView 4139 { 4140 NSView *attachmentView = _data->_inspectorAttachmentView.get(); 4141 return attachmentView ? attachmentView : self; 4142 } 4143 4144 - (void)_setInspectorAttachmentView:(NSView *)newView 4145 { 4146 NSView *oldView = _data->_inspectorAttachmentView.get(); 4147 if (oldView == newView) 4148 return; 4149 4150 _data->_inspectorAttachmentView = newView; 4151 _data->_page->inspector()->attachmentViewDidChange(oldView ? oldView : self, newView ? newView : self); 4152 } 4153 4135 4154 - (NSView *)fullScreenPlaceholderView 4136 4155 { -
trunk/Source/WebKit2/UIProcess/WebInspectorProxy.cpp
r179705 r181881 482 482 483 483 if (!m_underTest) { 484 m_canAttach = canAttach;484 m_canAttach = platformCanAttach(canAttach); 485 485 m_isAttached = shouldOpenAttached(); 486 486 m_attachmentSide = static_cast<AttachmentSide>(inspectorPagePreferences().inspectorAttachmentSide()); … … 556 556 void WebInspectorProxy::attachAvailabilityChanged(bool available) 557 557 { 558 m_canAttach = available; 559 560 platformAttachAvailabilityChanged(available); 558 bool previousCanAttach = m_canAttach; 559 560 m_canAttach = platformCanAttach(available); 561 562 if (previousCanAttach == m_canAttach) 563 return; 564 565 platformAttachAvailabilityChanged(m_canAttach); 561 566 } 562 567 -
trunk/Source/WebKit2/UIProcess/WebInspectorProxy.h
r179705 r181881 43 43 OBJC_CLASS NSButton; 44 44 OBJC_CLASS NSURL; 45 OBJC_CLASS NSView; 45 46 OBJC_CLASS NSWindow; 46 47 OBJC_CLASS WKWebInspectorProxyObjCAdapter; … … 107 108 108 109 void closeTimerFired(); 110 111 void attachmentViewDidChange(NSView *oldView, NSView *newView); 109 112 #endif 110 113 … … 118 121 void showMainResourceForFrame(WebFrameProxy*); 119 122 123 AttachmentSide attachmentSide() const { return m_attachmentSide; } 120 124 bool isAttached() const { return m_isAttached; } 121 125 void attachRight(); … … 173 177 void platformSave(const String& filename, const String& content, bool base64Encoded, bool forceSaveAs); 174 178 void platformAppend(const String& filename, const String& content); 179 180 #if PLATFORM(MAC) 181 bool platformCanAttach(bool webProcessCanAttach); 182 #else 183 bool platformCanAttach(bool webProcessCanAttach) { return webProcessCanAttach; } 184 #endif 175 185 176 186 // Called by WebInspectorProxy messages -
trunk/Source/WebKit2/UIProcess/mac/WebInspectorProxyMac.mm
r180570 r181881 291 291 } 292 292 293 void WebInspectorProxy::attachmentViewDidChange(NSView *oldView, NSView *newView) 294 { 295 [[NSNotificationCenter defaultCenter] removeObserver:m_inspectorProxyObjCAdapter.get() name:NSViewFrameDidChangeNotification object:oldView]; 296 [[NSNotificationCenter defaultCenter] addObserver:m_inspectorProxyObjCAdapter.get() selector:@selector(inspectedViewFrameDidChange:) name:NSViewFrameDidChangeNotification object:newView]; 297 298 if (m_isAttached) 299 attach(m_attachmentSide); 300 } 301 293 302 void WebInspectorProxy::setInspectorWindowFrame(WKRect& frame) 294 303 { … … 318 327 m_inspectorView = nil; 319 328 } 329 330 [[NSNotificationCenter defaultCenter] removeObserver:m_inspectorProxyObjCAdapter.get()]; 320 331 321 332 [m_inspectorProxyObjCAdapter close]; … … 460 471 ASSERT(!m_inspectorProxyObjCAdapter); 461 472 473 NSView *inspectedView = inspectedPage()->wkView()._inspectorAttachmentView; 474 462 475 NSRect initialRect; 463 476 if (m_isAttached) { 464 NSRect inspectedViewFrame = inspected Page()->wkView().frame;477 NSRect inspectedViewFrame = inspectedView.frame; 465 478 466 479 switch (m_attachmentSide) { … … 508 521 509 522 [m_inspectorView setInspectorProxyObjCAdapter:m_inspectorProxyObjCAdapter.get()]; 523 524 [[NSNotificationCenter defaultCenter] addObserver:m_inspectorProxyObjCAdapter.get() selector:@selector(inspectedViewFrameDidChange:) name:NSViewFrameDidChangeNotification object:inspectedView]; 510 525 511 526 WebPageProxy* inspectorPage = m_inspectorView->_page.get(); … … 567 582 } 568 583 584 bool WebInspectorProxy::platformCanAttach(bool webProcessCanAttach) 585 { 586 NSView *inspectedView = inspectedPage()->wkView()._inspectorAttachmentView; 587 if ([inspectedView isKindOfClass:[WKView class]]) 588 return webProcessCanAttach; 589 590 static const float minimumAttachedHeight = 250; 591 static const float maximumAttachedHeightRatio = 0.75; 592 static const float minimumAttachedWidth = 750; 593 594 NSRect inspectedViewFrame = inspectedView.frame; 595 596 float maximumAttachedHeight = NSHeight(inspectedViewFrame) * maximumAttachedHeightRatio; 597 return minimumAttachedHeight <= maximumAttachedHeight && minimumAttachedWidth <= NSWidth(inspectedViewFrame); 598 } 599 569 600 void WebInspectorProxy::platformOpen() 570 601 { … … 728 759 void WebInspectorProxy::inspectedViewFrameDidChange(CGFloat currentDimension) 729 760 { 730 if (!m_isAttached || !m_isVisible) 731 return; 732 733 WKView *inspectedView = inspectedPage()->wkView(); 761 if (!m_isVisible) 762 return; 763 764 if (!m_isAttached) { 765 // Check if the attach avaibility changed. We need to do this here in case 766 // the attachment view is not the WKView. 767 attachAvailabilityChanged(platformCanAttach(canAttach())); 768 return; 769 } 770 771 NSView *inspectedView = inspectedPage()->wkView()._inspectorAttachmentView; 734 772 NSRect inspectedViewFrame = [inspectedView frame]; 735 773 NSRect inspectorFrame = NSZeroRect; … … 761 799 // top position for the inspector view since the banners only stretch as wide as the the inspected view. 762 800 inspectedViewFrame = NSMakeRect(0, 0, parentWidth - inspectorWidth, inspectedViewTop); 763 CGFloat insetExcludingBanners = inspectedView._topContentInset - inspectedView._totalHeightOfBanners; 801 CGFloat insetExcludingBanners = 0; 802 if ([inspectedView isKindOfClass:[WKView class]]) 803 insetExcludingBanners = ((WKView *)inspectedView)._topContentInset - ((WKView *)inspectedView)._totalHeightOfBanners; 764 804 inspectorFrame = NSMakeRect(parentWidth - inspectorWidth, 0, inspectorWidth, NSHeight(parentBounds) - insetExcludingBanners); 765 805 break; … … 781 821 unsigned WebInspectorProxy::platformInspectedWindowHeight() 782 822 { 783 WKView *inspectedView = inspectedPage()->wkView();823 NSView *inspectedView = inspectedPage()->wkView()._inspectorAttachmentView; 784 824 NSRect inspectedViewRect = [inspectedView frame]; 785 825 return static_cast<unsigned>(inspectedViewRect.size.height); … … 788 828 unsigned WebInspectorProxy::platformInspectedWindowWidth() 789 829 { 790 WKView *inspectedView = inspectedPage()->wkView();830 NSView *inspectedView = inspectedPage()->wkView()._inspectorAttachmentView; 791 831 NSRect inspectedViewRect = [inspectedView frame]; 792 832 return static_cast<unsigned>(inspectedViewRect.size.width); … … 795 835 void WebInspectorProxy::platformAttach() 796 836 { 797 WKView *inspectedView = inspectedPage()->wkView(); 798 [[NSNotificationCenter defaultCenter] addObserver:m_inspectorProxyObjCAdapter.get() selector:@selector(inspectedViewFrameDidChange:) name:NSViewFrameDidChangeNotification object:inspectedView]; 837 NSView *inspectedView = inspectedPage()->wkView()._inspectorAttachmentView; 799 838 800 839 if (m_inspectorWindow) { … … 828 867 void WebInspectorProxy::platformDetach() 829 868 { 830 WKView *inspectedView = inspectedPage()->wkView(); 831 [[NSNotificationCenter defaultCenter] removeObserver:m_inspectorProxyObjCAdapter.get() name:NSViewFrameDidChangeNotification object:inspectedView]; 869 NSView *inspectedView = inspectedPage()->wkView()._inspectorAttachmentView; 832 870 833 871 [m_inspectorView removeFromSuperview];
Note:
See TracChangeset
for help on using the changeset viewer.