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();
|
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() {
|
void WebContents::Undo() {
|
||||||
web_contents()->Undo();
|
web_contents()->Undo();
|
||||||
}
|
}
|
||||||
|
@ -591,6 +598,7 @@ mate::ObjectTemplateBuilder WebContents::GetObjectTemplateBuilder(
|
||||||
.SetMethod("openDevTools", &WebContents::OpenDevTools)
|
.SetMethod("openDevTools", &WebContents::OpenDevTools)
|
||||||
.SetMethod("closeDevTools", &WebContents::CloseDevTools)
|
.SetMethod("closeDevTools", &WebContents::CloseDevTools)
|
||||||
.SetMethod("isDevToolsOpened", &WebContents::IsDevToolsOpened)
|
.SetMethod("isDevToolsOpened", &WebContents::IsDevToolsOpened)
|
||||||
|
.SetMethod("inspectElement", &WebContents::InspectElement)
|
||||||
.SetMethod("undo", &WebContents::Undo)
|
.SetMethod("undo", &WebContents::Undo)
|
||||||
.SetMethod("redo", &WebContents::Redo)
|
.SetMethod("redo", &WebContents::Redo)
|
||||||
.SetMethod("cut", &WebContents::Cut)
|
.SetMethod("cut", &WebContents::Cut)
|
||||||
|
|
|
@ -67,6 +67,7 @@ class WebContents : public mate::EventEmitter,
|
||||||
void OpenDevTools();
|
void OpenDevTools();
|
||||||
void CloseDevTools();
|
void CloseDevTools();
|
||||||
bool IsDevToolsOpened();
|
bool IsDevToolsOpened();
|
||||||
|
void InspectElement(int x, int y);
|
||||||
|
|
||||||
// Editing commands.
|
// Editing commands.
|
||||||
void Undo();
|
void Undo();
|
||||||
|
|
|
@ -255,6 +255,7 @@ registerWebViewElement = ->
|
||||||
"openDevTools"
|
"openDevTools"
|
||||||
"closeDevTools"
|
"closeDevTools"
|
||||||
"isDevToolsOpened"
|
"isDevToolsOpened"
|
||||||
|
"inspectElement"
|
||||||
"undo"
|
"undo"
|
||||||
"redo"
|
"redo"
|
||||||
"cut"
|
"cut"
|
||||||
|
|
|
@ -219,6 +219,13 @@ Closes the devtools window of guest page.
|
||||||
|
|
||||||
Returns whether guest page has a devtools window attached.
|
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()
|
### `<webview>`.undo()
|
||||||
|
|
||||||
Executes editing command `undo` in page.
|
Executes editing command `undo` in page.
|
||||||
|
|
Loading…
Reference in a new issue