REGRESSION(r179429): Can't type comments in Facebook
[WebKit-https.git] / Source / WebCore / inspector / InspectorFrontendClientLocal.cpp
index 56e3586..415ff7c 100644 (file)
  */
 
 #include "config.h"
-
-#if ENABLE(INSPECTOR)
-
 #include "InspectorFrontendClientLocal.h"
 
 #include "Chrome.h"
 #include "DOMWrapperWorld.h"
 #include "Document.h"
 #include "FloatRect.h"
-#include "Frame.h"
 #include "FrameLoadRequest.h"
 #include "FrameLoader.h"
 #include "FrameView.h"
-#include "InspectorBackendDispatcher.h"
 #include "InspectorController.h"
 #include "InspectorFrontendHost.h"
 #include "InspectorPageAgent.h"
+#include "MainFrame.h"
 #include "Page.h"
 #include "ScriptController.h"
-#include "ScriptFunctionCall.h"
-#include "ScriptObject.h"
+#include "ScriptGlobalObject.h"
 #include "ScriptState.h"
 #include "Settings.h"
 #include "Timer.h"
 #include "UserGestureIndicator.h"
 #include "WindowFeatures.h"
+#include <bindings/ScriptValue.h>
+#include <inspector/InspectorBackendDispatchers.h>
 #include <wtf/Deque.h>
 #include <wtf/text/CString.h>
-#include <wtf/text/WTFString.h>
+
+using namespace Inspector;
 
 namespace WebCore {
 
@@ -73,7 +71,7 @@ class InspectorBackendDispatchTask {
 public:
     InspectorBackendDispatchTask(InspectorController* inspectorController)
         : m_inspectorController(inspectorController)
-        , m_timer(this, &InspectorBackendDispatchTask::onTimer)
+        , m_timer(*this, &InspectorBackendDispatchTask::timerFired)
     {
     }
 
@@ -90,7 +88,7 @@ public:
         m_timer.stop();
     }
 
-    void onTimer(Timer<InspectorBackendDispatchTask>*)
+    void timerFired()
     {
         if (!m_messages.isEmpty()) {
             // Dispatch can lead to the timer destruction -> schedule the next shot first.
@@ -101,7 +99,7 @@ public:
 
 private:
     InspectorController* m_inspectorController;
-    Timer<InspectorBackendDispatchTask> m_timer;
+    Timer m_timer;
     Deque<String> m_messages;
 };
 
@@ -114,15 +112,18 @@ void InspectorFrontendClientLocal::Settings::setProperty(const String&, const St
 {
 }
 
-InspectorFrontendClientLocal::InspectorFrontendClientLocal(InspectorController* inspectorController, Page* frontendPage, PassOwnPtr<Settings> settings)
+InspectorFrontendClientLocal::InspectorFrontendClientLocal(InspectorController* inspectorController, Page* frontendPage, std::unique_ptr<Settings> settings)
     : m_inspectorController(inspectorController)
     , m_frontendPage(frontendPage)
-    , m_settings(settings)
+    , m_settings(WTF::move(settings))
     , m_frontendLoaded(false)
-    , m_dockSide(UNDOCKED)
+    , m_dockSide(DockSide::Undocked)
 {
     m_frontendPage->settings().setAllowFileAccessFromFileURLs(true);
-    m_dispatchTask = adoptPtr(new InspectorBackendDispatchTask(inspectorController));
+    m_frontendPage->settings().setJavaScriptRuntimeFlags({
+        JSC::RuntimeFlags::SymbolEnabled
+    });
+    m_dispatchTask = std::make_unique<InspectorBackendDispatchTask>(inspectorController);
 }
 
 InspectorFrontendClientLocal::~InspectorFrontendClientLocal()
@@ -159,7 +160,7 @@ void InspectorFrontendClientLocal::frontendLoaded()
 
 void InspectorFrontendClientLocal::requestSetDockSide(DockSide dockSide)
 {
-    if (dockSide == UNDOCKED) {
+    if (dockSide == DockSide::Undocked) {
         detachWindow();
         setAttachedWindow(dockSide);
     } else if (canAttachWindow()) {
@@ -176,12 +177,12 @@ bool InspectorFrontendClientLocal::canAttachWindow()
         return false;
 
     // If we are already attached, allow attaching again to allow switching sides.
-    if (m_dockSide != UNDOCKED)
+    if (m_dockSide != DockSide::Undocked)
         return true;
 
     // Don't allow the attach if the window would be too small to accommodate the minimum inspector size.
-    unsigned inspectedPageHeight = m_inspectorController->inspectedPage()->mainFrame().view()->visibleHeight();
-    unsigned inspectedPageWidth = m_inspectorController->inspectedPage()->mainFrame().view()->visibleWidth();
+    unsigned inspectedPageHeight = m_inspectorController->inspectedPage().mainFrame().view()->visibleHeight();
+    unsigned inspectedPageWidth = m_inspectorController->inspectedPage().mainFrame().view()->visibleWidth();
     unsigned maximumAttachedHeight = inspectedPageHeight * maximumAttachedHeightRatio;
     return minimumAttachedHeight <= maximumAttachedHeight && minimumAttachedWidth <= inspectedPageWidth;
 }
@@ -193,7 +194,7 @@ void InspectorFrontendClientLocal::setDockingUnavailable(bool unavailable)
 
 void InspectorFrontendClientLocal::changeAttachedWindowHeight(unsigned height)
 {
-    unsigned totalHeight = m_frontendPage->mainFrame().view()->visibleHeight() + m_inspectorController->inspectedPage()->mainFrame().view()->visibleHeight();
+    unsigned totalHeight = m_frontendPage->mainFrame().view()->visibleHeight() + m_inspectorController->inspectedPage().mainFrame().view()->visibleHeight();
     unsigned attachedHeight = constrainedAttachedWindowHeight(height, totalHeight);
     m_settings->setProperty(inspectorAttachedHeightSetting, String::number(attachedHeight));
     setAttachedWindowHeight(attachedHeight);
@@ -201,7 +202,7 @@ void InspectorFrontendClientLocal::changeAttachedWindowHeight(unsigned height)
 
 void InspectorFrontendClientLocal::changeAttachedWindowWidth(unsigned width)
 {
-    unsigned totalWidth = m_frontendPage->mainFrame().view()->visibleWidth() + m_inspectorController->inspectedPage()->mainFrame().view()->visibleWidth();
+    unsigned totalWidth = m_frontendPage->mainFrame().view()->visibleWidth() + m_inspectorController->inspectedPage().mainFrame().view()->visibleWidth();
     unsigned attachedWidth = constrainedAttachedWindowWidth(width, totalWidth);
     setAttachedWindowWidth(attachedWidth);
 }
@@ -209,8 +210,7 @@ void InspectorFrontendClientLocal::changeAttachedWindowWidth(unsigned width)
 void InspectorFrontendClientLocal::openInNewTab(const String& url)
 {
     UserGestureIndicator indicator(DefinitelyProcessingUserGesture);
-    Page* page = m_inspectorController->inspectedPage();
-    Frame& mainFrame = page->mainFrame();
+    Frame& mainFrame = m_inspectorController->inspectedPage().mainFrame();
     FrameLoadRequest request(mainFrame.document()->securityOrigin(), ResourceRequest(), "_blank");
 
     bool created;
@@ -223,7 +223,7 @@ void InspectorFrontendClientLocal::openInNewTab(const String& url)
     frame->page()->setOpenedByDOM();
 
     // FIXME: Why does one use mainFrame and the other frame?
-    frame->loader().changeLocation(mainFrame.document()->securityOrigin(), frame->document()->completeURL(url), "", false, false);
+    frame->loader().changeLocation(mainFrame.document()->securityOrigin(), frame->document()->completeURL(url), "", LockHistory::No, LockBackForwardList::No);
 }
 
 void InspectorFrontendClientLocal::moveWindowBy(float x, float y)
@@ -237,13 +237,13 @@ void InspectorFrontendClientLocal::setAttachedWindow(DockSide dockSide)
 {
     const char* side = "undocked";
     switch (dockSide) {
-    case UNDOCKED:
+    case DockSide::Undocked:
         side = "undocked";
         break;
-    case DOCKED_TO_RIGHT:
+    case DockSide::Right:
         side = "right";
         break;
-    case DOCKED_TO_BOTTOM:
+    case DockSide::Bottom:
         side = "bottom";
         break;
     }
@@ -255,7 +255,7 @@ void InspectorFrontendClientLocal::setAttachedWindow(DockSide dockSide)
 
 void InspectorFrontendClientLocal::restoreAttachedWindowHeight()
 {
-    unsigned inspectedPageHeight = m_inspectorController->inspectedPage()->mainFrame().view()->visibleHeight();
+    unsigned inspectedPageHeight = m_inspectorController->inspectedPage().mainFrame().view()->visibleHeight();
     String value = m_settings->getProperty(inspectorAttachedHeightSetting);
     unsigned preferredHeight = value.isEmpty() ? defaultAttachedHeight : value.toUInt();
     
@@ -344,7 +344,7 @@ bool InspectorFrontendClientLocal::isUnderTest()
 
 bool InspectorFrontendClientLocal::evaluateAsBoolean(const String& expression)
 {
-    ScriptValue value = m_frontendPage->mainFrame().script().executeScript(expression);
+    Deprecated::ScriptValue value = m_frontendPage->mainFrame().script().executeScript(expression);
     return value.toString(mainWorldExecState(&m_frontendPage->mainFrame())) == "true";
 }
 
@@ -357,5 +357,3 @@ void InspectorFrontendClientLocal::evaluateOnLoad(const String& expression)
 }
 
 } // namespace WebCore
-
-#endif