Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement NodeIterator #5981

Merged
merged 5 commits into from May 28, 2015
Merged

Implement NodeIterator #5981

merged 5 commits into from May 28, 2015

Conversation

@Jinwoo-Song
Copy link
Contributor

Jinwoo-Song commented May 8, 2015

Implement NodeIterator's basic functionality. (Fixes #1235) But the cases for node removals are not implemented yet.

r? @jdm
cc @yichoi

Review on Reviewable

@highfive
Copy link

highfive commented May 8, 2015

Thanks for the pull request, and welcome! The Servo team is excited to review your changes, and you should hear from @glennw (or someone else) soon.

@hoppipolla-critic-bot
Copy link

hoppipolla-critic-bot commented May 8, 2015

Critic review: https://critic.hoppipolla.co.uk/r/4935

This is an external review system which you may optionally use for the code review of your pull request.

In order to help critic track your changes, please do not make in-place history rewrites (e.g. via git rebase -i or git commit --amend) when updating this pull request.

@Jinwoo-Song Jinwoo-Song force-pushed the Jinwoo-Song:nodeiterator branch 2 times, most recently from 336486a to 22983ff May 8, 2015
reflector_: Reflector
reflector_: Reflector,
root_node: JS<Node>,
reference_node: MutNullableHeap<JS<Node>>,

This comment has been minimized.

@nox

nox May 8, 2015

Member

AFAICT you never set it to None, so MutHeap would be enough here.

@larsbergstrom
Copy link
Contributor

larsbergstrom commented May 8, 2015

@jdm @Ms2ger Will one of the two of you be reviewing this?

@jdm jdm self-assigned this May 8, 2015
@nox
Copy link
Member

nox commented May 14, 2015

components/script/dom/nodeiterator.rs, line 308 [r4] (raw file):
This can be confusing given we have dom::bindings::js::JS.


tests/wpt/metadata/dom/interfaces.html.ini, line 444 [r4] (raw file):
If #5902 gets merged before this PR, this test is going to pass.


tests/wpt/metadata/dom/traversal/NodeIterator.html.ini, line 5 [r4] (raw file):
Why isn't that test passing?


Comments from the review on Reviewable.io

@nox
Copy link
Member

nox commented May 14, 2015

components/script/dom/nodeiterator.rs, line 97 [r4] (raw file):
No need for a helper if it is already a DOM method, remove prev_node().


components/script/dom/nodeiterator.rs, line 102 [r4] (raw file):
Idem, remove next_node().


components/script/dom/nodeiterator.rs, line 118 [r4] (raw file):
It is a bit confusing that the methods in the trait and the impl aren't in the same order.


components/script/dom/nodeiterator.rs, line 121 [r4] (raw file):
To clean this helper and first_preceding_node_not_preceding_root, I'm pretty sure we can instead tweak TreeIterator in node.rs to take both a root and a current node.


components/script/dom/nodeiterator.rs, line 194 [r4] (raw file):
Just write "Step 1.", "Step 2.", etc like in other files.


components/script/dom/nodeiterator.rs, line 234 [r4] (raw file):
Link to spec.


components/script/dom/nodeiterator.rs, line 235 [r4] (raw file):
Step 1.


components/script/dom/nodeiterator.rs, line 236 [r4] (raw file):
Root this right there.


components/script/dom/nodeiterator.rs, line 250 [r4] (raw file):
Why do you need the ref forever?


components/script/dom/nodeiterator.rs, line 269 [r4] (raw file):
Why do you need the ref forever?


components/script/dom/nodeiterator.rs, line 282 [r4] (raw file):
Why do you need the ref forever?


Comments from the review on Reviewable.io

@jdm
Copy link
Member

jdm commented May 14, 2015

-S-awaiting-review +S-needs-code-changes
@nox reviewed this with my blessing. Thanks for implementing this, @Jinwoo-Song!


Reviewed files:

  • components/script/dom/document.rs @ r3
  • components/script/dom/nodeiterator.rs @ r1, r2, r3, r4
  • components/script/dom/webidls/Document.webidl @ r3
  • components/script/dom/webidls/NodeIterator.webidl @ r1, r2, r4
  • tests/wpt/metadata/dom/interfaces.html.ini @ r4
  • tests/wpt/metadata/dom/traversal/NodeIterator.html.ini @ r4

components/script/dom/nodeiterator.rs, line 25 [r1] (raw file):
nit: indent these to match root_node


components/script/dom/nodeiterator.rs, line 91 [r4] (raw file):
Add a spec link.


components/script/dom/nodeiterator.rs, line 104 [r2] (raw file):
Let's just move the implementation of these into NextNode and PrevNode.


Comments from the review on Reviewable.io

@bors-servo
Copy link
Contributor

bors-servo commented May 14, 2015

The latest upstream changes (presumably #6037) made this pull request unmergeable. Please resolve the merge conflicts.

@jdm jdm added the S-needs-rebase label May 14, 2015
@Jinwoo-Song
Copy link
Contributor Author

Jinwoo-Song commented May 21, 2015

Review status: all files reviewed, 18 unresolved discussions, some commit checks failed.


components/script/dom/nodeiterator.rs, line 24 [r4] (raw file):
Done. Yes, latest spec says referenceNode cannot be NULL.


components/script/dom/nodeiterator.rs, line 33 [r1] (raw file):
Done.


components/script/dom/nodeiterator.rs, line 91 [r4] (raw file):
Done.


components/script/dom/nodeiterator.rs, line 97 [r4] (raw file):
Done.


components/script/dom/nodeiterator.rs, line 102 [r4] (raw file):
Done.


components/script/dom/nodeiterator.rs, line 118 [r4] (raw file):
Done.


components/script/dom/nodeiterator.rs, line 121 [r4] (raw file):
Done. I added following_node() and preceding_nod() in node.rs and used them in nodeiterator.rs


components/script/dom/nodeiterator.rs, line 194 [r4] (raw file):
Done.


components/script/dom/nodeiterator.rs, line 219 [r2] (raw file):
Done.


components/script/dom/nodeiterator.rs, line 234 [r4] (raw file):
Done.


components/script/dom/nodeiterator.rs, line 235 [r4] (raw file):
Done.


components/script/dom/nodeiterator.rs, line 236 [r4] (raw file):
Done.


components/script/dom/nodeiterator.rs, line 250 [r4] (raw file):
Done. Fixed the code not to use ref forever.


components/script/dom/nodeiterator.rs, line 269 [r4] (raw file):
Done. Fixed the code not to use ref forever.


components/script/dom/nodeiterator.rs, line 282 [r4] (raw file):
Done. Fixed the code not to use ref forever.


components/script/dom/nodeiterator.rs, line 308 [r4] (raw file):
Would you suggest a candidate? :)


tests/wpt/metadata/dom/interfaces.html.ini, line 444 [r4] (raw file):
Great!


tests/wpt/metadata/dom/traversal/NodeIterator.html.ini, line 5 [r4] (raw file):
Actually, I have no idea for this why this fails. Could you give me some advice?


Comments from the review on Reviewable.io

@Jinwoo-Song Jinwoo-Song force-pushed the Jinwoo-Song:nodeiterator branch from 22983ff to e0726fe May 21, 2015
@jdm jdm removed the S-needs-rebase label May 21, 2015
@nox
Copy link
Member

nox commented May 25, 2015

Review status: 1 of 7 files reviewed, 10 unresolved discussions, all commit checks successful.


components/script/dom/document.rs, line 1318 [r5] (raw file):
https://dom.spec.whatwg.org/#dom-document-createnodeiteratorroot-whattoshow-filter


components/script/dom/node.rs, line 1306 [r5] (raw file):
As a follow-up ticket to file, or if you want to do it right now, TreeIterator and FollowingRootIterator can be merged. Their only difference is that I stored the current depth instead of the root in the former.

Otherwise that's exactly what I had in mind.


components/script/dom/nodeiterator.rs, line 98 [r4] (raw file):
Mmmh, that's a bit similar isn't? :) The point was to remove helper methods when they are used in a proper DOM method as-is. No need to have extra layers of indirections.


components/script/dom/nodeiterator.rs, line 103 [r5] (raw file):
Ditto.


components/script/dom/nodeiterator.rs, line 157 [r5] (raw file):
if result == NodeFilterConstants::FILTER_ACCEPT { … }


components/script/dom/nodeiterator.rs, line 247 [r4] (raw file):
I don't have any good candidate. :s

Callback? Interpreted? NotNative? :P


tests/wpt/metadata/dom/interfaces.html.ini, line 357 [r4] (raw file):
In fact, it won't, I was wrong I fixed other lengths but not this one. Oh well. :)


tests/wpt/metadata/dom/traversal/NodeIterator.html.ini, line 5 [r4] (raw file):
I'll look into it.


Comments from the review on Reviewable.io

@nox
Copy link
Member

nox commented May 25, 2015

Review status: 1 of 7 files reviewed, 11 unresolved discussions, all commit checks successful.


tests/wpt/metadata/dom/traversal/NodeIterator.html.ini, line 5 [r4] (raw file):
So I've looked into it, and apparently it comes from callback::CallSetup::drop() not taking into account the CallSetup's exception handling mode. It shouldn't report the exception if the value is ExceptionHandling::Rethrow. You can either fix it or file a follow-up issue and I'll take care of it.


Comments from the review on Reviewable.io

@nox
Copy link
Member

nox commented May 25, 2015

Review status: 1 of 7 files reviewed, 14 unresolved discussions, all commit checks successful.


components/script/dom/node.rs, line 790 [r5] (raw file):
following_nodes


components/script/dom/node.rs, line 797 [r5] (raw file):
preceding_nodes


components/script/dom/node.rs, line 804 [r5] (raw file):
descending_last_children? I find that name confusing but I can't find a better one right now.


Comments from the review on Reviewable.io

@nox
Copy link
Member

nox commented May 25, 2015

Review status: 2 of 7 files reviewed, 14 unresolved discussions, all commit checks successful.
Reviewed files:

  • components/script/dom/node.rs @ r5

Comments from the review on Reviewable.io

@Jinwoo-Song
Copy link
Contributor Author

Jinwoo-Song commented May 27, 2015

@Jinwoo-Song Jinwoo-Song force-pushed the Jinwoo-Song:nodeiterator branch from e0726fe to 6d570e9 May 27, 2015
Jinwoo-Song added 4 commits Apr 27, 2015
 - root, whatToShow, and filter
Just implement the skelectons
 - referenceNode attribute
 - nextNode() and previousNode()
First patch to resolve #1235. We need more implementation for handling node removals,
and I'll implement in next patch.
@nox
Copy link
Member

nox commented May 27, 2015

Review status: 2 of 7 files reviewed, 4 unresolved discussions, all commit checks successful.
Reviewed files:

  • components/script/dom/node.rs @ r6

Comments from the review on Reviewable.io

@Jinwoo-Song
Copy link
Contributor Author

Jinwoo-Song commented May 27, 2015

Review status: 2 of 7 files reviewed, 4 unresolved discussions, all commit checks successful.
Reviewed files:

  • components/script/dom/node.rs @ r6

tests/wpt/metadata/dom/interfaces.html.ini, line 444 [r4] (raw file):
It seems that all other tests for 'object length' fail. But I do not have idea for this right now.


Comments from the review on Reviewable.io

@Manishearth
Copy link
Member

Manishearth commented May 27, 2015

Review status: 5 of 7 files reviewed, 4 unresolved discussions, all commit checks successful.
Reviewed files:

  • components/script/dom/webidls/Document.webidl @ r5
  • components/script/dom/webidls/NodeIterator.webidl @ r5
  • tests/wpt/metadata/dom/interfaces.html.ini @ r5

tests/wpt/metadata/dom/interfaces.html.ini, line 444 [r4] (raw file):
Try rebasing again and testing


Comments from the review on Reviewable.io

@nox
Copy link
Member

nox commented May 27, 2015

Review status: all files reviewed, 4 unresolved discussions, all commit checks successful.
Reviewed files:

  • components/script/dom/document.rs @ r6
  • components/script/dom/nodeiterator.rs @ r6
  • components/script/dom/webidls/Document.webidl @ r5
  • components/script/dom/webidls/NodeIterator.webidl @ r5
  • tests/wpt/metadata/dom/interfaces.html.ini @ r5
  • tests/wpt/metadata/dom/traversal/NodeIterator.html.ini @ r4

tests/wpt/metadata/dom/interfaces.html.ini, line 357 [r4] (raw file):
@Manisheart Nah I was saying I thought I fixed them but I didn't, so even if he rebases nothing will change. I just made a remark for nothing.


Comments from the review on Reviewable.io

@Manishearth
Copy link
Member

Manishearth commented May 28, 2015

@nox Is there anything left to resolve? Or should I r+?

@nox
Copy link
Member

nox commented May 28, 2015

@Manishearth No, LGTM. :)

@Manishearth
Copy link
Member

Manishearth commented May 28, 2015

@bors-servo
Copy link
Contributor

bors-servo commented May 28, 2015

📌 Commit 6d570e9 has been approved by Manishearth

@bors-servo
Copy link
Contributor

bors-servo commented May 28, 2015

Testing commit 6d570e9 with merge 06e7b51...

bors-servo pushed a commit that referenced this pull request May 28, 2015
Implement NodeIterator's basic functionality. (Fixes #1235)  But the cases for node removals are not implemented yet. 

r? @jdm 
cc @yichoi

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/5981)
<!-- Reviewable:end -->
@bors-servo
Copy link
Contributor

bors-servo commented May 28, 2015

💔 Test failed - mac1

@nox
Copy link
Member

nox commented May 28, 2015

@Jinwoo-Song

/html/dom/interfaces.html
-------------------------
PASS expected FAIL Document interface: document.implementation.createDocument(null, "", null) must inherit property "createNodeIterator" with the proper type (25)
PASS expected FAIL Document interface: calling createNodeIterator(Node,unsigned long,NodeFilter) on document.implementation.createDocument(null, "", null) with too few arguments must throw TypeError

Almost done! :)

@Jinwoo-Song Jinwoo-Song force-pushed the Jinwoo-Song:nodeiterator branch from 6d570e9 to db25be7 May 28, 2015
@Jinwoo-Song
Copy link
Contributor Author

Jinwoo-Song commented May 28, 2015

Updated test result!

@nox
Copy link
Member

nox commented May 28, 2015

Review status: all files reviewed, 4 unresolved discussions, all commit checks successful.
Reviewed files:

  • components/script/dom/document.rs @ r7
  • components/script/dom/node.rs @ r7
  • tests/wpt/metadata/html/dom/interfaces.html.ini @ r7

Comments from the review on Reviewable.io

@Manishearth
Copy link
Member

Manishearth commented May 28, 2015

@bors-servo
Copy link
Contributor

bors-servo commented May 28, 2015

📌 Commit db25be7 has been approved by Manishearth

@bors-servo
Copy link
Contributor

bors-servo commented May 28, 2015

Testing commit db25be7 with merge 2b52006...

bors-servo pushed a commit that referenced this pull request May 28, 2015
Implement NodeIterator's basic functionality. (Fixes #1235)  But the cases for node removals are not implemented yet. 

r? @jdm 
cc @yichoi

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/5981)
<!-- Reviewable:end -->
@bors-servo
Copy link
Contributor

bors-servo commented May 28, 2015

☀️ Test successful - android, gonk, linux1, linux2, mac1, mac2

@bors-servo bors-servo merged commit db25be7 into servo:master May 28, 2015
2 checks passed
2 checks passed
continuous-integration/travis-ci/pr The Travis CI build passed
Details
homu Test successful
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

8 participants
You can’t perform that action at this time.