Commit graph

18143 commits

Author SHA1 Message Date
Emilio Cobos Álvarez
b7238c43cd
style: Properly compare the value of the alignment flags.
What this did before happens to be ok for these constants, but it's not great,
because it depends on their particular value.
2018-01-29 10:45:13 +01:00
Emilio Cobos Álvarez
8d7a3f4f3d
style: Update align-self / justify-self to the spec too.
MozReview-Commit-ID: 8JKF5ucCbYm
2018-01-29 10:37:17 +01:00
Emilio Cobos Álvarez
4c773a1424
style: Fix the position of the <overflow-position> in content distribution shorthands, and remove fallback.
MozReview-Commit-ID: 4rPICzZ5gMn
2018-01-29 10:37:17 +01:00
Emilio Cobos Álvarez
fd47a93b9c
style: Restrict <baseline-position> and <content-position> depending on the axis in content distribution properties.
This fixes https://bugzilla.mozilla.org/show_bug.cgi?id=1430817, and updates us
to the current version of the css-align spec.

MozReview-Commit-ID: LtBcdqYJeK
2018-01-29 10:37:16 +01:00
Emilio Cobos Álvarez
7497720081
style: Make content distribution parsing know the axis it's parsed for.
MozReview-Commit-ID: LMPXVtKU1mq
2018-01-29 10:37:16 +01:00
Emilio Cobos Álvarez
0aee33081f
style: Serialize <overflow-position> before other align bits.
Otherwise the serialisation wouldn't roundtrip with the new syntax, which fixes
the position of <overflow-position>.

Also make Servo and Gecko agree on whether to serialize "unsafe".

Bug: 1430817
MozReview-Commit-ID: L3GSMk5pZ3F
2018-01-29 10:37:15 +01:00
CYBAI
37802dfd19 script: Move style as Element method 2018-01-28 23:47:39 +08:00
bors-servo
2a46067587 Auto merge of #19881 - jonleighton:issue-19811, r=emilio
Add layout RPC query for getting an element's style

This enables us to implement Element::has_css_layout_box() in a more
direct way, and also enables us to remove some of the existing more
specific queries.

Fixes #19811.

r? @emilio

<!-- 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/19881)
<!-- Reviewable:end -->
2018-01-28 05:52:56 -06:00
Jon Leighton
fe583fc5d0 Add layout RPC query for getting an element's style
This enables us to implement Element::has_css_layout_box() in a more
direct way, and also enables us to remove some of the existing more
specific queries.

Fixes #19811.
2018-01-28 10:59:45 +01:00
Emilio Cobos Álvarez
2d395a48aa
style: Update bindings.
Signed-off-by: Emilio Cobos Álvarez <emilio@crisal.io>
2018-01-27 03:18:32 +01:00
Emilio Cobos Álvarez
657d8b8e31
style: Look at the snapshots when invalidating due to stylesheet changes.
Otherwise removal of stylesheets may get out of sync with other DOM changes, and
we may fail to invalidate the style of the affected elements.

Bug: 1432850
Reviewed-by: bz
MozReview-Commit-ID: DrMTgLzQcnk
2018-01-27 02:34:27 +01:00
bors-servo
c2dfece49f Auto merge of #19544 - jonleighton:issue-19171-5, r=nox
Text selection API conformance

This is my next batch of changes for issue #19171. All the tests in tests/wpt/metadata/html/semantics/forms/textfieldselection/ are now passing (and also some tests outside of there).

I've made detailed notes about the changes in each commit message.

r? @KiChjang

<!-- 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/19544)
<!-- Reviewable:end -->
2018-01-26 13:58:01 -06:00
Jon Leighton
a8b64aca2a Steps 7-9 of the input type change algorithm
Spec: https://html.spec.whatwg.org/multipage/input.html#input-type-change

In short, this resets the selection to the start of the field when the
type has changed from one which doesn't support the selection API to one
that does.

I couldn't see an existing WPT test covering this.
2018-01-26 20:12:38 +01: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
e34f7c58c9 Don't fire select event when selection hasn't changed 2018-01-26 19:50:53 +01:00
Jon Leighton
648bfbeb02 Fix clearing the selection when value is changed
The implementation of adjust_horizontal_to_limit() is written with UI in
mind. As such, when there's a selection and we "adjust horizontal", the
selection will be cleared and the cursor will and up at the start/end of
the previous selection. This is what happens when you have a selection
and you press an arrow key on your keyboard, but it isn't the behaviour
we want when programmatically changing the value.

Instead, we need to first clear the selection, and then move the cursor
to the end. (We also need to reset the selection direction when clearing
the selection.)
2018-01-26 19:50:52 +01:00
Jon Leighton
02883a6f54 Fix selection{Start,End} when selectionDirection is "backward"
Per the spec, selectionStart and selectionEnd should return the same
values regardless of the selectionDirection. (That is, selectionStart is
always less than or equal to selectionEnd; the direction then implies
which of selectionStart or selectionEnd is the cursor position.)

There was no explicit WPT test for this, so I added one.

This bug was initially quite hard to wrap my head around, and I think
part of the problem is the code in TextInput. Therefore, in the process
of fixing it I have refactored the implementation of TextInput:

* Rename selection_begin to selection_origin. This value doesn't
  necessarily correspond directly to the selectionStart DOM value - in
  the case of a backward selection, it corresponds to selectionEnd.
  I feel that "origin" doesn't imply a specific ordering as strongly as
  "begin" (or "start" for that matter) does.

* In various other cases where "begin" is used as a synonym for "start",
  just use "start" for consistency.

* Implement selection_start() and selection_end() methods (and their
  _offset() variants) which directly correspond to their DOM
  equivalents.

* Rename other related methods to make them less wordy and more
  consistent / intention-revealing.

* Add assertions to assert_ok_selection() to ensure that our assumptions
  about the ordering of selection_origin and edit_point are met. This
  then revealed a bug in adjust_selection_for_horizontal_change() where
  the value of selection_direction was not maintained correctly (causing
  a unit test failure when the new assertion failed).
2018-01-26 19:50:50 +01:00
Jon Leighton
0148e9705b Support the select() method on input/textarea
Issue #19171
2018-01-26 19:50:45 +01:00
Anthony Ramine
31a14082eb Make JSTraceable for DomRefCell<T> panic if cell is mutably borrowed (see #19871) 2018-01-26 10:12:40 +01:00
bors-servo
c9ba16f9fb Auto merge of #19868 - CYBAI:specific-assertion, r=emilio
Use specific assertions

Similar to #19865
r? jdm

Note: Should I squash all the commits into one commit?

---
- [x] `./mach build -d` does not report any errors
- [x] `./mach test-tidy` does not report any errors
- [x] These changes do not require tests because it should not break anything

<!-- 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/19868)
<!-- Reviewable:end -->
2018-01-25 18:06:33 -06:00
bors-servo
fc3b178931 Auto merge of #19865 - servo:jdm-patch-6, r=KiChjang
Use more specific assertions for http tests.

<!-- 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/19865)
<!-- Reviewable:end -->
2018-01-25 17:11:42 -06:00
bors-servo
e9ab91d257 Auto merge of #19864 - nox:callbacks, r=Manishearth
Make some callback-related code unsafe

<!-- 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/19864)
<!-- Reviewable:end -->
2018-01-25 16:21:10 -06:00
bors-servo
e035f5a17f Auto merge of #19848 - glennw:update-wr-tcrt, r=jdm
Update WR (new capture API, render target cache optimization)

<!-- 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/19848)
<!-- Reviewable:end -->
2018-01-25 13:48:24 -06:00
CYBAI
6e4e318b24 Use specific negative assertion for ServoArc 2018-01-26 02:24:06 +08:00
CYBAI
5104d2947f Use specific negative assertion for DOM XMLHttpRequest 2018-01-26 02:23:49 +08:00
CYBAI
2a17230623 Use specific negative assertion for DOM Window Proxy 2018-01-26 02:23:39 +08:00
CYBAI
f372bc0f40 Use specific negative assertion for DOM HTMLCollection 2018-01-26 02:11:02 +08:00
CYBAI
1ba2b67b00 Use specific negative assertion for DOM globalscope 2018-01-26 02:08:11 +08:00
CYBAI
5475059df7 Use specific negative assertion for DOM document 2018-01-26 02:07:47 +08:00
CYBAI
1f9ce9e5d7 Use specific negative assertion for DOM bindings utils 2018-01-26 02:07:27 +08:00
CYBAI
86b876c52e Use specific negative assertion for unit tests of net trait pub_domain 2018-01-26 01:55:39 +08:00
CYBAI
baccc4eda2 Use specific negative assertion for layout floats 2018-01-26 01:55:24 +08:00
CYBAI
73bc7a81e9 Use specific negative assertion for hashglobe hash set 2018-01-26 01:55:12 +08:00
CYBAI
d4d32c9962 Use specific negative assertion for hashglobe hash map 2018-01-26 01:54:55 +08:00
CYBAI
4765b7b248 Use specific negative assertion for gfx platform macos font 2018-01-26 01:46:39 +08:00
CYBAI
8fedc3a188 Use specific negative assertion for gfx platform freetype font_list 2018-01-26 01:40:39 +08:00
CYBAI
08f9123065 Use specific negative assertion for config opts 2018-01-26 01:39:54 +08:00
CYBAI
0c6ada833b Use specific assertion for net hsts tests 2018-01-26 01:30:32 +08:00
CYBAI
7f5a1538d3 Use specific assertion for net fetch methods 2018-01-26 01:30:31 +08:00
CYBAI
775d6abb34 Use specific assertion for style logical geometry 2018-01-26 01:30:31 +08:00
CYBAI
985ffa3342 Use specific assertion for webdriver server 2018-01-26 01:19:00 +08:00
CYBAI
e4799cc997 Use specific assertion for specified text 2018-01-26 01:18:59 +08:00
CYBAI
f81ba5e9dd Use specific assertion for ServoArc 2018-01-26 01:18:59 +08:00
CYBAI
40e40e0f8b Use specific assertion for DOM XMLHttpRequest 2018-01-26 01:18:58 +08:00
CYBAI
15a1faff03 Use specific assertion for DOM webgl shader 2018-01-26 01:18:58 +08:00
CYBAI
9a358014f9 Use specific assertion for DOM servoparser 2018-01-26 01:18:57 +08:00
CYBAI
0e6f446a61 Use specific assertion for DOM servoparser async_html 2018-01-26 01:18:56 +08:00
CYBAI
5486335708 Use specific assertion for DOM create 2018-01-26 01:18:56 +08:00
CYBAI
9ee27d62ae Use specific assertion for DOM binding refcounted 2018-01-26 01:18:55 +08:00
CYBAI
1c31370a08 Use specific assertion for DOM binding interface 2018-01-26 01:18:55 +08:00