Summary: | Setting up OrderIterator shouldn't require an extra Vector | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Product: | WebKit | Reporter: | Ryosuke Niwa <rniwa> | ||||||||||||||||
Component: | Layout and Rendering | Assignee: | Manuel Rego Casasnovas <rego> | ||||||||||||||||
Status: | RESOLVED FIXED | ||||||||||||||||||
Severity: | Normal | CC: | commit-queue, dino, esprehn+autocc, glenn, hyatt, jfernandez, kling, koivisto, kondapallykalyan, rego, simon.fraser, svillar | ||||||||||||||||
Priority: | P2 | Keywords: | BlinkMergeCandidate | ||||||||||||||||
Version: | 528+ (Nightly build) | ||||||||||||||||||
Hardware: | Unspecified | ||||||||||||||||||
OS: | Unspecified | ||||||||||||||||||
Bug Depends on: | 132408 | ||||||||||||||||||
Bug Blocks: | |||||||||||||||||||
Attachments: |
|
Description
Ryosuke Niwa
2013-07-24 12:47:46 PDT
Also see https://chromium.googlesource.com/chromium/blink/+/bff4f889e1e3f97952fca3a9464212e887ccb0db Also https://src.chromium.org/viewvc/blink?revision=154445&view=revision and https://chromium.googlesource.com/chromium/blink/+/336cf4c90ae5dd5759f5c1aea09b568461bcb856 Created attachment 228336 [details] Patch This is a patch merging https://src.chromium.org/viewvc/blink?revision=153971&view=revision and https://src.chromium.org/viewvc/blink?revision=158388&view=revision from Blink. As the other changes were finally reverted there. Created attachment 228537 [details] Patch I've realized that std::set is not used in WebKit, so I think it's better to go step by step and this first patch will only port https://src.chromium.org/viewvc/blink?revision=153971&view=revision from Blink. Further improvements could be done in later patches. Created attachment 228585 [details] Patch This is a different approach partially based on Blink r153971.\n\nThe idea is to avoid the extra loops in OrderIterator for each different order value. It has some minor performance impact in the grid tests, however it drastically improves the performance if you use different order values.\nOn top of that, OrderIterator code is simplified. Created attachment 230107 [details]
Patch
Remove unneeded initialization of OrderIterator using default constructor.
Comment on attachment 230107 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=230107&action=review Looks good. review- because of the use of an iterator rather than an index for m_childrenIterator. > Source/WebCore/rendering/OrderIterator.cpp:59 > +static bool sortByOrderValueAndIndex(ChildIndex childIndex1, const ChildIndex childIndex2) The const here is neither needed nor helpful. I don’t think the name “sort” is good for a less-than function. Maybe “compareBy” or “isLessThanBy”? > Source/WebCore/rendering/OrderIterator.cpp:74 > + m_iterator.m_children.append(std::make_pair(&child, m_childIndex++)); No need for make_pair any more, can just use braces in C++11: m_iterator.m_children.append({ &child, m_childIndex++ }); > Source/WebCore/rendering/OrderIterator.h:42 > +typedef std::pair<RenderBox*, int> ChildIndex; Seems a little overkill to typedef this. Also the name is too broad. ChildIndex doesn’t give a rendering context, or even an OrderIterator context. > Source/WebCore/rendering/OrderIterator.h:44 > class OrderIterator { This name also seems to broad. I think OrderedRendererChildIterator would be better, or some other name like this. > Source/WebCore/rendering/OrderIterator.h:55 > + typedef Vector<ChildIndex> ChildrenVector; No need for a typedef here. > Source/WebCore/rendering/OrderIterator.h:57 > + ChildrenVector::const_iterator m_childrenIterator; Should use an index, not an iterator, to track a position within a vector. It’s especially dangerous to have this if there’s any chance m_children might be modified while the iterator is around, since the vector memory can be reallocated. (In reply to comment #7) > (From update of attachment 230107 [details]) > View in context: https://bugs.webkit.org/attachment.cgi?id=230107&action=review > > Looks good. review- because of the use of an iterator rather than an index for m_childrenIterator. Thanks for the review. I'm uploading a new patch following your suggestions. > > Source/WebCore/rendering/OrderIterator.h:44 > > class OrderIterator { > > This name also seems to broad. I think OrderedRendererChildIterator would be better, or some other name like this. I think we can leave this change for a later patch to avoid mixing the rename with this change. Created attachment 230172 [details]
Patch
Comment on attachment 230172 [details] Patch Clearing flags on attachment: 230172 Committed r167879: <http://trac.webkit.org/changeset/167879> All reviewed patches have been landed. Closing bug. This patch introduces a regression in RenderFlexibleBox that is being managed at bug #132337 (with patch included). Re-opened since this is blocked by bug 132408 I forgot to note down the bug that leads me to rollout this change. It was bug #132400 which I didn't manage to reproduce in GTK+ port yet, but I'll keep taking a look. (In reply to comment #14) > I forgot to note down the bug that leads me to rollout this change. It was bug #132400 which I didn't manage to reproduce in GTK+ port yet, but I'll keep taking a look. Maybe the problem is that we're not adding/removing new children from OrderIterator. In addition, knowing that we're using a Vector of pairs it won't be easy/cheap to keep it updated. So I think that as initial step we could only port the Blink change that will allow us to share code between grids and flexboxes: https://src.chromium.org/viewvc/blink?revision=153971&view=revision Created attachment 232071 [details]
Patch
New patch sharing code between RenderFlexibleBox and RenderGrid.
Comment on attachment 232071 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=232071&action=review > Source/WebCore/rendering/OrderIterator.cpp:94 > + OrderIterator::OrderValues& orderValues = m_iterator.m_orderValues; I suggest auto& here. > Source/WebCore/rendering/OrderIterator.h:46 > + OrderIterator(RenderBox&); Should mark this explicit. > Source/WebCore/rendering/OrderIterator.h:58 > + typedef Vector<int, 1> OrderValues; I don’t think we need a typedef for this. The only places that would use this type should just use auto instead. > Source/WebCore/rendering/OrderIterator.h:73 > + OrderIteratorPopulator(OrderIterator& iterator) > + : m_iterator(iterator) > + { > + // Note that we don't release the memory here, we only invalidate the size > + // This avoids unneeded reallocation if the size ends up not changing. > + m_iterator.m_orderValues.shrink(0); > + } > + > + ~OrderIteratorPopulator(); I’m not sure I understand why the constructor is inlined and included here in the header but none of the other functions are. It would be nice to be consistent. Maybe no inlining is the right way to start. > Source/WebCore/rendering/OrderIterator.h:78 > + Please omit this blank line. Created attachment 232094 [details]
Patch for landing.
Comment on attachment 232094 [details] Patch for landing. Clearing flags on attachment: 232094 Committed r169372: <http://trac.webkit.org/changeset/169372> All reviewed patches have been landed. Closing bug. |