Commit 307d0cea authored by Kent Tamura's avatar Kent Tamura Committed by Commit Bot

TextControl NG: Add runtime flags

This CL adds two flags, LayoutNGTextArea for <input> and
LayoutNGTextField for <textarea>. They depend on EditingNG flag.

SearchFieldCancelButtonElement and EditingViewPortElement refer to
LayoutNGTextField flag because only <input> uses them.

Both of <input> and <textarea> use TextControlInnerEditorElement.
So its TypeShouldForceLegacyLayout() checks the host element type.

This CL has no behavior changes. These flags are not enabled yet.

Bug: 1040826
Change-Id: I1caf433edb57ab2fec21c17744eff166d0a4deee
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2444636Reviewed-by: default avatarYoshifumi Inoue <yosin@chromium.org>
Commit-Queue: Kent Tamura <tkent@chromium.org>
Cr-Commit-Position: refs/heads/master@{#813188}
parent d6d00034
......@@ -214,10 +214,16 @@ void HTMLTextAreaElement::ParseAttribute(
}
}
bool HTMLTextAreaElement::TypeShouldForceLegacyLayout() const {
if (RuntimeEnabledFeatures::LayoutNGTextAreaEnabled())
return false;
UseCounter::Count(GetDocument(), WebFeature::kLegacyLayoutByTextControl);
return true;
}
LayoutObject* HTMLTextAreaElement::CreateLayoutObject(
const ComputedStyle& style,
LegacyLayout legacy) {
UseCounter::Count(GetDocument(), WebFeature::kLegacyLayoutByTextControl);
return LayoutObjectFactory::CreateTextControlMultiLine(*this, style, legacy);
}
......
......@@ -117,7 +117,7 @@ class CORE_EXPORT HTMLTextAreaElement final : public TextControlElement {
const QualifiedName&,
const AtomicString&,
MutableCSSPropertyValueSet*) override;
bool TypeShouldForceLegacyLayout() const override { return true; }
bool TypeShouldForceLegacyLayout() const override;
LayoutObject* CreateLayoutObject(const ComputedStyle&, LegacyLayout) override;
void AppendToFormData(FormData&) override;
void ResetImpl() override;
......
......@@ -64,6 +64,10 @@ EditingViewPortElement::CustomStyleForLayoutObject() {
return style;
}
bool EditingViewPortElement::TypeShouldForceLegacyLayout() const {
return !RuntimeEnabledFeatures::LayoutNGTextFieldEnabled();
}
// ---------------------------
TextControlInnerEditorElement::TextControlInnerEditorElement(Document& document)
......@@ -118,6 +122,12 @@ void TextControlInnerEditorElement::FocusChanged() {
style_change_reason::kControl));
}
bool TextControlInnerEditorElement::TypeShouldForceLegacyLayout() const {
if (OwnerShadowHost()->HasTagName(html_names::kInputTag))
return !RuntimeEnabledFeatures::LayoutNGTextFieldEnabled();
return !RuntimeEnabledFeatures::LayoutNGTextAreaEnabled();
}
LayoutObject* TextControlInnerEditorElement::CreateLayoutObject(
const ComputedStyle& style,
LegacyLayout legacy) {
......@@ -241,6 +251,10 @@ bool SearchFieldCancelButtonElement::WillRespondToMouseClickEvents() {
return HTMLDivElement::WillRespondToMouseClickEvents();
}
bool SearchFieldCancelButtonElement::TypeShouldForceLegacyLayout() const {
return !RuntimeEnabledFeatures::LayoutNGTextFieldEnabled();
}
// ----------------------------
PasswordRevealButtonElement::PasswordRevealButtonElement(Document& document)
......
......@@ -40,7 +40,7 @@ class EditingViewPortElement final : public HTMLDivElement {
scoped_refptr<ComputedStyle> CustomStyleForLayoutObject() override;
private:
bool TypeShouldForceLegacyLayout() const final { return true; }
bool TypeShouldForceLegacyLayout() const final;
bool SupportsFocus() const override { return false; }
};
......@@ -56,7 +56,7 @@ class TextControlInnerEditorElement final : public HTMLDivElement {
private:
LayoutObject* CreateLayoutObject(const ComputedStyle&, LegacyLayout) override;
bool TypeShouldForceLegacyLayout() const final { return true; }
bool TypeShouldForceLegacyLayout() const final;
scoped_refptr<ComputedStyle> CustomStyleForLayoutObject() override;
bool SupportsFocus() const override { return false; }
bool is_visible_ = true;
......@@ -70,7 +70,7 @@ class SearchFieldCancelButtonElement final : public HTMLDivElement {
bool WillRespondToMouseClickEvents() override;
private:
bool TypeShouldForceLegacyLayout() const final { return true; }
bool TypeShouldForceLegacyLayout() const final;
bool SupportsFocus() const override { return false; }
};
......
......@@ -277,14 +277,16 @@ void TextFieldInputType::CustomStyleForLayoutObject(ComputedStyle& style) {
}
bool TextFieldInputType::TypeShouldForceLegacyLayout() const {
if (RuntimeEnabledFeatures::LayoutNGTextFieldEnabled())
return false;
UseCounter::Count(GetElement().GetDocument(),
WebFeature::kLegacyLayoutByTextControl);
return true;
}
LayoutObject* TextFieldInputType::CreateLayoutObject(
const ComputedStyle& style,
LegacyLayout legacy) const {
UseCounter::Count(GetElement().GetDocument(),
WebFeature::kLegacyLayoutByTextControl);
return LayoutObjectFactory::CreateTextControlSingleLine(GetElement(), style,
legacy);
}
......
......@@ -1034,6 +1034,14 @@
{
name: "LayoutNGTable",
},
{
name: "LayoutNGTextArea",
depends_on: ["EditingNG"],
},
{
name: "LayoutNGTextField",
depends_on: ["EditingNG"],
},
{
// Adds the "sources" attribute to the LayoutShift interface for the
// Layout Instability API (bit.ly/cls-sources).
......
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