WebKit Bugzilla
Attachment 369035 Details for
Bug 197330
: Web Inspector: DOM: dragging a node to the console should log the node
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-197330-20190503190505.patch (text/plain), 8.60 KB, created by
Devin Rousso
on 2019-05-03 19:05:06 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Devin Rousso
Created:
2019-05-03 19:05:06 PDT
Size:
8.60 KB
patch
obsolete
>diff --git a/Source/WebInspectorUI/ChangeLog b/Source/WebInspectorUI/ChangeLog >index 97206c896b10ddf3ad958b68b3f8bce3e8085713..c84b918095a214dc37fdd4878c43ce9fe9f490c2 100644 >--- a/Source/WebInspectorUI/ChangeLog >+++ b/Source/WebInspectorUI/ChangeLog >@@ -1,3 +1,26 @@ >+2019-05-03 Devin Rousso <drousso@apple.com> >+ >+ Web Inspector: DOM: dragging a node to the console should log the node >+ https://bugs.webkit.org/show_bug.cgi?id=197330 >+ >+ Reviewed by Timothy Hatcher. >+ >+ * UserInterface/Views/DOMTreeOutline.js: >+ (WI.DOMTreeOutline.prototype._ondragstart): >+ * UserInterface/Views/LogContentView.js: >+ (WI.LogContentView): >+ (WI.LogContentView.prototype._handleDragOver): Added. >+ (WI.LogContentView.prototype._handleDrop): Added. >+ * UserInterface/Views/QuickConsole.js: >+ (WI.QuickConsole): >+ (WI.QuickConsole.prototype._handleDragOver): Added. >+ (WI.QuickConsole.prototype._handleDrop): Added. >+ >+ * UserInterface/Views/GeneralStyleDetailsSidebarPanel.js: >+ Drive-by: update the format to be more unique. >+ >+ * Localizations/en.lproj/localizedStrings.js: >+ > 2019-05-03 Devin Rousso <drousso@apple.com> > > Web Inspector: DOM: rename "low power" to "display composited" >diff --git a/Source/WebInspectorUI/Localizations/en.lproj/localizedStrings.js b/Source/WebInspectorUI/Localizations/en.lproj/localizedStrings.js >index 50b23c2a8b7dce452c635c641d4292dc6eeba54d..50466169e1fd1a8fa43a5db4547c24dd139c90f4 100644 >--- a/Source/WebInspectorUI/Localizations/en.lproj/localizedStrings.js >+++ b/Source/WebInspectorUI/Localizations/en.lproj/localizedStrings.js >@@ -348,6 +348,8 @@ localizedStrings["Domain"] = "Domain"; > localizedStrings["Done"] = "Done"; > localizedStrings["Download"] = "Download"; > localizedStrings["Download Web Archive"] = "Download Web Archive"; >+localizedStrings["Dropped Element"] = "Dropped Element"; >+localizedStrings["Dropped Node"] = "Dropped Node"; > localizedStrings["Duplicate property"] = "Duplicate property"; > localizedStrings["Duration"] = "Duration"; > localizedStrings["Duration: %s"] = "Duration: %s"; >diff --git a/Source/WebInspectorUI/UserInterface/Views/DOMTreeOutline.js b/Source/WebInspectorUI/UserInterface/Views/DOMTreeOutline.js >index 7a091390cc38eb1f7691f070c0269ad4ae6c38ce..668f8eaaa59cecfca0b0124784755a0ddaa337dd 100644 >--- a/Source/WebInspectorUI/UserInterface/Views/DOMTreeOutline.js >+++ b/Source/WebInspectorUI/UserInterface/Views/DOMTreeOutline.js >@@ -485,6 +485,9 @@ WI.DOMTreeOutline = class DOMTreeOutline extends WI.TreeOutline > if (!treeElement) > return false; > >+ event.dataTransfer.effectAllowed = "copyMove"; >+ event.dataTransfer.setData(DOMTreeOutline.DOMNodeIdDragType, treeElement.representedObject.id); >+ > if (!this._isValidDragSourceOrTarget(treeElement)) > return false; > >@@ -492,7 +495,6 @@ WI.DOMTreeOutline = class DOMTreeOutline extends WI.TreeOutline > return false; > > event.dataTransfer.setData("text/plain", treeElement.listItemElement.textContent); >- event.dataTransfer.effectAllowed = "copyMove"; > this._nodeBeingDragged = treeElement.representedObject; > > WI.domManager.hideDOMNodeHighlight(); >@@ -648,3 +650,5 @@ WI.DOMTreeOutline = class DOMTreeOutline extends WI.TreeOutline > WI.DOMTreeOutline.Event = { > SelectedNodeChanged: "dom-tree-outline-selected-node-changed" > }; >+ >+WI.DOMTreeOutline.DOMNodeIdDragType = "web-inspector/dom-node-id"; >diff --git a/Source/WebInspectorUI/UserInterface/Views/GeneralStyleDetailsSidebarPanel.js b/Source/WebInspectorUI/UserInterface/Views/GeneralStyleDetailsSidebarPanel.js >index f09a95c0497c40e7ff30c1fb3faf201275bc0b7c..a10004512a9dd1eaa498481ca78eea1a08dfdf0e 100644 >--- a/Source/WebInspectorUI/UserInterface/Views/GeneralStyleDetailsSidebarPanel.js >+++ b/Source/WebInspectorUI/UserInterface/Views/GeneralStyleDetailsSidebarPanel.js >@@ -463,4 +463,4 @@ WI.GeneralStyleDetailsSidebarPanel.NoFilterMatchInSectionClassName = "filter-sec > WI.GeneralStyleDetailsSidebarPanel.NoFilterMatchInPropertyClassName = "filter-property-non-matching"; > > WI.GeneralStyleDetailsSidebarPanel.ToggledClassesSymbol = Symbol("css-style-details-sidebar-panel-toggled-classes-symbol"); >-WI.GeneralStyleDetailsSidebarPanel.ToggledClassesDragType = "text/classname"; >+WI.GeneralStyleDetailsSidebarPanel.ToggledClassesDragType = "web-inspector/css-class"; >diff --git a/Source/WebInspectorUI/UserInterface/Views/LogContentView.js b/Source/WebInspectorUI/UserInterface/Views/LogContentView.js >index feebd4bbc2038cb350822ac138bfa03c37f0ca31..35924ae386b047ead5101162f63e451dca028b22 100644 >--- a/Source/WebInspectorUI/UserInterface/Views/LogContentView.js >+++ b/Source/WebInspectorUI/UserInterface/Views/LogContentView.js >@@ -47,6 +47,8 @@ WI.LogContentView = class LogContentView extends WI.ContentView > this.messagesElement.addEventListener("keydown", this._keyDown.bind(this)); > this.messagesElement.addEventListener("keypress", this._keyPress.bind(this)); > this.messagesElement.addEventListener("dragstart", this._ondragstart.bind(this), true); >+ this.messagesElement.addEventListener("dragover", this._handleDragOver.bind(this)); >+ this.messagesElement.addEventListener("drop", this._handleDrop.bind(this)); > this.element.appendChild(this.messagesElement); > > this.prompt = WI.quickConsole.prompt; >@@ -618,6 +620,32 @@ WI.LogContentView = class LogContentView extends WI.ContentView > } > } > >+ _handleDragOver(event) >+ { >+ if (event.dataTransfer.types.includes(WI.DOMTreeOutline.DOMNodeIdDragType)) { >+ event.preventDefault(); >+ event.dataTransfer.dropEffect = "copy"; >+ } >+ } >+ >+ _handleDrop(event) >+ { >+ let domNodeId = event.dataTransfer.getData(WI.DOMTreeOutline.DOMNodeIdDragType); >+ if (domNodeId) { >+ event.preventDefault(); >+ >+ let domNode = WI.domManager.nodeForId(domNodeId); >+ WI.RemoteObject.resolveNode(domNode, WI.RuntimeManager.ConsoleObjectGroup) >+ .then((remoteObject) => { >+ let text = domNode.nodeType() === Node.ELEMENT_NODE ? WI.UIString("Dropped Element") : WI.UIString("Dropped Node"); >+ const addSpecialUserLogClass = true; >+ WI.consoleLogViewController.appendImmediateExecutionWithResult(text, remoteObject, addSpecialUserLogClass); >+ >+ this.prompt.focus(); >+ }); >+ } >+ } >+ > handleEvent(event) > { > switch (event.type) { >diff --git a/Source/WebInspectorUI/UserInterface/Views/QuickConsole.js b/Source/WebInspectorUI/UserInterface/Views/QuickConsole.js >index 5187b3074c16223c904891c69350f6568cb34568..01eea3d828b0a612408158826a4200b70e39e551 100644 >--- a/Source/WebInspectorUI/UserInterface/Views/QuickConsole.js >+++ b/Source/WebInspectorUI/UserInterface/Views/QuickConsole.js >@@ -46,6 +46,8 @@ WI.QuickConsole = class QuickConsole extends WI.View > > this.element.classList.add("quick-console"); > this.element.addEventListener("mousedown", this._handleMouseDown.bind(this)); >+ this.element.addEventListener("dragover", this._handleDragOver.bind(this)); >+ this.element.addEventListener("drop", this._handleDrop.bind(this), true); // Ensure that dropping a DOM node doesn't copy text. > > this.prompt = new WI.ConsolePrompt(null, "text/javascript"); > this.addSubview(this.prompt); >@@ -171,6 +173,32 @@ WI.QuickConsole = class QuickConsole extends WI.View > this.prompt.focus(); > } > >+ _handleDragOver(event) >+ { >+ if (event.dataTransfer.types.includes(WI.DOMTreeOutline.DOMNodeIdDragType)) { >+ event.preventDefault(); >+ event.dataTransfer.dropEffect = "copy"; >+ } >+ } >+ >+ _handleDrop(event) >+ { >+ let domNodeId = event.dataTransfer.getData(WI.DOMTreeOutline.DOMNodeIdDragType); >+ if (domNodeId) { >+ event.preventDefault(); >+ >+ let domNode = WI.domManager.nodeForId(domNodeId); >+ WI.RemoteObject.resolveNode(domNode, WI.RuntimeManager.ConsoleObjectGroup) >+ .then((remoteObject) => { >+ let text = domNode.nodeType() === Node.ELEMENT_NODE ? WI.UIString("Dropped Element") : WI.UIString("Dropped Node"); >+ const addSpecialUserLogClass = true; >+ WI.consoleLogViewController.appendImmediateExecutionWithResult(text, remoteObject, addSpecialUserLogClass); >+ >+ this.prompt.focus(); >+ }); >+ } >+ } >+ > _executionContextPathComponentsToDisplay() > { > // If we are in the debugger the console will use the active call frame, don't show the selector.
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 197330
:
368414
| 369035