Commit 39ed4b08 authored by Kent Tamura's avatar Kent Tamura Committed by Commit Bot

Remove LayoutFileUploadControl::UpdateFromElement()

* FileInputType::SetValue()
 |input.value =""| triggered style recalc because style recalc triggered
 UpdateFromElement(). However, we don't need style recalc in this case
 and we need to do just paint invalidation.

* UpdateFromElement() just does paint invalidation. The function is
 called from
 - HTMLFormControlElement::AttachLayoutTree()
 - HTMLFormControlElement::DidRecalcStyle()
  For both of them, paint invalidation by UpdateFromElement() is
  redundant. So we can remove UpdateFromElement().

This CL has no behavior changes.

Bug: 1040828
Change-Id: I3e180de69cef7eef20d1944283938deec8de9685
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2006436Reviewed-by: default avatarYoshifumi Inoue <yosin@chromium.org>
Commit-Queue: Kent Tamura <tkent@chromium.org>
Cr-Commit-Position: refs/heads/master@{#732784}
parent a4cb1d48
......@@ -24,7 +24,6 @@
#include "third_party/blink/public/platform/file_path_conversion.h"
#include "third_party/blink/public/strings/grit/blink_strings.h"
#include "third_party/blink/renderer/core/css/style_change_reason.h"
#include "third_party/blink/renderer/core/dom/events/event.h"
#include "third_party/blink/renderer/core/dom/shadow_root.h"
#include "third_party/blink/renderer/core/events/keyboard_event.h"
......@@ -249,9 +248,8 @@ void FileInputType::SetValue(const String&,
return;
file_list_->clear();
GetElement().SetNeedsStyleRecalc(
kSubtreeStyleChange,
StyleChangeReasonForTracing::Create(style_change_reason::kControlValue));
if (auto* layout_object = GetElement().GetLayoutObject())
layout_object->SetShouldDoFullPaintInvalidation();
GetElement().SetNeedsValidityCheck();
}
......
......@@ -38,22 +38,12 @@ const int kDefaultWidthNumChars = 34;
const int kButtonShadowHeight = 2;
LayoutFileUploadControl::LayoutFileUploadControl(HTMLInputElement* input)
: LayoutBlockFlow(input) {}
LayoutFileUploadControl::~LayoutFileUploadControl() = default;
void LayoutFileUploadControl::UpdateFromElement() {
auto* input = To<HTMLInputElement>(GetNode());
: LayoutBlockFlow(input) {
DCHECK_EQ(input->type(), input_type_names::kFile);
// This only supports clearing out the files, but that's OK because for
// security reasons that's the only change the DOM is allowed to make.
FileList* files = input->files();
DCHECK(files);
if (files && files->IsEmpty())
SetShouldDoFullPaintInvalidation();
}
LayoutFileUploadControl::~LayoutFileUploadControl() = default;
int LayoutFileUploadControl::MaxFilenameWidth() const {
int upload_button_width =
(UploadButton() && UploadButton()->GetLayoutBox())
......
......@@ -62,7 +62,6 @@ class CORE_EXPORT LayoutFileUploadControl final : public LayoutBlockFlow {
const char* GetName() const override { return "LayoutFileUploadControl"; }
private:
void UpdateFromElement() override;
void ComputeIntrinsicLogicalWidths(
LayoutUnit& min_logical_width,
LayoutUnit& max_logical_width) const override;
......
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