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 @@
#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_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 {
......@@ -76,14 +76,15 @@ bool BaseButtonInputType::ShouldSaveAndRestoreFormControlState() const {
void BaseButtonInputType::AppendToFormData(FormData&) const {}
bool BaseButtonInputType::TypeShouldForceLegacyLayout() const {
UseCounter::Count(GetElement().GetDocument(),
WebFeature::kLegacyLayoutByButton);
return true;
}
LayoutObject* BaseButtonInputType::CreateLayoutObject(const ComputedStyle&,
LegacyLayout) const {
UseCounter::Count(GetElement().GetDocument(),
WebFeature::kLegacyLayoutByButton);
return new LayoutButton(&GetElement());
LayoutObject* BaseButtonInputType::CreateLayoutObject(
const ComputedStyle& style,
LegacyLayout legacy) const {
return LayoutObjectFactory::CreateButton(GetElement(), style, legacy);
}
InputType::ValueMode BaseButtonInputType::GetValueMode() const {
......
......@@ -31,7 +31,8 @@
#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_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"
namespace blink {
......@@ -45,6 +46,11 @@ void HTMLButtonElement::setType(const AtomicString& type) {
setAttribute(html_names::kTypeAttr, type);
}
bool HTMLButtonElement::TypeShouldForceLegacyLayout() const {
UseCounter::Count(GetDocument(), WebFeature::kLegacyLayoutByButton);
return true;
}
LayoutObject* HTMLButtonElement::CreateLayoutObject(const ComputedStyle& style,
LegacyLayout legacy) {
// https://html.spec.whatwg.org/C/#button-layout
......@@ -54,8 +60,7 @@ LayoutObject* HTMLButtonElement::CreateLayoutObject(const ComputedStyle& style,
display == EDisplay::kInlineLayoutCustom ||
display == EDisplay::kLayoutCustom)
return HTMLFormControlElement::CreateLayoutObject(style, legacy);
UseCounter::Count(GetDocument(), WebFeature::kLegacyLayoutByButton);
return new LayoutButton(this);
return LayoutObjectFactory::CreateButton(*this, style, legacy);
}
const AtomicString& HTMLButtonElement::FormControlType() const {
......
......@@ -60,7 +60,7 @@ class HTMLButtonElement final : public HTMLFormControlElement {
bool IsEnumeratable() 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 MatchesDefaultPseudoClass() const override;
......
......@@ -7,6 +7,7 @@
#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/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_fieldset.h"
#include "third_party/blink/renderer/core/layout/layout_file_upload_control.h"
......@@ -25,6 +26,7 @@
#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_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/grid/layout_ng_grid.h"
#include "third_party/blink/renderer/core/layout/ng/inline/layout_ng_text.h"
......@@ -226,6 +228,16 @@ LayoutBox* LayoutObjectFactory::CreateTableSection(Node& node,
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,
const ComputedStyle& style,
LegacyLayout legacy) {
......
......@@ -65,10 +65,15 @@ class LayoutObjectFactory {
static LayoutBox* CreateTableSection(Node&,
const ComputedStyle&,
LegacyLayout);
static LayoutObject* CreateButton(Node& node,
const ComputedStyle& style,
LegacyLayout legacy);
static LayoutBlock* CreateFieldset(Node&, const ComputedStyle&, LegacyLayout);
static LayoutBlockFlow* CreateFileUploadControl(Node& node,
const ComputedStyle& style,
LegacyLayout legacy);
static LayoutText* CreateText(Node*, scoped_refptr<StringImpl>, LegacyLayout);
static LayoutTextFragment* CreateTextFragment(Node*,
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