WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
189075
Modernize SlotAssignment
https://bugs.webkit.org/show_bug.cgi?id=189075
Summary
Modernize SlotAssignment
Ryosuke Niwa
Reported
2018-08-28 22:23:16 PDT
Modernize SlotAssignment
Attachments
Cleanup
(10.66 KB, patch)
2018-08-28 22:28 PDT
,
Ryosuke Niwa
no flags
Details
Formatted Diff
Diff
Patch for landing
(10.72 KB, patch)
2018-08-29 13:40 PDT
,
Ryosuke Niwa
no flags
Details
Formatted Diff
Diff
Show Obsolete
(1)
View All
Add attachment
proposed patch, testcase, etc.
Ryosuke Niwa
Comment 1
2018-08-28 22:28:06 PDT
Created
attachment 348392
[details]
Cleanup
Radar WebKit Bug Importer
Comment 2
2018-08-28 22:39:30 PDT
<
rdar://problem/43829595
>
Antti Koivisto
Comment 3
2018-08-29 03:36:36 PDT
Comment on
attachment 348392
[details]
Cleanup View in context:
https://bugs.webkit.org/attachment.cgi?id=348392&action=review
> Source/WebCore/dom/SlotAssignment.cpp:87 > const AtomicString& slotName = slotNameFromAttributeValue(name); > - auto addResult = m_slots.add(slotName, std::unique_ptr<SlotInfo>()); > + auto addResult = m_slots.ensure(slotName, [&slotElement] { > + return std::make_unique<Slot>(makeWeakPtr(slotElement)); > + }); > if (addResult.isNewEntry) { > - addResult.iterator->value = std::make_unique<SlotInfo>(slotElement); > - if (slotName == defaultSlotName()) // Because assignSlots doesn't collect nodes assigned to the default slot as an optimzation. > + // Unlike named slots, assignSlots doesn't collect nodes assigned to the default slot > + // to avoid always having a vector of all child nodes of a shadow host. > + if (slotName == defaultSlotName()) > m_slotAssignmentsIsValid = false; > return; > }
Alternative factoring: - Call plain constructor for Slot in ensure (just std::make_unique<Slot>(), you can remove the the slot element constructor) - Move the remaining code in addResult.isNewEntry branch to the ensure lambda - Remove the early return and let the code below handle setting the slot element and incrementing the count. It seems to do the right thing. I think this would make the logic simpler and easier to follow.
Ryosuke Niwa
Comment 4
2018-08-29 13:38:46 PDT
(In reply to Antti Koivisto from
comment #3
)
> Comment on
attachment 348392
[details]
> Cleanup > > View in context: >
https://bugs.webkit.org/attachment.cgi?id=348392&action=review
> > > Source/WebCore/dom/SlotAssignment.cpp:87 > > const AtomicString& slotName = slotNameFromAttributeValue(name); > > - auto addResult = m_slots.add(slotName, std::unique_ptr<SlotInfo>()); > > + auto addResult = m_slots.ensure(slotName, [&slotElement] { > > + return std::make_unique<Slot>(makeWeakPtr(slotElement)); > > + }); > > if (addResult.isNewEntry) { > > - addResult.iterator->value = std::make_unique<SlotInfo>(slotElement); > > - if (slotName == defaultSlotName()) // Because assignSlots doesn't collect nodes assigned to the default slot as an optimzation. > > + // Unlike named slots, assignSlots doesn't collect nodes assigned to the default slot > > + // to avoid always having a vector of all child nodes of a shadow host. > > + if (slotName == defaultSlotName()) > > m_slotAssignmentsIsValid = false; > > return; > > } > > Alternative factoring: > > - Call plain constructor for Slot in ensure (just std::make_unique<Slot>(), > you can remove the the slot element constructor) > - Move the remaining code in addResult.isNewEntry branch to the ensure lambda > - Remove the early return and let the code below handle setting the slot > element and incrementing the count. It seems to do the right thing. > > I think this would make the logic simpler and easier to follow.
Sure, will do that. Thanks for the review!
Ryosuke Niwa
Comment 5
2018-08-29 13:40:09 PDT
Created
attachment 348427
[details]
Patch for landing
Ryosuke Niwa
Comment 6
2018-08-29 13:40:37 PDT
Comment on
attachment 348427
[details]
Patch for landing Wait for EWS.
Ryosuke Niwa
Comment 7
2018-08-29 15:23:32 PDT
Committed
r235483
: <
https://trac.webkit.org/changeset/235483
>
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