Web Inspector: Add Support for OS X Full Screen Mode
authorjoepeck@webkit.org <joepeck@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 26 Jun 2015 01:45:58 +0000 (01:45 +0000)
committerjoepeck@webkit.org <joepeck@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 26 Jun 2015 01:45:58 +0000 (01:45 +0000)
https://bugs.webkit.org/show_bug.cgi?id=123510

Reviewed by Timothy Hatcher.

Source/WebKit/mac:

* WebCoreSupport/WebInspectorClient.h:
* WebCoreSupport/WebInspectorClient.mm:
(WebInspectorClient::didResizeMainFrame):
(WebInspectorClient::windowFullScreenDidChange):
(WebInspectorClient::canAttach):
(WebInspectorFrontendClient::canAttach):
(-[WebInspectorWindowController showWindow:]):
Consolidate canAttach logic into canAttach functions.

(-[WebInspectorWindowController window:]):
Share the same full screen behavior as WebKit2.

(-[WebInspectorWindowController windowDidEnterFullScreen:]):
(-[WebInspectorWindowController windowDidExitFullScreen:]):
Attach availability may have changed.

Source/WebKit2:

* UIProcess/mac/WebInspectorProxyMac.mm:
(WebKit::WebInspectorProxy::createInspectorWindow):
Allow full screen.

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

Source/WebKit/mac/ChangeLog
Source/WebKit/mac/WebCoreSupport/WebInspectorClient.h
Source/WebKit/mac/WebCoreSupport/WebInspectorClient.mm
Source/WebKit2/ChangeLog
Source/WebKit2/UIProcess/mac/WebInspectorProxyMac.mm

index 245241c..685b659 100644 (file)
@@ -1,5 +1,28 @@
 2015-06-25  Joseph Pecoraro  <pecoraro@apple.com>
 
+        Web Inspector: Add Support for OS X Full Screen Mode
+        https://bugs.webkit.org/show_bug.cgi?id=123510
+
+        Reviewed by Timothy Hatcher.
+
+        * WebCoreSupport/WebInspectorClient.h:
+        * WebCoreSupport/WebInspectorClient.mm:
+        (WebInspectorClient::didResizeMainFrame):
+        (WebInspectorClient::windowFullScreenDidChange):
+        (WebInspectorClient::canAttach):
+        (WebInspectorFrontendClient::canAttach):
+        (-[WebInspectorWindowController showWindow:]):
+        Consolidate canAttach logic into canAttach functions.
+
+        (-[WebInspectorWindowController window:]):
+        Share the same full screen behavior as WebKit2.
+
+        (-[WebInspectorWindowController windowDidEnterFullScreen:]):
+        (-[WebInspectorWindowController windowDidExitFullScreen:]):
+        Attach availability may have changed.
+
+2015-06-25  Joseph Pecoraro  <pecoraro@apple.com>
+
         [Mac] Web Inspector: Window dragging on toolbar should behave more like native window dragging
         https://bugs.webkit.org/show_bug.cgi?id=146324
 
index 7a513ff..1e0bbab 100644 (file)
@@ -92,6 +92,10 @@ public:
     bool inspectorAttachDisabled();
     void setInspectorAttachDisabled(bool);
 
+    void windowFullScreenDidChange();
+
+    bool canAttach();
+
     void releaseFrontend();
 
 private:
@@ -109,6 +113,7 @@ public:
     WebInspectorFrontendClient(WebView*, WebInspectorWindowController*, WebCore::InspectorController*, WebCore::Page*, std::unique_ptr<Settings>);
 
     void attachAvailabilityChanged(bool);
+    bool canAttach();
 
     virtual void frontendLoaded() override;
 
index d3e88bb..0114e8d 100644 (file)
@@ -59,6 +59,11 @@ SOFT_LINK_STAGED_FRAMEWORK(WebInspectorUI, PrivateFrameworks, A)
 
 using namespace WebCore;
 
+static const CGFloat minimumWindowWidth = 750;
+static const CGFloat minimumWindowHeight = 400;
+static const CGFloat initialWindowWidth = 1000;
+static const CGFloat initialWindowHeight = 650;
+
 @interface WebInspectorWindowController : NSWindowController <NSWindowDelegate, WebPolicyDelegate, WebUIDelegate> {
 @private
     RetainPtr<WebView> _inspectedWebView;
@@ -131,7 +136,18 @@ void WebInspectorClient::bringFrontendToFront()
 void WebInspectorClient::didResizeMainFrame(Frame*)
 {
     if (m_frontendClient)
-        m_frontendClient->attachAvailabilityChanged(m_frontendClient->canAttachWindow() && !inspectorAttachDisabled());
+        m_frontendClient->attachAvailabilityChanged(canAttach());
+}
+
+void WebInspectorClient::windowFullScreenDidChange()
+{
+    if (m_frontendClient)
+        m_frontendClient->attachAvailabilityChanged(canAttach());
+}
+
+bool WebInspectorClient::canAttach()
+{
+    return m_frontendClient->canAttach() && !inspectorAttachDisabled();
 }
 
 void WebInspectorClient::highlight()
@@ -177,6 +193,14 @@ void WebInspectorFrontendClient::attachAvailabilityChanged(bool available)
     [m_windowController.get() setDockingUnavailable:!available];
 }
 
+bool WebInspectorFrontendClient::canAttach()
+{
+    if ([[m_windowController window] styleMask] & NSFullScreenWindowMask)
+        return false;
+
+    return canAttachWindow();
+}
+
 void WebInspectorFrontendClient::frontendLoaded()
 {
     [m_windowController.get() showWindow:nil];
@@ -455,9 +479,17 @@ void WebInspectorFrontendClient::append(const String& suggestedURL, const String
     NSUInteger styleMask = NSTitledWindowMask | NSClosableWindowMask | NSMiniaturizableWindowMask | NSResizableWindowMask | NSTexturedBackgroundWindowMask;
 #endif
 
-    window = [[NSWindow alloc] initWithContentRect:NSMakeRect(60.0, 200.0, 750.0, 650.0) styleMask:styleMask backing:NSBackingStoreBuffered defer:NO];
+    window = [[NSWindow alloc] initWithContentRect:NSMakeRect(0, 0, initialWindowWidth, initialWindowHeight) styleMask:styleMask backing:NSBackingStoreBuffered defer:NO];
     [window setDelegate:self];
-    [window setMinSize:NSMakeSize(400.0, 400.0)];
+    [window setMinSize:NSMakeSize(minimumWindowWidth, minimumWindowHeight)];
+    [window setCollectionBehavior:([window collectionBehavior] | NSWindowCollectionBehaviorFullScreenPrimary)];
+
+#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101100
+    CGFloat approximatelyHalfScreenSize = (window.screen.frame.size.width / 2) - 4;
+    CGFloat minimumFullScreenWidth = std::max<CGFloat>(636, approximatelyHalfScreenSize);
+    [window setMinFullScreenContentSize:NSMakeSize(minimumFullScreenWidth, minimumWindowHeight)];
+    [window setCollectionBehavior:([window collectionBehavior] | NSWindowCollectionBehaviorFullScreenAllowsTiling)];
+#endif
 
 #if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101000
     window.titlebarAppearsTransparent = YES;
@@ -489,6 +521,16 @@ void WebInspectorFrontendClient::append(const String& suggestedURL, const String
     return YES;
 }
 
+- (void)windowDidEnterFullScreen:(NSNotification *)notification
+{
+    _inspectorClient->windowFullScreenDidChange();
+}
+
+- (void)windowDidExitFullScreen:(NSNotification *)notification
+{
+    _inspectorClient->windowFullScreenDidChange();
+}
+
 - (void)close
 {
     if (!_visible)
@@ -533,7 +575,7 @@ void WebInspectorFrontendClient::append(const String& suggestedURL, const String
 
     _visible = YES;
 
-    _shouldAttach = _inspectorClient->inspectorStartsAttached() && _frontendClient->canAttachWindow() && !_inspectorClient->inspectorAttachDisabled();
+    _shouldAttach = _inspectorClient->inspectorStartsAttached() && _frontendClient->canAttach();
 
     if (_shouldAttach) {
         WebFrameView *frameView = [[_inspectedWebView.get() mainFrame] frameView];
index 9b5dba7..f80e176 100644 (file)
@@ -1,3 +1,14 @@
+2015-06-25  Joseph Pecoraro  <pecoraro@apple.com>
+
+        Web Inspector: Add Support for OS X Full Screen Mode
+        https://bugs.webkit.org/show_bug.cgi?id=123510
+
+        Reviewed by Timothy Hatcher.
+
+        * UIProcess/mac/WebInspectorProxyMac.mm:
+        (WebKit::WebInspectorProxy::createInspectorWindow):
+        Allow full screen.
+
 2015-06-25  Hyungwook Lee  <hyungwook.lee@navercorp.com>
 
         [EFL] Make send / receive messages to communicate the Web and UI Processes using Injected Bundle.
index 887ace1..13f4938 100644 (file)
@@ -314,7 +314,7 @@ void WebInspectorProxy::createInspectorWindow()
     [window setDelegate:m_inspectorProxyObjCAdapter.get()];
     [window setMinSize:NSMakeSize(minimumWindowWidth, minimumWindowHeight)];
     [window setReleasedWhenClosed:NO];
-    [window setCollectionBehavior:([window collectionBehavior] | NSWindowCollectionBehaviorFullScreenAuxiliary)];
+    [window setCollectionBehavior:([window collectionBehavior] | NSWindowCollectionBehaviorFullScreenPrimary)];
 
 #if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101100
     CGFloat approximatelyHalfScreenSize = (window.screen.frame.size.width / 2) - 4;