Commit e37fc7c6 authored by Jochen Eisinger's avatar Jochen Eisinger Committed by Commit Bot

Remove hack for TreatNullAsString

This was supposed to be a temporary workaround until issue 714866 is
fixed, but never got removed.

BUG=774176,783916
R=mkwst@chromium.org,haraken@chromium.org

Change-Id: I381d0bca04707d0a361d9ce12c96e189b626c389
Reviewed-on: https://chromium-review.googlesource.com/762436
Commit-Queue: Jochen Eisinger <jochen@chromium.org>
Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Reviewed-by: default avatarHayato Ito <hayato@chromium.org>
Cr-Commit-Position: refs/heads/master@{#515861}
parent ea7edb72
<!doctype html>
<script src="../../../resources/testharness.js"></script>
<script src="../../../resources/testharnessreport.js"></script>
<script>
test(() => {
let p = document.createElement("p");
p.innerHTML = "null";
assert_equals(p.innerText, "null");
}, "Setting innerHTML to the string null doesn't result in an empty element");
</script>
......@@ -14,6 +14,7 @@ bindings_core_v8_files =
"core/v8/custom/V8CustomXPathNSResolver.h",
"core/v8/custom/V8DevToolsHostCustom.cpp",
"core/v8/custom/V8DocumentCustom.cpp",
"core/v8/custom/V8ElementCustom.cpp",
"core/v8/custom/V8ErrorEventCustom.cpp",
"core/v8/custom/V8EventTargetCustom.cpp",
"core/v8/custom/V8HTMLAllCollectionCustom.cpp",
......@@ -22,6 +23,7 @@ bindings_core_v8_files =
"core/v8/custom/V8MessageEventCustom.cpp",
"core/v8/custom/V8PopStateEventCustom.cpp",
"core/v8/custom/V8PromiseRejectionEventCustom.cpp",
"core/v8/custom/V8ShadowRootCustom.cpp",
"core/v8/custom/V8WindowCustom.cpp",
"core/v8/custom/V8XMLHttpRequestCustom.cpp",
"core/v8/ArrayValue.cpp",
......
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "bindings/core/v8/V8Element.h"
#include "bindings/core/v8/ExceptionState.h"
#include "bindings/core/v8/IDLTypes.h"
#include "bindings/core/v8/V8TrustedHTML.h"
#include "core/html/custom/V0CustomElementProcessingStack.h"
namespace blink {
// HTMLElement -----------------------------------------------------------------
void V8Element::innerHTMLAttributeSetterCustom(
v8::Local<v8::Value> value,
const v8::FunctionCallbackInfo<v8::Value>& info) {
v8::Isolate* isolate = info.GetIsolate();
v8::Local<v8::Object> holder = info.Holder();
Element* impl = V8Element::ToImpl(holder);
V0CustomElementProcessingStack::CallbackDeliveryScope delivery_scope;
ExceptionState exception_state(isolate, ExceptionState::kSetterContext,
"Element", "innerHTML");
// Prepare the value to be set.
StringOrTrustedHTML cpp_value;
// This if statement is the only difference to the generated code and ensures
// that only null but not undefined is treated as the empty string.
// https://crbug.com/783916
if (value->IsNull()) {
cpp_value.SetString(String());
} else {
V8StringOrTrustedHTML::ToImpl(info.GetIsolate(), value, cpp_value,
UnionTypeConversionMode::kNotNullable,
exception_state);
}
if (exception_state.HadException())
return;
impl->setInnerHTML(cpp_value, exception_state);
}
void V8Element::outerHTMLAttributeSetterCustom(
v8::Local<v8::Value> value,
const v8::FunctionCallbackInfo<v8::Value>& info) {
v8::Isolate* isolate = info.GetIsolate();
v8::Local<v8::Object> holder = info.Holder();
Element* impl = V8Element::ToImpl(holder);
V0CustomElementProcessingStack::CallbackDeliveryScope delivery_scope;
ExceptionState exception_state(isolate, ExceptionState::kSetterContext,
"Element", "outerHTML");
// Prepare the value to be set.
StringOrTrustedHTML cpp_value;
// This if statement is the only difference to the generated code and ensures
// that only null but not undefined is treated as the empty string.
// https://crbug.com/783916
if (value->IsNull()) {
cpp_value.SetString(String());
} else {
V8StringOrTrustedHTML::ToImpl(info.GetIsolate(), value, cpp_value,
UnionTypeConversionMode::kNotNullable,
exception_state);
}
if (exception_state.HadException())
return;
impl->setOuterHTML(cpp_value, exception_state);
}
} // namespace blink
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "bindings/core/v8/V8ShadowRoot.h"
#include "bindings/core/v8/ExceptionState.h"
#include "bindings/core/v8/IDLTypes.h"
#include "bindings/core/v8/V8TrustedHTML.h"
#include "core/html/custom/V0CustomElementProcessingStack.h"
namespace blink {
// HTMLShadowRoot --------------------------------------------------------------
void V8ShadowRoot::innerHTMLAttributeSetterCustom(
v8::Local<v8::Value> value,
const v8::FunctionCallbackInfo<v8::Value>& info) {
v8::Isolate* isolate = info.GetIsolate();
v8::Local<v8::Object> holder = info.Holder();
ShadowRoot* impl = V8ShadowRoot::ToImpl(holder);
V0CustomElementProcessingStack::CallbackDeliveryScope delivery_scope;
ExceptionState exception_state(isolate, ExceptionState::kSetterContext,
"ShadowRoot", "innerHTML");
// Prepare the value to be set.
StringOrTrustedHTML cpp_value;
// This if statement is the only difference to the generated code and ensures
// that only null but not undefined is treated as the empty string.
// https://crbug.com/783916
if (value->IsNull()) {
cpp_value.SetString(String());
} else {
V8StringOrTrustedHTML::ToImpl(info.GetIsolate(), value, cpp_value,
UnionTypeConversionMode::kNotNullable,
exception_state);
}
if (exception_state.HadException())
return;
impl->setInnerHTML(cpp_value, exception_state);
}
} // namespace blink
......@@ -3107,12 +3107,6 @@ void Element::setInnerHTML(const StringOrTrustedHTML& string_or_html,
? string_or_html.GetAsString()
: string_or_html.GetAsTrustedHTML()->toString();
// TODO(mkwst): This is an ugly hack that will be resolved once `TreatNullAs`
// is treated as an extended attribute on the `DOMString` type rather than
// as an extended attribute on the attribute. https://crbug.com/714866
if (html == "null")
html = "";
SetInnerHTMLFromString(html, exception_state);
}
......@@ -3169,12 +3163,6 @@ void Element::setOuterHTML(const StringOrTrustedHTML& string_or_html,
? string_or_html.GetAsString()
: string_or_html.GetAsTrustedHTML()->toString();
// TODO(mkwst): This is an ugly hack that will be resolved once `TreatNullAs`
// is treated as an extended attribute on the `DOMString` type rather than
// as an extended attribute on the attribute. https://crbug.com/714866
if (html == "null")
html = "";
SetOuterHTMLFromString(html, exception_state);
}
......
......@@ -82,8 +82,8 @@ interface Element : Node {
// https://w3c.github.io/DOM-Parsing/#extensions-to-the-element-interface
//
// TODO(mkwst): Write a spec for the `TrustedHTML` variants.
[TreatNullAs=NullString, CEReactions, CustomElementCallbacks, RaisesException=Setter, RuntimeCallStatsCounter=ElementInnerHTML] attribute HTMLString innerHTML;
[TreatNullAs=NullString, CEReactions, CustomElementCallbacks, RaisesException=Setter] attribute HTMLString outerHTML;
[CEReactions, CustomElementCallbacks, Custom=Setter, RuntimeCallStatsCounter=ElementInnerHTML] attribute HTMLString innerHTML;
[CEReactions, CustomElementCallbacks, Custom=Setter] attribute HTMLString outerHTML;
[CEReactions, CustomElementCallbacks, RaisesException] void insertAdjacentHTML(DOMString position, HTMLString text);
// Pointer Lock
......
......@@ -151,12 +151,6 @@ void ShadowRoot::setInnerHTML(const StringOrTrustedHTML& stringOrHtml,
? stringOrHtml.GetAsString()
: stringOrHtml.GetAsTrustedHTML()->toString();
// TODO(mkwst): This is an ugly hack that will be resolved once `TreatNullAs`
// is treated as an extended attribute on the `DOMString` type rather than
// as an extended attribute on the attribute. https://crbug.com/714866
if (html == "null")
html = "";
SetInnerHTMLFromString(html, exception_state);
}
......
......@@ -29,7 +29,7 @@
interface ShadowRoot : DocumentFragment {
readonly attribute ShadowRootMode mode;
readonly attribute Element host;
[TreatNullAs=NullString, CEReactions, CustomElementCallbacks, RaisesException=Setter] attribute HTMLString innerHTML;
[CEReactions, CustomElementCallbacks, Custom=Setter] attribute HTMLString innerHTML;
readonly attribute boolean delegatesFocus;
};
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment