Web Inspector: drag/drop over the sidebar should load an imported file in Canvas...
[WebKit-https.git] / Source / WebInspectorUI / UserInterface / Views / AuditTabContentView.js
index 9a9e68e..f0cc9cb 100644 (file)
@@ -32,9 +32,6 @@ WI.AuditTabContentView = class AuditTabContentView extends WI.ContentBrowserTabC
         this._startStopShortcut = new WI.KeyboardShortcut(null, WI.KeyboardShortcut.Key.Space, this._handleSpace.bind(this));
         this._startStopShortcut.implicitlyPreventsDefault = false;
         this._startStopShortcut.disabled = true;
-
-        this.element.addEventListener("dragover", this._handleDragOver.bind(this));
-        this.element.addEventListener("drop", this._handleDrop.bind(this));
     }
 
     // Static
@@ -86,6 +83,11 @@ WI.AuditTabContentView = class AuditTabContentView extends WI.ContentBrowserTabC
         super.hidden();
     }
 
+    async handleFileDrop(files)
+    {
+        await WI.FileUtilities.readJSON(files, (result) => WI.auditManager.processJSON(result));
+    }
+
     // Protected
 
     initialLayout()
@@ -111,25 +113,6 @@ WI.AuditTabContentView = class AuditTabContentView extends WI.ContentBrowserTabC
 
         event.preventDefault();
     }
-
-    _handleDragOver(event)
-    {
-        if (event.dataTransfer.types.includes("Files"))
-            event.preventDefault();
-    }
-
-    _handleDrop(event)
-    {
-        if (!event.dataTransfer.files || !event.dataTransfer.files.length)
-            return;
-
-        event.preventDefault();
-
-        WI.FileUtilities.readJSON(event.dataTransfer.files, (result) => WI.auditManager.processJSON(result))
-        .then(() => {
-            event.dataTransfer.clearData();
-        });
-    }
 };
 
 WI.AuditTabContentView.Type = "audit";