Commit graph

25 commits

Author SHA1 Message Date
Jan Andre Ikenmeyer
6b0c111126
Update MPL license to https (part 2) 2018-11-19 14:46:57 +01:00
Josh Matthews
6d3ff9f742
Remove unnecessary CEReactions.
This incorporates a spec update in https://github.com/whatwg/html/pull/3901.
2018-08-13 11:16:46 -04:00
tigercosmos
bdb6706f19 textarea minLength/maxLength 2018-06-18 02:01:59 -07:00
tigercosmos
0907940db8 add TextLength 2018-06-15 09:47:37 -07:00
Jon Leighton
ce7bae8834 Implement setRangeText API
Spec: https://html.spec.whatwg.org/multipage/#dom-textarea/input-setrangetext

In order to do this, we need to define the SelectionMode enum in WebIDL:
https://html.spec.whatwg.org/multipage/#selectionmode

Since the enum is used by HTMLTextAreaElement and HTMLInputElement, it
doesn't seem to make sense to define it in the WebIDL file for one or
other of those.

However, we also can't create a stand-alone SelectionMode.webidl file,
because the current binding-generation code won't generate a "pub mod
SelectionMode;" line in mod.rs unless SelectionMode.webidl contains
either an interface or a namespace. (This logic happens in
components/script/dom/bindings/codegen/Configuration.py:35, in the
Configuration.__init__ method.)

I thought about changing the binding-generation code, but that seems
difficult. So I settled for placing the enum inside
HTMLFormElement.webidl, as that seems like a "neutral" location. We
could equally settle for putting it under HTMLTextAreaElement or
HTMLInputElement, it probably doesn't really matter.

The setRangeText algorithm set the "dirty value flag" on the
input/textarea. I made some clean-ups related to this:

1. HTMLTextAreaElement called its dirty value flag "value_changed"; I
   changed this to "value_dirty" to be consistent with the spec.

2. HTMLInputElement had a "value_changed" field and also a "value_dirty"
   field, which were each used in slightly different places (and
   sometimes in both places). I consolidated these into a single
   "value_dirty" field, which was necessary in order to make some of the
   tests pass.

TextControl::set_dom_range_text replaces part of the existing textinput
content with the replacement string (steps 9-10 of the algorithm). My
implementation changes the textinput's selection and then replaces the
selection. A downside of this approach is that we lose the original
selection state from before the call to setRangeText. Therefore, we have
to save the state into the original_selection_state variable so that we
can later pass it into TextControl::set_selection_range. This allows
TextControl::set_selection_range to correctly decide whether or not to
fire the select event.

An alternative approach would be to implement a method on TextInput
which allows a subtring of the content to be mutated, without touching
the current selection state. However, any such method would potentially
put the TextInput into an inconsistent state where the edit_point and/or
selection_origin is a TextPoint which doesn't exist in the content. It
would be up to the caller to subsequently make sure that the TextInput
gets put back into a valid state (which would actually happen, when
TextControl::set_selection_range is called).

I think TextInput's public API should not make it possible to put it
into an invalid state, as that would be a potential source of bugs.
That's why I didn't take this approach. (TextInput's public API does
currently make it possible to create an invalid state, but I'd like to
submit a follow-up patch to lock this down.)
2018-01-26 20:12:33 +01:00
Jon Leighton
0148e9705b Support the select() method on input/textarea
Issue #19171
2018-01-26 19:50:45 +01:00
Jon Leighton
71a013dd50 Handle cases where selection API doesn't apply
The selection API only applies to certain <input> types:

https://html.spec.whatwg.org/multipage/#do-not-apply

This commit ensures that we handle that correctly.

Some notes:

1. TextControl::set_dom_selection_direction now calls
   set_selection_range(), which means that setting selectionDirection will
   now fire a selection event, as it should per the spec.

2. There is a test for the firing of the select event in
   tests/wpt/web-platform-tests/html/semantics/forms/textfieldselection/select-event.html,
   however the test did not run due to this syntax error:

   (pid:26017) "ERROR:script::dom::bindings::error: Error at http://web-platform.test:8000/html/semantics/forms/textfieldselection/select-event.html:50:11 missing = in const declaration"

   This happens due to the us of the "for (const foo of ...)" construct.
   Per https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/for...of
   this should actually work, so it's somewhat unsatisfying to have to
   change the test.

4. If an <input>'s type is unset, it defaults to a text, and the
   selection API applies. Also, if an <input>'s type is set to an
   invalid value, it defaults to a text too. I've expanded the tests
   to account for this second case.
2017-12-08 21:07:05 +01:00
Connor Brewster
2460997ee1 Add CEReactions where needed 2017-07-18 12:22:20 -06:00
Connor Brewster
d951dee640 Add HTMLConstructor attributes where needed 2017-06-15 21:16:57 -06:00
Jean SIMARD
2aed5b9781
partial-fix #12415: incorrect exposure of Window,Worker in webidl
* HTMLTemplateElement.webidl
* HTMLTextAreaElement.webidl
* HTMLTimeElement.webidl
* HTMLTitleElement.webidl
* HTMLTrackElement.webidl
* HTMLUnknownElement.webidl
* HTMLUListElement.webidl
* HTMLVideoElement.webidl
2016-07-22 17:10:36 -04:00
Ms2ger
ed743bb50c Explicitly expose everything everywhere. 2016-07-12 13:06:48 +02:00
edunham
7ae63b1213 Remove modelines everywhere but tests/wpt 2016-04-20 10:49:09 -07:00
Alberto Corona
5e863f2eb8
Implement HTMLTextArea.setSelectionRange 2016-04-17 17:27:26 +02:00
Corey Farwell
9df375195e Implement 'labels' attribute on 'labelable elements' 2015-11-01 09:50:14 -05:00
Corey Farwell
9b68d715de Explicitly place '/' before fragment for multipage spec links
This prevents us from 301 redirecting, which could cause the fragment to
get lost
2015-10-10 12:07:10 -04:00
Corey Farwell
85f2b6fc5b Replace usage of old-style WHATWG spec links 2015-10-10 11:55:09 -04:00
Philipp Hartwig
8d67914c7f Add form getters for additional elements; update test expectations
This adds form getters for fieldset, label, object, output, select and
textarea elements.
2015-09-27 19:08:53 +02:00
Corey Farwell
9415c92a5c Clean up whitespace, long lines for WebIDLs 2015-07-26 22:12:10 +07:00
Anthony Ramine
fedad2af1f Improve support of limited unsigned long attributes 2015-05-06 20:18:08 +02:00
Corey Farwell
5eaa922045 Update WHATWG links to use HTTPS
Extracted this out of #5649

This commit was created with the following commands:

```
find . -iname "*.webidl" -type f -print0 | xargs -0 sed -i '' 's/http:\(.*\)whatwg.org/https:\1whatwg.org/g'
```

```
find . -iname "*.rs" -type f -print0 | xargs -0 sed -i '' 's/http:\(.*\)whatwg.org/https:\1whatwg.org/g'
```
2015-04-13 21:34:27 -07:00
Matthew Rasmus
7e0c39a82d Implements FormControl for HTMLTextAreaElement 2014-12-16 11:34:04 -08:00
Matthew Rasmus
29241699fd Implements multi line text input for TextArea 2014-12-05 12:21:31 -08:00
Matthew Rasmus
fd65b5f438 Implements some HTMLTextAreaElement attributes
These attributes all reflect their own related content values, with the
exception of defaultValue, which acts as an alias for its IDL
textContent attribute.

Many of these do have default values and constraints which are currently unimplemented.
2014-12-05 12:21:31 -08:00
Manish Goregaokar
8a2c746e61 Add type IDL attr for submittable elements 2014-10-11 09:48:15 +05:30
Jack Moffitt
c6ab60dbfc Cargoify servo 2014-09-08 20:21:42 -06:00
Renamed from src/components/script/dom/webidls/HTMLTextAreaElement.webidl (Browse further)