Commit graph

295 commits

Author SHA1 Message Date
rohan.prinja
1f02c4ebbb task -> thread 2016-01-10 17:58:13 +09:00
bors-servo
9da739acef Auto merge of #9123 - karyon:clippy_cleanup, r=Manishearth
Fix a bunch of clippy lints

This fixes about 130 clippy lints. Let me know if i should split up the commit.

I wasn't sure about some of the changes, especially map_or instead of map(...).unwrap_or(...) and if let instead of single arm match were not always a strict improvement in my opinion, but i'll leave that decision to the reviewer :)

There are about 150 lints left which i thought were clippy bugs or i didn't know how to fix.

cc @Manishearth

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/9123)
<!-- Reviewable:end -->
2016-01-03 09:16:34 +05:30
Iszak Bryan
1fa3d36167 Store state of fill or style for canvas pattern 2016-01-02 23:35:04 +00:00
Johannes Linke
6b215f38ee Fix a bunch of clippy lints 2016-01-02 23:27:15 +01:00
bors-servo
11d160fc73 Auto merge of #9109 - nerith:createpattern, r=jdm
Support empty strings as the repeat argument (CreatePattern)

According to the third step in the specification [1], createPattern
should let the repetition argument be "repeat" when it is the empty
string.

The code in CanvasRenderingContext2D::CreatePattern did not implement
this step and instead threw a SyntaxError exception when an empty
string was supplied as the repetition argument.

Fixes #9079.

[1] https://html.spec.whatwg.org/multipage/#dom-context-2d-createpattern

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/9109)
<!-- Reviewable:end -->
2016-01-01 21:04:51 +05:30
Brandon Fairchild
1ccab328f9 Support empty strings as the repeat argument (CreatePattern)
According to the third step in the specification [1], createPattern
should let the repetition argument be "repeat" when it is the empty
string.

The code in CanvasRenderingContext2D::CreatePattern did not implement
this step and instead threw a SyntaxError exception when an empty
string was supplied as the repetition argument.

Fixes #9079.

[1] https://html.spec.whatwg.org/multipage/#dom-context-2d-createpattern
2015-12-31 11:48:15 -05:00
Alberto Corona
e6a3c16e9a Enable Pattern variant of CanvasFillOrStrokeStyle
Closes #7608
2015-12-29 10:38:00 -05:00
David Zbarsky
b8e9064fe6 Add origin-clean flag tracking for canvas 2015-12-17 11:40:38 -08:00
Tomas Cernaj
5507be2653 Move ScriptMsg from msg crate into script_traits 2015-12-09 20:50:11 +01:00
David Zbarsky
789a90a82f Implement IsPointInPath 2015-12-05 17:49:49 -08:00
David Zbarsky
302f41d34b Reset canvas state when changing bitmap dimensions 2015-11-30 21:23:51 -08:00
David Zbarsky
ee3f7ad451 Update Canvas webIDL to spec 2015-11-28 20:03:48 -08:00
Simon Sapin
18ecf54d10 Tidy. 2015-11-23 16:16:35 +01:00
David Zbarsky
8408891ec5 Parse currentColor as Canvas2D color 2015-11-21 11:59:19 -08:00
bors-servo
acbe413052 Auto merge of #8530 - KiChjang:split-constellation-msg, r=jdm
Split ConstellationMsg into ScriptMsg and CompositorMsg

Fixes #8356.

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/8530)
<!-- Reviewable:end -->
2015-11-19 04:39:20 +05:30
Ms2ger
0c61be7a57 Rustfmt some of script. 2015-11-18 11:14:05 +01:00
Keith Yeung
19294db6e5 Split ConstellationMsg into ScriptMsg and CompositorMsg 2015-11-16 23:10:53 -08: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
David Zbarsky
722aa86c89 Get rid of a bunch of explicit derefs 2015-11-03 19:51:46 -08:00
rohan.prinja
6e774ea6eb merge from master 2015-11-03 19:01:23 +09:00
Eli Friedman
df7fb8fa32 Remove JSTraceable implementation from RefCell.
The implementation wasn't really right, and we would rather just use
DOMRefCell anyway.
2015-11-02 14:40:57 -08:00
nxnfufunezn
d8ef3809a6 Removed JS::root Fixes #8251 2015-10-31 18:15:16 +05:30
rohan.prinja
45224028db more refactoring 2015-10-30 20:26:29 +09:00
rohan.prinja
bb2536cd01 move Castable into dom::bindings::inheritance 2015-10-30 20:24:42 +09:00
Eli Friedman
81ecf7824c Make unrooted_must_root a bit more aggressive.
Basically, instead of trying to check for specific kinds of statements,
just check the types of all local variables.

Also included are some commented-out proposals for some slightly more
aggressive lints which might be useful (but trigger a little too
frequently at the moment).
2015-10-23 14:43:44 -07:00
bors-servo
9a34decec2 Auto merge of #8086 - froydnj:premultiply-tables, r=jdm
add (un)premultiply tables for canvas {Get,Put}ImageData operations

Pretty straightforward use of lookup tables to replace a bunch of expensive float operations.

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/8086)
<!-- Reviewable:end -->
2015-10-21 17:48:49 -06:00
bors-servo
252e73ff9b Auto merge of #8115 - nerith:canvas, r=jdm
Don't require the CanvasFillOrStrokeStyle enum to be public

CanvasFillOrStrokeStyle is only used in a single file,
so it does not need to be a public enum.

Fixes #8105.

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/8115)
<!-- Reviewable:end -->
2015-10-21 08:32:36 -06:00
Anthony Ramine
68014af78e Clean up the cast calls 2015-10-21 11:40:34 +02:00
Anthony Ramine
13ea3ac413 Introduce trait Castable
This trait is used to hold onto the downcast and upcast functions of all
castable IDL interfaces. A castable IDL interface is one which either derives
from or is derived by other interfaces.

The deriving relation is represented by implementations of marker trait
DerivedFrom<T: Castable> generated in InheritTypes.

/^[ ]*use dom::bindings::codegen::InheritTypes::.*(Base|Cast|Derived)/ {
    /::[a-zA-Z]+(Base|Cast|Derived);/d
    s/([{ ])[a-zA-Z]+(Base|Cast|Derived), /\1/g
    s/([{ ])[a-zA-Z]+(Base|Cast|Derived), /\1/g
    s/, [a-zA-Z]+(Base|Cast|Derived)([},])/\2/g
    s/, [a-zA-Z]+(Base|Cast|Derived)([},])/\2/g
    /\{([a-zA-Z]+(Base|Cast|Derived))?\};$/d
    s/\{([a-zA-Z_]+)\};$/\1;/
}

s/([a-zA-Z]+)Cast::from_ref\(\&?\**([a-zA-Z_]+)(\.r\(\))?\)/\2.upcast::<\1>()/g
s/([a-zA-Z]+)Cast::from_ref\(\&?\**([a-zA-Z_]+)(\.[a-zA-Z_]+\(\))?\)/\2\3.upcast::<\1>()/g
s/\(([a-zA-Z]+)Cast::from_ref\)/\(Castable::upcast::<\1>\)/g

s/([a-zA-Z]+)Cast::from_root/Root::upcast::<\1>/g

s/([a-zA-Z]+)Cast::from_layout_js\(\&([a-zA-Z_.]+)\)/\2.upcast::<\1>()/g

s/([a-zA-Z]+)Cast::to_ref\(\&?\**([a-zA-Z_]+)(\.r\(\))?\)/\2.downcast::<\1>()/g
s/([a-zA-Z]+)Cast::to_ref\(\&?\**([a-zA-Z_]+)(\.[a-zA-Z_]+\(\))?\)/\2\3.downcast::<\1>()/g
s/\(([a-zA-Z]+)Cast::to_ref\)/\(Castable::downcast::<\1>\)/g

s/([a-zA-Z]+)Cast::to_root/Root::downcast::<\1>/g

s/([a-zA-Z]+)Cast::to_layout_js\(&?([a-zA-Z_.]+(\(\))?)\)/\2.downcast::<\1>()/g

s/\.is_document\(\)/.is::<Document>()/g
s/\.is_htmlanchorelement\(\)/.is::<HTMLAnchorElement>()/g
s/\.is_htmlappletelement\(\)/.is::<HTMLAppletElement>()/g
s/\.is_htmlareaelement\(\)/.is::<HTMLAreaElement>()/g
s/\.is_htmlbodyelement\(\)/.is::<HTMLBodyElement>()/g
s/\.is_htmlembedelement\(\)/.is::<HTMLEmbedElement>()/g
s/\.is_htmlfieldsetelement\(\)/.is::<HTMLFieldSetElement>()/g
s/\.is_htmlformelement\(\)/.is::<HTMLFormElement>()/g
s/\.is_htmlframesetelement\(\)/.is::<HTMLFrameSetElement>()/g
s/\.is_htmlhtmlelement\(\)/.is::<HTMLHtmlElement>()/g
s/\.is_htmlimageelement\(\)/.is::<HTMLImageElement>()/g
s/\.is_htmllegendelement\(\)/.is::<HTMLLegendElement>()/g
s/\.is_htmloptgroupelement\(\)/.is::<HTMLOptGroupElement>()/g
s/\.is_htmloptionelement\(\)/.is::<HTMLOptionElement>()/g
s/\.is_htmlscriptelement\(\)/.is::<HTMLScriptElement>()/g
s/\.is_htmltabledatacellelement\(\)/.is::<HTMLTableDataCellElement>()/g
s/\.is_htmltableheadercellelement\(\)/.is::<HTMLTableHeaderCellElement>()/g
s/\.is_htmltablerowelement\(\)/.is::<HTMLTableRowElement>()/g
s/\.is_htmltablesectionelement\(\)/.is::<HTMLTableSectionElement>()/g
s/\.is_htmltitleelement\(\)/.is::<HTMLTitleElement>()/g
2015-10-21 11:37:16 +02:00
Brandon Fairchild
60beb78bf3 Don't require the CanvasFillOrStrokeStyle enum to be public
CanvasFillOrStrokeStyle is only used in a single file,
so it does not need to be a public enum.

Fixes #8105.
2015-10-21 00:25:44 -04:00
Nathan Froyd
50b14e6670 add un-premultiply table for GetImageData
Fixes #6969.
2015-10-20 04:51:29 -04:00
Eli Friedman
88a1cbb28b Stop implementing Copy for JS<T>.
A copy of a JS<T> doesn't have the rooting properties of the original,
so it makes no sense for it to implement Copy.
2015-10-15 14:02:45 -07:00
Eli Friedman
fa606bf1c8 Link to the HTML multipage spec, not the single-page one. 2015-10-13 11:48:51 -07:00
Anthony Urena
ba86131cd5 Refactor Error enum usage to consistently be qualified 2015-10-06 05:43:52 -04:00
Emilio Cobos Álvarez
e2b7a01055 webgl: texImage2D with a canvas argument 2015-09-25 16:20:31 +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
Thiago Pontes
a2a9c0489d Make use of FromStr and Default traits in lib canvas
fixup! Make use of FromStr and Default traits in lib canvas
2015-09-03 14:42:53 -03: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
Corey Farwell
5ccb0d43ef Merge adjacent identical impl sections
Prior to #7416 and #7401, many of these `impl` sections were not
identical
2015-08-28 10:30:42 -04:00
Anthony Ramine
709d347872 Make the traits for the IDL interfaces take &self 2015-08-27 22:27:43 +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
João Oliveira
fd87c8cb3e make dom_struct derive HeapSizeOf,
closes #7357
2015-08-27 01:17:48 +01:00
ecoal95
6341c77700 webgl: Implement multiple calls and improve error detection
This commit implements WebGL's:
 * cullFace
 * frontFace
 * enable
 * disable
 * depthMask
 * colorMask
 * clearDepth
 * clearStencil
 * depthFunc
 * depthRange
 * hint
 * lineWidth
 * pixelStorei
 * polygonOffset
 * texParameteri
 * texParameterf
 * texImage2D (partially)

It inlines a lot of OpenGL calls to keep the file
`components/canvas/webgl_paint_task.rs` as small as possible while
keeping readability.

It also improves error detection on previous calls, and sets node damage
on the canvas in the drawing calls.

It adds a `TexImage2D` reftest, even though it's not enabled because:
 * WebGL paints the image when it loads (asynchronously), so the reftest doesn't wait for it and it finishes early
 * If we change the source for the base64 src of the image it works as expected in non-headless mode, but the test harness locks
2015-08-25 17:16:46 +02:00
Johann Tuffe
ec07178b6f sort all uses 2015-08-20 20:47:12 +08:00
Josh Matthews
8bb853f643 Fix existing syntactics nits. 2015-08-16 10:30:43 -04:00
Bogdan Cuza
45145108da Measure heap memory usage for more types. Fixes #6951 2015-08-13 21:44:41 +03:00
bors-servo
6a8bc85284 Auto merge of #7092 - dzbarsky:putimagedata, r=jdm
Clean up and fix PutImageData



<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/7092)
<!-- Reviewable:end -->
2015-08-09 07:00:56 -06:00
David Zbarsky
2f47bdff4b Fix getImageData with sizes < 1 pixel 2015-08-08 15:43:22 -04:00