Skip to content

Commit

Permalink
Reduce use of downcast<>() in DataTransfer.cpp
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=270759

Reviewed by Anne van Kesteren.

Reduce use of downcast<>() in DataTransfer.cpp, for performance.

* Source/WebCore/dom/DataTransfer.cpp:
(WebCore::DataTransfer::setDataFromItemList):
(WebCore::DataTransfer::commitToPasteboard):

Canonical link: https://commits.webkit.org/275894@main
  • Loading branch information
cdumez committed Mar 10, 2024
1 parent e8e13ca commit fd14342
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions Source/WebCore/dom/DataTransfer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -261,10 +261,10 @@ void DataTransfer::setData(Document& document, const String& type, const String&
void DataTransfer::setDataFromItemList(Document& document, const String& type, const String& data)
{
ASSERT(canWriteData());
RELEASE_ASSERT(is<StaticPasteboard>(*m_pasteboard));

auto& pasteboard = checkedDowncast<StaticPasteboard>(*m_pasteboard);
if (!DeprecatedGlobalSettings::customPasteboardDataEnabled()) {
m_pasteboard->writeString(type, data);
pasteboard.writeString(type, data);
return;
}

Expand All @@ -284,10 +284,10 @@ void DataTransfer::setDataFromItemList(Document& document, const String& type, c
}

if (sanitizedData != data)
downcast<StaticPasteboard>(*m_pasteboard).writeStringInCustomData(type, data);
pasteboard.writeStringInCustomData(type, data);

if (Pasteboard::isSafeTypeForDOMToReadAndWrite(type) && !sanitizedData.isNull())
m_pasteboard->writeString(type, sanitizedData);
pasteboard.writeString(type, sanitizedData);
}

void DataTransfer::updateFileList(ScriptExecutionContext* context)
Expand Down Expand Up @@ -451,7 +451,7 @@ Ref<DataTransfer> DataTransfer::createForInputEvent(const String& plainText, con

void DataTransfer::commitToPasteboard(Pasteboard& nativePasteboard)
{
ASSERT(is<StaticPasteboard>(*m_pasteboard) && !is<StaticPasteboard>(nativePasteboard));
ASSERT(!is<StaticPasteboard>(nativePasteboard));
auto& staticPasteboard = downcast<StaticPasteboard>(*m_pasteboard);
if (!staticPasteboard.hasNonDefaultData()) {
// We clear the platform pasteboard here to ensure that the pasteboard doesn't contain any data
Expand Down

0 comments on commit fd14342

Please sign in to comment.