feat: add removeInsertedCSS (#16579)

This commit is contained in:
Heilig Benedek 2019-06-17 17:39:36 +02:00 committed by John Kleinschmidt
parent deebde66f9
commit 5a08522b98
8 changed files with 88 additions and 9 deletions

View file

@ -325,11 +325,22 @@ void InsertText(v8::Local<v8::Value> window, const std::string& text) {
}
}
void InsertCSS(v8::Local<v8::Value> window, const std::string& css) {
base::string16 InsertCSS(v8::Local<v8::Value> window, const std::string& css) {
blink::WebFrame* web_frame = GetRenderFrame(window)->GetWebFrame();
if (web_frame->IsWebLocalFrame()) {
web_frame->ToWebLocalFrame()->GetDocument().InsertStyleSheet(
blink::WebString::FromUTF8(css));
return web_frame->ToWebLocalFrame()
->GetDocument()
.InsertStyleSheet(blink::WebString::FromUTF8(css))
.Utf16();
}
return base::string16();
}
void RemoveInsertedCSS(v8::Local<v8::Value> window, const base::string16& key) {
blink::WebFrame* web_frame = GetRenderFrame(window)->GetWebFrame();
if (web_frame->IsWebLocalFrame()) {
web_frame->ToWebLocalFrame()->GetDocument().RemoveInsertedStyleSheet(
blink::WebString::FromUTF16(key));
}
}
@ -546,6 +557,7 @@ void Initialize(v8::Local<v8::Object> exports,
dict.SetMethod("setSpellCheckProvider", &SetSpellCheckProvider);
dict.SetMethod("insertText", &InsertText);
dict.SetMethod("insertCSS", &InsertCSS);
dict.SetMethod("removeInsertedCSS", &RemoveInsertedCSS);
dict.SetMethod("executeJavaScript", &ExecuteJavaScript);
dict.SetMethod("executeJavaScriptInIsolatedWorld",
&ExecuteJavaScriptInIsolatedWorld);