Bug 64072 - [Meta] "Flattened tree" concept should be explicit in the code
: [Meta] "Flattened tree" concept should be explicit in the code
Status: RESOLVED DUPLICATE of bug 79197
Product: WebKit
Classification: Unclassified
Component: HTML DOM
: 528+ (Nightly build)
: Unspecified Unspecified
: P2 Normal
Assigned To: Nobody
:
Depends on: 61110 64144 64251 64849 64850
Blocks: 72352 63522
  Show dependency treegraph
 
Reported: 2011-07-07 01:13 PDT by Hajime Morrita
Modified: 2012-02-27 19:02 PST (History)
4 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Hajime Morrita 2011-07-07 01:13:03 PDT
Working on Bug 63977, It became clear that we should have a way to beware "flattened tree" concept in XBL mean.

Here is a rough idea:
- At first, extract NodeFlattener from NodeRenderingContext.
- Then expand its usage to where we should care about flattened tree:
  - Focus handling,
  - Text iteration,
  - And possibly more!

NodeFlattener would look like this:
----
class NodeFlattener
{
public:
    Node* nextSibling() const;
    Node* previousSibling() const;
    Node* parent() const;
    Node* next() const; // dfs traversal like traverseNextNode()

    void moveToNextSibling();
    .... // more moveTo family will come here.
private:
    Node* m_node;
   ... // Pull a part of NodeRenderingContext state here.
};
----

NodeFlattener is like TreeWalker, but should be more lightweight.
- It doesn't have script binding.
- It's stack-based.
Ideally, it would be great if the flattener can be used as a smart pointer for the node.
But I think it isn't feasible because it has a many state
which makes a copy operation bit expensive.
Comment 1 Hajime Morrita 2011-07-07 01:33:36 PDT
Bug 61110 might relates.
Comment 2 Dimitri Glazkov (Google) 2011-07-07 07:52:31 PDT
I think "Flattener" is a completely wrong term here. It's just a tree walker, aware of shadow DOM subtrees.

Can we call it TreeIterator instead?
Comment 3 Hajime Morrita 2011-07-07 18:33:52 PDT
(In reply to comment #2)
> I think "Flattener" is a completely wrong term here. It's just a tree walker, aware of shadow DOM subtrees.
> 
> Can we call it TreeIterator instead?
That sounds fine. It's a bit too generic though.
We would also want to have non-shadow aware iterator... FlatTreeIterator?
Comment 4 Hajime Morrita 2011-07-11 02:07:58 PDT
I found that this change is hard to be done with only naive refactoring
because there is no link from forwarded nodes to content elements.
So I'm trying to introduce that link, which is tracked on Bug 64251 and Bug 64252.
Comment 5 Hayato Ito 2012-02-27 19:02:50 PST
I marked it DUPLICATE in favor of bug79197.
https://bugs.webkit.org/show_bug.cgi?id=79197

If you have any concerns, please reopen this.

*** This bug has been marked as a duplicate of bug 79197 ***