WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
120248
Element child and descendant iterators
https://bugs.webkit.org/show_bug.cgi?id=120248
Summary
Element child and descendant iterators
Antti Koivisto
Reported
2013-08-24 09:33:46 PDT
Better approach to iterating.
Attachments
maybe something along these lines
(9.35 KB, patch)
2013-08-24 12:39 PDT
,
Antti Koivisto
no flags
Details
Formatted Diff
Diff
patch
(31.80 KB, patch)
2013-08-25 11:48 PDT
,
Antti Koivisto
no flags
Details
Formatted Diff
Diff
another
(31.88 KB, patch)
2013-08-25 11:51 PDT
,
Antti Koivisto
webkit-ews
: commit-queue-
Details
Formatted Diff
Diff
yet another
(36.26 KB, patch)
2013-08-25 13:56 PDT
,
Antti Koivisto
sam
: review+
Details
Formatted Diff
Diff
Show Obsolete
(3)
View All
Add attachment
proposed patch, testcase, etc.
Antti Koivisto
Comment 1
2013-08-24 12:39:52 PDT
Created
attachment 209551
[details]
maybe something along these lines
Andreas Kling
Comment 2
2013-08-24 12:50:13 PDT
Comment on
attachment 209551
[details]
maybe something along these lines I think this would be absolutely magical with C++11 range-based for loops. I also think get() should return an Element& and we can have something like getPtr() for Element*. (This to encourage ourselves to use references.)
Darin Adler
Comment 3
2013-08-24 14:46:17 PDT
Will look nice in C++11 for loops. When we use element pointers, it’s well defined what happens if the document changes while we are iterating. For iterators, we’d want to define what happens in that case. What our hash tables do with iterators is that in debug versions they invalidate iterators when changes are made to the underlying data structure. Maybe we could do some variation on that.
Darin Adler
Comment 4
2013-08-24 14:46:55 PDT
(In reply to
comment #2
)
> I also think get() should return an Element& and we can have something like getPtr() for Element*. (This to encourage ourselves to use references.)
C++ iterators normally use *iterator, not iterator.get().
Andreas Kling
Comment 5
2013-08-24 14:48:53 PDT
Comment on
attachment 209551
[details]
maybe something along these lines View in context:
https://bugs.webkit.org/attachment.cgi?id=209551&action=review
> Source/WebCore/dom/ElementTraversal.h:107 > + bool operator!=(const ElementDescendantIterator& other) const { return m_current != other.m_current; }
This method could assert that both iterators have the same root.
Antti Koivisto
Comment 6
2013-08-24 23:43:49 PDT
(In reply to
comment #3
)
> Will look nice in C++11 for loops. > > When we use element pointers, it’s well defined what happens if the document changes while we are iterating. For iterators, we’d want to define what happens in that case. What our hash tables do with iterators is that in debug versions they invalidate iterators when changes are made to the underlying data structure. Maybe we could do some variation on that.
Yeah. I think we should assert that there are no tree mutations during iteration. Not just in the current subtree, in the entire tree.
Darin Adler
Comment 7
2013-08-24 23:49:25 PDT
(In reply to
comment #6
)
> Yeah. I think we should assert that there are no tree mutations during iteration. Not just in the current subtree, in the entire tree.
Should probably go further and also assert that no DOM events were dispatched. An event handler could have mutated the tree; just because it didn’t actually happen does not mean the code is OK.
Antti Koivisto
Comment 8
2013-08-25 11:48:09 PDT
Created
attachment 209595
[details]
patch
Antti Koivisto
Comment 9
2013-08-25 11:51:54 PDT
Created
attachment 209596
[details]
another
Early Warning System Bot
Comment 10
2013-08-25 11:59:38 PDT
Comment on
attachment 209596
[details]
another
Attachment 209596
[details]
did not pass qt-ews (qt): Output:
http://webkit-queues.appspot.com/results/1564277
Early Warning System Bot
Comment 11
2013-08-25 12:01:53 PDT
Comment on
attachment 209596
[details]
another
Attachment 209596
[details]
did not pass qt-wk2-ews (qt-wk2): Output:
http://webkit-queues.appspot.com/results/1561584
EFL EWS Bot
Comment 12
2013-08-25 12:07:56 PDT
Comment on
attachment 209596
[details]
another
Attachment 209596
[details]
did not pass efl-wk2-ews (efl-wk2): Output:
http://webkit-queues.appspot.com/results/1544952
EFL EWS Bot
Comment 13
2013-08-25 12:14:15 PDT
Comment on
attachment 209596
[details]
another
Attachment 209596
[details]
did not pass efl-ews (efl): Output:
http://webkit-queues.appspot.com/results/1562424
kov's GTK+ EWS bot
Comment 14
2013-08-25 12:56:17 PDT
Comment on
attachment 209596
[details]
another
Attachment 209596
[details]
did not pass gtk-ews (gtk): Output:
http://webkit-queues.appspot.com/results/1564290
kov's GTK+ EWS bot
Comment 15
2013-08-25 13:35:16 PDT
Comment on
attachment 209596
[details]
another
Attachment 209596
[details]
did not pass gtk-ews (gtk): Output:
http://webkit-queues.appspot.com/results/1559658
Antti Koivisto
Comment 16
2013-08-25 13:56:06 PDT
Created
attachment 209603
[details]
yet another
Sam Weinig
Comment 17
2013-08-25 14:00:49 PDT
Comment on
attachment 209603
[details]
yet another View in context:
https://bugs.webkit.org/attachment.cgi?id=209603&action=review
> Source/WebCore/WebCore.vcxproj/WebCore.vcxproj:-1 > -<?xml version="1.0" encoding="utf-8"?>
Removing this was probably a mistake.
Antti Koivisto
Comment 18
2013-08-25 14:30:37 PDT
https://trac.webkit.org/r154581
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