Skip to content
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

Fix some char/byte bugs in textinput #10350

Merged
merged 4 commits into from Apr 2, 2016
Merged

Conversation

mbrubeck
Copy link
Contributor

@mbrubeck mbrubeck commented Apr 1, 2016

Fixes #9569. r? @SimonSapin or @Ms2ger


This change is Reviewable

@highfive
Copy link

highfive commented Apr 1, 2016

Heads up! This PR modifies the following files:

@highfive highfive added the S-awaiting-review There is new code that needs to be reviewed. label Apr 1, 2016
@SimonSapin
Copy link
Member

The HTML spec for the maxlength attribute links to code-unit length. maxlen is counted neither in bytes nor in char/code points but in UTF-16 code units. So (c: char) <= '\u{FFFF}' count as 1 while other chars count as 2 each.

@mbrubeck
Copy link
Contributor Author

mbrubeck commented Apr 2, 2016

maxlen is counted neither in bytes nor in char/code points but in UTF-16 code units.

Ugh.

@mbrubeck
Copy link
Contributor Author

mbrubeck commented Apr 2, 2016

Fixed to use UTF-16 code units for max_length.

@SimonSapin
Copy link
Member

Reviewed 1 of 2 files at r5, 1 of 1 files at r6.
Review status: all files reviewed at latest revision, 4 unresolved discussions.


components/script/textinput.rs, line 214 [r6] (raw file):
Nit: this would do slightly less work: slice.chars().map(char::len_utf16).sum()


components/script/textinput.rs, line 333 [r6] (raw file):
With col as it is defined above, isn’t this line a no-op? I read it as "Set .index to the UTF-8 len corresponding to the number of code points in the first .index UTF-8 bytes of the line", which simplifies to "Set .index to itself".


components/script/textinput.rs, line 533 [r6] (raw file):
Nit: this would do slightly less work: l.chars().map(char::len_utf16).sum()


tests/unit/script/textinput.rs, line 138 [r6] (raw file):
Maybe add a test case where maxlen falls in the "middle" of a non-BMP code point?


Comments from Reviewable

@mbrubeck
Copy link
Contributor Author

mbrubeck commented Apr 2, 2016

Review status: all files reviewed at latest revision, 4 unresolved discussions.


components/script/textinput.rs, line 214 [r6] (raw file):
Done.


components/script/textinput.rs, line 333 [r6] (raw file):
No, because self.edit_point.line has changed. We find the column on the original line, then find the corresponding column on the new line.


components/script/textinput.rs, line 533 [r6] (raw file):
Done.


tests/unit/script/textinput.rs, line 138 [r6] (raw file):
Done.


Comments from Reviewable

@SimonSapin
Copy link
Member

@bors-servo r+


Reviewed 3 of 3 files at r7.
Review status: all files reviewed at latest revision, all discussions resolved.


Comments from Reviewable

@bors-servo
Copy link
Contributor

📌 Commit deca979 has been approved by SimonSapin

@highfive highfive added S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. and removed S-awaiting-review There is new code that needs to be reviewed. labels Apr 2, 2016
@bors-servo
Copy link
Contributor

⌛ Testing commit deca979 with merge c0bfcc5...

bors-servo pushed a commit that referenced this pull request Apr 2, 2016
Fix some char/byte bugs in textinput

Fixes #9569. r? @SimonSapin or @Ms2ger

<!-- 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/10350)
<!-- Reviewable:end -->
@bors-servo
Copy link
Contributor

☀️ Test successful - android, arm32, linux-dev, linux-rel, mac-dev-unit, mac-rel-css, mac-rel-wpt, status-appveyor

@bors-servo bors-servo merged commit deca979 into servo:master Apr 2, 2016
@highfive highfive removed the S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. label Apr 2, 2016
@mbrubeck mbrubeck deleted the selection-chars branch May 17, 2016 22:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants