Commit graph

56 commits

Author SHA1 Message Date
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
Ms2ger
903305416a Implement Clone for Copy types. 2015-04-28 23:31:10 +02:00
Ms2ger
a862479ca8 Remove as_slice() calls from script. 2015-04-26 10:52:55 +02:00
Avi Weinstock
cf6aef5d51 Make the channel argument to TextInput::new be optional, to support the signature expected by the unit tests. 2015-04-21 15:18:23 -04:00
Avi Weinstock
503cc9e6d6 Moved clipboard integration from textinput to constellation, to facilitate sandboxing. 2015-04-21 09:31:20 -04:00
Avi Weinstock
ba4c455438 Implement X11 clipboard integration (Issue #5376). 2015-04-21 08:36:15 -04:00
Simon Sapin
dc431c9bdb Move script crate unit tests into the unit_tests crate. 2015-04-08 01:07:53 +02:00
Ms2ger
c2e81be8a5 Stop using int/uint in script. 2015-04-03 20:47:53 +02:00
Corey Farwell
d838fcce30 Remove some unnecessary uses of as_slice
For the majority of these cases, `as_slice` can be removed due to
`Deref`. In particular, `Deref` for:

* `String` -> `str`
* `Atom` -> `str`

The latter of those two requires, a bump of the locked `string-cache`
library
2015-03-29 14:42:19 -04:00
Josh Matthews
837be27347 Use platform-sized integers for textinput.rs 2015-02-20 16:12:58 -05:00
Ms2ger
e921ce859e Fix some warnings in script. 2015-02-12 20:05:14 +01:00
Ms2ger
505159a464 Import the util crate as util rather than servo_util.
This used to conflict with the util crate from the standard library, which
has long since been removed.

The import in layout has not been changed because of a conflict with the
util mod there.
2015-01-29 12:16:41 +01:00
Josh Matthews
95fc29fa0d Update rustc to 00b112c45a604fa6f4b59af2a40c9deeadfdb7c6/rustc-1.0.0-dev. 2015-01-28 10:16:49 +10:00
Ms2ger
024571dfa3 Use chars().count() rather than char_len().
The latter is obsolete in current Rust.
2015-01-22 14:49:26 +01:00
Ms2ger
01ed338746 Move to to_owned rather than into_string.
into_string has been removed from Rust.
2015-01-20 14:49:07 +01:00
Peter Reid
2963caf708 Fix TextInput's edit point after set_content
Previously, when the edit point was being clamped leftward by a shortened
line, it would be placed one one character too far to the left instead of
at the very end.
2015-01-17 12:41:18 -05:00
donaldpipowitch
d0cc280119 added unit tests for TextInput - fixes #4352 2015-01-16 12:14:20 +01:00
Matt McCoy
64dda93242 Fixes #4573 Replaces the boolean argument of TextInput::adjust[horizontal|vertical] with enum to self document the code 2015-01-08 18:13:52 -05:00
Ms2ger
16c7060bc8 Update rustc to revision 2cfb5acb5a2751c759627377e602bac4f88f2d19. 2015-01-08 09:58:46 -05:00
Manish Goregaokar
e9d1740e19 script: to_string() -> into_string() 2014-12-27 14:48:36 +01:00
James Moughan
0a6ebfa3ee Allow selection of all text in a text control using the ctrl-a/cmd-a shortcut.
Fixes #4411.
2014-12-24 00:14:17 +00:00
Emanuel Rylke
c732a779eb On left/right keydown place edit_point correctly when there is a selection in TextInput
Fixes #4447
2014-12-21 14:31:15 +01:00
Ms2ger
466faac2a5 Update rustc to revision 3dcd2157403163789aaf21a9ab3c4d30a7c6494d. 2014-12-17 15:19:45 -05:00
Matthew Rasmus
f686943eb4 Fix crash in textinput 2014-12-16 11:06:55 -08:00
Rohan Prinja
0c851d9a0c some fixes for multiple-mode textinput 2014-12-11 23:40:57 +05:30
Emanuel Rylke
29b672ded4 Implement selection ranges and deletion of \n for TextInput. 2014-12-08 17:29:38 +01:00
Emanuel Rylke
b5e7cba598 Fix bug of TextInput.adjust_horizontal causing stack overflow or wraparound
When the edit_point is in the first position of a multiline TextInput
adjust_horizontal(-1) moves the edit_point to the end of the first line.
When the first line is empty this causes a stack overflow. When the edit_point
is in the last position adjust_horizontal(1) causes a stack overflow.
2014-12-06 20:59:04 +01:00
Emanuel Rylke
f99c0e2c15 Implement Page(Up|Down) functionality for TextInput. 2014-12-06 15:34:37 +01:00