Commit 10a9e83f authored by Gyuyoung Kim's avatar Gyuyoung Kim Committed by Commit Bot

Inline static Create() factory functions from renderer/core

This CL removes unnecessary Create() factory functions in
//third_partyb/blink/renderer/core only when it
meets the policy of removing Create() so that we support
only one of Create() methods or public constructors in a class.
Then, this CL makes all callers use MakeGarbageCollected<Foo>
instead.

This CL removes below Create() functions,
  - InsertIncrementalTextCommand::Create
  - InspectorStyleSheetForInlineStyle::Create
  - NetworkResourcesData::Create

Bug: 939691
Change-Id: I003a97c5dfe37f780f25af9f9a36138cffb76a03
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1980525Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Commit-Queue: Gyuyoung Kim <gyuyoung@igalia.com>
Cr-Commit-Position: refs/heads/master@{#727294}
parent 18e12838
...@@ -118,14 +118,6 @@ SelectionInDOMTree ComputeSelectionForInsertion( ...@@ -118,14 +118,6 @@ SelectionInDOMTree ComputeSelectionForInsertion(
} // anonymous namespace } // anonymous namespace
InsertIncrementalTextCommand* InsertIncrementalTextCommand::Create(
Document& document,
const String& text,
RebalanceType rebalance_type) {
return MakeGarbageCollected<InsertIncrementalTextCommand>(document, text,
rebalance_type);
}
InsertIncrementalTextCommand::InsertIncrementalTextCommand( InsertIncrementalTextCommand::InsertIncrementalTextCommand(
Document& document, Document& document,
const String& text, const String& text,
......
...@@ -12,15 +12,11 @@ namespace blink { ...@@ -12,15 +12,11 @@ namespace blink {
class CORE_EXPORT InsertIncrementalTextCommand final class CORE_EXPORT InsertIncrementalTextCommand final
: public InsertTextCommand { : public InsertTextCommand {
public: public:
static InsertIncrementalTextCommand* Create( InsertIncrementalTextCommand(
Document&, Document&,
const String&, const String& text,
RebalanceType = kRebalanceLeadingAndTrailingWhitespaces); RebalanceType = kRebalanceLeadingAndTrailingWhitespaces);
InsertIncrementalTextCommand(Document&,
const String& text,
RebalanceType);
private: private:
void DoApply(EditingState*) override; void DoApply(EditingState*) override;
}; };
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#include "third_party/blink/renderer/core/editing/frame_selection.h" #include "third_party/blink/renderer/core/editing/frame_selection.h"
#include "third_party/blink/renderer/core/editing/selection_template.h" #include "third_party/blink/renderer/core/editing/selection_template.h"
#include "third_party/blink/renderer/core/editing/testing/editing_test_base.h" #include "third_party/blink/renderer/core/editing/testing/editing_test_base.h"
#include "third_party/blink/renderer/platform/heap/heap.h"
namespace blink { namespace blink {
...@@ -23,7 +24,8 @@ TEST_F(InsertIncrementalTextCommandTest, SurrogatePairsReplace) { ...@@ -23,7 +24,8 @@ TEST_F(InsertIncrementalTextCommandTest, SurrogatePairsReplace) {
.Build(), .Build(),
SetSelectionOptions()); SetSelectionOptions());
CompositeEditCommand* const command = CompositeEditCommand* const command =
InsertIncrementalTextCommand::Create(GetDocument(), new_text); MakeGarbageCollected<InsertIncrementalTextCommand>(GetDocument(),
new_text);
command->Apply(); command->Apply();
EXPECT_EQ(String(Vector<UChar>{'b', 0xD83D, 0xDE38}), EXPECT_EQ(String(Vector<UChar>{'b', 0xD83D, 0xDE38}),
...@@ -41,7 +43,8 @@ TEST_F(InsertIncrementalTextCommandTest, SurrogatePairsNoReplace) { ...@@ -41,7 +43,8 @@ TEST_F(InsertIncrementalTextCommandTest, SurrogatePairsNoReplace) {
.Build(), .Build(),
SetSelectionOptions()); SetSelectionOptions());
CompositeEditCommand* const command = CompositeEditCommand* const command =
InsertIncrementalTextCommand::Create(GetDocument(), new_text); MakeGarbageCollected<InsertIncrementalTextCommand>(GetDocument(),
new_text);
command->Apply(); command->Apply();
EXPECT_EQ(String(Vector<UChar>{'b', 0xD83D, 0xDE3A}), EXPECT_EQ(String(Vector<UChar>{'b', 0xD83D, 0xDE3A}),
...@@ -61,7 +64,8 @@ TEST_F(InsertIncrementalTextCommandTest, SurrogatePairsTwo) { ...@@ -61,7 +64,8 @@ TEST_F(InsertIncrementalTextCommandTest, SurrogatePairsTwo) {
.Build(), .Build(),
SetSelectionOptions()); SetSelectionOptions());
CompositeEditCommand* const command = CompositeEditCommand* const command =
InsertIncrementalTextCommand::Create(GetDocument(), new_text); MakeGarbageCollected<InsertIncrementalTextCommand>(GetDocument(),
new_text);
command->Apply(); command->Apply();
EXPECT_EQ(String(Vector<UChar>{'b', 0xD83D, 0xDE38}), EXPECT_EQ(String(Vector<UChar>{'b', 0xD83D, 0xDE38}),
......
...@@ -663,7 +663,7 @@ void TypingCommand::InsertTextRunWithoutNewlines(const String& text, ...@@ -663,7 +663,7 @@ void TypingCommand::InsertTextRunWithoutNewlines(const String& text,
EditingState* editing_state) { EditingState* editing_state) {
CompositeEditCommand* command; CompositeEditCommand* command;
if (IsIncrementalInsertion()) { if (IsIncrementalInsertion()) {
command = InsertIncrementalTextCommand::Create( command = MakeGarbageCollected<InsertIncrementalTextCommand>(
GetDocument(), text, GetDocument(), text,
composition_type_ == kTextCompositionNone composition_type_ == kTextCompositionNone
? InsertIncrementalTextCommand:: ? InsertIncrementalTextCommand::
......
...@@ -1832,7 +1832,7 @@ InspectorStyleSheetForInlineStyle* InspectorCSSAgent::AsInspectorStyleSheet( ...@@ -1832,7 +1832,7 @@ InspectorStyleSheetForInlineStyle* InspectorCSSAgent::AsInspectorStyleSheet(
return nullptr; return nullptr;
InspectorStyleSheetForInlineStyle* inspector_style_sheet = InspectorStyleSheetForInlineStyle* inspector_style_sheet =
InspectorStyleSheetForInlineStyle::Create(element, this); MakeGarbageCollected<InspectorStyleSheetForInlineStyle>(element, this);
id_to_inspector_style_sheet_for_inline_style_.Set(inspector_style_sheet->Id(), id_to_inspector_style_sheet_for_inline_style_.Set(inspector_style_sheet->Id(),
inspector_style_sheet); inspector_style_sheet);
node_to_inspector_style_sheet_.Set(element, inspector_style_sheet); node_to_inspector_style_sheet_.Set(element, inspector_style_sheet);
......
...@@ -1702,8 +1702,9 @@ InspectorNetworkAgent::InspectorNetworkAgent( ...@@ -1702,8 +1702,9 @@ InspectorNetworkAgent::InspectorNetworkAgent(
: inspected_frames_(inspected_frames), : inspected_frames_(inspected_frames),
worker_global_scope_(worker_global_scope), worker_global_scope_(worker_global_scope),
v8_session_(v8_session), v8_session_(v8_session),
resources_data_(NetworkResourcesData::Create(kDefaultTotalBufferSize, resources_data_(MakeGarbageCollected<NetworkResourcesData>(
kDefaultResourceBufferSize)), kDefaultTotalBufferSize,
kDefaultResourceBufferSize)),
devtools_token_(worker_global_scope_ devtools_token_(worker_global_scope_
? worker_global_scope_->GetParentDevToolsToken() ? worker_global_scope_->GetParentDevToolsToken()
: inspected_frames->Root()->GetDevToolsFrameToken()), : inspected_frames->Root()->GetDevToolsFrameToken()),
......
...@@ -1906,13 +1906,6 @@ bool InspectorStyleSheet::InspectorStyleSheetText(String* result) { ...@@ -1906,13 +1906,6 @@ bool InspectorStyleSheet::InspectorStyleSheetText(String* result) {
return true; return true;
} }
InspectorStyleSheetForInlineStyle* InspectorStyleSheetForInlineStyle::Create(
Element* element,
Listener* listener) {
return MakeGarbageCollected<InspectorStyleSheetForInlineStyle>(element,
listener);
}
InspectorStyleSheetForInlineStyle::InspectorStyleSheetForInlineStyle( InspectorStyleSheetForInlineStyle::InspectorStyleSheetForInlineStyle(
Element* element, Element* element,
Listener* listener) Listener* listener)
......
...@@ -241,8 +241,6 @@ class InspectorStyleSheet : public InspectorStyleSheetBase { ...@@ -241,8 +241,6 @@ class InspectorStyleSheet : public InspectorStyleSheetBase {
class InspectorStyleSheetForInlineStyle final : public InspectorStyleSheetBase { class InspectorStyleSheetForInlineStyle final : public InspectorStyleSheetBase {
public: public:
static InspectorStyleSheetForInlineStyle* Create(Element*, Listener*);
InspectorStyleSheetForInlineStyle(Element*, Listener*); InspectorStyleSheetForInlineStyle(Element*, Listener*);
void DidModifyElementAttribute(); void DidModifyElementAttribute();
bool SetText(const String&, ExceptionState&) override; bool SetText(const String&, ExceptionState&) override;
......
...@@ -202,12 +202,6 @@ class NetworkResourcesData final ...@@ -202,12 +202,6 @@ class NetworkResourcesData final
scoped_refptr<EncodedFormData> post_data_; scoped_refptr<EncodedFormData> post_data_;
}; };
static NetworkResourcesData* Create(size_t total_buffer_size,
size_t resource_buffer_size) {
return MakeGarbageCollected<NetworkResourcesData>(total_buffer_size,
resource_buffer_size);
}
NetworkResourcesData(size_t total_buffer_size, size_t resource_buffer_size); NetworkResourcesData(size_t total_buffer_size, size_t resource_buffer_size);
~NetworkResourcesData(); ~NetworkResourcesData();
......
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