Skip to content

HTML input value - #9514

Merged
bors-servo merged 1 commit into
servo:masterfrom
g-k:html-input-value
Feb 27, 2016
Merged

bors-servo merged 1 commit into
servo:masterfrom
g-k:html-input-value

Conversation

@g-k

@g-k g-k commented Feb 3, 2016

Copy link
Copy Markdown
Contributor

Ready for review.

Fixes #9455.

Review on Reviewable

@highfive highfive added the S-awaiting-review There is new code that needs to be reviewed. label Feb 3, 2016

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Move these impl up to where the enum is.

@frewsxcv

frewsxcv commented Feb 3, 2016

Copy link
Copy Markdown
Contributor
./components/script/dom/htmlinputelement.rs:396: link to WHATWG may break in the future, use this format instead: https://html.spec.whatwg.org/multipage/#input-type-attr-summary
./components/script/dom/htmlinputelement.rs:411: missing space before {

@g-k

g-k commented Feb 3, 2016

Copy link
Copy Markdown
Contributor Author

Thanks for the feedback!

I broke a bunch of tests in: tests/wpt/web-platform-tests/html/semantics/forms/the-input-element/ so I'm going to work on getting those passing next.

@g-k

g-k commented Feb 5, 2016

Copy link
Copy Markdown
Contributor Author

OK, I'm stuck.

9a4b26f passes the radionodelist test and the tests/wpt/web-platform-tests/html/semantics/forms/the-input-element/ tests except for the one below.

I tried to get it test passing by setting the value to the textinput value when the type attribute changes (in VirtualMethods attribute_mutated for type AttributeMutation::Set), but that crashes.

  ▶ Unexpected subtest result in /html/semantics/forms/the-input-element/type-change-state.html:
  │ FAIL [expected PASS] change state from hidden to checkbox
  │   → assert_equals: input.value should be '  foo\rbar  ' after change of state expected "  foo\rbar  " but got "on"
  │ FAIL [expected PASS] change state from hidden to radio
  │   → assert_equals: input.value should be '  foo\rbar  ' after change of state expected "  foo\rbar  " but got "on"
...
  │ FAIL [expected PASS] change state from image to reset
  │   → assert_equals: input.value should be '  foo\rbar  ' after change of state expected "  foo\rbar  " but got ""
  │ FAIL [expected PASS] change state from image to button
  │   → assert_equals: input.value should be '  foo\rbar  ' after change of state expected "  foo\rbar  " but got ""
  │ 
  │ @http://web-platform.test:8000/html/semantics/forms/the-input-element/type-change-state.html:42:15
  │ Test.prototype.step@http://web-platform.test:8000/resources/testharness.js:1381:20
  │ test@http://web-platform.test:8000/resources/testharness.js:495:9
  └ @http://web-platform.test:8000/html/semantics/forms/the-input-element/type-change-state.html:28:1

} else {
input.upcast::<Element>()
.get_attribute(&ns!(), &atom!("value"))
.map_or_else(|| default,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks like a .map_or() is enough, no need for .map_or_else()

@KiChjang

KiChjang commented Feb 5, 2016

Copy link
Copy Markdown
Contributor

Could you also provide step annotations for the functions that you've wrote? It's hard to follow which part of the spec you're implementing.

// https://html.spec.whatwg.org/multipage/#dom-input-value
fn Value(&self) -> DOMString {
self.textinput.borrow().get_content()
InputValueMode::from_input_element(&self).get_value(self)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure how I missed this, but this style is kind of weird. I'd expect InputValueMode to be a field in HTMLInputElement, and this method would just be a call to self.get_value(). Here you're constructing a new InputValueMode every time you get or set the value of an HTMLInputElement, and then calling a method on the InputValueMode, supplying it with an instance of HTMLInputElement.

@KiChjang

KiChjang commented Feb 5, 2016

Copy link
Copy Markdown
Contributor

I suspect that the test failures are because of the changes between InputModeValues - some of them make changes to the attributes on the upcasted Element struct, and some don't. Filed whatwg/html#628 for some clairifications.

@g-k
g-k force-pushed the html-input-value branch from 9a4b26f to a9994e1 Compare February 8, 2016 05:13
@g-k

g-k commented Feb 8, 2016

Copy link
Copy Markdown
Contributor Author

Ah! I thought only content attributes were called attributes.

I made the suggested changes and the input and raidonodelist tests pass, but the implementation is wrong since SetValue for default/on updates the content attribute.

I need to find out if the simple list iterator does a tree order traversal (pre-order, depth-first traversal of DOM nodes) and whether remove attribute on an Element should call attribute_mutated when it's an HTMLInputElement.

// assert_equals(document.getElementById("r1").value, -39); // but got string "1"

rdoList.value = "on";
// expected "1" but got "2"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Revert changes to this file, please.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will. This is a WIP branch.

I just thought it was interesting, because it seems like IDL attribute has the right value before it is set to "on".

@KiChjang KiChjang added S-needs-code-changes Changes have not yet been made that were requested by a reviewer. and removed S-awaiting-review There is new code that needs to be reviewed. labels Feb 14, 2016

// On setting, if the new value is the empty string, it
// must empty the list of selected files; otherwise, it
// must throw an InvalidStateError exception.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All of these annotations are unnecessary; we only need step numbers.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I might be misreading the spec or looking in the wrong place, but I don't see any step numbers on: https://html.spec.whatwg.org/multipage/forms.html#dom-input-value

@g-k
g-k force-pushed the html-input-value branch from a9994e1 to a2efef6 Compare February 17, 2016 04:24
@highfive highfive added S-awaiting-review There is new code that needs to be reviewed. and removed S-needs-code-changes Changes have not yet been made that were requested by a reviewer. labels Feb 17, 2016
@g-k
g-k force-pushed the html-input-value branch 2 times, most recently from 8fc5c64 to 7b21d8e Compare February 17, 2016 04:37
|a| DOMString::from(a.summarize().value)),
ValueMode::DefaultOn =>
self.upcast::<Element>()
.get_attribute(&ns!(), &atom!("value"))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Indentation

@bors-servo

Copy link
Copy Markdown
Contributor

⌛ Testing commit e6c31e3 with merge b9698bf...

bors-servo pushed a commit that referenced this pull request Feb 26, 2016
@bors-servo

Copy link
Copy Markdown
Contributor

💔 Test failed - linux-rel

@highfive highfive added S-tests-failed The changes caused existing tests to fail. and removed S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. labels Feb 26, 2016
@nox

nox commented Feb 26, 2016

Copy link
Copy Markdown
Contributor

@bors-servo retry #9148

@nox nox added S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. and removed S-tests-failed The changes caused existing tests to fail. labels Feb 26, 2016
@bors-servo

Copy link
Copy Markdown
Contributor

⚡ Previous build results for android, gonk, linux-dev, mac-dev-unit, mac-rel-css, mac-rel-wpt are reusable. Rebuilding only linux-rel...

@bors-servo

Copy link
Copy Markdown
Contributor

💔 Test failed - linux-rel

@highfive highfive added S-tests-failed The changes caused existing tests to fail. and removed S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. labels Feb 26, 2016
@KiChjang

Copy link
Copy Markdown
Contributor

@bors-servo

Copy link
Copy Markdown
Contributor

⌛ Testing commit e6c31e3 with merge f30fb64...

bors-servo pushed a commit that referenced this pull request Feb 26, 2016
@highfive highfive added S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. and removed S-tests-failed The changes caused existing tests to fail. labels Feb 26, 2016
@bors-servo

Copy link
Copy Markdown
Contributor

💔 Test failed - linux-rel

@highfive highfive added S-tests-failed The changes caused existing tests to fail. and removed S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. labels Feb 26, 2016
@KiChjang

Copy link
Copy Markdown
Contributor

@bors-servo

Copy link
Copy Markdown
Contributor

⌛ Testing commit e6c31e3 with merge 0d7a2ee...

bors-servo pushed a commit that referenced this pull request Feb 26, 2016
@highfive highfive added S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. and removed S-tests-failed The changes caused existing tests to fail. labels Feb 26, 2016
@bors-servo

Copy link
Copy Markdown
Contributor

☀️ Test successful - android, gonk, linux-dev, linux-rel, mac-dev-unit, mac-rel-css, mac-rel-wpt

@bors-servo
bors-servo merged commit e6c31e3 into servo:master Feb 27, 2016
@g-k
g-k deleted the html-input-value branch February 27, 2016 01:02
ivanzr pushed a commit to ivanzr/web-platform-tests that referenced this pull request Jun 29, 2016
According to step 3 of
https://html.spec.whatwg.org/multipage/forms.html#input-type-change a
value mode transition from non-filename to filename should update the
input internal value state to the empty string.

According to
https://html.spec.whatwg.org/multipage/forms.html#dom-input-value a
subsequent read of the value IDL attribute should return the empty
string (assuming no selected files).

Refs: servo/servo#9514
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants