Commit 5c3e5134 authored by Kent Tamura's avatar Kent Tamura Committed by Commit Bot

LayoutNG for buttons: Add LayoutObjectFactory::CreateButton()

This CL has no behavior changes.

Bug: 1040826
Change-Id: Id9bd44baa60ff39650f924eec0d39236e3d5765a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2301559
Auto-Submit: Kent Tamura <tkent@chromium.org>
Commit-Queue: Koji Ishii <kojii@chromium.org>
Reviewed-by: default avatarKoji Ishii <kojii@chromium.org>
Cr-Commit-Position: refs/heads/master@{#789180}
parent 23835402
...@@ -38,7 +38,7 @@ ...@@ -38,7 +38,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/parser/html_parser_idioms.h" #include "third_party/blink/renderer/core/html/parser/html_parser_idioms.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_button.h" #include "third_party/blink/renderer/core/layout/layout_object_factory.h"
namespace blink { namespace blink {
...@@ -76,14 +76,15 @@ bool BaseButtonInputType::ShouldSaveAndRestoreFormControlState() const { ...@@ -76,14 +76,15 @@ bool BaseButtonInputType::ShouldSaveAndRestoreFormControlState() const {
void BaseButtonInputType::AppendToFormData(FormData&) const {} void BaseButtonInputType::AppendToFormData(FormData&) const {}
bool BaseButtonInputType::TypeShouldForceLegacyLayout() const { bool BaseButtonInputType::TypeShouldForceLegacyLayout() const {
UseCounter::Count(GetElement().GetDocument(),
WebFeature::kLegacyLayoutByButton);
return true; return true;
} }
LayoutObject* BaseButtonInputType::CreateLayoutObject(const ComputedStyle&, LayoutObject* BaseButtonInputType::CreateLayoutObject(
LegacyLayout) const { const ComputedStyle& style,
UseCounter::Count(GetElement().GetDocument(), LegacyLayout legacy) const {
WebFeature::kLegacyLayoutByButton); return LayoutObjectFactory::CreateButton(GetElement(), style, legacy);
return new LayoutButton(&GetElement());
} }
InputType::ValueMode BaseButtonInputType::GetValueMode() const { InputType::ValueMode BaseButtonInputType::GetValueMode() const {
......
...@@ -31,7 +31,8 @@ ...@@ -31,7 +31,8 @@
#include "third_party/blink/renderer/core/html/forms/form_data.h" #include "third_party/blink/renderer/core/html/forms/form_data.h"
#include "third_party/blink/renderer/core/html/forms/html_form_element.h" #include "third_party/blink/renderer/core/html/forms/html_form_element.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_button.h" #include "third_party/blink/renderer/core/layout/layout_object_factory.h"
#include "third_party/blink/renderer/core/style/computed_style.h"
#include "third_party/blink/renderer/platform/wtf/std_lib_extras.h" #include "third_party/blink/renderer/platform/wtf/std_lib_extras.h"
namespace blink { namespace blink {
...@@ -45,6 +46,11 @@ void HTMLButtonElement::setType(const AtomicString& type) { ...@@ -45,6 +46,11 @@ void HTMLButtonElement::setType(const AtomicString& type) {
setAttribute(html_names::kTypeAttr, type); setAttribute(html_names::kTypeAttr, type);
} }
bool HTMLButtonElement::TypeShouldForceLegacyLayout() const {
UseCounter::Count(GetDocument(), WebFeature::kLegacyLayoutByButton);
return true;
}
LayoutObject* HTMLButtonElement::CreateLayoutObject(const ComputedStyle& style, LayoutObject* HTMLButtonElement::CreateLayoutObject(const ComputedStyle& style,
LegacyLayout legacy) { LegacyLayout legacy) {
// https://html.spec.whatwg.org/C/#button-layout // https://html.spec.whatwg.org/C/#button-layout
...@@ -54,8 +60,7 @@ LayoutObject* HTMLButtonElement::CreateLayoutObject(const ComputedStyle& style, ...@@ -54,8 +60,7 @@ LayoutObject* HTMLButtonElement::CreateLayoutObject(const ComputedStyle& style,
display == EDisplay::kInlineLayoutCustom || display == EDisplay::kInlineLayoutCustom ||
display == EDisplay::kLayoutCustom) display == EDisplay::kLayoutCustom)
return HTMLFormControlElement::CreateLayoutObject(style, legacy); return HTMLFormControlElement::CreateLayoutObject(style, legacy);
UseCounter::Count(GetDocument(), WebFeature::kLegacyLayoutByButton); return LayoutObjectFactory::CreateButton(*this, style, legacy);
return new LayoutButton(this);
} }
const AtomicString& HTMLButtonElement::FormControlType() const { const AtomicString& HTMLButtonElement::FormControlType() const {
......
...@@ -60,7 +60,7 @@ class HTMLButtonElement final : public HTMLFormControlElement { ...@@ -60,7 +60,7 @@ class HTMLButtonElement final : public HTMLFormControlElement {
bool IsEnumeratable() const override { return true; } bool IsEnumeratable() const override { return true; }
bool IsLabelable() const override { return true; } bool IsLabelable() const override { return true; }
bool TypeShouldForceLegacyLayout() const final { return true; } bool TypeShouldForceLegacyLayout() const final;
bool IsInteractiveContent() const override; bool IsInteractiveContent() const override;
bool MatchesDefaultPseudoClass() const override; bool MatchesDefaultPseudoClass() const override;
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#include "third_party/blink/renderer/core/dom/element.h" #include "third_party/blink/renderer/core/dom/element.h"
#include "third_party/blink/renderer/core/dom/node_computed_style.h" #include "third_party/blink/renderer/core/dom/node_computed_style.h"
#include "third_party/blink/renderer/core/layout/layout_block_flow.h" #include "third_party/blink/renderer/core/layout/layout_block_flow.h"
#include "third_party/blink/renderer/core/layout/layout_button.h"
#include "third_party/blink/renderer/core/layout/layout_deprecated_flexible_box.h" #include "third_party/blink/renderer/core/layout/layout_deprecated_flexible_box.h"
#include "third_party/blink/renderer/core/layout/layout_fieldset.h" #include "third_party/blink/renderer/core/layout/layout_fieldset.h"
#include "third_party/blink/renderer/core/layout/layout_file_upload_control.h" #include "third_party/blink/renderer/core/layout/layout_file_upload_control.h"
...@@ -25,6 +26,7 @@ ...@@ -25,6 +26,7 @@
#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_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_button.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"
#include "third_party/blink/renderer/core/layout/ng/grid/layout_ng_grid.h" #include "third_party/blink/renderer/core/layout/ng/grid/layout_ng_grid.h"
#include "third_party/blink/renderer/core/layout/ng/inline/layout_ng_text.h" #include "third_party/blink/renderer/core/layout/ng/inline/layout_ng_text.h"
...@@ -226,6 +228,16 @@ LayoutBox* LayoutObjectFactory::CreateTableSection(Node& node, ...@@ -226,6 +228,16 @@ LayoutBox* LayoutObjectFactory::CreateTableSection(Node& node,
node, style, legacy, disable_ng_for_type); node, style, legacy, disable_ng_for_type);
} }
LayoutObject* LayoutObjectFactory::CreateButton(Node& node,
const ComputedStyle& style,
LegacyLayout legacy) {
bool disable_ng_for_type = !RuntimeEnabledFeatures::LayoutNGFlexBoxEnabled();
if (disable_ng_for_type)
UseCounter::Count(node.GetDocument(), WebFeature::kLegacyLayoutByFlexBox);
return CreateObject<LayoutBlock, LayoutNGButton, LayoutButton>(
node, style, legacy, disable_ng_for_type);
}
LayoutBlock* LayoutObjectFactory::CreateFieldset(Node& node, LayoutBlock* LayoutObjectFactory::CreateFieldset(Node& node,
const ComputedStyle& style, const ComputedStyle& style,
LegacyLayout legacy) { LegacyLayout legacy) {
......
...@@ -65,10 +65,15 @@ class LayoutObjectFactory { ...@@ -65,10 +65,15 @@ class LayoutObjectFactory {
static LayoutBox* CreateTableSection(Node&, static LayoutBox* CreateTableSection(Node&,
const ComputedStyle&, const ComputedStyle&,
LegacyLayout); LegacyLayout);
static LayoutObject* CreateButton(Node& node,
const ComputedStyle& style,
LegacyLayout legacy);
static LayoutBlock* CreateFieldset(Node&, const ComputedStyle&, LegacyLayout); static LayoutBlock* CreateFieldset(Node&, const ComputedStyle&, LegacyLayout);
static LayoutBlockFlow* CreateFileUploadControl(Node& node, static LayoutBlockFlow* CreateFileUploadControl(Node& node,
const ComputedStyle& style, const ComputedStyle& style,
LegacyLayout legacy); 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*,
StringImpl*, StringImpl*,
......
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