Commit 3d66250d authored by Kent Tamura's avatar Kent Tamura Committed by Commit Bot

TextControl NG: Add CreateTextControl*() to LayoutObjectFactory

Add CreateTextControlInnerEditor(), CreateTextControlMultiLine(),
CreateTextControlSingleLine() to blink::LayoutObjectFactory so that we
can switch text control's LayoutObject to LayoutNGTextContorl*.

- Change the constructor arguments of LayoutTextControl*Line to
|Element*|. It's a requirement of LayoutObjectFactory.

This CL has no behavior changes because their LegacyLayout arguments
are always kForce.

Bug: 1040826
Change-Id: I5960d5c9163c1c975a3ddc195dad177ae9380a23
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2440000
Auto-Submit: Kent Tamura <tkent@chromium.org>
Reviewed-by: default avatarKoji Ishii <kojii@chromium.org>
Commit-Queue: Kent Tamura <tkent@chromium.org>
Cr-Commit-Position: refs/heads/master@{#812630}
parent 03cf65ef
...@@ -47,7 +47,8 @@ ...@@ -47,7 +47,8 @@
#include "third_party/blink/renderer/core/html/parser/html_parser_idioms.h" #include "third_party/blink/renderer/core/html/parser/html_parser_idioms.h"
#include "third_party/blink/renderer/core/html/shadow/shadow_element_names.h" #include "third_party/blink/renderer/core/html/shadow/shadow_element_names.h"
#include "third_party/blink/renderer/core/html_names.h" #include "third_party/blink/renderer/core/html_names.h"
#include "third_party/blink/renderer/core/layout/layout_text_control_multi_line.h" #include "third_party/blink/renderer/core/layout/layout_object.h"
#include "third_party/blink/renderer/core/layout/layout_object_factory.h"
#include "third_party/blink/renderer/core/page/chrome_client.h" #include "third_party/blink/renderer/core/page/chrome_client.h"
#include "third_party/blink/renderer/core/page/page.h" #include "third_party/blink/renderer/core/page/page.h"
#include "third_party/blink/renderer/platform/bindings/exception_state.h" #include "third_party/blink/renderer/platform/bindings/exception_state.h"
...@@ -213,10 +214,11 @@ void HTMLTextAreaElement::ParseAttribute( ...@@ -213,10 +214,11 @@ void HTMLTextAreaElement::ParseAttribute(
} }
} }
LayoutObject* HTMLTextAreaElement::CreateLayoutObject(const ComputedStyle&, LayoutObject* HTMLTextAreaElement::CreateLayoutObject(
LegacyLayout) { const ComputedStyle& style,
LegacyLayout legacy) {
UseCounter::Count(GetDocument(), WebFeature::kLegacyLayoutByTextControl); UseCounter::Count(GetDocument(), WebFeature::kLegacyLayoutByTextControl);
return new LayoutTextControlMultiLine(this); return LayoutObjectFactory::CreateTextControlMultiLine(*this, style, legacy);
} }
void HTMLTextAreaElement::AppendToFormData(FormData& form_data) { void HTMLTextAreaElement::AppendToFormData(FormData& form_data) {
......
...@@ -35,7 +35,7 @@ ...@@ -35,7 +35,7 @@
#include "third_party/blink/renderer/core/html/forms/html_input_element.h" #include "third_party/blink/renderer/core/html/forms/html_input_element.h"
#include "third_party/blink/renderer/core/html/shadow/shadow_element_names.h" #include "third_party/blink/renderer/core/html/shadow/shadow_element_names.h"
#include "third_party/blink/renderer/core/html_names.h" #include "third_party/blink/renderer/core/html_names.h"
#include "third_party/blink/renderer/core/layout/layout_text_control_single_line.h" #include "third_party/blink/renderer/core/layout/layout_object_factory.h"
namespace blink { namespace blink {
...@@ -119,9 +119,10 @@ void TextControlInnerEditorElement::FocusChanged() { ...@@ -119,9 +119,10 @@ void TextControlInnerEditorElement::FocusChanged() {
} }
LayoutObject* TextControlInnerEditorElement::CreateLayoutObject( LayoutObject* TextControlInnerEditorElement::CreateLayoutObject(
const ComputedStyle&, const ComputedStyle& style,
LegacyLayout) { LegacyLayout legacy) {
return new LayoutTextControlInnerEditor(this); return LayoutObjectFactory::CreateTextControlInnerEditor(*this, style,
legacy);
} }
scoped_refptr<ComputedStyle> scoped_refptr<ComputedStyle>
......
...@@ -46,8 +46,7 @@ ...@@ -46,8 +46,7 @@
#include "third_party/blink/renderer/core/html/shadow/shadow_element_names.h" #include "third_party/blink/renderer/core/html/shadow/shadow_element_names.h"
#include "third_party/blink/renderer/core/html_names.h" #include "third_party/blink/renderer/core/html_names.h"
#include "third_party/blink/renderer/core/layout/layout_details_marker.h" #include "third_party/blink/renderer/core/layout/layout_details_marker.h"
#include "third_party/blink/renderer/core/layout/layout_text_control_single_line.h" #include "third_party/blink/renderer/core/layout/layout_object_factory.h"
#include "third_party/blink/renderer/core/layout/layout_theme.h"
#include "third_party/blink/renderer/core/page/chrome_client.h" #include "third_party/blink/renderer/core/page/chrome_client.h"
#include "third_party/blink/renderer/core/page/page.h" #include "third_party/blink/renderer/core/page/page.h"
#include "third_party/blink/renderer/core/paint/paint_layer.h" #include "third_party/blink/renderer/core/paint/paint_layer.h"
...@@ -281,11 +280,13 @@ bool TextFieldInputType::TypeShouldForceLegacyLayout() const { ...@@ -281,11 +280,13 @@ bool TextFieldInputType::TypeShouldForceLegacyLayout() const {
return true; return true;
} }
LayoutObject* TextFieldInputType::CreateLayoutObject(const ComputedStyle&, LayoutObject* TextFieldInputType::CreateLayoutObject(
LegacyLayout) const { const ComputedStyle& style,
LegacyLayout legacy) const {
UseCounter::Count(GetElement().GetDocument(), UseCounter::Count(GetElement().GetDocument(),
WebFeature::kLegacyLayoutByTextControl); WebFeature::kLegacyLayoutByTextControl);
return new LayoutTextControlSingleLine(&GetElement()); return LayoutObjectFactory::CreateTextControlSingleLine(GetElement(), style,
legacy);
} }
void TextFieldInputType::CreateShadowSubtree() { void TextFieldInputType::CreateShadowSubtree() {
......
...@@ -25,6 +25,8 @@ ...@@ -25,6 +25,8 @@
#include "third_party/blink/renderer/core/layout/layout_table_row.h" #include "third_party/blink/renderer/core/layout/layout_table_row.h"
#include "third_party/blink/renderer/core/layout/layout_table_section.h" #include "third_party/blink/renderer/core/layout/layout_table_section.h"
#include "third_party/blink/renderer/core/layout/layout_text.h" #include "third_party/blink/renderer/core/layout/layout_text.h"
#include "third_party/blink/renderer/core/layout/layout_text_control_multi_line.h"
#include "third_party/blink/renderer/core/layout/layout_text_control_single_line.h"
#include "third_party/blink/renderer/core/layout/layout_text_fragment.h" #include "third_party/blink/renderer/core/layout/layout_text_fragment.h"
#include "third_party/blink/renderer/core/layout/layout_view.h" #include "third_party/blink/renderer/core/layout/layout_view.h"
#include "third_party/blink/renderer/core/layout/ng/flex/layout_ng_flexible_box.h" #include "third_party/blink/renderer/core/layout/ng/flex/layout_ng_flexible_box.h"
...@@ -36,6 +38,9 @@ ...@@ -36,6 +38,9 @@
#include "third_party/blink/renderer/core/layout/ng/layout_ng_fieldset.h" #include "third_party/blink/renderer/core/layout/ng/layout_ng_fieldset.h"
#include "third_party/blink/renderer/core/layout/ng/layout_ng_progress.h" #include "third_party/blink/renderer/core/layout/ng/layout_ng_progress.h"
#include "third_party/blink/renderer/core/layout/ng/layout_ng_ruby_as_block.h" #include "third_party/blink/renderer/core/layout/ng/layout_ng_ruby_as_block.h"
#include "third_party/blink/renderer/core/layout/ng/layout_ng_text_control_inner_editor.h"
#include "third_party/blink/renderer/core/layout/ng/layout_ng_text_control_multi_line.h"
#include "third_party/blink/renderer/core/layout/ng/layout_ng_text_control_single_line.h"
#include "third_party/blink/renderer/core/layout/ng/list/layout_ng_inside_list_marker.h" #include "third_party/blink/renderer/core/layout/ng/list/layout_ng_inside_list_marker.h"
#include "third_party/blink/renderer/core/layout/ng/list/layout_ng_list_item.h" #include "third_party/blink/renderer/core/layout/ng/list/layout_ng_list_item.h"
#include "third_party/blink/renderer/core/layout/ng/list/layout_ng_outside_list_marker.h" #include "third_party/blink/renderer/core/layout/ng/list/layout_ng_outside_list_marker.h"
...@@ -266,6 +271,30 @@ LayoutObject* LayoutObjectFactory::CreateSliderTrack(Node& node, ...@@ -266,6 +271,30 @@ LayoutObject* LayoutObjectFactory::CreateSliderTrack(Node& node,
node, style, legacy); node, style, legacy);
} }
LayoutObject* LayoutObjectFactory::CreateTextControlInnerEditor(
Node& node,
const ComputedStyle& style,
LegacyLayout legacy) {
return CreateObject<LayoutBlockFlow, LayoutNGTextControlInnerEditor,
LayoutTextControlInnerEditor>(node, style, legacy);
}
LayoutObject* LayoutObjectFactory::CreateTextControlMultiLine(
Node& node,
const ComputedStyle& style,
LegacyLayout legacy) {
return CreateObject<LayoutBlockFlow, LayoutNGTextControlMultiLine,
LayoutTextControlMultiLine>(node, style, legacy);
}
LayoutObject* LayoutObjectFactory::CreateTextControlSingleLine(
Node& node,
const ComputedStyle& style,
LegacyLayout legacy) {
return CreateObject<LayoutBlockFlow, LayoutNGTextControlSingleLine,
LayoutTextControlSingleLine>(node, style, legacy);
}
LayoutText* LayoutObjectFactory::CreateText(Node* node, LayoutText* LayoutObjectFactory::CreateText(Node* node,
scoped_refptr<StringImpl> str, scoped_refptr<StringImpl> str,
LegacyLayout legacy) { LegacyLayout legacy) {
......
...@@ -76,6 +76,15 @@ class LayoutObjectFactory { ...@@ -76,6 +76,15 @@ class LayoutObjectFactory {
static LayoutObject* CreateSliderTrack(Node& node, static LayoutObject* CreateSliderTrack(Node& node,
const ComputedStyle& style, const ComputedStyle& style,
LegacyLayout legacy); LegacyLayout legacy);
static LayoutObject* CreateTextControlInnerEditor(Node& node,
const ComputedStyle& style,
LegacyLayout legacy);
static LayoutObject* CreateTextControlMultiLine(Node& node,
const ComputedStyle& style,
LegacyLayout legacy);
static LayoutObject* CreateTextControlSingleLine(Node& node,
const ComputedStyle& style,
LegacyLayout legacy);
static LayoutText* CreateText(Node*, scoped_refptr<StringImpl>, LegacyLayout); static LayoutText* CreateText(Node*, scoped_refptr<StringImpl>, LegacyLayout);
static LayoutTextFragment* CreateTextFragment(Node*, static LayoutTextFragment* CreateTextFragment(Node*,
......
...@@ -28,10 +28,9 @@ ...@@ -28,10 +28,9 @@
namespace blink { namespace blink {
LayoutTextControlMultiLine::LayoutTextControlMultiLine( LayoutTextControlMultiLine::LayoutTextControlMultiLine(Element* element)
HTMLTextAreaElement* element) : LayoutTextControl(To<TextControlElement>(element)) {
: LayoutTextControl(element) { DCHECK(IsA<HTMLTextAreaElement>(element));
DCHECK(element);
} }
LayoutTextControlMultiLine::~LayoutTextControlMultiLine() = default; LayoutTextControlMultiLine::~LayoutTextControlMultiLine() = default;
......
...@@ -27,11 +27,9 @@ ...@@ -27,11 +27,9 @@
namespace blink { namespace blink {
class HTMLTextAreaElement;
class LayoutTextControlMultiLine final : public LayoutTextControl { class LayoutTextControlMultiLine final : public LayoutTextControl {
public: public:
LayoutTextControlMultiLine(HTMLTextAreaElement*); explicit LayoutTextControlMultiLine(Element*);
~LayoutTextControlMultiLine() override; ~LayoutTextControlMultiLine() override;
private: private:
......
...@@ -27,6 +27,7 @@ ...@@ -27,6 +27,7 @@
#include "third_party/blink/renderer/core/css_value_keywords.h" #include "third_party/blink/renderer/core/css_value_keywords.h"
#include "third_party/blink/renderer/core/dom/shadow_root.h" #include "third_party/blink/renderer/core/dom/shadow_root.h"
#include "third_party/blink/renderer/core/frame/local_frame_view.h" #include "third_party/blink/renderer/core/frame/local_frame_view.h"
#include "third_party/blink/renderer/core/html/forms/html_input_element.h"
#include "third_party/blink/renderer/core/html/shadow/shadow_element_names.h" #include "third_party/blink/renderer/core/html/shadow/shadow_element_names.h"
#include "third_party/blink/renderer/core/layout/hit_test_result.h" #include "third_party/blink/renderer/core/layout/hit_test_result.h"
#include "third_party/blink/renderer/core/layout/layout_analyzer.h" #include "third_party/blink/renderer/core/layout/layout_analyzer.h"
...@@ -35,9 +36,10 @@ ...@@ -35,9 +36,10 @@
namespace blink { namespace blink {
LayoutTextControlSingleLine::LayoutTextControlSingleLine( LayoutTextControlSingleLine::LayoutTextControlSingleLine(Element* element)
HTMLInputElement* element) : LayoutTextControl(To<TextControlElement>(element)) {
: LayoutTextControl(element) {} DCHECK(IsA<HTMLInputElement>(element));
}
LayoutTextControlSingleLine::~LayoutTextControlSingleLine() = default; LayoutTextControlSingleLine::~LayoutTextControlSingleLine() = default;
......
...@@ -24,13 +24,10 @@ ...@@ -24,13 +24,10 @@
#ifndef THIRD_PARTY_BLINK_RENDERER_CORE_LAYOUT_LAYOUT_TEXT_CONTROL_SINGLE_LINE_H_ #ifndef THIRD_PARTY_BLINK_RENDERER_CORE_LAYOUT_LAYOUT_TEXT_CONTROL_SINGLE_LINE_H_
#define THIRD_PARTY_BLINK_RENDERER_CORE_LAYOUT_LAYOUT_TEXT_CONTROL_SINGLE_LINE_H_ #define THIRD_PARTY_BLINK_RENDERER_CORE_LAYOUT_LAYOUT_TEXT_CONTROL_SINGLE_LINE_H_
#include "third_party/blink/renderer/core/html/forms/html_input_element.h"
#include "third_party/blink/renderer/core/layout/layout_text_control.h" #include "third_party/blink/renderer/core/layout/layout_text_control.h"
namespace blink { namespace blink {
class HTMLInputElement;
// LayoutObject for text-field <input>s. // LayoutObject for text-field <input>s.
// //
// This class inherits from LayoutTextControl and LayoutBlockFlow. If we'd like // This class inherits from LayoutTextControl and LayoutBlockFlow. If we'd like
...@@ -39,7 +36,7 @@ class HTMLInputElement; ...@@ -39,7 +36,7 @@ class HTMLInputElement;
// base class. // base class.
class LayoutTextControlSingleLine : public LayoutTextControl { class LayoutTextControlSingleLine : public LayoutTextControl {
public: public:
LayoutTextControlSingleLine(HTMLInputElement*); explicit LayoutTextControlSingleLine(Element*);
~LayoutTextControlSingleLine() override; ~LayoutTextControlSingleLine() override;
protected: protected:
......
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