Bug 120563

Summary: Add element ancestor iterator
Product: WebKit Reporter: Antti Koivisto <koivisto>
Component: DOMAssignee: Nobody <webkit-unassigned>
Status: RESOLVED FIXED    
Severity: Normal CC: darin, kling, rniwa
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
patch kling: review+

Antti Koivisto
Reported 2013-08-31 12:00:42 PDT
rniwa wanted one
Attachments
patch (28.91 KB, patch)
2013-08-31 12:12 PDT, Antti Koivisto
kling: review+
Antti Koivisto
Comment 1 2013-08-31 12:12:02 PDT
Andreas Kling
Comment 2 2013-08-31 13:09:39 PDT
Comment on attachment 210201 [details] patch View in context: https://bugs.webkit.org/attachment.cgi?id=210201&action=review > Source/WebCore/ChangeLog:22 > + auto lineage = elementLineage(this); > + for (auto it = lineage.begin(), end = lineage.end(); it != end; ++it) { > + Element& element = *it; > + ... Poetic.
Ryosuke Niwa
Comment 3 2013-08-31 15:53:03 PDT
Can we add a version that optionally stops when it hits a node with a certain condition? (Let it take a function pointer or node's member function? e.g. A lot of editing code needs to stop ancestor search once it hits an editing boundary.
Antti Koivisto
Comment 4 2013-09-01 00:53:53 PDT
I don't think anything else than actual iteration belong to iterators. They are stl compatible and you can add your own helpers. With stl you can do things like: auto lineage = elementLineage(this); auto nearestEditable = std::find_if(lineage.begin(), lineage.end(), [](Element& e) { return e.rendererIsEditable(); } );
Antti Koivisto
Comment 5 2013-09-01 03:45:38 PDT
You could have *Adapter class that give ancestor ranges the editing code wants, something like: auto editableAncestors = ancestorsWithinEditableBounds(this);
Antti Koivisto
Comment 6 2013-09-01 03:47:56 PDT
https://trac.webkit.org/r154940 Dropped Node* version of the interface functions in favour of Element only. Call sites should be tightened as needed. Added lineageOfType<>.
Note You need to log in before you can comment on or make changes to this bug.