Commit graph

689 commits

Author SHA1 Message Date
Patrick Walton
4e7ac19380 script: Use a timer when rAF is used for non-animation purposes
After this patch, when the page calls `requestAnimationFrame()` too many
times in the row without actually mutating the DOM, further calls to
`rAF` will actually perform the moral equivalent of `setTimeout(16)`.
This saves a lot of CPU time compared to actually waiting for the
vertical blanking interval, because waiting for that requires us to draw
the page.

Reduces CPU usage drastically on nytimes.com, which has a perpetual
`requestAnimationFrame()` loop that checks whether ads are in view.
2017-03-03 23:25:29 +01:00
Fernando Jiménez Moreno
31d833f32c s/nodes_from_point/nodes_from_point_response and change test from reftest to regular test checking only the fixed crash 2017-03-02 16:59:04 +01:00
Fernando Jiménez Moreno
7426d902a3 Trigger reflow on document.elementsFromPoint 2017-03-02 10:44:38 +01:00
bors-servo
a204c4176d Auto merge of #15715 - nox:custom-derive, r=SimonSapin
Make #[dom_struct] a proc_macro attribute

The rustup is needed for https://github.com/rust-lang/rust/pull/40039.

<!-- 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/15715)
<!-- Reviewable:end -->
2017-02-24 05:56:30 -08:00
Anthony Ramine
b2adcfb40b Test that StorageEvent's URL is empty from document.createEvent 2017-02-24 12:22:10 +01:00
Anthony Ramine
31e9d81c0f Make #[dom_struct] a proc_macro attribute 2017-02-24 01:50:51 +01:00
Glenn Watson
30ff2f8f0d Introduce CSSPixel as a replacement for ViewportPx and PagePx. 2017-02-24 06:58:10 +10:00
Connor Brewster
bfd7b950ad Add ImmutableOrigin to allow for serializing origins 2017-02-22 11:11:59 -06:00
Josh Matthews
103fa0246d Update document constructor spec link. 2017-02-17 15:51:46 -05:00
bors-servo
8926db302a Auto merge of #15359 - freeatnet:15332-macroed-event-handlers-check-for-window, r=KiChjang
Event handlers forwarded to a window check for window presence

<!-- Please describe your changes on the following line: -->
This change adds a check for the presence of a window in event handlers of `body` and `frameset` that are forwarded to the window.

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

<!-- Either: -->
- [x] 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. -->

I'm new to both Servo and Rust — so any suggestions for improvement are very welcome.

<!-- 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/15359)
<!-- Reviewable:end -->
2017-02-03 13:10:50 -08:00
Arseniy Ivanov
d23b34e243 Check for the presence of a window when working with event handlers forwarded to the window 2017-02-03 13:23:34 -05:00
Anthony Ramine
ac254046e4 Implement document.open and document.close (fixes #14591) 2017-02-03 16:50:12 +01:00
Emilio Cobos Álvarez
cb304fd42c
script: insert the restyle attribute restyle hint when a style attribute is modified. 2017-01-30 19:24:42 +01:00
Emilio Cobos Álvarez
d37e6f8c66
script: Propagate the attribute into the document's element_attr_will_change method. 2017-01-30 19:24:42 +01:00
Emilio Cobos Álvarez
7a9cdbb857
style: Add a style attribute restyle hint. 2017-01-30 19:24:41 +01:00
Alan Jeffrey
403499a9d5 Allow windows to share browsing contexts. 2017-01-28 21:57:03 -06:00
bors-servo
b5c94bad37 Auto merge of #14971 - asajeffrey:script-track-active-documents, r=cbrewster
Constellation informs script about documents becoming inactive, active or fully active.

<!-- Please describe your changes on the following line: -->

This PR replaces the current freeze/thaw mechanism by messages from the constellation to script informing it about when documents become inactive, active or fully active.

This means we can now implement |Document::is_active()| which is used in |document.write|.

This PR also changes how timers work: previously they were initialized running, and were then frozen/thawed. This means there was a transitory period when timers were running even though the document was not fully active. With this PR, timers are initially suspended, and are only resumed when the document is made fully active.

---
<!-- 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 #14876
- [X] These changes do not require tests because it's an interal refactoring.

<!-- 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/14971)
<!-- Reviewable:end -->
2017-01-27 16:30:37 -08:00
Alan Jeffrey
ca9cee084e Fix document.write check for activity. 2017-01-27 17:25:40 -06:00
Alan Jeffrey
a43c842099 The constellation notifies the script thread about documents becoming inactive, active and fully active. 2017-01-27 12:39:43 -06:00
bors-servo
a1187c12ee Auto merge of #15262 - alon:master, r=Ms2ger
dom/document: scripting_enabled can be a bool. #15260

Fix #15260 - scripting_enabled can be a bool

---
- [x] `./mach build -d` does not report any errors
- [x] `./mach test-tidy` does not report any errors
- [x] These changes fix #15260

<!-- Either: -->
- [ ] There are tests for these changes OR
- [x] These changes do not require tests because - there were no tests previously (not a real good excuse :)

<!-- 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/15262)
<!-- Reviewable:end -->
2017-01-27 08:57:38 -08:00
Anthony Ramine
d8238646a0 Kill ServoParser::pipeline 2017-01-27 12:12:21 +01:00
Alon Levy
d966f1fae2 dom/document: scripting_enabled can be a bool. #15260 2017-01-27 12:01:27 +02:00
Anthony Ramine
7dd5945237 Inline dom::eventdispatcher into dom::event 2017-01-22 15:31:47 +01:00
Anthony Ramine
03d79185ff Support document.createElement("beforeunloadevent") 2017-01-21 15:16:19 +01:00
Anthony Ramine
1f8106a1dc Expose PopStateEvent only in Window 2017-01-21 15:16:14 +01:00
Anthony Ramine
bd5ffd2833 Expose PageTransitionEvent only in Window 2017-01-21 15:16:02 +01:00
Anthony Ramine
2221203359 Expose HashChangeEvent only in Window 2017-01-21 15:15:50 +01:00
Anthony Ramine
ee1ff1d385 Make FocusEvent::new_uninitialized take a &Window 2017-01-21 14:32:37 +01:00
Anthony Ramine
969e6e5ac3 Add some comments for the end 2017-01-20 23:55:32 +01:00
Anthony Ramine
6c788feaf7 Process pending parsing blocking script before deferred scripts
Processing the blocking script beforehand may allow the parser to finish parsing,
in which case deferred scripts have the opportunity to get executed.
2017-01-20 23:54:42 +01:00
Anthony Ramine
e9feb20775 Simplify processing of deferred scripts
It is now done on-demand when a deferred script finished loading, and when
the page source finished loading.
2017-01-20 16:41:49 +01:00
Anthony Ramine
abdb390da8 Simplify processing of pending parsing-blocking scripts
This is done outside of finish_load in a more straightforward way now.
2017-01-20 16:30:34 +01:00
Anthony Ramine
1bf0db5537 Process deferred scripts less often
Only do it from finish_load when a stylesheet finished loading, and from
deferred_script_loaded directly.
2017-01-20 16:08:59 +01:00
Anthony Ramine
9912721f06 Simplify processing of asap scripts in order 2017-01-20 15:35:22 +01:00
Anthony Ramine
f7df804630 Simplify the processing of asap scripts 2017-01-20 15:25:24 +01:00
bors-servo
6272cb5a51 Auto merge of #15098 - nox:load-fixes, r=jdm
Mark the page source as loaded only after parsing is done

<!-- 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/15098)
<!-- Reviewable:end -->
2017-01-19 07:32:45 -08:00
Anthony Ramine
0f244d6948 Mark the page source as loaded only after parsing is done 2017-01-19 16:17:14 +01:00
bors-servo
ba59ee6627 Auto merge of #15053 - emilio:image-width, r=jdm
Return the intrinsic image dimension when the image is not rendered

See individual commits for details.

r? @jdm

<!-- 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/15053)
<!-- Reviewable:end -->
2017-01-18 08:43:19 -08:00
Emilio Cobos Álvarez
bdd7cb9753
script: Rename bounding_content_box to bounding_content_box_or_zero.
And make bounding_content_box preserve whether the element is rendered.
2017-01-18 16:49:52 +01:00
Anthony Ramine
d29726971a Remove an obsolete reflow 2017-01-17 13:15:00 +01:00
Anthony Ramine
a60bbc81b8 Reorder some Document methods to put them together 2017-01-17 13:14:59 +01:00
Anthony Ramine
30f0553ac7 Introduce PendingScript
This moves scripts' loading results in Document, instead of maintaining them
behind a DOMRefCell in each HTMLScriptElement.
2017-01-11 17:37:19 +01:00
Anthony Ramine
438182a7de Introduce Document::has_pending_parsing_blocking_script 2017-01-11 14:52:40 +01:00
Anthony Ramine
749ac42854 Do not pass an Option to Document::set_pending_parsing_blocking_script 2017-01-10 21:57:02 +01:00
Alan Jeffrey
7c2de62124 Implement browsing context discarding. 2017-01-05 21:12:57 +00:00
bors-servo
2fe914e2fa Auto merge of #14845 - jdm:restyle-ood, r=emilio
Avoid restyling elements that aren't in a document

- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [X] These changes fix #14480
- [X] There are tests for these changes

<!-- 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/14845)
<!-- Reviewable:end -->
2017-01-04 12:19:00 -08:00
bors-servo
6f9ff7b8bf Auto merge of #14738 - Wafflespeanut:keypress, r=jdm
Properly dispatch keypress event

<!-- Please describe your changes on the following line: -->

This was an attempt to fix #14659. It turned out that the problem wasn't what I thought it was. So, I didn't fix that. On the brighter side, this fixes two related issues.

- Previously, we were unable to launch `keypress` events from `input` and `textarea` elements, because [we'd been cancelling](1327ebd52f/components/script/dom/htmlinputelement.rs (L1120-L1124)) the key events, so that they don't trigger window navigation - #8400). I've introduced an enum to represent an additional state to an event's cancellation.
- [According to the spec](https://w3c.github.io/uievents/#keypress-event-order), `keypress` (if available) should be dispatched immediately after `keydown`, and it should be followed by `input`. Canceling `keypress` should also cancel `input`. But, we'd been dispatching `input` before `keypress`. We now dispatch `input` once the `keypress` event is on the respective elements.

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

<!-- Either: -->
- [x] These changes do not require tests because it's a refactor?

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->

r? @jdm or anyone interested

<!-- 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/14738)
<!-- Reviewable:end -->
2017-01-04 10:52:06 -08:00
Josh Matthews
9a264c8173 Only pass nodes to layout for restyling that are actually in the document. 2017-01-04 12:42:12 -05:00
Ravi Shankar
5f0b3bd53c Fire 'input' event after 'keypress' in input and textarea elements 2016-12-27 15:57:34 +05:30
Ravi Shankar
08662cc64e Allow 'keypress' event to emerge from input and textarea elements 2016-12-27 15:57:23 +05:30