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( ...@@ -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( LayoutObject* HTMLTextAreaElement::CreateLayoutObject(
const ComputedStyle& style, const ComputedStyle& style,
LegacyLayout legacy) { LegacyLayout legacy) {
UseCounter::Count(GetDocument(), WebFeature::kLegacyLayoutByTextControl);
return LayoutObjectFactory::CreateTextControlMultiLine(*this, style, legacy); return LayoutObjectFactory::CreateTextControlMultiLine(*this, style, legacy);
} }
......
...@@ -117,7 +117,7 @@ class CORE_EXPORT HTMLTextAreaElement final : public TextControlElement { ...@@ -117,7 +117,7 @@ class CORE_EXPORT HTMLTextAreaElement final : public TextControlElement {
const QualifiedName&, const QualifiedName&,
const AtomicString&, const AtomicString&,
MutableCSSPropertyValueSet*) override; MutableCSSPropertyValueSet*) override;
bool TypeShouldForceLegacyLayout() const override { return true; } bool TypeShouldForceLegacyLayout() const override;
LayoutObject* CreateLayoutObject(const ComputedStyle&, LegacyLayout) override; LayoutObject* CreateLayoutObject(const ComputedStyle&, LegacyLayout) override;
void AppendToFormData(FormData&) override; void AppendToFormData(FormData&) override;
void ResetImpl() override; void ResetImpl() override;
......
...@@ -64,6 +64,10 @@ EditingViewPortElement::CustomStyleForLayoutObject() { ...@@ -64,6 +64,10 @@ EditingViewPortElement::CustomStyleForLayoutObject() {
return style; return style;
} }
bool EditingViewPortElement::TypeShouldForceLegacyLayout() const {
return !RuntimeEnabledFeatures::LayoutNGTextFieldEnabled();
}
// --------------------------- // ---------------------------
TextControlInnerEditorElement::TextControlInnerEditorElement(Document& document) TextControlInnerEditorElement::TextControlInnerEditorElement(Document& document)
...@@ -118,6 +122,12 @@ void TextControlInnerEditorElement::FocusChanged() { ...@@ -118,6 +122,12 @@ void TextControlInnerEditorElement::FocusChanged() {
style_change_reason::kControl)); style_change_reason::kControl));
} }
bool TextControlInnerEditorElement::TypeShouldForceLegacyLayout() const {
if (OwnerShadowHost()->HasTagName(html_names::kInputTag))
return !RuntimeEnabledFeatures::LayoutNGTextFieldEnabled();
return !RuntimeEnabledFeatures::LayoutNGTextAreaEnabled();
}
LayoutObject* TextControlInnerEditorElement::CreateLayoutObject( LayoutObject* TextControlInnerEditorElement::CreateLayoutObject(
const ComputedStyle& style, const ComputedStyle& style,
LegacyLayout legacy) { LegacyLayout legacy) {
...@@ -241,6 +251,10 @@ bool SearchFieldCancelButtonElement::WillRespondToMouseClickEvents() { ...@@ -241,6 +251,10 @@ bool SearchFieldCancelButtonElement::WillRespondToMouseClickEvents() {
return HTMLDivElement::WillRespondToMouseClickEvents(); return HTMLDivElement::WillRespondToMouseClickEvents();
} }
bool SearchFieldCancelButtonElement::TypeShouldForceLegacyLayout() const {
return !RuntimeEnabledFeatures::LayoutNGTextFieldEnabled();
}
// ---------------------------- // ----------------------------
PasswordRevealButtonElement::PasswordRevealButtonElement(Document& document) PasswordRevealButtonElement::PasswordRevealButtonElement(Document& document)
......
...@@ -40,7 +40,7 @@ class EditingViewPortElement final : public HTMLDivElement { ...@@ -40,7 +40,7 @@ class EditingViewPortElement final : public HTMLDivElement {
scoped_refptr<ComputedStyle> CustomStyleForLayoutObject() override; scoped_refptr<ComputedStyle> CustomStyleForLayoutObject() override;
private: private:
bool TypeShouldForceLegacyLayout() const final { return true; } bool TypeShouldForceLegacyLayout() const final;
bool SupportsFocus() const override { return false; } bool SupportsFocus() const override { return false; }
}; };
...@@ -56,7 +56,7 @@ class TextControlInnerEditorElement final : public HTMLDivElement { ...@@ -56,7 +56,7 @@ class TextControlInnerEditorElement final : public HTMLDivElement {
private: private:
LayoutObject* CreateLayoutObject(const ComputedStyle&, LegacyLayout) override; LayoutObject* CreateLayoutObject(const ComputedStyle&, LegacyLayout) override;
bool TypeShouldForceLegacyLayout() const final { return true; } bool TypeShouldForceLegacyLayout() const final;
scoped_refptr<ComputedStyle> CustomStyleForLayoutObject() override; scoped_refptr<ComputedStyle> CustomStyleForLayoutObject() override;
bool SupportsFocus() const override { return false; } bool SupportsFocus() const override { return false; }
bool is_visible_ = true; bool is_visible_ = true;
...@@ -70,7 +70,7 @@ class SearchFieldCancelButtonElement final : public HTMLDivElement { ...@@ -70,7 +70,7 @@ class SearchFieldCancelButtonElement final : public HTMLDivElement {
bool WillRespondToMouseClickEvents() override; bool WillRespondToMouseClickEvents() override;
private: private:
bool TypeShouldForceLegacyLayout() const final { return true; } bool TypeShouldForceLegacyLayout() const final;
bool SupportsFocus() const override { return false; } bool SupportsFocus() const override { return false; }
}; };
......
...@@ -277,14 +277,16 @@ void TextFieldInputType::CustomStyleForLayoutObject(ComputedStyle& style) { ...@@ -277,14 +277,16 @@ void TextFieldInputType::CustomStyleForLayoutObject(ComputedStyle& style) {
} }
bool TextFieldInputType::TypeShouldForceLegacyLayout() const { bool TextFieldInputType::TypeShouldForceLegacyLayout() const {
if (RuntimeEnabledFeatures::LayoutNGTextFieldEnabled())
return false;
UseCounter::Count(GetElement().GetDocument(),
WebFeature::kLegacyLayoutByTextControl);
return true; return true;
} }
LayoutObject* TextFieldInputType::CreateLayoutObject( LayoutObject* TextFieldInputType::CreateLayoutObject(
const ComputedStyle& style, const ComputedStyle& style,
LegacyLayout legacy) const { LegacyLayout legacy) const {
UseCounter::Count(GetElement().GetDocument(),
WebFeature::kLegacyLayoutByTextControl);
return LayoutObjectFactory::CreateTextControlSingleLine(GetElement(), style, return LayoutObjectFactory::CreateTextControlSingleLine(GetElement(), style,
legacy); legacy);
} }
......
...@@ -1034,6 +1034,14 @@ ...@@ -1034,6 +1034,14 @@
{ {
name: "LayoutNGTable", name: "LayoutNGTable",
}, },
{
name: "LayoutNGTextArea",
depends_on: ["EditingNG"],
},
{
name: "LayoutNGTextField",
depends_on: ["EditingNG"],
},
{ {
// Adds the "sources" attribute to the LayoutShift interface for the // Adds the "sources" attribute to the LayoutShift interface for the
// Layout Instability API (bit.ly/cls-sources). // 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