|
|
Created:
4 years, 8 months ago by hayato Modified:
4 years, 6 months ago CC:
darktears, apavlov+blink_chromium.org, blink-reviews, blink-reviews-css, blink-reviews-dom_chromium.org, blink-reviews-style_chromium.org, chromium-reviews, dglazkov+blink, eae+blinkwatch, rwlbuis, sof Base URL:
https://chromium.googlesource.com/chromium/src.git@master Target Ref:
refs/pending/heads/master Project:
chromium Visibility:
Public. |
DescriptionIntroduce Node::containingTreeScope(), which asserts that the node's root is a tree scope
The difference between Node::containingTreeScope() and Node::treeScope() is that
Node::containingTreeScope() asserts that the node is in a treeScope.
Node::treeScope() does not.
Replace some of the current usage of Node::treeScope() with
Node::containingTreeScope() if containingTreeScope() is better to express their
intention.
This CL also introduces Element::adjustedFocusedElementInTreeScope() to optimize
some code path where we can early exit if the element is not in a tree scope.
BUG=602556
Committed: https://crrev.com/97a40b7bad083e7f9382a92e00adf1bd650db4a5
Cr-Commit-Position: refs/heads/master@{#397065}
Patch Set 1 #Patch Set 2 : wip #
Total comments: 2
Patch Set 3 : rebased #
Total comments: 2
Patch Set 4 : Add Element::adjustedFocusElementinTreeScope #Patch Set 5 : renamed #Messages
Total messages: 65 (29 generated)
The CQ bit was checked by hayato@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1883083002/1 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/1883083002/1
Description was changed from ========== Introduce Node::rootTreeScope(), which checks the node's root is a tree scope BUG= ========== to ========== Introduce Node::rootTreeScope(), which asserts that the node's root is a tree scope The difference between Node::rootTreeScope() and Node::treeScope() is that Node::rootTreeScope() asserts that the node is in a treeScope. Replace some of the current usage of Node::treeScope() with Node::rootTreeScope() if rootTreeScope() is better to express the intention. This CL also optimize some code pass by explicitly checking Node::isInTreeScope() before calling Node::rootTreeScope(), where we can *early exit*. BUG=602556 ==========
Description was changed from ========== Introduce Node::rootTreeScope(), which asserts that the node's root is a tree scope The difference between Node::rootTreeScope() and Node::treeScope() is that Node::rootTreeScope() asserts that the node is in a treeScope. Replace some of the current usage of Node::treeScope() with Node::rootTreeScope() if rootTreeScope() is better to express the intention. This CL also optimize some code pass by explicitly checking Node::isInTreeScope() before calling Node::rootTreeScope(), where we can *early exit*. BUG=602556 ========== to ========== Introduce Node::rootTreeScope(), which asserts that the node's root is a tree scope The difference between Node::rootTreeScope() and Node::treeScope() is that Node::rootTreeScope() asserts that the node is in a treeScope. Replace some of the current usage of Node::treeScope() with Node::rootTreeScope() if rootTreeScope() is better to express the intention. This CL also optimize some code path by explicitly checking Node::isInTreeScope() before calling Node::rootTreeScope(), where we can *early exit*. BUG=602556 ==========
Description was changed from ========== Introduce Node::rootTreeScope(), which asserts that the node's root is a tree scope The difference between Node::rootTreeScope() and Node::treeScope() is that Node::rootTreeScope() asserts that the node is in a treeScope. Replace some of the current usage of Node::treeScope() with Node::rootTreeScope() if rootTreeScope() is better to express the intention. This CL also optimize some code path by explicitly checking Node::isInTreeScope() before calling Node::rootTreeScope(), where we can *early exit*. BUG=602556 ========== to ========== Introduce Node::rootTreeScope(), which asserts that the node's root is a tree scope The difference between Node::rootTreeScope() and Node::treeScope() is that Node::rootTreeScope() asserts that the node is in a treeScope. Replace some of the current usage of Node::treeScope() with Node::rootTreeScope() if rootTreeScope() is better to express the intention. This CL also optimize some code path by explicitly checking Node::isInTreeScope() before calling Node::rootTreeScope(), where we can *early exit* if the node is not in a tree scope. BUG=602556 ==========
Description was changed from ========== Introduce Node::rootTreeScope(), which asserts that the node's root is a tree scope The difference between Node::rootTreeScope() and Node::treeScope() is that Node::rootTreeScope() asserts that the node is in a treeScope. Replace some of the current usage of Node::treeScope() with Node::rootTreeScope() if rootTreeScope() is better to express the intention. This CL also optimize some code path by explicitly checking Node::isInTreeScope() before calling Node::rootTreeScope(), where we can *early exit* if the node is not in a tree scope. BUG=602556 ========== to ========== Introduce Node::rootTreeScope(), which asserts that the node's root is a tree scope The difference between Node::rootTreeScope() and Node::treeScope() is that Node::rootTreeScope() asserts that the node is in a treeScope. Replace some of the current usage of Node::treeScope() with Node::rootTreeScope() if rootTreeScope() is better to express the intention. This CL also optimize some code path by explicitly checking Node::isInTreeScope() before calling Node::rootTreeScope(), where we can *early exit* if the node is not in a tree scope. BUG=602556 ==========
Description was changed from ========== Introduce Node::rootTreeScope(), which asserts that the node's root is a tree scope The difference between Node::rootTreeScope() and Node::treeScope() is that Node::rootTreeScope() asserts that the node is in a treeScope. Replace some of the current usage of Node::treeScope() with Node::rootTreeScope() if rootTreeScope() is better to express the intention. This CL also optimize some code path by explicitly checking Node::isInTreeScope() before calling Node::rootTreeScope(), where we can *early exit* if the node is not in a tree scope. BUG=602556 ========== to ========== Introduce Node::rootTreeScope(), which asserts that the node's root is a tree scope The difference between Node::rootTreeScope() and Node::treeScope() is that Node::rootTreeScope() asserts that the node is in a treeScope. Replace some of the current usage of Node::treeScope() with Node::rootTreeScope() if rootTreeScope() is better to express the intention. This CL also optimize some code path by explicitly checking Node::isInTreeScope() before calling Node::rootTreeScope(), where we can *early exit* if the node is not in a tree scope. BUG=602556 ==========
The CQ bit was checked by hayato@chromium.org to run a CQ dry run
wip
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1883083002/20001 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/1883083002/20001
hayato@chromium.org changed reviewers: + esprehn@chromium.org, rune@opera.com
Elliot, Rune, could you give me early feedback about this CL? It looks there are other places where we can use Node::rootTreeScope(), instead of Node::treeScope(), but I would like to know whether this CL is a right direction or not. https://codereview.chromium.org/1883083002/diff/20001/third_party/WebKit/Sour... File third_party/WebKit/Source/core/dom/SelectorQuery.cpp (left): https://codereview.chromium.org/1883083002/diff/20001/third_party/WebKit/Sour... third_party/WebKit/Source/core/dom/SelectorQuery.cpp:264: if (selector->match() == CSSSelector::Id && !rootNode.document().containsMultipleElementsWithId(selector->value())) { Using document() here looks a bug to me.
Description was changed from ========== Introduce Node::rootTreeScope(), which asserts that the node's root is a tree scope The difference between Node::rootTreeScope() and Node::treeScope() is that Node::rootTreeScope() asserts that the node is in a treeScope. Replace some of the current usage of Node::treeScope() with Node::rootTreeScope() if rootTreeScope() is better to express the intention. This CL also optimize some code path by explicitly checking Node::isInTreeScope() before calling Node::rootTreeScope(), where we can *early exit* if the node is not in a tree scope. BUG=602556 ========== to ========== Introduce Node::rootTreeScope(), which asserts that the node's root is a tree scope The difference between Node::rootTreeScope() and Node::treeScope() is that Node::rootTreeScope() asserts that the node is in a treeScope. Node::treeScope() does not. Replace some of the current usage of Node::treeScope() with Node::rootTreeScope() if rootTreeScope() is better to express the intention. This CL also optimize some code pass by explicitly checking Node::isInTreeScope() before calling Node::rootTreeScope(), where we can *early exit*. BUG=602556 ==========
hayato@chromium.org changed reviewers: - esprehn@chromium.org, rune@opera.com
Description was changed from ========== Introduce Node::rootTreeScope(), which asserts that the node's root is a tree scope The difference between Node::rootTreeScope() and Node::treeScope() is that Node::rootTreeScope() asserts that the node is in a treeScope. Node::treeScope() does not. Replace some of the current usage of Node::treeScope() with Node::rootTreeScope() if rootTreeScope() is better to express the intention. This CL also optimize some code pass by explicitly checking Node::isInTreeScope() before calling Node::rootTreeScope(), where we can *early exit*. BUG=602556 ========== to ========== Introduce Node::rootTreeScope(), which asserts that the node's root is a tree scope The difference between Node::rootTreeScope() and Node::treeScope() is that Node::rootTreeScope() asserts that the node is in a treeScope. Node::treeScope() does not. Replace some of the current usage of Node::treeScope() with Node::rootTreeScope() if rootTreeScope() is better to express the intention. This CL also optimize some code path by explicitly checking Node::isInTreeScope() before calling Node::rootTreeScope(), where we can *early exit* if the node is not in a tree scope. BUG=602556 ==========
Description was changed from ========== Introduce Node::rootTreeScope(), which asserts that the node's root is a tree scope The difference between Node::rootTreeScope() and Node::treeScope() is that Node::rootTreeScope() asserts that the node is in a treeScope. Node::treeScope() does not. Replace some of the current usage of Node::treeScope() with Node::rootTreeScope() if rootTreeScope() is better to express the intention. This CL also optimize some code path by explicitly checking Node::isInTreeScope() before calling Node::rootTreeScope(), where we can *early exit* if the node is not in a tree scope. BUG=602556 ========== to ========== Introduce Node::rootTreeScope(), which asserts that the node's root is a tree scope The difference between Node::rootTreeScope() and Node::treeScope() is that Node::rootTreeScope() asserts that the node is in a treeScope. Node::treeScope() does not. Replace some of the current usage of Node::treeScope() with Node::rootTreeScope() if rootTreeScope() is better to express the intention. This CL also optimize some code path by explicitly checking Node::isInTreeScope() before calling Node::rootTreeScope(), where we can *early exit* if the node is not in a tree scope. BUG=602556 ==========
rune@opera.com changed reviewers: + rune@opera.com
I think I would prefer to have the DCHECK in treeScope() instead and add a treeScopeOrDocument() in the cases where that's what we expect. treeScopeOrDocument() could do: DCHECK(isInTreeScope() || treeScope() == document()) https://codereview.chromium.org/1883083002/diff/20001/third_party/WebKit/Sour... File third_party/WebKit/Source/core/dom/SelectorQuery.cpp (left): https://codereview.chromium.org/1883083002/diff/20001/third_party/WebKit/Sour... third_party/WebKit/Source/core/dom/SelectorQuery.cpp:264: if (selector->match() == CSSSelector::Id && !rootNode.document().containsMultipleElementsWithId(selector->value())) { On 2016/04/14 07:29:58, hayato wrote: > Using document() here looks a bug to me. Yes. Perhaps fix that in a separate CL. Reported https://crbug.com/603431
On 2016/04/14 at 08:48:01, rune wrote: > I think I would prefer to have the DCHECK in treeScope() instead and add a treeScopeOrDocument() in the cases where that's what we expect. > > treeScopeOrDocument() could do: > > DCHECK(isInTreeScope() || treeScope() == document()) I don't think any method that has a name like that makes sense, all tree scopes are documents. I'd rather we didn't mess with the existing treeScope() method at all. This patch seems fine and the naming of rootTreeScope seems okay too, it matches rootNode which was added recently. > > https://codereview.chromium.org/1883083002/diff/20001/third_party/WebKit/Sour... > File third_party/WebKit/Source/core/dom/SelectorQuery.cpp (left): > > https://codereview.chromium.org/1883083002/diff/20001/third_party/WebKit/Sour... > third_party/WebKit/Source/core/dom/SelectorQuery.cpp:264: if (selector->match() == CSSSelector::Id && !rootNode.document().containsMultipleElementsWithId(selector->value())) { > On 2016/04/14 07:29:58, hayato wrote: > > Using document() here looks a bug to me. > > Yes. Perhaps fix that in a separate CL. > > Reported https://crbug.com/603431 Yeah let's fix the bug separately.
Thanks. My current plan is: - Introduce Node::rootTreeScope(). - Do not touch Node::treeScope(). Let it be as is. That would not upset blink developers, I hope. Let me refine this CL.
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: This issue passed the CQ dry run.
I've been thinking about this from the bug and the reason we have document and treeScope is to model the global in JS. For example in the blink C++ you write document().createElement(...) or whatever it might be. That's pretty but confusing since document is also a method and you can write node.document().foo(...), and we have this inDocument() bit that doesn't relate. One path could be to rename the existing method to globalDocument(). I suspect we don't need globalTreeScope at all, since anyone using that can just use globalDocument. Then we rename treeScope() and document() to something like rootTreeScope() with the assert like you have here and connectedDocument() that similarly has the inDocument() assert, I think the spec is using the language connected now too? That's more verbose but makes each call site clear about whether it means the global document or the connected one. -- You received this message because you are subscribed to the Google Groups "Blink Reviews" group. To unsubscribe from this group and stop receiving emails from it, send an email to blink-reviews+unsubscribe@chromium.org.
I've been thinking about this from the bug and the reason we have document and treeScope is to model the global in JS. For example in the blink C++ you write document().createElement(...) or whatever it might be. That's pretty but confusing since document is also a method and you can write node.document().foo(...), and we have this inDocument() bit that doesn't relate. One path could be to rename the existing method to globalDocument(). I suspect we don't need globalTreeScope at all, since anyone using that can just use globalDocument. Then we rename treeScope() and document() to something like rootTreeScope() with the assert like you have here and connectedDocument() that similarly has the inDocument() assert, I think the spec is using the language connected now too? That's more verbose but makes each call site clear about whether it means the global document or the connected one. -- You received this message because you are subscribed to the Google Groups "Chromium-reviews" group. To unsubscribe from this group and stop receiving emails from it, send an email to chromium-reviews+unsubscribe@chromium.org.
The CQ bit was checked by hayato@chromium.org to run a CQ dry run
rebased
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1883083002/40001 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/1883083002/40001
I see. Thanks. Thus, the long time goal would be: 1). Document& Node::globalDocument() { return ... // The behavior is same to the current Node::document(). } 2). Document& Node::connectedDocument() { DCHECK(inShadowIncludingDocument()); return globalDocument(); } 3). Document& Node::treeScope() { DCHECK(inTreeScope()); return m_treeScope; } 4). TreeScope& Node::treeScopeOrGlobalDocument() { // I am not sure whether we still need this return m_treeScope; } That would makes sense. A bug of querySelectorAll was fixed in another CL: https://codereview.chromium.org/1892743002 I rebased this CL on top on it. In any case, this CL might be okay because if we introduce Node::rootTreeScope() here, we can rename it to 3) mechanically later.
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: This issue passed the CQ dry run.
PTAL
lgtm, but please wait for esprehn.
Elliott, could you take a look?
On 2016/04/22 at 07:48:46, hayato wrote: > Elliott, could you take a look? Yeah I'll look soon, sorry for the delay.
https://codereview.chromium.org/1883083002/diff/40001/third_party/WebKit/Sour... File third_party/WebKit/Source/core/dom/Element.cpp (right): https://codereview.chromium.org/1883083002/diff/40001/third_party/WebKit/Sour... third_party/WebKit/Source/core/dom/Element.cpp:2212: if (isInTreeScope() && rootTreeScope().adjustedFocusedElement() == this) { Why do we need to add the check here? We do adjustedFocusedElement() == this in many places, if that's too expensive then we should add a method to Element that checks isInTreeScope for you.
I think this got tackled some other way? Do we still want to do this? What's the status? :)
On 2016/05/18 at 00:36:35, esprehn wrote: > I think this got tackled some other way? Do we still want to do this? What's the status? :) No update. :) I guess I have to rebase this CL. This CL is not a urgent task for Blink. Let me remove you from reviewers, tentatively. If this CL becomes ready again, I might send another review request.
hayato@chromium.org changed reviewers: - esprehn@chromium.org, rune@opera.com
The CQ bit was checked by hayato@chromium.org to run a CQ dry run
Add Element::adjustedFocusElementinTreeScope
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1883083002/60001 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/1883083002/60001
Description was changed from ========== Introduce Node::rootTreeScope(), which asserts that the node's root is a tree scope The difference between Node::rootTreeScope() and Node::treeScope() is that Node::rootTreeScope() asserts that the node is in a treeScope. Node::treeScope() does not. Replace some of the current usage of Node::treeScope() with Node::rootTreeScope() if rootTreeScope() is better to express the intention. This CL also optimize some code path by explicitly checking Node::isInTreeScope() before calling Node::rootTreeScope(), where we can *early exit* if the node is not in a tree scope. BUG=602556 ========== to ========== Introduce Node::rootTreeScope(), which asserts that the node's root is a tree scope The difference between Node::rootTreeScope() and Node::treeScope() is that Node::rootTreeScope() asserts that the node is in a treeScope. Node::treeScope() does not. Replace some of the current usage of Node::treeScope() with Node::rootTreeScope() if rootTreeScope() is better to express their intention. This CL also introduces Element::adjustedFocusedElementInTreeScope() to optimize some code path where we can early exit if the element is not in a tree scope. BUG=602556 ==========
hayato@chromium.org changed reviewers: + rune@opera.com
Description was changed from ========== Introduce Node::rootTreeScope(), which asserts that the node's root is a tree scope The difference between Node::rootTreeScope() and Node::treeScope() is that Node::rootTreeScope() asserts that the node is in a treeScope. Node::treeScope() does not. Replace some of the current usage of Node::treeScope() with Node::rootTreeScope() if rootTreeScope() is better to express their intention. This CL also introduces Element::adjustedFocusedElementInTreeScope() to optimize some code path where we can early exit if the element is not in a tree scope. BUG=602556 ========== to ========== Introduce Node::rootTreeScope(), which asserts that the node's root is a tree scope The difference between Node::rootTreeScope() and Node::treeScope() is that Node::rootTreeScope() asserts that the node is in a treeScope. Node::treeScope() does not. Replace some of the current usage of Node::treeScope() with Node::rootTreeScope() if rootTreeScope() is better to express their intention. This CL also introduces Element::adjustedFocusedElementInTreeScope() to optimize some code path where we can early exit if the element is not in a tree scope. BUG=602556 ==========
hayato@chromium.org changed reviewers: + esprehn@chromium.org
PTAL again. I have rebased this. https://codereview.chromium.org/1883083002/diff/40001/third_party/WebKit/Sour... File third_party/WebKit/Source/core/dom/Element.cpp (right): https://codereview.chromium.org/1883083002/diff/40001/third_party/WebKit/Sour... third_party/WebKit/Source/core/dom/Element.cpp:2212: if (isInTreeScope() && rootTreeScope().adjustedFocusedElement() == this) { Done. Yeah, TreeScope::adjustedFocusedElement() could be expensive. I introduced Element::adjustedFocusedElementInTreeScope(), and updated callers of TreeScope::adjustedFocusedElement() to use that. That would be a small performance gain.
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: Try jobs failed on following builders: linux_chromium_rel_ng on tryserver.chromium.linux (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.linux/builders/linux_chromium_...)
Elliott, could you take a look?
Sure I'll look tomorrow, sorry for the delay. -- You received this message because you are subscribed to the Google Groups "Chromium-reviews" group. To unsubscribe from this group and stop receiving emails from it, send an email to chromium-reviews+unsubscribe@chromium.org.
Sure I'll look tomorrow, sorry for the delay. -- You received this message because you are subscribed to the Google Groups "Blink Reviews" group. To unsubscribe from this group and stop receiving emails from it, send an email to blink-reviews+unsubscribe@chromium.org.
Hmm, the name rootTreeScope is confusing since this isn't root of the tree of scopes, maybe that's okay. I might have gone with containingTreeScope like containingShadowRoot?
lgtm
On 2016/05/31 at 19:40:33, esprehn wrote: > Hmm, the name rootTreeScope is confusing since this isn't root of the tree of scopes, maybe that's okay. I might have gone with containingTreeScope like containingShadowRoot? I do not have a strong opinion on the name. Thus, let's rename it to containingTreeScope. I'll land this patch after renaming. Thanks!
Description was changed from ========== Introduce Node::rootTreeScope(), which asserts that the node's root is a tree scope The difference between Node::rootTreeScope() and Node::treeScope() is that Node::rootTreeScope() asserts that the node is in a treeScope. Node::treeScope() does not. Replace some of the current usage of Node::treeScope() with Node::rootTreeScope() if rootTreeScope() is better to express their intention. This CL also introduces Element::adjustedFocusedElementInTreeScope() to optimize some code path where we can early exit if the element is not in a tree scope. BUG=602556 ========== to ========== Introduce Node::containingTreeScope(), which asserts that the node's root is a tree scope The difference between Node::containingTreeScope() and Node::treeScope() is that Node::containingTreeScope() asserts that the node is in a treeScope. Node::treeScope() does not. Replace some of the current usage of Node::treeScope() with Node::containingTreeScope() if containingTreeScope() is better to express their intention. This CL also introduces Element::adjustedFocusedElementInTreeScope() to optimize some code path where we can early exit if the element is not in a tree scope. BUG=602556 ==========
The CQ bit was checked by hayato@chromium.org to run a CQ dry run
renamed
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1883083002/80001 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/1883083002/80001
The CQ bit was unchecked by hayato@chromium.org
The CQ bit was checked by hayato@chromium.org
The patchset sent to the CQ was uploaded after l-g-t-m from rune@opera.com, esprehn@chromium.org Link to the patchset: https://codereview.chromium.org/1883083002/#ps80001 (title: "renamed")
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1883083002/80001 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/1883083002/80001
Message was sent while issue was closed.
Committed patchset #5 (id:80001)
Message was sent while issue was closed.
Description was changed from ========== Introduce Node::containingTreeScope(), which asserts that the node's root is a tree scope The difference between Node::containingTreeScope() and Node::treeScope() is that Node::containingTreeScope() asserts that the node is in a treeScope. Node::treeScope() does not. Replace some of the current usage of Node::treeScope() with Node::containingTreeScope() if containingTreeScope() is better to express their intention. This CL also introduces Element::adjustedFocusedElementInTreeScope() to optimize some code path where we can early exit if the element is not in a tree scope. BUG=602556 ========== to ========== Introduce Node::containingTreeScope(), which asserts that the node's root is a tree scope The difference between Node::containingTreeScope() and Node::treeScope() is that Node::containingTreeScope() asserts that the node is in a treeScope. Node::treeScope() does not. Replace some of the current usage of Node::treeScope() with Node::containingTreeScope() if containingTreeScope() is better to express their intention. This CL also introduces Element::adjustedFocusedElementInTreeScope() to optimize some code path where we can early exit if the element is not in a tree scope. BUG=602556 Committed: https://crrev.com/97a40b7bad083e7f9382a92e00adf1bd650db4a5 Cr-Commit-Position: refs/heads/master@{#397065} ==========
Message was sent while issue was closed.
Patchset 5 (id:??) landed as https://crrev.com/97a40b7bad083e7f9382a92e00adf1bd650db4a5 Cr-Commit-Position: refs/heads/master@{#397065} |