webview: add inspectElement method
This commit is contained in:
parent
67bc4afe88
commit
cdb1711fe1
4 changed files with 17 additions and 0 deletions
|
@ -470,6 +470,13 @@ bool WebContents::IsDevToolsOpened() {
|
|||
return storage_->IsDevToolsViewShowing();
|
||||
}
|
||||
|
||||
void WebContents::InspectElement(int x, int y) {
|
||||
OpenDevTools();
|
||||
scoped_refptr<content::DevToolsAgentHost> agent(
|
||||
content::DevToolsAgentHost::GetOrCreateFor(storage_->GetWebContents()));
|
||||
agent->InspectElement(x, y);
|
||||
}
|
||||
|
||||
void WebContents::Undo() {
|
||||
web_contents()->Undo();
|
||||
}
|
||||
|
@ -591,6 +598,7 @@ mate::ObjectTemplateBuilder WebContents::GetObjectTemplateBuilder(
|
|||
.SetMethod("openDevTools", &WebContents::OpenDevTools)
|
||||
.SetMethod("closeDevTools", &WebContents::CloseDevTools)
|
||||
.SetMethod("isDevToolsOpened", &WebContents::IsDevToolsOpened)
|
||||
.SetMethod("inspectElement", &WebContents::InspectElement)
|
||||
.SetMethod("undo", &WebContents::Undo)
|
||||
.SetMethod("redo", &WebContents::Redo)
|
||||
.SetMethod("cut", &WebContents::Cut)
|
||||
|
|
|
@ -67,6 +67,7 @@ class WebContents : public mate::EventEmitter,
|
|||
void OpenDevTools();
|
||||
void CloseDevTools();
|
||||
bool IsDevToolsOpened();
|
||||
void InspectElement(int x, int y);
|
||||
|
||||
// Editing commands.
|
||||
void Undo();
|
||||
|
|
|
@ -255,6 +255,7 @@ registerWebViewElement = ->
|
|||
"openDevTools"
|
||||
"closeDevTools"
|
||||
"isDevToolsOpened"
|
||||
"inspectElement"
|
||||
"undo"
|
||||
"redo"
|
||||
"cut"
|
||||
|
|
|
@ -219,6 +219,13 @@ Closes the devtools window of guest page.
|
|||
|
||||
Returns whether guest page has a devtools window attached.
|
||||
|
||||
### `<webview>`.inspectElement(x, y)
|
||||
|
||||
* `x` Integer
|
||||
* `y` Integer
|
||||
|
||||
Starts inspecting element at position (`x`, `y`) of guest page.
|
||||
|
||||
### `<webview>`.undo()
|
||||
|
||||
Executes editing command `undo` in page.
|
||||
|
|
Loading…
Reference in a new issue