Move the ResourceUsageOverlay out of the way by default.
authorakling@apple.com <akling@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 1 Nov 2015 21:59:42 +0000 (21:59 +0000)
committerakling@apple.com <akling@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 1 Nov 2015 21:59:42 +0000 (21:59 +0000)
<https://webkit.org/b/150776>

Reviewed by Darin Adler.

Have the ResourceUsageOverlay show up in the bottom center of the viewport
by default, instead of the top left. This way, you won't have to drag it
out of the way all the time.

* page/ResourceUsageOverlay.cpp:
(WebCore::ResourceUsageOverlay::ResourceUsageOverlay):
(WebCore::ResourceUsageOverlay::initialize):
* page/ResourceUsageOverlay.h:
* page/cocoa/ResourceUsageOverlayCocoa.mm:
(WebCore::ResourceUsageOverlay::platformInitialize):

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

Source/WebCore/ChangeLog
Source/WebCore/page/ResourceUsageOverlay.cpp
Source/WebCore/page/ResourceUsageOverlay.h
Source/WebCore/page/cocoa/ResourceUsageOverlayCocoa.mm

index 9bec401..5eb719a 100644 (file)
@@ -1,3 +1,21 @@
+2015-11-01  Andreas Kling  <akling@apple.com>
+
+        Move the ResourceUsageOverlay out of the way by default.
+        <https://webkit.org/b/150776>
+
+        Reviewed by Darin Adler.
+
+        Have the ResourceUsageOverlay show up in the bottom center of the viewport
+        by default, instead of the top left. This way, you won't have to drag it
+        out of the way all the time.
+
+        * page/ResourceUsageOverlay.cpp:
+        (WebCore::ResourceUsageOverlay::ResourceUsageOverlay):
+        (WebCore::ResourceUsageOverlay::initialize):
+        * page/ResourceUsageOverlay.h:
+        * page/cocoa/ResourceUsageOverlayCocoa.mm:
+        (WebCore::ResourceUsageOverlay::platformInitialize):
+
 2015-11-01  Philip Chimento  <philip.chimento@gmail.com>
 
         [GTK] Fix combinations of PLATFORM(GTK) and OS(DARWIN)
index f6bcd9f..26f5ab3 100644 (file)
@@ -39,12 +39,11 @@ ResourceUsageOverlay::ResourceUsageOverlay(Page& page)
     : m_page(page)
     , m_overlay(PageOverlay::create(*this, PageOverlay::OverlayType::View))
 {
-    m_overlay->setFrame(IntRect(80, 80, 500, 120));
-    m_overlay->setShouldIgnoreMouseEventsOutsideBounds(false);
-
-    m_page.mainFrame().pageOverlayController().installPageOverlay(m_overlay.get(), PageOverlay::FadeMode::DoNotFade);
-
-    platformInitialize();
+    // Let the event loop cycle before continuing with initialization.
+    // This way we'll have access to the FrameView's dimensions.
+    callOnMainThread([this] {
+        initialize();
+    });
 }
 
 ResourceUsageOverlay::~ResourceUsageOverlay()
@@ -56,6 +55,18 @@ ResourceUsageOverlay::~ResourceUsageOverlay()
         m_page.mainFrame().pageOverlayController().uninstallPageOverlay(m_overlay.get(), PageOverlay::FadeMode::DoNotFade);
 }
 
+void ResourceUsageOverlay::initialize()
+{
+    if (!m_page.mainFrame().view())
+        return;
+
+    FrameView& frameView = *m_page.mainFrame().view();
+    m_overlay->setFrame(IntRect(frameView.width() / 2 - normalWidth / 2, frameView.height() - normalHeight - 20, normalWidth, normalHeight));
+    m_overlay->setShouldIgnoreMouseEventsOutsideBounds(false);
+    m_page.mainFrame().pageOverlayController().installPageOverlay(m_overlay.get(), PageOverlay::FadeMode::DoNotFade);
+    platformInitialize();
+}
+
 bool ResourceUsageOverlay::mouseEvent(PageOverlay&, const PlatformMouseEvent& event)
 {
     if (event.button() != LeftButton)
index 89e4b63..7538fae 100644 (file)
@@ -64,6 +64,8 @@ private:
     bool mouseEvent(PageOverlay&, const PlatformMouseEvent&) override;
     void didScrollFrame(PageOverlay&, Frame&) override { }
 
+    void initialize();
+
     void platformInitialize();
     void platformDestroy();
 
@@ -76,6 +78,9 @@ private:
     ThreadIdentifier m_threadID { 0 };
     RetainPtr<CALayer> m_layer;
 #endif
+
+    static const int normalWidth = 500;
+    static const int normalHeight = 120;
 };
 
 }
index d126aa7..a28907d 100644 (file)
@@ -170,7 +170,7 @@ void ResourceUsageOverlay::platformInitialize()
 
     [m_layer.get() setContentsScale:2.0];
     [m_layer.get() setBackgroundColor:adoptCF(CGColorCreateGenericRGB(0, 0, 0, 0.8)).get()];
-    [m_layer.get() setFrame:CGRectMake(0, 0, 500, 120)];
+    [m_layer.get() setFrame:CGRectMake(0, 0, normalWidth, normalHeight)];
 
     data.overlayLayers.add(m_layer.get());
 }