WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
177991
Split StaticPasteboard::writeString into writeString and writeStringInCustomData
https://bugs.webkit.org/show_bug.cgi?id=177991
Summary
Split StaticPasteboard::writeString into writeString and writeStringInCustomData
Ryosuke Niwa
Reported
2017-10-05 21:12:42 PDT
Split the function to write into platform data versus custom data like we did for readString.
Attachments
Cleanup
(5.37 KB, patch)
2017-10-05 21:53 PDT
,
Ryosuke Niwa
wenson_hsieh
: review+
wenson_hsieh
: commit-queue-
Details
Formatted Diff
Diff
View All
Add attachment
proposed patch, testcase, etc.
Ryosuke Niwa
Comment 1
2017-10-05 21:53:08 PDT
Created
attachment 322986
[details]
Cleanup
Wenson Hsieh
Comment 2
2017-10-05 23:22:28 PDT
Comment on
attachment 322986
[details]
Cleanup View in context:
https://bugs.webkit.org/attachment.cgi?id=322986&action=review
> Source/WebCore/dom/DataTransfer.cpp:162 > + m_itemList->didSetStringData(type);
Is the change from normalizedType => type intended? This would make it so that if you setData('text', 'foo') after the item list has been ensured, the DataTransferItemList will contain an item of type 'text', rather than 'text/plain'.
> Source/WebCore/platform/StaticPasteboard.cpp:63 > + updateTypes(m_types, type, !m_platformData.set(type, value).isNewEntry || m_customData.contains(type));
I think this code is a little hard to follow — I imagined this would look something like writeString: moveToEndOfTypes(type); m_platformData.set(type, value); ...and writeStringInCustomData: moveToEndOfTypes(type); m_customData.set(type, value); ...and the private helper method moveToEndOfTypes would just do: if (m_types.contains(types)) m_types.removeFirst(type); m_types.append(type); (or if we want to avoid the linear search through all types) if (m_customData.contains(type) || m_platformData.contains(type)) m_types.removeFirst(type); m_types.append(type); ...but I don't think it's that big a deal. Up to you!
Ryosuke Niwa
Comment 3
2017-10-06 00:21:39 PDT
(In reply to Wenson Hsieh from
comment #2
)
> Comment on
attachment 322986
[details]
> Cleanup > > View in context: >
https://bugs.webkit.org/attachment.cgi?id=322986&action=review
> > > Source/WebCore/dom/DataTransfer.cpp:162 > > + m_itemList->didSetStringData(type); > > Is the change from normalizedType => type intended? This would make it so > that if you setData('text', 'foo') after the item list has been ensured, the > DataTransferItemList will contain an item of type 'text', rather than > 'text/plain'.
Oh oops, unintended. Fixed.
> > Source/WebCore/platform/StaticPasteboard.cpp:63 > > + updateTypes(m_types, type, !m_platformData.set(type, value).isNewEntry || m_customData.contains(type)); > > I think this code is a little hard to follow — I imagined this would look > something like > > writeString: > > moveToEndOfTypes(type); > m_platformData.set(type, value); > > ...and writeStringInCustomData: > > moveToEndOfTypes(type); > m_customData.set(type, value);
We don't want to do that because that'd result in two hash lookups.
> ...and the private helper method moveToEndOfTypes would just do: > > if (m_types.contains(types)) > m_types.removeFirst(type); > m_types.append(type); > > (or if we want to avoid the linear search through all types) > > if (m_customData.contains(type) || m_platformData.contains(type)) > m_types.removeFirst(type); > m_types.append(type); > > ...but I don't think it's that big a deal. Up to you!
That's what I'm doing now but I guess it's not that clear. Revised it as: bool typeWasAlreadyPresent = !m_platformData.set(type, value).isNewEntry || m_customData.contains(type); updateTypes(m_types, type, typeWasAlreadyPresent); and renamed the last argument from replace to moveToEnd: static void updateTypes(Vector<String>& types, String type, bool moveToEnd) { if (moveToEnd) types.removeFirst(type); ASSERT(!types.contains(type)); types.append(type); }
Ryosuke Niwa
Comment 4
2017-10-06 00:30:23 PDT
Committed
r222964
: <
http://trac.webkit.org/changeset/222964
>
Radar WebKit Bug Importer
Comment 5
2017-10-06 00:31:03 PDT
<
rdar://problem/34851671
>
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug