rniwa wanted one
Created attachment 210201 [details] patch
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.
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.
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(); } );
You could have *Adapter class that give ancestor ranges the editing code wants, something like: auto editableAncestors = ancestorsWithinEditableBounds(this);
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<>.