Commit graph

83 commits

Author SHA1 Message Date
bors-servo
e45546edf0 Auto merge of #15822 - charlesvdv:unicode-panic, r=emilio
Correct unicode handling for text input

<!-- Please describe your changes on the following line: -->
Allow proprer handling of unicode sequence in text input.

---
<!-- 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 #15819

<!-- Either: -->
- [ ] There are tests for these changes OR
- [ ] These changes do not require tests because _____

<!-- 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/15822)
<!-- Reviewable:end -->
2017-04-16 15:08:59 -05:00
Clement Miao
ea3c840983 new keyboard shortcuts inside text input 2017-04-07 01:05:13 -07:00
Charles Vandevoorde
26e6c09776 Correct unicode handling for text input 2017-03-05 13:58:33 +01:00
Jean-Marie Comets
319153640c Return KeyReaction::Nothing for a Tab event
Hitting the tab key in an html text input shouldn't submit the form, and
for any text input, the tab key should have a particular action
associated, not the default action. This cleans up #12701.
2016-11-12 15:49:00 +01:00
Taryn Hill
2cb5adf6c6 Implement minlength for text inputs 2016-09-21 07:54:39 -05:00
Connor Brewster
8e5d5a45ef Take selection direction into account when setting selection 2016-07-06 16:14:32 -06:00
Josh Matthews
6496d73210 Make textinput handle actual key values. Don't restrict character values to a single byte. 2016-07-06 00:10:24 -04:00
Josh Matthews
04ce86c08c Associate logical and physical keypresses together to support non-QWERTY keyboards. 2016-07-05 18:06:42 -04:00
Alan Jeffrey
7ed8408f12 Added checks that selection is valid, and fix set_selection_range. 2016-06-29 07:24:19 -05:00
Anthony Ramine
ff899dc703 Implement :placeholder-shown (fixes #10561) 2016-06-03 14:45:14 +02:00
Anthony Ramine
cdc7bca944 Move DOMString back to script
This entirely removes the 'non-geckolib' feature of the util crate.
2016-05-24 10:54:57 +02:00
Matt Brubeck
c4872d9544 Replace range::Range with std::ops::Range in script 2016-04-28 14:54:07 -07:00
Alberto Corona
5e863f2eb8
Implement HTMLTextArea.setSelectionRange 2016-04-17 17:27:26 +02:00
Matt Brubeck
deca979967 TextInput::max_length should be in code units, not bytes 2016-04-02 07:33:53 -07:00
Matt Brubeck
29fb3f1150 Find the correct column index in adjust_vertical 2016-04-01 14:00:50 -07:00
Matt Brubeck
e17ed2e6b0 Add/correct documentation comments in textinput 2016-04-01 14:00:49 -07:00
Matt Brubeck
d7e6f8b0f1 Use correct byte indices in replace_selection 2016-04-01 13:54:02 -07:00
bors-servo
db95de6e58 Auto merge of #10182 - mbrubeck:delete_char, r=jdm
Fix delete_char when selection range is empty

An empty selection range should be treated the same as no selection.  Fixes browserhtml/browserhtml#930.

r? @jdm

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="35" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/10182)
<!-- Reviewable:end -->
2016-03-28 20:43:11 +05:30
Matt Brubeck
db2c1841cb Fix delete_char when selection range is empty
An empty selection range should be treated the same as no selection.
Fixes browserhtml/browserhtml#930.
2016-03-25 08:39:53 -07:00
Matt Brubeck
6171000875 Highlight selected text in input fields
Fixes #9993.  This does not yet allow stylesheets to set the selection colors;
instead it uses a hard-coded orange background and white foreground.
2016-03-24 18:33:26 -07:00
Saurav Sachidanand
0b593759df Resets selection in textinput when its content is changed.
Adds a wpt test as well.
2016-03-16 22:20:22 +05:30
Saurav Sachidanand
a3d77790a6 Implement input.setSelectionRange 2016-03-10 19:54:21 +05:30
Anthony Ramine
cb5cd8d881 Say farewell to in-tree HeapSizeOf 2016-02-04 22:03:32 +01:00
Tetsuharu OHZEKI
e8c12c1c6d Fix warnings: Use Vec.extend_from_slice instead of Vec.push_all 2015-12-10 16:49:29 -05:00
Sam Gibson
d26c555e2a Adds support for input element's maxlength attr
servo/servo#7320
servo/servo#7004
2015-12-03 14:00:51 +11:00
Alan Jeffrey
5db67b5981 Added in-place mutation to DOMString.
The methods which are currently implemented are the ones on String that are currently being used:
string.push_str(...), string.clear() and string.extend(...). We may want to revisit this API.
2015-11-12 17:53:01 -06:00
Alan Jeffrey
84bde75b42 Replaced DOMString constructor by conversion functions.
Replaced DOMString(...) by DOMString::from(...).
Replaced ....0 by String::from(...).
Removed any uses of .to_owner() in DOMString::from("...").
2015-11-12 17:52:59 -06:00
Ms2ger
6b75078503 Make DOMString a newtype around String, rather than a typedef.
This should make it somewhat easier to experiment with alternative
representations in the future. To reduce churn, this commit leaves the String
field public, though.

Also, this will allow us to use the default String type to represent the IDL
USVString type, which explicitly forbids unpaired surrogates, ans as such is
a better match to the Rust String type.
2015-11-04 12:09:11 +01:00
Ms2ger
e6aa976462 Use DOMString::new() somewhat consistently. 2015-11-04 12:09:10 +01:00
Florian Merz
80e8a674e2 display input caret for textarea. fixes #7758 2015-10-21 22:38:23 +02:00
Ravi Shankar
889eec364b sorted the extern crate, mod & use declarations 2015-09-24 02:12:45 +05:30
Brandon Fairchild
de3547e401 Fix reported test-tidy errors for unmerged import blocks
This merges import blocks that were reported by tidy as unmerged.
2015-09-19 12:50:14 -04:00
Patrick Walton
34d9a6091b script: Ask layout to redraw the selection whenever the user moves the
caret in an input element.
2015-09-17 13:31:11 +02:00
Brandon Fairchild
d61a6e2161 Fix reported test-tidy errors
This fixes lines that were reported to have missing
space after a comma.
2015-09-01 16:30:42 -04:00
erneyja
17663315dd make test-tidy check that = have space after them 2015-09-01 07:18:19 -04:00
Simon Sapin
95a252a650 Refactor script::textinput to count UTF-8 bytes rather than code points. 2015-08-28 11:57:40 +02:00
Anthony Ramine
c831c2c0a5 Remove helper traits
Now that JSRef<T> is gone, there is no need to have helper traits.

On components/script/*.rs:

    # Remove imports.
    /^ *use dom::[a-z]+::\{.*Helpers/ {
        s/\{(Raw[^L]|[^L][^a])[a-zA-Z]+Helpers, /\{/
        s/, (Raw[^L]|[^L][^a])[a-zA-Z]+Helpers([,}])/\2/g
        s/\{([a-zA-Z]+)\}/\1/
        /\{\}/d
        s/::self;$/;/
    }
    /^ *use dom::[a-z]+::\{?(Raw[^L]|[^L][^a])[a-zA-Z]+Helpers\}?;$/d

On components/script/dom/*.rs:

    # Ignore layout things.
    /^(pub )?(impl|trait).*Layout.* \{/,/^}$/ { P; D; }

    # Delete helpers traits.
    /^(pub )?trait ([^L][^ ]|L[^a])[^ ]+Helpers(<'a>)? \{$/,/^\}$/D

    # Patch private helpers.
    /^impl.*Private.*Helpers/,/^\}$/ {
        s/^impl<'a> Private([^L][^ ]|L[^a])[^ ]+Helpers(<'a>)? for &'a ([^ ]+) \{$/impl \3 {/
        /^ *(unsafe )?fn .*\(self.*[<&]'a/ {
            s/&'a /\&/g
            s/<'a, /</g
        }
        /^ *(unsafe )?fn /s/\(self([,)])/\(\&self\1/
    }

    # Patch public helpers.
    /^impl.*Helpers/,/^\}$/ {
        s/^impl(<'a>)? ([^L][^ ]|L[^a])[^ ]+Helpers(<'a>)? for (&'a )?([^ ]+) \{$/impl \5 {/
        /^ *(unsafe )?fn .*\(self.*[<&]'a/ {
            s/&'a /\&/g
            s/<'a, /</g
        }
        /^ *(unsafe )?fn .*\(&?self[,)]/s/(unsafe )?fn/pub &/
        /^ *pub (unsafe )?fn /s/\(self([,)])/\(\&self\1/
    }

The few error cases were then fixed by hand.
2015-08-27 16:59:02 +02:00
Johann Tuffe
ec07178b6f sort all uses 2015-08-20 20:47:12 +08:00
Manish Goregaokar
ac1b7a3896 Cleanup textinput, timers 2015-08-18 18:37:12 +05:30
Bogdan Cuza
45145108da Measure heap memory usage for more types. Fixes #6951 2015-08-13 21:44:41 +03:00
Jack Moffitt
dae1a398a4 Use local slice_chars
StrExt::slice_chars is deprecated and will be removed in Rust. This
lifts the implementation from Rust libstd and puts it in util::str.

This fixes a bunch of deprecation warnings in Servo.
2015-07-31 12:23:13 -06:00
Avi Weinstock
9ba18850dd Update rust-clipboard to the version with working set_contents. 2015-07-29 12:19:39 -04:00
Avi Weinstock
f86252a60b Add set_clipboard_context function and relevant plumbing. Use Option more consistantly (less unwraps) in textinput's selection handling. 2015-07-29 12:19:37 -04:00
David Winslow
4cf46bff2d Refactor #[jstraceable] to #[derive(JSTraceable)]
fixes #6524
2015-07-01 18:27:06 -04:00
Michael Wu
675267b782 Upgrade to SM 39 2015-06-19 18:42:48 -04:00
Avi Weinstock
b1486720e9 Remove some unnecessary allocations in text input handling. 2015-06-11 12:50:40 -04:00
Corey Farwell
435e551753 Remove get_ prefix on getters
Part of #6224

I certainly didn't remove all of them; I avoided `unsafe` areas and also `components/script`
2015-06-02 08:54:44 -04:00
Avi Weinstock
0587717944 Change the dispatch in TextInput::handle_keydown_aux match on enum values instead of strings. 2015-05-06 11:46:21 -04:00
Avi Weinstock
b742eeca05 Made the clipboard-related functionality in TextInput more testable. Added test_clipboard_paste to the "test-unit" suite. 2015-05-06 11:46:18 -04:00
Simon Sapin
ef8edd4e87 Upgrade to rustc 551a74dddd84cf01440ee84148ebd18bc68bd7c8. 2015-05-05 10:07:34 -04:00