Skip to content
This repository has been archived by the owner on Dec 11, 2019. It is now read-only.

Fixes dev tools inspect element functionality #10660

Merged
merged 1 commit into from
Aug 26, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions app/browser/reducers/tabsReducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,11 @@ const tabsReducer = (state, action, immutableAction) => {
tabs.toggleDevTools(action.get('tabId'))
})
break
case appConstants.APP_INSPECT_ELEMENT:
setImmediate(() => {
tabs.inspectElement(action.get('tabId'), action.get('x'), action.get('y'))
})
break
case appConstants.APP_LOAD_URL_REQUESTED:
setImmediate(() => {
tabs.loadURL(action)
Expand Down
7 changes: 7 additions & 0 deletions app/browser/tabs.js
Original file line number Diff line number Diff line change
Expand Up @@ -525,6 +525,13 @@ const api = {
}
},

inspectElement: (tabId, x, y) => {
const tab = getWebContents(tabId)
if (tab && !tab.isDestroyed()) {
tab.inspectElement(x, y)
}
},

setActive: (tabId) => {
let tab = getWebContents(tabId)
if (tab && !tab.isDestroyed()) {
Expand Down
15 changes: 15 additions & 0 deletions js/actions/appActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -867,6 +867,21 @@ const appActions = {
})
},

/**
* Dispatches a message to inspect desired element on the page
* @param {number} tabId - The tabId
* @param {number} x - horizontal position of the element
* @param {number} y - vertical position of the element
*/
inspectElement: function (tabId, x, y) {
dispatch({
actionType: appConstants.APP_INSPECT_ELEMENT,
tabId,
x,
y
})
},

/**
* Dispatches a message when a tab is being cloned
* @param {number} tabId - The tabId of the tab to clone
Expand Down
12 changes: 0 additions & 12 deletions js/actions/webviewActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,6 @@ const webviewActions = {
}
},

/**
* Inspect the element for the active webview at the x, y content position
* @param {number} x - horizontal position of the element to inspect
* @param {number} y - vertical position of the element to inspect
*/
inspectElement: function (x, y) {
const webview = getWebview()
if (webview) {
webview.inspectElement(x, y)
}
},

/**
* Shows the certificate infomation
*/
Expand Down
3 changes: 2 additions & 1 deletion js/constants/appConstants.js
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,8 @@ const appConstants = {
APP_REMOVE_BOOKMARK_FOLDER: _,
APP_REMOVE_BOOKMARK: _,
APP_MOVE_BOOKMARK_FOLDER: _,
APP_MOVE_BOOKMARK: _
APP_MOVE_BOOKMARK: _,
APP_INSPECT_ELEMENT: _
}

module.exports = mapValuesByKeys(appConstants)
4 changes: 2 additions & 2 deletions js/contextMenus.js
Original file line number Diff line number Diff line change
Expand Up @@ -1154,8 +1154,8 @@ function mainTemplateInit (nodeProps, frame, tab) {
if (!isAboutPage) {
template.push({
label: locale.translation('inspectElement'),
click: (item) => {
webviewActions.inspectElement(nodeProps.x, nodeProps.y)
click: () => {
appActions.inspectElement(frame.get('tabId'), nodeProps.x, nodeProps.y)
}
})
}
Expand Down