-
Notifications
You must be signed in to change notification settings - Fork 233
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 support for form owner #249
Conversation
r? @jdm |
Implement the form owner concept <!-- Please describe your changes on the following line: --> Implemention of the core logic for form owners. It's rebased version of #6613, addressed most of the comments and fixed some of the code. I needed to update the code by hand instead of rebasing old main commit because of the massive merge conflicts over the years. The html5ever PR is here: servo/html5ever#249 Currently I'm using my html5ever fork to run the tests. I'll undo the changes in Cargo.toml and Cargo.lock once it gets merged. --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: --> - [X] `./mach build -d` does not report any errors - [X] `./mach test-tidy` does not report any errors - [X] These changes fix #3553 (github issue number if applicable). <!-- Either: --> - [X] There are tests for these changes <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/15283) <!-- Reviewable:end -->
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good! Most of my comments are just about clarifying documenation or names of things to match the current specification text better.
src/tree_builder/interface.rs
Outdated
@@ -72,6 +72,10 @@ pub trait TreeSink { | |||
/// Do two handles refer to the same node? | |||
fn same_node(&self, x: Self::Handle, y: Self::Handle) -> bool; | |||
|
|||
/// Are two handles present in the same tree | |||
/// https://html.spec.whatwg.org/multipage/infrastructure.html#home-subtree |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This link isn't valid any more. The text in step 12 of https://html.spec.whatwg.org/multipage/syntax.html#create-an-element-for-the-token just says "same tree" with a link to https://dom.spec.whatwg.org/#concept-tree; we can probably just name this same_tree
in that case.
src/tree_builder/actions.rs
Outdated
@@ -775,10 +743,39 @@ impl<Handle, Sink> TreeBuilderActions<Handle> | |||
// FIXME: application cache selection algorithm | |||
} | |||
|
|||
// https://html.spec.whatwg.org/multipage/syntax.html#create-an-element-for-the-token |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove syntax.html
. However, we really will need comments labelling which steps are being implemented in the code, because it's really hard to figure out the association. I guess the majority of the new code is in support of the form owner stuff in step 12?
src/tree_builder/actions.rs
Outdated
BeforeSibling(ref p) => p.clone() | ||
}; | ||
|
||
// Step 4. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This step number is wrong.
src/tree_builder/actions.rs
Outdated
if form_associatable(qname.clone()) | ||
&& self.form_elem.is_some() | ||
&& !(reassociatable(qname.clone()) | ||
&& attrs.iter().any(|a| a.name == qualname!("","form"))) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: && belongs on the previous line in all these cases.
src/tree_builder/actions.rs
Outdated
@@ -747,7 +747,7 @@ impl<Handle, Sink> TreeBuilderActions<Handle> | |||
fn insert_element(&mut self, push: PushFlag, ns: Namespace, name: LocalName, attrs: Vec<Attribute>) | |||
-> Handle { | |||
declare_tag_set!(form_associatable = | |||
"button" "fieldset" "input" "keygen" "label" | |||
"button" "fieldset" "input" "keygen" "label" "legend" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://html.spec.whatwg.org/multipage/forms.html#form-associated-element seems to contradict this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm, legend element's tests were not passing without this change. But maybe I missed something I'll look into that.
src/tree_builder/actions.rs
Outdated
// TODO: Handle template element case | ||
if form_associatable(qname.clone()) | ||
&& self.form_elem.is_some() | ||
&& !(reassociatable(qname.clone()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not clear why we're using reassociatable instead of the definition of listed here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think its name is changed since 2015. They weren't different except names. I renamed it that way.
src/tree_builder/actions.rs
Outdated
}; | ||
|
||
// Step 12. | ||
// TODO: Handle template element case |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's required to handle this? We support template elements elsewhere in the parser now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, you're right. I forgot about it. Implemented it now, but I need to be sure that it's right :) https://html.spec.whatwg.org/multipage/syntax.html#create-an-element-for-the-token step 12 says:
...and there is no template element on the stack of open elements...
I hope I understand it right.
If you squash the commits, I'll merge them. Thanks! |
Squashed it. Thanks for the help! |
@bors-servo r=jdm |
📌 Commit 69f7069 has been approved by |
Implement support for form owner This is rebased version of #137. Fixed merge conflicts, updated to current codebase and addressed some comments. But there are still some todo's needs to be addressed. Servo side of this changes is currently WIP. Opening this for early feedbacks. <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/html5ever/249) <!-- Reviewable:end -->
☀️ Test successful - status-travis |
Revert "Implement support for form owner" This reverts commit 69f7069 (#249). <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/html5ever/252) <!-- Reviewable:end -->
We're going to need to make a new PR to merge this when servo/servo#15283 is ready to merge. |
@canaltinova Was there really no way to avoid separating the concept of appropriate place for insertion and the insertion itself? |
This is rebased version of #137. Fixed merge conflicts, updated to current codebase and addressed some comments. But there are still some todo's needs to be addressed. Servo side of this changes is currently WIP. Opening this for early feedbacks.
This change is