servo: Merge #3948 - Rust upgrade to rustc hash b03a2755193cd756583bcf5831cf4545d75ecb8a (from servo:rustup-20141105_2); r=Manishearth

Source-Repo: https://github.com/servo/servo
Source-Revision: c5e1b0d32e17fad29799023c85e2e73ac89c3af7
This commit is contained in:
Glenn Watson 2014-11-12 20:48:31 -07:00
parent 8cec6a7fbe
commit 22c4035692
158 changed files with 1441 additions and 1197 deletions

View File

@ -1,5 +1,3 @@
paths = ["support/glfw-rs"]
[target.arm-linux-androideabi]
ar = "arm-linux-androideabi-ar"
linker = "arm-linux-androideabi-g++"

170
servo/Cargo.lock generated
View File

@ -5,9 +5,11 @@ dependencies = [
"compositing 0.0.1",
"gfx 0.0.1",
"glfw_app 0.0.1",
"green 0.0.1 (git+https://github.com/alexcrichton/green-rs)",
"layout 0.0.1",
"msg 0.0.1",
"net 0.0.1",
"rustuv 0.0.1 (git+https://github.com/alexcrichton/green-rs)",
"script 0.0.1",
"url 0.1.0 (git+https://github.com/servo/rust-url)",
"util 0.0.1",
@ -16,16 +18,16 @@ dependencies = [
[[package]]
name = "alert"
version = "0.1.0"
source = "git+https://github.com/servo/rust-alert#fdc24f13be8d8a2d15214ec228d166b3221b809e"
source = "git+https://github.com/servo/rust-alert#9bd18fc406683bae448bc6f5d546872970af252e"
dependencies = [
"cocoa 0.1.0 (git+https://github.com/servo/rust-cocoa)",
"cocoa 0.1.1 (git+https://github.com/servo/rust-cocoa)",
"core_foundation 0.1.0 (git+https://github.com/servo/rust-core-foundation)",
]
[[package]]
name = "azure"
version = "0.1.0"
source = "git+https://github.com/servo/rust-azure#8e9b6b1fdbbe0386655d61b0f58e1a9910497311"
source = "git+https://github.com/servo/rust-azure#612ffc4fbf80c1bd5faae4b86dfc539dda06fb0c"
dependencies = [
"core_foundation 0.1.0 (git+https://github.com/servo/rust-core-foundation)",
"core_graphics 0.1.0 (git+https://github.com/servo/rust-core-graphics)",
@ -50,15 +52,15 @@ dependencies = [
[[package]]
name = "cgl"
version = "0.0.1"
source = "git+https://github.com/servo/rust-cgl#698c6c5409c1049ba5a7e0f7bdddf97f91dc4cf5"
source = "git+https://github.com/servo/rust-cgl#7b7090729f65e2287c3d80651df02e547911b119"
dependencies = [
"gleam 0.0.1 (git+https://github.com/servo/gleam)",
]
[[package]]
name = "cocoa"
version = "0.1.0"
source = "git+https://github.com/servo/rust-cocoa#acb9b4efc70c3f285057c2aee774f38f81a1b98d"
version = "0.1.1"
source = "git+https://github.com/servo/rust-cocoa#f926323d306401df33f528c9aeca8e582cad063b"
[[package]]
name = "compositing"
@ -86,12 +88,12 @@ dependencies = [
[[package]]
name = "core_foundation"
version = "0.1.0"
source = "git+https://github.com/servo/rust-core-foundation#5c3b85b079ab2fe4a046497a84e55386db7598e8"
source = "git+https://github.com/servo/rust-core-foundation#6fa0b908f3912e20d081193e83bf5a9aa958fb83"
[[package]]
name = "core_graphics"
version = "0.1.0"
source = "git+https://github.com/servo/rust-core-graphics#6a9919f8a912cc67571b891ba198d5325964a104"
source = "git+https://github.com/servo/rust-core-graphics#9434e2bda65d259f825104170b5fa6cc6dbaf5a9"
dependencies = [
"core_foundation 0.1.0 (git+https://github.com/servo/rust-core-foundation)",
]
@ -99,7 +101,7 @@ dependencies = [
[[package]]
name = "core_text"
version = "0.1.0"
source = "git+https://github.com/servo/rust-core-text#967a97fa7e9ae47f96aee5e48f5fb0be1345d89e"
source = "git+https://github.com/servo/rust-core-text#85784007b6fa1b8f9614059edcd0429b2bd69a11"
dependencies = [
"core_foundation 0.1.0 (git+https://github.com/servo/rust-core-foundation)",
"core_graphics 0.1.0 (git+https://github.com/servo/rust-core-graphics)",
@ -108,9 +110,9 @@ dependencies = [
[[package]]
name = "cssparser"
version = "0.1.0"
source = "git+https://github.com/servo/rust-cssparser#7b0549a5d122135848b8813ec401112ab588063c"
source = "git+https://github.com/servo/rust-cssparser#cbbfd66f794bd019bbdeaefc88b29eff455b62e5"
dependencies = [
"encoding 0.1.0 (git+https://github.com/lifthrasiir/rust-encoding)",
"encoding 0.2.0 (git+https://github.com/lifthrasiir/rust-encoding)",
]
[[package]]
@ -136,8 +138,40 @@ source = "git+https://github.com/servo/rust-egl#88f2a13812ddbce2bf2317221663a61c
[[package]]
name = "encoding"
version = "0.1.0"
source = "git+https://github.com/lifthrasiir/rust-encoding#28eafb604a92c7786685b46c0fc02682ba3ab265"
version = "0.2.0"
source = "git+https://github.com/lifthrasiir/rust-encoding#a06637cc6d0da37c12c68661e2ee9ca1999764a4"
dependencies = [
"encoding-index-japanese 1.0.20140915 (git+https://github.com/lifthrasiir/rust-encoding)",
"encoding-index-korean 1.0.20140915 (git+https://github.com/lifthrasiir/rust-encoding)",
"encoding-index-simpchinese 1.0.20140915 (git+https://github.com/lifthrasiir/rust-encoding)",
"encoding-index-singlebyte 1.0.20140915 (git+https://github.com/lifthrasiir/rust-encoding)",
"encoding-index-tradchinese 1.0.20140915 (git+https://github.com/lifthrasiir/rust-encoding)",
]
[[package]]
name = "encoding-index-japanese"
version = "1.0.20140915"
source = "git+https://github.com/lifthrasiir/rust-encoding#a06637cc6d0da37c12c68661e2ee9ca1999764a4"
[[package]]
name = "encoding-index-korean"
version = "1.0.20140915"
source = "git+https://github.com/lifthrasiir/rust-encoding#a06637cc6d0da37c12c68661e2ee9ca1999764a4"
[[package]]
name = "encoding-index-simpchinese"
version = "1.0.20140915"
source = "git+https://github.com/lifthrasiir/rust-encoding#a06637cc6d0da37c12c68661e2ee9ca1999764a4"
[[package]]
name = "encoding-index-singlebyte"
version = "1.0.20140915"
source = "git+https://github.com/lifthrasiir/rust-encoding#a06637cc6d0da37c12c68661e2ee9ca1999764a4"
[[package]]
name = "encoding-index-tradchinese"
version = "1.0.20140915"
source = "git+https://github.com/lifthrasiir/rust-encoding#a06637cc6d0da37c12c68661e2ee9ca1999764a4"
[[package]]
name = "expat-sys"
@ -147,7 +181,7 @@ source = "git+https://github.com/servo/libexpat#da2ddaf78cbef836b8790807bb76b357
[[package]]
name = "fontconfig"
version = "0.1.0"
source = "git+https://github.com/servo/rust-fontconfig#b16c1e12ecb74b1e4e9a9b23c2b98580a34cf201"
source = "git+https://github.com/servo/rust-fontconfig#f42ff5cbd0404fe4d2cd64e8d9bb6307bad8fd7c"
dependencies = [
"fontconfig-sys 2.11.1 (git+https://github.com/servo/libfontconfig)",
]
@ -164,7 +198,7 @@ dependencies = [
[[package]]
name = "freetype"
version = "0.1.0"
source = "git+https://github.com/servo/rust-freetype#0b03da276e4bdeae2300596dabc4ccb16733ad70"
source = "git+https://github.com/servo/rust-freetype#e55b06110fb2d74a2db68ead740db7e98fb98060"
[[package]]
name = "freetype-sys"
@ -199,11 +233,17 @@ dependencies = [
"util 0.0.1",
]
[[package]]
name = "gl_common"
version = "0.0.1"
source = "git+https://github.com/bjz/gl-rs.git#79cd3b3f9f19aa0e39f6af572fc8673a6d9760bc"
[[package]]
name = "gl_generator"
version = "0.0.1"
source = "git+https://github.com/bjz/gl-rs.git#2857ad712bd443196983ea7c0bd4b6bdcf653e7c"
source = "git+https://github.com/bjz/gl-rs.git#79cd3b3f9f19aa0e39f6af572fc8673a6d9760bc"
dependencies = [
"gl_common 0.0.1 (git+https://github.com/bjz/gl-rs.git)",
"khronos_api 0.0.1 (git+https://github.com/bjz/gl-rs.git)",
"rust-xml 0.1.0 (git+https://github.com/netvl/rust-xml)",
]
@ -211,7 +251,7 @@ dependencies = [
[[package]]
name = "gleam"
version = "0.0.1"
source = "git+https://github.com/servo/gleam#5ebe1656d63087c68512c93c6528f9300abcd199"
source = "git+https://github.com/servo/gleam#8e77178eaebddfeae6557dfec2bcccbefaba93f3"
dependencies = [
"gl_generator 0.0.1 (git+https://github.com/bjz/gl-rs.git)",
]
@ -219,16 +259,16 @@ dependencies = [
[[package]]
name = "glfw"
version = "0.0.1"
source = "git+https://github.com/servo/glfw-rs?ref=servo#a15c2d04b8969aea653841d1d79e5fdf68de664b"
source = "git+https://github.com/servo/glfw-rs?ref=servo#46f82b46589720f202ab2d4a99e4f4fd48df6469"
dependencies = [
"glfw-sys 3.0.4 (git+https://github.com/servo/glfw?ref=cargo-3.0.4)",
"semver 0.0.1 (git+https://github.com/rust-lang/semver)",
"semver 0.1.0 (git+https://github.com/rust-lang/semver)",
]
[[package]]
name = "glfw-sys"
version = "3.0.4"
source = "git+https://github.com/servo/glfw?ref=cargo-3.0.4#aa8e0d26cccdb4145f34c5a1724d7e48e0399674"
source = "git+https://github.com/servo/glfw?ref=cargo-3.0.4#765dace7e4125b87c764f5ac0e7a80eae5c550b2"
[[package]]
name = "glfw_app"
@ -247,20 +287,25 @@ dependencies = [
[[package]]
name = "glx"
version = "0.0.1"
source = "git+https://github.com/servo/rust-glx#e2ce3d297260ccd23fcb4627f6ed218b68e1095f"
source = "git+https://github.com/servo/rust-glx#7126ffa09fcfcc9f85f1406f3b5db729f5fdb7c3"
dependencies = [
"gl_generator 0.0.1 (git+https://github.com/bjz/gl-rs.git)",
]
[[package]]
name = "green"
version = "0.0.1"
source = "git+https://github.com/alexcrichton/green-rs#215f3c87bf545b36a90100b7fb209ba640f2f481"
[[package]]
name = "harfbuzz"
version = "0.1.0"
source = "git+https://github.com/servo/rust-harfbuzz#ad520942cc17232e1a40cdd8a99c2905623d35f6"
source = "git+https://github.com/servo/rust-harfbuzz#8aab215463214647b7a81f66011da552bbb1121c"
[[package]]
name = "html5ever"
version = "0.0.0"
source = "git+https://github.com/servo/html5ever?ref=servo#0bdd6087dc8df6a92c96e1859bbb4ebbb0be7c1f"
source = "git+https://github.com/servo/html5ever?ref=servo#87c7e8b710391338b2463652be835f498923653c"
dependencies = [
"html5ever_macros 0.0.0 (git+https://github.com/servo/html5ever?ref=servo)",
"phf 0.0.0 (git+https://github.com/sfackler/rust-phf)",
@ -272,12 +317,12 @@ dependencies = [
[[package]]
name = "html5ever_macros"
version = "0.0.0"
source = "git+https://github.com/servo/html5ever?ref=servo#0bdd6087dc8df6a92c96e1859bbb4ebbb0be7c1f"
source = "git+https://github.com/servo/html5ever?ref=servo#87c7e8b710391338b2463652be835f498923653c"
[[package]]
name = "http"
version = "0.1.0-pre"
source = "git+https://github.com/servo/rust-http?ref=servo#5e9b063b36028a5b40a417c661ee5c628b594be9"
source = "git+https://github.com/servo/rust-http?ref=servo#3597f981aa001c57d3c918eb9f8ab58d3f0bf5a5"
dependencies = [
"openssl 0.0.0 (git+https://github.com/sfackler/rust-openssl.git)",
"url 0.1.0 (git+https://github.com/servo/rust-url)",
@ -286,7 +331,7 @@ dependencies = [
[[package]]
name = "io_surface"
version = "0.1.0"
source = "git+https://github.com/servo/rust-io-surface#3f8220ab2e94651ced69b04068c5126b1adadf1f"
source = "git+https://github.com/servo/rust-io-surface#691cbccc320c4fb9b75e215da9b0b82539d729bd"
dependencies = [
"cgl 0.0.1 (git+https://github.com/servo/rust-cgl)",
"core_foundation 0.1.0 (git+https://github.com/servo/rust-core-foundation)",
@ -297,20 +342,22 @@ dependencies = [
[[package]]
name = "js"
version = "0.1.0"
source = "git+https://github.com/servo/rust-mozjs#1ec216a2577c03738fa11a78958bb2a0fd3f7fbd"
source = "git+https://github.com/servo/rust-mozjs#b8109aa873d886b6ee295ea17359063da7fd3e2f"
dependencies = [
"green 0.0.1 (git+https://github.com/alexcrichton/green-rs)",
"mozjs-sys 0.0.0 (git+https://github.com/servo/mozjs)",
"rustuv 0.0.1 (git+https://github.com/alexcrichton/green-rs)",
]
[[package]]
name = "khronos_api"
version = "0.0.1"
source = "git+https://github.com/bjz/gl-rs.git#2857ad712bd443196983ea7c0bd4b6bdcf653e7c"
source = "git+https://github.com/bjz/gl-rs.git#79cd3b3f9f19aa0e39f6af572fc8673a6d9760bc"
[[package]]
name = "layers"
version = "0.1.0"
source = "git+https://github.com/servo/rust-layers#3737b00270644594a95896a2cd37ffca36d5bc5f"
source = "git+https://github.com/servo/rust-layers#36bcefcdc791bd6fa4ab389f472e449ce2e1e159"
dependencies = [
"cgl 0.0.1 (git+https://github.com/servo/rust-cgl)",
"core_foundation 0.1.0 (git+https://github.com/servo/rust-core-foundation)",
@ -326,7 +373,7 @@ dependencies = [
name = "layout"
version = "0.0.1"
dependencies = [
"encoding 0.1.0 (git+https://github.com/lifthrasiir/rust-encoding)",
"encoding 0.2.0 (git+https://github.com/lifthrasiir/rust-encoding)",
"geom 0.1.0 (git+https://github.com/servo/rust-geom)",
"gfx 0.0.1",
"layout_traits 0.0.1",
@ -355,7 +402,7 @@ dependencies = [
[[package]]
name = "lazy_static"
version = "0.1.0"
source = "git+https://github.com/Kimundi/lazy-static.rs#e62a65372f1dd9019e37eb9381d819edff80e360"
source = "git+https://github.com/Kimundi/lazy-static.rs#62976cb611c5396e11315ae64c9c389576240eb7"
[[package]]
name = "mozjs-sys"
@ -391,17 +438,23 @@ dependencies = [
[[package]]
name = "openssl"
version = "0.0.0"
source = "git+https://github.com/sfackler/rust-openssl.git#a495465b75ffb18ff2303c5a11a103e00a15a13d"
source = "git+https://github.com/sfackler/rust-openssl.git#766ce4b7785c0b038bee95b74564e5b9bf7e9a4b"
[[package]]
name = "phf"
version = "0.0.0"
source = "git+https://github.com/sfackler/rust-phf#06254fdde7708630a6397c41c6c17ef81a4b66a0"
source = "git+https://github.com/sfackler/rust-phf#18a5ecc028055c3dbd650cc5a064b6fb033d82ef"
dependencies = [
"xxhash 0.0.1 (git+https://github.com/Jurily/rust-xxhash)",
]
[[package]]
name = "phf_mac"
version = "0.0.0"
source = "git+https://github.com/sfackler/rust-phf#06254fdde7708630a6397c41c6c17ef81a4b66a0"
source = "git+https://github.com/sfackler/rust-phf#18a5ecc028055c3dbd650cc5a064b6fb033d82ef"
dependencies = [
"xxhash 0.0.1 (git+https://github.com/Jurily/rust-xxhash)",
]
[[package]]
name = "plugins"
@ -410,7 +463,7 @@ version = "0.0.1"
[[package]]
name = "png"
version = "0.1.0"
source = "git+https://github.com/servo/rust-png#74418ffbf20e94b0d3bed4a9d004062a13342c79"
source = "git+https://github.com/servo/rust-png#b0b4acde0080dd475dee93615276bfc19207a21e"
dependencies = [
"png-sys 1.6.3 (git+https://github.com/servo/libpng?ref=servo)",
]
@ -423,7 +476,16 @@ source = "git+https://github.com/servo/libpng?ref=servo#d01f32b4eb86904695efe7fc
[[package]]
name = "rust-xml"
version = "0.1.0"
source = "git+https://github.com/netvl/rust-xml#fdc021b2bfec7855866b964f459559903c6b7808"
source = "git+https://github.com/netvl/rust-xml#d6c57380a300b94f7e7881979dbe5459dbe4ca06"
[[package]]
name = "rustuv"
version = "0.0.1"
source = "git+https://github.com/alexcrichton/green-rs#215f3c87bf545b36a90100b7fb209ba640f2f481"
dependencies = [
"green 0.0.1 (git+https://github.com/alexcrichton/green-rs)",
"tls 0.0.1 (git+https://github.com/alexcrichton/green-rs)",
]
[[package]]
name = "script"
@ -432,7 +494,7 @@ dependencies = [
"canvas 0.0.1",
"cssparser 0.1.0 (git+https://github.com/servo/rust-cssparser)",
"devtools_traits 0.0.1",
"encoding 0.1.0 (git+https://github.com/lifthrasiir/rust-encoding)",
"encoding 0.2.0 (git+https://github.com/lifthrasiir/rust-encoding)",
"geom 0.1.0 (git+https://github.com/servo/rust-geom)",
"gfx 0.0.1",
"html5ever 0.0.0 (git+https://github.com/servo/html5ever?ref=servo)",
@ -464,13 +526,13 @@ dependencies = [
[[package]]
name = "semver"
version = "0.0.1"
source = "git+https://github.com/rust-lang/semver#d04583a173395b76c1eaa15cc630a5f6f8f0ae10"
version = "0.1.0"
source = "git+https://github.com/rust-lang/semver#7dca047a9cd40e929a4545b37a1917daff82f156"
[[package]]
name = "skia-sys"
version = "0.0.20130412"
source = "git+https://github.com/servo/skia#6d696712962fd0d41120b7a414a48417da8e6a92"
source = "git+https://github.com/servo/skia#d92603043a9b7dd0b25c0b3b562099a0cc32ac6c"
dependencies = [
"expat-sys 2.1.0 (git+https://github.com/servo/libexpat)",
"freetype-sys 2.4.11 (git+https://github.com/servo/libfreetype2)",
@ -479,22 +541,24 @@ dependencies = [
[[package]]
name = "stb_image"
version = "0.1.0"
source = "git+https://github.com/servo/rust-stb-image#f5022de4ad6bb474a03493d1f274dde9b0f1af0c"
source = "git+https://github.com/servo/rust-stb-image#74488fef4740acf287ff5dc248d65cc74033467a"
[[package]]
name = "string_cache"
version = "0.0.0"
source = "git+https://github.com/servo/string-cache#124b891ebb4564743068f99aaeb0e154de343efb"
source = "git+https://github.com/servo/string-cache#ae950525434b642eff5f4904f5e0c76cd6ea99b9"
dependencies = [
"lazy_static 0.1.0 (git+https://github.com/Kimundi/lazy-static.rs)",
"phf 0.0.0 (git+https://github.com/sfackler/rust-phf)",
"phf_mac 0.0.0 (git+https://github.com/sfackler/rust-phf)",
"string_cache_macros 0.0.0 (git+https://github.com/servo/string-cache)",
"xxhash 0.0.1 (git+https://github.com/Jurily/rust-xxhash)",
]
[[package]]
name = "string_cache_macros"
version = "0.0.0"
source = "git+https://github.com/servo/string-cache#124b891ebb4564743068f99aaeb0e154de343efb"
source = "git+https://github.com/servo/string-cache#ae950525434b642eff5f4904f5e0c76cd6ea99b9"
dependencies = [
"lazy_static 0.1.0 (git+https://github.com/Kimundi/lazy-static.rs)",
]
@ -504,7 +568,7 @@ name = "style"
version = "0.0.1"
dependencies = [
"cssparser 0.1.0 (git+https://github.com/servo/rust-cssparser)",
"encoding 0.1.0 (git+https://github.com/lifthrasiir/rust-encoding)",
"encoding 0.2.0 (git+https://github.com/lifthrasiir/rust-encoding)",
"geom 0.1.0 (git+https://github.com/servo/rust-geom)",
"lazy_static 0.1.0 (git+https://github.com/Kimundi/lazy-static.rs)",
"plugins 0.0.1",
@ -518,12 +582,17 @@ dependencies = [
name = "task_info"
version = "0.0.1"
[[package]]
name = "tls"
version = "0.0.1"
source = "git+https://github.com/alexcrichton/green-rs#215f3c87bf545b36a90100b7fb209ba640f2f481"
[[package]]
name = "url"
version = "0.1.0"
source = "git+https://github.com/servo/rust-url#29f70a47230c2aa736e263977247c786e0b2c243"
source = "git+https://github.com/servo/rust-url#8a61b7654ab5378b488225a1d8a9cbbbcbd38894"
dependencies = [
"encoding 0.1.0 (git+https://github.com/lifthrasiir/rust-encoding)",
"encoding 0.2.0 (git+https://github.com/lifthrasiir/rust-encoding)",
]
[[package]]
@ -541,10 +610,15 @@ dependencies = [
[[package]]
name = "uuid"
version = "0.0.1"
source = "git+https://github.com/rust-lang/uuid#c3041068f413a5e46d795d21a346072794593839"
source = "git+https://github.com/rust-lang/uuid#7c5af48d4f9074717199e05a1895f42b9fb1c1f0"
[[package]]
name = "xlib"
version = "0.1.0"
source = "git+https://github.com/servo/rust-xlib#581d4faddec5188d3c3ae5307dbea28aab90644c"
source = "git+https://github.com/servo/rust-xlib#58ec3847b592aeabdcfeb6a2d02033d3a2c7f427"
[[package]]
name = "xxhash"
version = "0.0.1"
source = "git+https://github.com/Jurily/rust-xxhash#7e4174e780af0cfb29a5e53ede0b987adca16396"

View File

@ -54,3 +54,9 @@ optional = true
[dependencies.url]
git = "https://github.com/servo/rust-url"
[dependencies.green]
git = "https://github.com/alexcrichton/green-rs"
[dependencies.rustuv]
git = "https://github.com/alexcrichton/green-rs"

View File

@ -20,8 +20,6 @@
These libraries are either internal but used by Servo or external and need
special integration:
* `support/glfw-rs`: Wrapping for the GLFW library. Will eventually move to
being completely out of tree.
* `support/rust-task_info`: A binding to the task_info library on OS X.
## Tests

View File

@ -2,7 +2,8 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#![deny(unused_imports, unused_variable)]
#![deny(unused_imports)]
#![deny(unused_variables)]
extern crate azure;
extern crate geom;

View File

@ -3,7 +3,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use compositor_layer::{CompositorData, CompositorLayer, DoesntWantScrollEvents};
use compositor_layer::{ScrollPositionChanged, WantsScrollEvents};
use compositor_layer::WantsScrollEvents;
use compositor_task::{ChangeReadyState, ChangeRenderState, CompositorEventListener};
use compositor_task::{CompositorProxy, CompositorReceiver, CompositorTask};
use compositor_task::{CreateOrUpdateDescendantLayer, CreateOrUpdateRootLayer, Exit};
@ -50,9 +50,11 @@ use servo_util::memory::MemoryProfilerChan;
use servo_util::opts;
use servo_util::time::{profile, TimeProfilerChan};
use servo_util::{memory, time};
use std::collections::hashmap::HashMap;
use std::collections::HashMap;
use std::collections::hash_map::{Occupied, Vacant};
use std::path::Path;
use std::rc::Rc;
use std::slice::bytes::copy_memory;
use time::{precise_time_ns, precise_time_s};
use url::Url;
@ -236,7 +238,7 @@ impl<Window: WindowMethods> IOCompositor<Window> {
fn handle_browser_message(&mut self, msg: Msg) -> bool {
match (msg, self.shutdown_state) {
(_, FinishedShuttingDown) =>
fail!("compositor shouldn't be handling messages after shutting down"),
panic!("compositor shouldn't be handling messages after shutting down"),
(Exit(chan), _) => {
debug!("shutting down the constellation");
@ -332,9 +334,14 @@ impl<Window: WindowMethods> IOCompositor<Window> {
}
fn change_ready_state(&mut self, pipeline_id: PipelineId, ready_state: ReadyState) {
self.ready_states.insert_or_update_with(pipeline_id,
ready_state,
|_key, value| *value = ready_state);
match self.ready_states.entry(pipeline_id) {
Occupied(entry) => {
*entry.into_mut() = ready_state;
}
Vacant(entry) => {
entry.set(ready_state);
}
}
self.window.set_ready_state(self.get_earliest_pipeline_ready_state());
// If we're rendering in headless mode, schedule a recomposite.
@ -352,9 +359,15 @@ impl<Window: WindowMethods> IOCompositor<Window> {
}
fn change_render_state(&mut self, pipeline_id: PipelineId, render_state: RenderState) {
self.render_states.insert_or_update_with(pipeline_id,
render_state,
|_key, value| *value = render_state);
match self.render_states.entry(pipeline_id) {
Occupied(entry) => {
*entry.into_mut() = render_state;
}
Vacant(entry) => {
entry.set(render_state);
}
}
self.window.set_render_state(render_state);
}
@ -486,7 +499,7 @@ impl<Window: WindowMethods> IOCompositor<Window> {
fn find_pipeline_root_layer(&self, pipeline_id: PipelineId) -> Rc<Layer<CompositorData>> {
match self.find_layer_with_pipeline_and_layer_id(pipeline_id, LayerId::null()) {
Some(ref layer) => layer.clone(),
None => fail!("Tried to create or update layer for unknown pipeline"),
None => panic!("Tried to create or update layer for unknown pipeline"),
}
}
@ -578,7 +591,7 @@ impl<Window: WindowMethods> IOCompositor<Window> {
match self.fragment_point.take() {
Some(point) => {
if !self.move_layer(pipeline_id, layer_id, Point2D::from_untyped(&point)) {
fail!("Compositor: Tried to scroll to fragment with unknown layer.");
panic!("Compositor: Tried to scroll to fragment with unknown layer.");
}
self.start_scrolling_timer_if_necessary();
@ -606,7 +619,7 @@ impl<Window: WindowMethods> IOCompositor<Window> {
Some(ref layer) => {
layer.bounds.borrow_mut().origin = Point2D::from_untyped(&new_origin)
}
None => fail!("Compositor received SetLayerOrigin for nonexistent layer"),
None => panic!("Compositor received SetLayerOrigin for nonexistent layer"),
};
self.send_buffer_requests_for_all_layers();
@ -636,7 +649,7 @@ impl<Window: WindowMethods> IOCompositor<Window> {
// FIXME: This may potentially be triggered by a race condition where a
// buffers are being rendered but the layer is removed before rendering
// completes.
fail!("compositor given paint command for non-existent layer");
panic!("compositor given paint command for non-existent layer");
}
}
}
@ -725,7 +738,6 @@ impl<Window: WindowMethods> IOCompositor<Window> {
return;
}
debug!("osmain: window resized to {:?}", new_size);
self.window_size = new_size;
self.scene.set_root_layer_size(new_size.as_f32());
@ -737,7 +749,7 @@ impl<Window: WindowMethods> IOCompositor<Window> {
self.got_load_complete_message = false;
let root_pipeline_id = match self.scene.root {
Some(ref layer) => layer.extra_data.borrow().pipeline.id.clone(),
None => fail!("Compositor: Received LoadUrlWindowEvent without initialized compositor \
None => panic!("Compositor: Received LoadUrlWindowEvent without initialized compositor \
layers"),
};
@ -783,12 +795,12 @@ impl<Window: WindowMethods> IOCompositor<Window> {
let delta = scroll_event.delta / self.scene.scale;
let cursor = scroll_event.cursor.as_f32() / self.scene.scale;
let scrolled = match self.scene.root {
match self.scene.root {
Some(ref mut layer) => {
layer.handle_scroll_event(delta, cursor) == ScrollPositionChanged
layer.handle_scroll_event(delta, cursor);
}
None => false,
};
None => {}
}
self.start_scrolling_timer_if_necessary();
self.send_buffer_requests_for_all_layers();
@ -876,10 +888,17 @@ impl<Window: WindowMethods> IOCompositor<Window> {
HashMap<PipelineId, (RenderChan, Vec<RenderRequest>)> = HashMap::new();
for (layer, mut layer_requests) in requests.into_iter() {
let pipeline_id = layer.extra_data.borrow().pipeline.id;
let &(_, ref mut vec) = results.find_or_insert_with(pipeline_id, |_| {
(layer.extra_data.borrow().pipeline.render_chan.clone(), Vec::new())
});
let &(_, ref mut vec) =
match results.entry(layer.extra_data.borrow().pipeline.id) {
Occupied(mut entry) => {
*entry.get_mut() =
(layer.extra_data.borrow().pipeline.render_chan.clone(), vec!());
entry.into_mut()
}
Vacant(entry) => {
entry.set((layer.extra_data.borrow().pipeline.render_chan.clone(), vec!()))
}
};
// All the BufferRequests are in layer/device coordinates, but the render task
// wants to know the page coordinates. We scale them before sending them.
@ -1045,11 +1064,9 @@ impl<Window: WindowMethods> IOCompositor<Window> {
for y in range(0, height) {
let dst_start = y * stride;
let src_start = (height - y - 1) * stride;
unsafe {
let src_slice = orig_pixels.slice(src_start, src_start + stride);
pixels.slice_mut(dst_start, dst_start + stride)
.copy_memory(src_slice.slice_to(stride));
}
let src_slice = orig_pixels.slice(src_start, src_start + stride);
copy_memory(pixels.slice_mut(dst_start, dst_start + stride),
src_slice.slice_to(stride));
}
let mut img = png::Image {
width: width as u32,
@ -1234,4 +1251,3 @@ impl<Window> CompositorEventListener for IOCompositor<Window> where Window: Wind
self.scrolling_timer.shutdown();
}
}

View File

@ -189,7 +189,7 @@ impl CompositorLayer for Layer<CompositorData> {
// layer buffer set is consumed, and None is returned.
fn add_buffers(&self, new_buffers: Box<LayerBufferSet>, epoch: Epoch) -> bool {
if self.extra_data.borrow().epoch != epoch {
debug!("add_buffers: compositor epoch mismatch: {:?} != {:?}, id: {:?}",
debug!("add_buffers: compositor epoch mismatch: {} != {}, id: {}",
self.extra_data.borrow().epoch,
epoch,
self.extra_data.borrow().pipeline.id);
@ -357,4 +357,3 @@ impl CompositorLayer for Layer<CompositorData> {
}
}

View File

@ -30,7 +30,7 @@ use servo_util::opts;
use servo_util::task::spawn_named;
use servo_util::time::TimeProfilerChan;
use std::cell::{Cell, RefCell};
use std::collections::hashmap::{HashMap, HashSet};
use std::collections::{HashMap, HashSet};
use std::io;
use std::mem::replace;
use std::rc::Rc;
@ -267,7 +267,7 @@ impl NavigationContext {
/// Loads a new set of page frames, returning all evicted frame trees
fn load(&mut self, frame_tree: Rc<FrameTree>) -> Vec<Rc<FrameTree>> {
debug!("navigating to {:?}", frame_tree.pipeline.id);
debug!("navigating to {}", frame_tree.pipeline.id);
let evicted = replace(&mut self.next, vec!());
if self.current.is_some() {
self.previous.push(self.current.take().unwrap());
@ -465,7 +465,7 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {
}
fn handle_failure_msg(&mut self, pipeline_id: PipelineId, subpage_id: Option<SubpageId>) {
debug!("handling failure message from pipeline {:?}, {:?}", pipeline_id, subpage_id);
debug!("handling failure message from pipeline {}, {}", pipeline_id, subpage_id);
if opts::get().hard_fail {
// It's quite difficult to make Servo exit cleanly if some tasks have failed.
@ -476,7 +476,7 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {
unsafe { libc::exit(1); }
}
let old_pipeline = match self.pipelines.find(&pipeline_id) {
let old_pipeline = match self.pipelines.get(&pipeline_id) {
None => {
debug!("no existing pipeline found; bailing out of failure recovery.");
return; // already failed?
@ -536,7 +536,7 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {
fn handle_frame_rect_msg(&mut self, pipeline_id: PipelineId, subpage_id: SubpageId,
rect: TypedRect<PagePx, f32>) {
debug!("Received frame rect {:?} from {:?}, {:?}", rect, pipeline_id, subpage_id);
debug!("Received frame rect {} from {}, {}", rect, pipeline_id, subpage_id);
let mut already_sent = HashSet::new();
// Returns true if a child frame tree's subpage id matches the given subpage id
@ -635,16 +635,16 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {
// and add the new pipeline to their sub frames.
let frame_trees = self.find_all(source_pipeline_id);
if frame_trees.is_empty() {
fail!("Constellation: source pipeline id of ScriptLoadedURLInIFrameMsg is not in
navigation context, nor is it in a pending frame. This should be
impossible.");
panic!("Constellation: source pipeline id of ScriptLoadedURLInIFrameMsg is not in
navigation context, nor is it in a pending frame. This should be
impossible.");
}
let next_pipeline_id = self.get_next_pipeline_id();
// Compare the pipeline's url to the new url. If the origin is the same,
// then reuse the script task in creating the new pipeline
let source_pipeline = self.pipelines.find(&source_pipeline_id).expect("Constellation:
let source_pipeline = self.pipelines.get(&source_pipeline_id).expect("Constellation:
source Id of ScriptLoadedURLInIFrameMsg does have an associated pipeline in
constellation. This should be impossible.").clone();
@ -655,10 +655,10 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {
// FIXME(tkuehn): Need to follow the standardized spec for checking same-origin
// Reuse the script task if the URL is same-origin
let script_pipeline = if same_script {
debug!("Constellation: loading same-origin iframe at {:?}", url);
debug!("Constellation: loading same-origin iframe at {}", url);
Some(source_pipeline.clone())
} else {
debug!("Constellation: loading cross-origin iframe at {:?}", url);
debug!("Constellation: loading cross-origin iframe at {}", url);
None
};
@ -669,7 +669,7 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {
LoadData::new(url)
);
let rect = self.pending_sizes.pop(&(source_pipeline_id, subpage_id));
let rect = self.pending_sizes.remove(&(source_pipeline_id, subpage_id));
for frame_tree in frame_trees.iter() {
frame_tree.children.borrow_mut().push(ChildFrameTree::new(
Rc::new(FrameTree::new(pipeline.clone(), Some(source_pipeline.clone()))),
@ -716,7 +716,7 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {
}
fn handle_navigate_msg(&mut self, direction: constellation_msg::NavigationDirection) {
debug!("received message to navigate {:?}", direction);
debug!("received message to navigate {}", direction);
// TODO(tkuehn): what is the "critical point" beyond which pending frames
// should not be cleared? Currently, the behavior is that forward/back
@ -762,7 +762,7 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {
}
fn handle_renderer_ready_msg(&mut self, pipeline_id: PipelineId) {
debug!("Renderer {:?} ready to send paint msg", pipeline_id);
debug!("Renderer {} ready to send paint msg", pipeline_id);
// This message could originate from a pipeline in the navigation context or
// from a pending frame. The only time that we will grant paint permission is
// when the message originates from a pending frame or the current frame.
@ -795,7 +795,7 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {
// If there are frames to revoke permission from, do so now.
match frame_change.before {
Some(revoke_id) if self.current_frame().is_some() => {
debug!("Constellation: revoking permission from {:?}", revoke_id);
debug!("Constellation: revoking permission from {}", revoke_id);
let current_frame = self.current_frame().as_ref().unwrap();
let to_revoke = current_frame.find(revoke_id).expect(
@ -812,7 +812,7 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {
let mut flag = false;
{
if to_add.parent.borrow().is_some() {
debug!("Constellation: replacing {:?} with {:?} in {:?}",
debug!("Constellation: replacing {} with {} in {}",
revoke_id, to_add.pipeline.id,
next_frame_tree.pipeline.id);
flag = true;
@ -830,7 +830,7 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {
let subpage_id = to_add.pipeline.subpage_id
.expect("Constellation:
Child frame's subpage id is None. This should be impossible.");
let rect = self.pending_sizes.pop(&(parent.id, subpage_id));
let rect = self.pending_sizes.remove(&(parent.id, subpage_id));
let parent = next_frame_tree.find(parent.id).expect(
"Constellation: pending frame has a parent frame that is not
active. This is a bug.");
@ -870,7 +870,7 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {
for change in self.pending_frames.iter() {
let frame_tree = &change.after;
if frame_tree.parent.borrow().is_none() {
debug!("constellation sending resize message to pending outer frame ({:?})",
debug!("constellation sending resize message to pending outer frame ({})",
frame_tree.pipeline.id);
let ScriptControlChan(ref chan) = frame_tree.pipeline.script_chan;
let _ = chan.send_opt(ResizeMsg(frame_tree.pipeline.id, new_size));
@ -990,4 +990,3 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {
}
}
}

View File

@ -7,13 +7,12 @@
#![feature(globs, phase, macro_rules)]
#![deny(unused_imports, unused_variable)]
#![deny(unused_imports)]
#![deny(unused_variables)]
#[phase(plugin, link)]
extern crate log;
extern crate debug;
extern crate alert;
extern crate azure;
extern crate devtools_traits;

View File

@ -168,7 +168,7 @@ impl Pipeline {
}
pub fn exit(&self) {
debug!("pipeline {:?} exiting", self.id);
debug!("pipeline {} exiting", self.id);
// Script task handles shutting down layout, and layout handles shutting down the renderer.
// For now, if the script task has failed, we give up on clean shutdown.
@ -189,4 +189,3 @@ impl Pipeline {
}
}
}

View File

@ -4,8 +4,8 @@
/// General actor system infrastructure.
use std::any::{AnyPrivate, AnyRefExt, AnyMutRefExt};
use std::collections::hashmap::HashMap;
use std::any::{Any, AnyRefExt, AnyMutRefExt};
use std::collections::HashMap;
use std::cell::{Cell, RefCell};
use std::intrinsics::TypeId;
use std::io::TcpStream;
@ -16,7 +16,7 @@ use serialize::json;
/// A common trait for all devtools actors that encompasses an immutable name
/// and the ability to process messages that are directed to particular actors.
/// TODO: ensure the name is immutable
pub trait Actor: AnyPrivate {
pub trait Actor {
fn handle_message(&self,
registry: &ActorRegistry,
msg_type: &String,
@ -45,9 +45,12 @@ impl<'a> AnyRefExt<'a> for &'a Actor + 'a {
fn is<T: 'static>(self) -> bool {
// This implementation is only needed so long as there's a Rust bug that
// prevents downcast_ref from giving realistic return values.
let t = TypeId::of::<T>();
let boxed = self.get_type_id();
t == boxed
unsafe {
let t = TypeId::of::<T>();
let this: &Actor = transmute(self);
let boxed: TypeId = this.get_type_id();
t == boxed
}
}
fn downcast_ref<T: 'static>(self) -> Option<&'a T> {
@ -94,7 +97,7 @@ impl ActorRegistry {
if script_id.as_slice() == "" {
return "".to_string();
}
self.script_actors.borrow().find(&script_id).unwrap().to_string()
self.script_actors.borrow().get(&script_id).unwrap().to_string()
}
pub fn script_actor_registered(&self, script_id: String) -> bool {
@ -108,7 +111,7 @@ impl ActorRegistry {
return key.to_string();
}
}
fail!("couldn't find actor named {:s}", actor)
panic!("couldn't find actor named {:s}", actor)
}
/// Create a unique name based on a monotonically increasing suffix
@ -134,7 +137,7 @@ impl ActorRegistry {
// fails for unknown reasons.
/*let actor: &Actor+Send+Sized = *self.actors.find(&name.to_string()).unwrap();
(actor as &Any).downcast_ref::<T>().unwrap()*/
self.actors.find(&name.to_string()).unwrap().downcast_ref::<T>().unwrap()
self.actors.get(&name.to_string()).unwrap().downcast_ref::<T>().unwrap()
}
/// Find an actor by registered name
@ -143,17 +146,17 @@ impl ActorRegistry {
// fails for unknown reasons.
/*let actor: &mut Actor+Send+Sized = *self.actors.find_mut(&name.to_string()).unwrap();
(actor as &mut Any).downcast_mut::<T>().unwrap()*/
self.actors.find_mut(&name.to_string()).unwrap().downcast_mut::<T>().unwrap()
self.actors.get_mut(&name.to_string()).unwrap().downcast_mut::<T>().unwrap()
}
/// Attempt to process a message as directed by its `to` property. If the actor is not
/// found or does not indicate that it knew how to process the message, ignore the failure.
pub fn handle_message(&mut self, msg: &json::JsonObject, stream: &mut TcpStream) {
let to = msg.find(&"to".to_string()).unwrap().as_string().unwrap();
match self.actors.find(&to.to_string()) {
let to = msg.get(&"to".to_string()).unwrap().as_string().unwrap();
match self.actors.get(&to.to_string()) {
None => println!("message received for unknown actor \"{:s}\"", to),
Some(actor) => {
let msg_type = msg.find(&"type".to_string()).unwrap().as_string().unwrap();
let msg_type = msg.get(&"type".to_string()).unwrap().as_string().unwrap();
if !actor.handle_message(self, &msg_type.to_string(), msg, stream) {
println!("unexpected message type \"{:s}\" found for actor \"{:s}\"",
msg_type, to);

View File

@ -32,11 +32,13 @@ struct StartedListenersReply {
}
#[deriving(Encodable)]
#[allow(dead_code)]
struct ConsoleAPIMessage {
_type: String, //FIXME: should this be __type__ instead?
}
#[deriving(Encodable)]
#[allow(dead_code)]
struct PageErrorMessage {
_type: String, //FIXME: should this be __type__ instead?
errorMessage: String,
@ -54,6 +56,7 @@ struct PageErrorMessage {
}
#[deriving(Encodable)]
#[allow(dead_code)]
struct LogMessage {
_type: String, //FIXME: should this be __type__ instead?
timeStamp: uint,
@ -61,6 +64,7 @@ struct LogMessage {
}
#[deriving(Encodable)]
#[allow(dead_code)]
enum ConsoleMessageType {
ConsoleAPIType(ConsoleAPIMessage),
PageErrorType(PageErrorMessage),
@ -115,7 +119,7 @@ impl Actor for ConsoleActor {
stream: &mut TcpStream) -> bool {
match msg_type.as_slice() {
"getCachedMessages" => {
let types = msg.find(&"messageTypes".to_string()).unwrap().as_list().unwrap();
let types = msg.get(&"messageTypes".to_string()).unwrap().as_list().unwrap();
let /*mut*/ messages = vec!();
for msg_type in types.iter() {
let msg_type = msg_type.as_string().unwrap();
@ -187,7 +191,7 @@ impl Actor for ConsoleActor {
//TODO: actually implement listener filters that support starting/stopping
let msg = StopListenersReply {
from: self.name(),
stoppedListeners: msg.find(&"listeners".to_string())
stoppedListeners: msg.get(&"listeners".to_string())
.unwrap()
.as_list()
.unwrap_or(&vec!())
@ -212,7 +216,7 @@ impl Actor for ConsoleActor {
}
"evaluateJS" => {
let input = msg.find(&"text".to_string()).unwrap().as_string().unwrap().to_string();
let input = msg.get(&"text".to_string()).unwrap().as_string().unwrap().to_string();
let (chan, port) = channel();
self.script_chan.send(EvaluateJS(self.pipeline, input.clone(), chan));

View File

@ -252,7 +252,7 @@ impl Actor for WalkerActor {
}
"children" => {
let target = msg.find(&"node".to_string()).unwrap().as_string().unwrap();
let target = msg.get(&"node".to_string()).unwrap().as_string().unwrap();
let (tx, rx) = channel();
self.script_chan.send(GetChildren(self.pipeline,
registry.actor_to_script(target.to_string()),
@ -347,6 +347,7 @@ struct GetLayoutReply {
}
#[deriving(Encodable)]
#[allow(dead_code)]
struct AutoMargins {
top: String,
bottom: String,
@ -389,14 +390,14 @@ impl Actor for PageStyleActor {
//TODO: query script for box layout properties of node (msg.node)
"getLayout" => {
let target = msg.find(&"node".to_string()).unwrap().as_string().unwrap();
let target = msg.get(&"node".to_string()).unwrap().as_string().unwrap();
let (tx, rx) = channel();
self.script_chan.send(GetLayout(self.pipeline,
registry.actor_to_script(target.to_string()),
tx));
let (width, height) = rx.recv();
let auto_margins = msg.find(&"autoMargins".to_string()).unwrap().as_boolean().unwrap();
let auto_margins = msg.get(&"autoMargins".to_string()).unwrap().as_boolean().unwrap();
//TODO: the remaining layout properties (margin, border, padding, position)
// as specified in getLayout in http://mxr.mozilla.org/mozilla-central/source/toolkit/devtools/server/actors/styles.js

View File

@ -23,7 +23,6 @@ extern crate log;
extern crate collections;
extern crate core;
extern crate devtools_traits;
extern crate debug;
extern crate serialize;
extern crate sync;
extern crate "msg" as servo_msg;
@ -69,7 +68,7 @@ pub fn start_server(port: u16) -> Sender<DevtoolsControlMsg> {
static POLL_TIMEOUT: u64 = 300;
fn run_server(receiver: Receiver<DevtoolsControlMsg>, port: u16) {
let listener = TcpListener::bind("127.0.0.1", port);
let listener = TcpListener::bind(format!("{}:{}", "127.0.0.1", port).as_slice());
// bind the listener to the specified address
let mut acceptor = listener.listen().unwrap();
@ -88,9 +87,9 @@ fn run_server(receiver: Receiver<DevtoolsControlMsg>, port: u16) {
/// Process the input from a single devtools client until EOF.
fn handle_client(actors: Arc<Mutex<ActorRegistry>>, mut stream: TcpStream) {
println!("connection established to {:?}", stream.peer_name().unwrap());
println!("connection established to {}", stream.peer_name().unwrap());
{
let mut actors = actors.lock();
let actors = actors.lock();
let msg = actors.find::<RootActor>("root").encodable();
stream.write_json_packet(&msg);
}

View File

@ -2,7 +2,8 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use std::collections::hashmap::HashMap;
use std::collections::HashMap;
use std::collections::hash_map::{Occupied, Vacant};
use geom::size::Size2D;
use layers::platform::surface::NativePaintingGraphicsContext;
use layers::layers::LayerBuffer;
@ -85,10 +86,17 @@ impl BufferMap {
self.mem += new_buffer.get_mem();
// use lazy insertion function to prevent unnecessary allocation
let counter = &self.counter;
self.map.find_or_insert_with(new_key, |_| BufferValue {
buffers: vec!(),
last_action: *counter
}).buffers.push(new_buffer);
match self.map.entry(new_key) {
Occupied(entry) => {
entry.into_mut().buffers.push(new_buffer);
}
Vacant(entry) => {
entry.set(BufferValue {
buffers: vec!(new_buffer),
last_action: *counter,
});
}
}
let mut opt_key: Option<BufferKey> = None;
while self.mem > self.max_mem {
@ -97,19 +105,19 @@ impl BufferMap {
None => {
match self.map.iter().min_by(|&(_, x)| x.last_action) {
Some((k, _)) => *k,
None => fail!("BufferMap: tried to delete with no elements in map"),
None => panic!("BufferMap: tried to delete with no elements in map"),
}
}
};
if {
let list = &mut self.map.get_mut(&old_key).buffers;
let list = &mut self.map[old_key].buffers;
let condemned_buffer = list.pop().take().unwrap();
self.mem -= condemned_buffer.get_mem();
condemned_buffer.destroy(graphics_context);
list.is_empty()
}
{ // then
self.map.pop(&old_key); // Don't store empty vectors!
self.map.remove(&old_key); // Don't store empty vectors!
opt_key = None;
} else {
opt_key = Some(old_key);
@ -121,7 +129,7 @@ impl BufferMap {
pub fn find(&mut self, size: Size2D<uint>) -> Option<Box<LayerBuffer>> {
let mut flag = false; // True if key needs to be popped after retrieval.
let key = BufferKey::get(size);
let ret = match self.map.find_mut(&key) {
let ret = match self.map.get_mut(&key) {
Some(ref mut buffer_val) => {
buffer_val.last_action = self.counter;
self.counter += 1;
@ -137,7 +145,7 @@ impl BufferMap {
};
if flag {
self.map.pop(&key); // Don't store empty vectors!
self.map.remove(&key); // Don't store empty vectors!
}
ret

View File

@ -20,7 +20,6 @@ use text::glyph::CharIndex;
use text::TextRun;
use azure::azure::AzFloat;
use collections::Deque;
use collections::dlist::{mod, DList};
use geom::{Point2D, Rect, SideOffsets2D, Size2D, Matrix2D};
use libc::uintptr_t;
@ -188,7 +187,7 @@ impl DisplayList {
/// Appends the given item to the display list.
#[inline]
pub fn push(&mut self, item: DisplayItem) {
self.list.push(item);
self.list.push_back(item);
}
/// Appends the items in the given display list to this one, removing them in the process.
@ -476,7 +475,7 @@ impl DisplayItem {
}
ImageDisplayItemClass(ref image_item) => {
debug!("Drawing image at {:?}.", image_item.base.bounds);
debug!("Drawing image at {}.", image_item.base.bounds);
let mut y_offset = Au(0);
while y_offset < image_item.base.bounds.size.height {

View File

@ -33,7 +33,7 @@ impl DisplayListOptimizer {
for item in display_list.iter() {
match self.process_display_item(item) {
None => {}
Some(display_item) => result.push(display_item),
Some(display_item) => result.push_back(display_item),
}
}
DisplayList {
@ -51,4 +51,3 @@ impl DisplayListOptimizer {
}
}
}

View File

@ -68,7 +68,7 @@ pub trait FontTableMethods {
fn with_buffer(&self, |*const u8, uint|);
}
#[deriving(Clone)]
#[deriving(Clone, Show)]
pub struct FontMetrics {
pub underline_size: Au,
pub underline_offset: Au,
@ -103,7 +103,7 @@ impl Font {
pub fn shape_text(&mut self, text: &str, is_whitespace: bool) -> Arc<GlyphStore> {
self.make_shaper();
let shaper = &self.shaper;
match self.shape_cache.find_equiv(&text) {
match self.shape_cache.find_equiv(text) {
None => {}
Some(glyphs) => return (*glyphs).clone(),
}

View File

@ -133,7 +133,7 @@ impl FontCache {
let maybe_resource = load_whole_resource(&self.resource_task, url.clone());
match maybe_resource {
Ok((_, bytes)) => {
let family = self.web_families.get_mut(&family_name);
let family = &mut self.web_families[family_name];
family.add_template(url.to_string().as_slice(), Some(bytes));
},
Err(_) => {
@ -142,7 +142,7 @@ impl FontCache {
}
}
LocalSource(ref local_family_name) => {
let family = self.web_families.get_mut(&family_name);
let family = &mut self.web_families[family_name];
get_variations_for_family(local_family_name.as_slice(), |path| {
family.add_template(path.as_slice(), None);
});
@ -170,7 +170,7 @@ impl FontCache {
}
fn transform_family(&self, family: &LowercaseString) -> LowercaseString {
match self.generic_fonts.find(family) {
match self.generic_fonts.get(family) {
None => family.clone(),
Some(mapped_family) => (*mapped_family).clone()
}
@ -182,7 +182,7 @@ impl FontCache {
// look up canonical name
if self.local_families.contains_key(family_name) {
debug!("FontList: Found font family with name={:s}", family_name.to_string());
let s = self.local_families.get_mut(family_name);
let s = &mut self.local_families[*family_name];
if s.templates.len() == 0 {
get_variations_for_family(family_name.as_slice(), |path| {
@ -207,7 +207,7 @@ impl FontCache {
fn find_font_in_web_family<'a>(&'a mut self, family_name: &LowercaseString, desc: &FontTemplateDescriptor)
-> Option<Arc<FontTemplateData>> {
if self.web_families.contains_key(family_name) {
let family = self.web_families.get_mut(family_name);
let family = &mut self.web_families[*family_name];
let maybe_font = family.find_font_for_style(desc, &self.font_context);
maybe_font
} else {
@ -237,7 +237,7 @@ impl FontCache {
}
}
fail!("Unable to find any fonts that match (do you have fallback fonts installed?)");
panic!("Unable to find any fonts that match (do you have fallback fonts installed?)");
}
}

View File

@ -25,12 +25,10 @@ use azure::AzFloat;
use azure::azure_hl::SkiaBackend;
use azure::scaled_font::ScaledFont;
#[cfg(target_os="linux")]
#[cfg(target_os="android")]
#[cfg(any(target_os="linux", target_os = "android"))]
use azure::scaled_font::FontData;
#[cfg(target_os="linux")]
#[cfg(target_os="android")]
#[cfg(any(target_os="linux", target_os = "android"))]
fn create_scaled_font(template: &Arc<FontTemplateData>, pt_size: Au) -> ScaledFont {
ScaledFont::new(SkiaBackend, FontData(&template.bytes), pt_size.to_subpx() as AzFloat)
}

View File

@ -4,13 +4,13 @@
#![feature(globs, macro_rules, phase, unsafe_destructor)]
#![deny(unused_imports, unused_variable)]
#![deny(unused_imports)]
#![deny(unused_variables)]
#![feature(phase)]
#[phase(plugin, link)]
extern crate log;
extern crate debug;
extern crate azure;
extern crate collections;
extern crate geom;
@ -38,8 +38,11 @@ extern crate url;
extern crate harfbuzz;
// Linux and Android-specific library dependencies
#[cfg(target_os="linux")] #[cfg(target_os="android")] extern crate fontconfig;
#[cfg(target_os="linux")] #[cfg(target_os="android")] extern crate freetype;
#[cfg(any(target_os="linux", target_os = "android"))]
extern crate fontconfig;
#[cfg(any(target_os="linux", target_os = "android"))]
extern crate freetype;
// Mac OS-specific library dependencies
#[cfg(target_os="macos")] extern crate core_foundation;

View File

@ -43,7 +43,7 @@ pub struct FontTable;
impl FontTableMethods for FontTable {
fn with_buffer(&self, _blk: |*const u8, uint|) {
fail!()
panic!()
}
}
@ -61,7 +61,7 @@ impl Drop for FontHandle {
assert!(self.face.is_not_null());
unsafe {
if !FT_Done_Face(self.face).succeeded() {
fail!("FT_Done_Face failed");
panic!("FT_Done_Face failed");
}
}
}
@ -139,15 +139,15 @@ impl FontHandleMethods for FontHandle {
if valid {
let weight =(*os2).usWeightClass;
match weight {
1 | 100..199 => font_weight::Weight100,
2 | 200..299 => font_weight::Weight200,
3 | 300..399 => font_weight::Weight300,
4 | 400..499 => font_weight::Weight400,
5 | 500..599 => font_weight::Weight500,
6 | 600..699 => font_weight::Weight600,
7 | 700..799 => font_weight::Weight700,
8 | 800..899 => font_weight::Weight800,
9 | 900..999 => font_weight::Weight900,
1 | 100...199 => font_weight::Weight100,
2 | 200...299 => font_weight::Weight200,
3 | 300...399 => font_weight::Weight300,
4 | 400...499 => font_weight::Weight400,
5 | 500...599 => font_weight::Weight500,
6 | 600...699 => font_weight::Weight600,
7 | 700...799 => font_weight::Weight700,
8 | 800...899 => font_weight::Weight800,
9 | 900...999 => font_weight::Weight900,
_ => default_weight
}
} else {
@ -190,7 +190,6 @@ impl FontHandleMethods for FontHandle {
let void_glyph = (*self.face).glyph;
let slot: FT_GlyphSlot = mem::transmute(void_glyph);
assert!(slot.is_not_null());
debug!("metrics: {:?}", (*slot).metrics);
let advance = (*slot).metrics.horiAdvance;
debug!("h_advance for {} is {}", glyph, advance);
let advance = advance as i32;
@ -255,7 +254,7 @@ impl FontHandleMethods for FontHandle {
line_gap: height,
};
debug!("Font metrics (@{:f} pt): {:?}", geometry::to_pt(em_size), metrics);
debug!("Font metrics (@{:f} pt): {}", geometry::to_pt(em_size), metrics);
return metrics;
}
@ -297,4 +296,3 @@ impl<'a> FontHandle {
return geometry::from_frac_px(value * x_scale);
}
}

View File

@ -70,7 +70,7 @@ impl FontContextHandle {
let mut ctx: FT_Library = ptr::null_mut();
let result = FT_New_Library(ptr as FT_Memory, &mut ctx);
if !result.succeeded() { fail!("Unable to initialize FreeType library"); }
if !result.succeeded() { panic!("Unable to initialize FreeType library"); }
FT_Add_Default_Modules(ctx);

View File

@ -75,13 +75,13 @@ pub fn get_variations_for_family(family_name: &str, callback: |String|) {
let file = if FcPatternGetString(*font, FC_FILE.as_ptr() as *mut i8, 0, &mut file) == FcResultMatch {
string::raw::from_buf(file as *const i8 as *const u8)
} else {
fail!();
panic!();
};
let mut index: libc::c_int = 0;
let index = if FcPatternGetInteger(*font, FC_INDEX.as_ptr() as *mut i8, 0, &mut index) == FcResultMatch {
index
} else {
fail!();
panic!();
};
debug!("variation file: {}", file);

View File

@ -178,7 +178,7 @@ impl FontHandleMethods for FontHandle {
average_advance: average_advance,
line_gap: Au::from_frac_px(line_gap),
};
debug!("Font metrics (@{:f} pt): {:?}", self.ctfont.pt_size() as f64, metrics);
debug!("Font metrics (@{:f} pt): {}", self.ctfont.pt_size() as f64, metrics);
return metrics;
}

View File

@ -2,15 +2,13 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#[cfg(target_os="linux")]
#[cfg(target_os="android")]
#[cfg(any(target_os="linux", target_os = "android"))]
pub use platform::freetype::{font, font_context, font_list, font_template};
#[cfg(target_os="macos")]
pub use platform::macos::{font, font_context, font_list, font_template};
#[cfg(target_os="linux")]
#[cfg(target_os="android")]
#[cfg(any(target_os="linux", target_os = "android"))]
pub mod freetype {
pub mod font;
pub mod font_context;

View File

@ -114,8 +114,8 @@ impl<'a> RenderContext<'a> {
let (pixel_width, pixels, source_format) = match image.pixels {
RGBA8(ref pixels) => (4, pixels.as_slice(), B8G8R8A8),
K8(ref pixels) => (1, pixels.as_slice(), A8),
RGB8(_) => fail!("RGB8 color type not supported"),
KA8(_) => fail!("KA8 color type not supported"),
RGB8(_) => panic!("RGB8 color type not supported"),
KA8(_) => panic!("KA8 color type not supported"),
};
let stride = image.width * pixel_width;
@ -366,7 +366,7 @@ impl<'a> RenderContext<'a> {
let is_groove = match style {
border_style::groove => true,
border_style::ridge => false,
_ => fail!("invalid border style")
_ => panic!("invalid border style")
};
let darker_color = self.scale_color(color, if is_groove { 1.0/3.0 } else { 2.0/3.0 });
let (outer_color, inner_color) = match (direction, is_groove) {
@ -388,7 +388,7 @@ impl<'a> RenderContext<'a> {
let is_inset = match style {
border_style::inset => true,
border_style::outset => false,
_ => fail!("invalid border style")
_ => panic!("invalid border style")
};
// original bounds as a Rect<f32>
let original_bounds = self.get_scaled_bounds(bounds, border, 0.0);

View File

@ -152,7 +152,7 @@ impl<C> RenderTask<C> where C: RenderListener + Send {
time_profiler_chan: TimeProfilerChan,
shutdown_chan: Sender<()>) {
let ConstellationChan(c) = constellation_chan.clone();
spawn_named_with_send_on_failure("RenderTask", task_state::Render, proc() {
spawn_named_with_send_on_failure("RenderTask", task_state::RENDER, proc() {
{
// Ensures that the render task and graphics context are destroyed before the
// shutdown message.
@ -237,7 +237,7 @@ impl<C> RenderTask<C> where C: RenderListener + Send {
if self.epoch == epoch {
self.render(&mut replies, buffer_requests, scale, layer_id);
} else {
debug!("renderer epoch mismatch: {:?} != {:?}", self.epoch, epoch);
debug!("renderer epoch mismatch: {} != {}", self.epoch, epoch);
}
}
@ -340,14 +340,14 @@ impl<C> RenderTask<C> where C: RenderListener + Send {
for (i, tile) in tiles.into_iter().enumerate() {
let thread_id = i % self.worker_threads.len();
let layer_buffer = self.find_or_create_layer_buffer_for_tile(&tile, scale);
self.worker_threads.get_mut(thread_id).paint_tile(tile,
layer_buffer,
render_layer.clone(),
scale);
self.worker_threads[thread_id].paint_tile(tile,
layer_buffer,
render_layer.clone(),
scale);
}
let new_buffers = Vec::from_fn(tile_count, |i| {
let thread_id = i % self.worker_threads.len();
self.worker_threads.get_mut(thread_id).get_painted_tile_buffer()
self.worker_threads[thread_id].get_painted_tile_buffer()
});
let layer_buffer_set = box LayerBufferSet {
@ -570,4 +570,3 @@ enum MsgToWorkerThread {
enum MsgFromWorkerThread {
PaintedTileMsgFromWorkerThread(Box<LayerBuffer>),
}

View File

@ -7,7 +7,7 @@ use servo_util::range;
use servo_util::range::{Range, RangeIndex, IntRangeIndex, EachIndex};
use servo_util::geometry::Au;
use std::cmp::{PartialOrd, PartialEq};
use std::cmp::PartialOrd;
use std::num::{NumCast, Zero};
use std::mem;
use std::u16;
@ -22,7 +22,7 @@ use geom::point::Point2D;
/// In the uncommon case (multiple glyphs per unicode character, large glyph index/advance, or
/// glyph offsets), we pack the glyph count into GlyphEntry, and store the other glyph information
/// in DetailedGlyphStore.
#[deriving(Clone)]
#[deriving(Clone, Show)]
struct GlyphEntry {
value: u32,
}
@ -251,7 +251,7 @@ impl GlyphEntry {
// Stores data for a detailed glyph, in the case that several glyphs
// correspond to one character, or the glyph's data couldn't be packed.
#[deriving(Clone)]
#[deriving(Clone, Show)]
struct DetailedGlyph {
id: GlyphId,
// glyph's advance, in the text's direction (RTL or RTL)
@ -270,7 +270,7 @@ impl DetailedGlyph {
}
}
#[deriving(PartialEq, Clone, Eq)]
#[deriving(PartialEq, Clone, Eq, Show)]
struct DetailedGlyphRecord {
// source string offset/GlyphEntry offset in the TextRun
entry_offset: CharIndex,
@ -319,7 +319,7 @@ impl<'a> DetailedGlyphStore {
detail_offset: self.detail_buffer.len() as int,
};
debug!("Adding entry[off={}] for detailed glyphs: {:?}", entry_offset, glyphs);
debug!("Adding entry[off={}] for detailed glyphs: {}", entry_offset, glyphs);
/* TODO: don't actually assert this until asserts are compiled
in/out based on severity, debug/release, etc. This assertion
@ -563,7 +563,7 @@ impl<'a> GlyphStore {
}
}.adapt_character_flags_of_entry(self.entry_buffer[i.to_uint()]);
*self.entry_buffer.get_mut(i.to_uint()) = entry;
self.entry_buffer[i.to_uint()] = entry;
}
pub fn add_glyphs_for_char_index(&mut self, i: CharIndex, data_for_glyphs: &[GlyphData]) {
@ -589,9 +589,9 @@ impl<'a> GlyphStore {
}
}.adapt_character_flags_of_entry(self.entry_buffer[i.to_uint()]);
debug!("Adding multiple glyphs[idx={}, count={}]: {:?}", i, glyph_count, entry);
debug!("Adding multiple glyphs[idx={}, count={}]: {}", i, glyph_count, entry);
*self.entry_buffer.get_mut(i.to_uint()) = entry;
self.entry_buffer[i.to_uint()] = entry;
}
// used when a character index has no associated glyph---for example, a ligature continuation.
@ -601,7 +601,7 @@ impl<'a> GlyphStore {
let entry = GlyphEntry::complex(cluster_start, ligature_start, 0);
debug!("adding spacer for chracter without associated glyph[idx={}]", i);
*self.entry_buffer.get_mut(i.to_uint()) = entry;
self.entry_buffer[i.to_uint()] = entry;
}
pub fn iter_glyphs_for_char_index(&'a self, i: CharIndex) -> GlyphIterator<'a> {
@ -611,10 +611,10 @@ impl<'a> GlyphStore {
#[inline]
pub fn iter_glyphs_for_char_range(&'a self, rang: &Range<CharIndex>) -> GlyphIterator<'a> {
if rang.begin() >= self.char_len() {
fail!("iter_glyphs_for_range: range.begin beyond length!");
panic!("iter_glyphs_for_range: range.begin beyond length!");
}
if rang.end() > self.char_len() {
fail!("iter_glyphs_for_range: range.end beyond length!");
panic!("iter_glyphs_for_range: range.end beyond length!");
}
GlyphIterator {
@ -666,25 +666,25 @@ impl<'a> GlyphStore {
pub fn set_char_is_space(&mut self, i: CharIndex) {
assert!(i < self.char_len());
let entry = self.entry_buffer[i.to_uint()];
*self.entry_buffer.get_mut(i.to_uint()) = entry.set_char_is_space();
self.entry_buffer[i.to_uint()] = entry.set_char_is_space();
}
pub fn set_char_is_tab(&mut self, i: CharIndex) {
assert!(i < self.char_len());
let entry = self.entry_buffer[i.to_uint()];
*self.entry_buffer.get_mut(i.to_uint()) = entry.set_char_is_tab();
self.entry_buffer[i.to_uint()] = entry.set_char_is_tab();
}
pub fn set_char_is_newline(&mut self, i: CharIndex) {
assert!(i < self.char_len());
let entry = self.entry_buffer[i.to_uint()];
*self.entry_buffer.get_mut(i.to_uint()) = entry.set_char_is_newline();
self.entry_buffer[i.to_uint()] = entry.set_char_is_newline();
}
pub fn set_can_break_before(&mut self, i: CharIndex, t: BreakType) {
assert!(i < self.char_len());
let entry = self.entry_buffer[i.to_uint()];
*self.entry_buffer.get_mut(i.to_uint()) = entry.set_can_break_before(t);
self.entry_buffer[i.to_uint()] = entry.set_can_break_before(t);
}
}

View File

@ -249,7 +249,7 @@ impl Shaper {
} else {
byte_to_glyph = Vec::from_elem(byte_max as uint, CONTINUATION_BYTE);
for (i, _) in text.char_indices() {
*byte_to_glyph.get_mut(i) = NO_GLYPH;
byte_to_glyph[i] = NO_GLYPH;
}
}
@ -259,7 +259,7 @@ impl Shaper {
let loc = glyph_data.byte_offset_of_glyph(i);
if loc < byte_max {
assert!(byte_to_glyph[loc as uint] != CONTINUATION_BYTE);
*byte_to_glyph.get_mut(loc as uint) = i as i32;
byte_to_glyph[loc as uint] = i as i32;
} else {
debug!("ERROR: tried to set out of range byte_to_glyph: idx={}, glyph idx={}",
loc,
@ -271,7 +271,7 @@ impl Shaper {
debug!("text: {:s}", text);
debug!("(char idx): char->(glyph index):");
for (i, ch) in text.char_indices() {
debug!("{}: {} --> {:d}", i, ch, *byte_to_glyph.get(i) as int);
debug!("{}: {} --> {:d}", i, ch, *byte_to_glyph.get(i).unwrap() as int);
}
// some helpers

View File

@ -238,9 +238,9 @@ impl<'a> TextRun {
}
pub fn min_width_for_range(&self, range: &Range<CharIndex>) -> Au {
debug!("iterating outer range {:?}", range);
debug!("iterating outer range {}", range);
self.iter_slices_for_range(range).fold(Au(0), |max_piece_width, (_, offset, slice_range)| {
debug!("iterated on {:?}[{:?}]", offset, slice_range);
debug!("iterated on {}[{}]", offset, slice_range);
Au::max(max_piece_width, self.advance_for_range(&slice_range))
})
}

View File

@ -48,7 +48,7 @@ pub fn transform_text(text: &str,
if ch != '\n' {
new_line_index = new_line_index + CharIndex(1);
}
output_text.push_char(ch);
output_text.push(ch);
}
}
text.len() > 0 && is_in_whitespace(text.char_at_reverse(0), mode)
@ -67,14 +67,14 @@ pub fn transform_text(text: &str,
// TODO: record skipped char
} else {
// TODO: record kept char
output_text.push_char(ch);
output_text.push(ch);
}
} else { /* next_in_whitespace; possibly add a space char */
if in_whitespace {
// TODO: record skipped char
} else {
// TODO: record kept char
output_text.push_char(' ');
output_text.push(' ');
}
}
// save whitespace context for next char

View File

@ -25,7 +25,7 @@
//!
//! http://dev.w3.org/csswg/css-sizing/
#![deny(unsafe_block)]
#![deny(unsafe_blocks)]
use construct::FlowConstructor;
use context::LayoutContext;
@ -37,7 +37,7 @@ use flow::{MutableFlowUtils, PreorderFlowTraversal, PostorderFlowTraversal, mut_
use flow;
use fragment::{Fragment, ImageFragment, InlineBlockFragment, FragmentBoundsIterator};
use fragment::ScannedTextFragment;
use incremental::{Reflow, ReflowOutOfFlow};
use incremental::{REFLOW, REFLOW_OUT_OF_FLOW};
use layout_debug;
use model::{Auto, IntrinsicISizes, MarginCollapseInfo, MarginsCollapse, MarginsCollapseThrough};
use model::{MaybeAuto, NoCollapsibleMargins, Specified, specified, specified_or_none};
@ -394,7 +394,7 @@ impl Iterator<MaybeAuto> for CandidateBSizeIterator {
Some(Specified(self.min_block_size))
}
FoundCandidateBSizeStatus => None,
InitialCandidateBSizeStatus => fail!(),
InitialCandidateBSizeStatus => panic!(),
}
}
}
@ -441,7 +441,7 @@ impl<'a> PreorderFlowTraversal for AbsoluteAssignBSizesTraversal<'a> {
}
assert!(block_flow.base.flags.is_absolutely_positioned());
if !block_flow.base.restyle_damage.intersects(ReflowOutOfFlow | Reflow) {
if !block_flow.base.restyle_damage.intersects(REFLOW_OUT_OF_FLOW | REFLOW) {
return
}
@ -551,7 +551,7 @@ pub struct BlockFlow {
bitflags! {
flags BlockFlowFlags: u8 {
#[doc="If this is set, then this block flow is the root flow."]
static IsRoot = 0x01,
const IS_ROOT = 0x01,
}
}
@ -787,7 +787,7 @@ impl BlockFlow {
}
let (block_start_margin_value, block_end_margin_value) = match self.base.collapsible_margins {
MarginsCollapseThrough(_) => fail!("Margins unexpectedly collapsed through root flow."),
MarginsCollapseThrough(_) => panic!("Margins unexpectedly collapsed through root flow."),
MarginsCollapse(block_start_margin, block_end_margin) => {
(block_start_margin.collapse(), block_end_margin.collapse())
}
@ -827,7 +827,7 @@ impl BlockFlow {
margins_may_collapse: MarginsMayCollapseFlag) {
let _scope = layout_debug_scope!("assign_block_size_block_base {:x}", self.base.debug_id());
if self.base.restyle_damage.contains(Reflow) {
if self.base.restyle_damage.contains(REFLOW) {
// Our current border-box position.
let mut cur_b = Au(0);
@ -1064,7 +1064,7 @@ impl BlockFlow {
// size has not yet been computed. (See `assign_inline_position_for_formatting_context()`.)
if !self.base.flags.is_absolutely_positioned() &&
self.formatting_context_type() == NonformattingContext {
self.base.restyle_damage.remove(ReflowOutOfFlow | Reflow);
self.base.restyle_damage.remove(REFLOW_OUT_OF_FLOW | REFLOW);
}
}
@ -1213,7 +1213,7 @@ impl BlockFlow {
self.fragment.border_box.size.block = block_size;
self.base.position.size.block = block_size;
self.base.restyle_damage.remove(ReflowOutOfFlow | Reflow);
self.base.restyle_damage.remove(REFLOW_OUT_OF_FLOW | REFLOW);
}
// Our inline-size was set to the inline-size of the containing block by the flow's parent.
@ -1405,7 +1405,7 @@ impl BlockFlow {
fn assign_inline_position_for_formatting_context(&mut self) {
debug_assert!(self.formatting_context_type() != NonformattingContext);
if !self.base.restyle_damage.intersects(ReflowOutOfFlow | Reflow) {
if !self.base.restyle_damage.intersects(REFLOW_OUT_OF_FLOW | REFLOW) {
return
}
@ -1538,7 +1538,7 @@ impl Flow for BlockFlow {
fn assign_inline_sizes(&mut self, layout_context: &LayoutContext) {
let _scope = layout_debug_scope!("block::assign_inline_sizes {:x}", self.base.debug_id());
if !self.base.restyle_damage.intersects(ReflowOutOfFlow | Reflow) {
if !self.base.restyle_damage.intersects(REFLOW_OUT_OF_FLOW | REFLOW) {
return
}
@ -1619,7 +1619,7 @@ impl Flow for BlockFlow {
}
if self.base.flags.impacted_by_floats() {
if self.base.restyle_damage.intersects(ReflowOutOfFlow | Reflow) {
if self.base.restyle_damage.intersects(REFLOW_OUT_OF_FLOW | REFLOW) {
self.assign_block_size(layout_context);
// Don't remove the restyle damage; `assign_block_size` decides whether that is
// appropriate (which in the case of e.g. absolutely-positioned flows, it is not).
@ -1731,7 +1731,7 @@ impl Flow for BlockFlow {
}
fn mark_as_root(&mut self) {
self.flags.insert(IsRoot)
self.flags.insert(IS_ROOT)
}
/// Return true if store overflow is delayed for this flow.
@ -1742,7 +1742,7 @@ impl Flow for BlockFlow {
}
fn is_root(&self) -> bool {
self.flags.contains(IsRoot)
self.flags.contains(IS_ROOT)
}
fn is_float(&self) -> bool {
@ -2325,7 +2325,7 @@ impl ISizeAndMarginsComputer for AbsoluteReplaced {
let inline_size = match computed_inline_size {
Specified(w) => w,
_ => fail!("{} {}",
_ => panic!("{} {}",
"The used value for inline_size for absolute replaced flow",
"should have already been calculated by now.")
};
@ -2436,7 +2436,7 @@ impl ISizeAndMarginsComputer for BlockReplaced {
-> ISizeConstraintSolution {
match input.computed_inline_size {
Specified(_) => {},
Auto => fail!("BlockReplaced: inline_size should have been computed by now")
Auto => panic!("BlockReplaced: inline_size should have been computed by now")
};
self.solve_block_inline_size_constraints(block, input)
}
@ -2491,7 +2491,7 @@ impl ISizeAndMarginsComputer for FloatReplaced {
let margin_inline_end = inline_end_margin.specified_or_zero();
let inline_size = match computed_inline_size {
Specified(w) => w,
Auto => fail!("FloatReplaced: inline_size should have been computed by now")
Auto => panic!("FloatReplaced: inline_size should have been computed by now")
};
debug!("assign_inline_sizes_float -- inline_size: {}", inline_size);
ISizeConstraintSolution::new(inline_size, margin_inline_start, margin_inline_end)

View File

@ -11,7 +11,7 @@
//! maybe it's an absolute or fixed position thing that hasn't found its containing block yet.
//! Construction items bubble up the tree from children to parents until they find their homes.
#![deny(unsafe_block)]
#![deny(unsafe_blocks)]
use css::node_style::StyledNode;
use block::BlockFlow;
@ -27,7 +27,7 @@ use fragment::{InlineAbsoluteHypotheticalFragmentInfo, InlineBlockFragment};
use fragment::{InlineBlockFragmentInfo, SpecificFragmentInfo, TableCellFragment};
use fragment::{TableColumnFragment, TableColumnFragmentInfo, TableFragment, TableRowFragment};
use fragment::{TableWrapperFragment, UnscannedTextFragment, UnscannedTextFragmentInfo};
use incremental::{ReconstructFlow, RestyleDamage};
use incremental::{RECONSTRUCT_FLOW, RestyleDamage};
use inline::InlineFlow;
use parallel;
use table_wrapper::TableWrapperFlow;
@ -38,7 +38,7 @@ use table_rowgroup::TableRowGroupFlow;
use table_row::TableRowFlow;
use table_cell::TableCellFlow;
use text::TextRunScanner;
use util::{HasNewlyConstructedFlow, LayoutDataAccess, OpaqueNodeMethods, LayoutDataWrapper};
use util::{HAS_NEWLY_CONSTRUCTED_FLOW, LayoutDataAccess, OpaqueNodeMethods, LayoutDataWrapper};
use wrapper::{PostorderNodeMutTraversal, TLayoutNode, ThreadSafeLayoutNode};
use wrapper::{Before, After, Normal};
@ -53,9 +53,9 @@ use script::dom::node::{DocumentNodeTypeId, ElementNodeTypeId, ProcessingInstruc
use script::dom::node::{TextNodeTypeId};
use script::dom::htmlobjectelement::is_image_data;
use servo_util::opts;
use std::collections::{DList, Deque};
use std::collections::DList;
use std::mem;
use std::sync::atomics::Relaxed;
use std::sync::atomic::Relaxed;
use style::ComputedValues;
use style::computed_values::{display, position, float};
use sync::Arc;
@ -193,7 +193,7 @@ impl InlineFragmentsAccumulator {
fn to_dlist(self) -> DList<Fragment> {
let InlineFragmentsAccumulator {
fragments: mut fragments,
mut fragments,
enclosing_style
} = self;
@ -403,7 +403,7 @@ impl<'a> FlowConstructor<'a> {
}
ConstructionItemConstructionResult(InlineFragmentsConstructionItem(
InlineFragmentsConstructionResult {
splits: splits,
splits,
fragments: successor_fragments,
abs_descendants: kid_abs_descendants,
})) => {
@ -412,7 +412,7 @@ impl<'a> FlowConstructor<'a> {
// Pull apart the {ib} split object and push its predecessor fragments
// onto the list.
let InlineBlockSplit {
predecessors: predecessors,
predecessors,
flow: kid_flow
} = split;
inline_fragment_accumulator.push_all(predecessors);
@ -461,7 +461,7 @@ impl<'a> FlowConstructor<'a> {
whitespace_style,
whitespace_damage,
fragment_info);
inline_fragment_accumulator.fragments.push(fragment);
inline_fragment_accumulator.fragments.push_back(fragment);
}
ConstructionItemConstructionResult(TableColumnFragmentConstructionItem(_)) => {
// TODO: Implement anonymous table objects for missing parents
@ -490,7 +490,7 @@ impl<'a> FlowConstructor<'a> {
node.type_id() == Some(ElementNodeTypeId(HTMLInputElementTypeId)) {
let fragment_info = UnscannedTextFragment(UnscannedTextFragmentInfo::new(node));
let fragment = Fragment::new_from_specific_info(node, fragment_info);
inline_fragment_accumulator.fragments.push(fragment);
inline_fragment_accumulator.fragments.push_back(fragment);
first_fragment = false;
}
@ -586,12 +586,12 @@ impl<'a> FlowConstructor<'a> {
InlineFragmentsAccumulator::from_inline_node(node)).to_dlist(),
flow: flow,
};
opt_inline_block_splits.push(split);
opt_inline_block_splits.push_back(split);
abs_descendants.push_descendants(kid_abs_descendants);
}
ConstructionItemConstructionResult(InlineFragmentsConstructionItem(
InlineFragmentsConstructionResult {
splits: splits,
splits,
fragments: successors,
abs_descendants: kid_abs_descendants,
})) => {
@ -599,7 +599,7 @@ impl<'a> FlowConstructor<'a> {
// Bubble up {ib} splits.
for split in splits.into_iter() {
let InlineBlockSplit {
predecessors: predecessors,
predecessors,
flow: kid_flow
} = split;
fragment_accumulator.push_all(predecessors);
@ -611,7 +611,7 @@ impl<'a> FlowConstructor<'a> {
.to_dlist(),
flow: kid_flow,
};
opt_inline_block_splits.push(split)
opt_inline_block_splits.push_back(split)
}
// Push residual fragments.
@ -629,7 +629,7 @@ impl<'a> FlowConstructor<'a> {
whitespace_style,
whitespace_damage,
fragment_info);
fragment_accumulator.fragments.push(fragment)
fragment_accumulator.fragments.push_back(fragment)
}
ConstructionItemConstructionResult(TableColumnFragmentConstructionItem(_)) => {
// TODO: Implement anonymous table objects for missing parents
@ -684,7 +684,7 @@ impl<'a> FlowConstructor<'a> {
};
let mut fragments = DList::new();
fragments.push(fragment);
fragments.push_back(fragment);
let construction_item = InlineFragmentsConstructionItem(InlineFragmentsConstructionResult {
splits: DList::new(),
@ -706,7 +706,7 @@ impl<'a> FlowConstructor<'a> {
let fragment = Fragment::new_from_specific_info(node, fragment_info);
let mut fragment_accumulator = InlineFragmentsAccumulator::from_inline_node(node);
fragment_accumulator.fragments.push(fragment);
fragment_accumulator.fragments.push_back(fragment);
let construction_item = InlineFragmentsConstructionItem(InlineFragmentsConstructionResult {
splits: DList::new(),
@ -731,7 +731,7 @@ impl<'a> FlowConstructor<'a> {
let fragment = Fragment::new_from_specific_info(node, fragment_info);
let mut fragment_accumulator = InlineFragmentsAccumulator::from_inline_node(node);
fragment_accumulator.fragments.push(fragment);
fragment_accumulator.fragments.push_back(fragment);
let construction_item = InlineFragmentsConstructionItem(InlineFragmentsConstructionResult {
splits: DList::new(),
@ -949,14 +949,14 @@ impl<'a> FlowConstructor<'a> {
pub fn repair_if_possible(&mut self, node: &ThreadSafeLayoutNode) -> bool {
// We can skip reconstructing the flow if we don't have to reconstruct and none of our kids
// did either.
if node.restyle_damage().contains(ReconstructFlow) {
if node.restyle_damage().contains(RECONSTRUCT_FLOW) {
return false
}
let mut need_to_reconstruct = false;
for kid in node.children() {
if kid.flags().contains(HasNewlyConstructedFlow) {
kid.remove_flags(HasNewlyConstructedFlow);
if kid.flags().contains(HAS_NEWLY_CONSTRUCTED_FLOW) {
kid.remove_flags(HAS_NEWLY_CONSTRUCTED_FLOW);
need_to_reconstruct = true
}
}
@ -1020,7 +1020,7 @@ impl<'a> PostorderNodeMutTraversal for FlowConstructor<'a> {
}
};
debug!("building flow for node: {:?} {:?}", display, float);
debug!("building flow for node: {} {}", display, float);
// Switch on display and floatedness.
match (display, float, positioning) {
@ -1124,7 +1124,7 @@ impl<'a> PostorderNodeMutTraversal for FlowConstructor<'a> {
}
}
node.insert_flags(HasNewlyConstructedFlow);
node.insert_flags(HAS_NEWLY_CONSTRUCTED_FLOW);
true
}
}
@ -1285,7 +1285,7 @@ pub fn strip_ignorable_whitespace_from_end(this: &mut DList<Fragment>) {
while !this.is_empty() && this.back().as_ref().unwrap().is_ignorable_whitespace() {
debug!("stripping ignorable whitespace from end");
drop(this.pop());
drop(this.pop_back());
}
}

View File

@ -602,7 +602,7 @@ impl<'ln> MatchMethods for LayoutNode<'ln> {
let mut layout_data_ref = self.mutate_layout_data();
match &mut *layout_data_ref {
&None => fail!("no layout data"),
&None => panic!("no layout data"),
&Some(ref mut layout_data) => {
match self.type_id() {
Some(TextNodeTypeId) => {

View File

@ -8,7 +8,7 @@
//! list building, as the actual painting does not happen here—only deciding *what* we're going to
//! paint.
#![deny(unsafe_block)]
#![deny(unsafe_blocks)]
use block::BlockFlow;
use context::LayoutContext;
@ -578,8 +578,8 @@ impl FragmentDisplayListBuilding for Fragment {
// Create special per-fragment-type display items.
match self.specific {
UnscannedTextFragment(_) => fail!("Shouldn't see unscanned fragments here."),
TableColumnFragment(_) => fail!("Shouldn't see table column fragments here."),
UnscannedTextFragment(_) => panic!("Shouldn't see unscanned fragments here."),
TableColumnFragment(_) => panic!("Shouldn't see table column fragments here."),
ScannedTextFragment(ref text_fragment) => {
// Create the text display item.
let orientation = if self.style.writing_mode.is_vertical() {
@ -733,7 +733,7 @@ impl FragmentDisplayListBuilding for Fragment {
Size2D(geometry::to_frac_px(content_size.width) as f32,
geometry::to_frac_px(content_size.height) as f32));
debug!("finalizing position and size of iframe for {:?},{:?}",
debug!("finalizing position and size of iframe for {},{}",
iframe_fragment.pipeline_id,
iframe_fragment.subpage_id);
let ConstellationChan(ref chan) = layout_context.shared.constellation_chan;
@ -841,7 +841,7 @@ impl BlockFlowDisplayListBuilding for BlockFlow {
background_color: color::rgba(1.0, 1.0, 1.0, 0.0),
scroll_policy: scroll_policy,
};
self.base.layers.push(new_layer)
self.base.layers.push_back(new_layer)
}
fn build_display_list_for_floating_block(&mut self, layout_context: &LayoutContext) {

View File

@ -21,7 +21,7 @@ pub enum FloatKind {
impl FloatKind {
pub fn from_property(property: float::T) -> FloatKind {
match property {
float::none => fail!("can't create a float type from an unfloated property"),
float::none => panic!("can't create a float type from an unfloated property"),
float::left => FloatLeft,
float::right => FloatRight,
}
@ -46,7 +46,7 @@ struct Float {
impl fmt::Show for Float {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "bounds={} kind={:?}", self.bounds, self.kind)
write!(f, "bounds={} kind={}", self.bounds, self.kind)
}
}
@ -95,7 +95,7 @@ pub struct PlacementInfo {
impl fmt::Show for PlacementInfo {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f,
"size={} ceiling={} max_inline_size={} kind={:?}",
"size={} ceiling={} max_inline_size={} kind={}",
self.size,
self.ceiling,
self.max_inline_size,
@ -232,7 +232,7 @@ impl Floats {
(max(block_start, r_block_start), r_block_end)
}
(None, None, None, None) => return None,
_ => fail!("Reached unreachable state when computing float area")
_ => panic!("Reached unreachable state when computing float area")
};
// FIXME(eatkinson): This assertion is too strong and fails in some cases. It is OK to
@ -261,7 +261,7 @@ impl Floats {
}
}
debug!("add_float: added float with info {:?}", new_info);
debug!("add_float: added float with info {}", new_info);
let new_float = Float {
bounds: LogicalRect::from_point_size(
@ -332,7 +332,7 @@ impl Floats {
let maybe_location = self.available_rect(float_b,
info.size.block,
info.max_inline_size);
debug!("place_float: Got available rect: {:?} for y-pos: {}", maybe_location, float_b);
debug!("place_float: Got available rect: {} for y-pos: {}", maybe_location, float_b);
match maybe_location {
// If there are no floats blocking us, return the current location
// TODO(eatkinson): integrate with overflow

View File

@ -32,7 +32,7 @@ use floats::Floats;
use flow_list::{FlowList, FlowListIterator, MutFlowListIterator};
use flow_ref::FlowRef;
use fragment::{Fragment, FragmentBoundsIterator, TableRowFragment, TableCellFragment};
use incremental::{ReconstructFlow, Reflow, ReflowOutOfFlow, RestyleDamage};
use incremental::{RECONSTRUCT_FLOW, REFLOW, REFLOW_OUT_OF_FLOW, RestyleDamage};
use inline::InlineFlow;
use model::{CollapsibleMargins, IntrinsicISizes, MarginCollapseInfo};
use parallel::FlowParallelInfo;
@ -59,7 +59,7 @@ use std::num::Zero;
use std::fmt;
use std::iter::Zip;
use std::raw;
use std::sync::atomics::{AtomicUint, SeqCst};
use std::sync::atomic::{AtomicUint, SeqCst};
use std::slice::MutItems;
use style::computed_values::{clear, float, position, text_align};
use style::ComputedValues;
@ -80,94 +80,94 @@ pub trait Flow: fmt::Show + ToString + Sync {
/// If this is a block flow, returns the underlying object, borrowed immutably. Fails
/// otherwise.
fn as_immutable_block<'a>(&'a self) -> &'a BlockFlow {
fail!("called as_immutable_block() on a non-block flow")
panic!("called as_immutable_block() on a non-block flow")
}
/// If this is a block flow, returns the underlying object. Fails otherwise.
fn as_block<'a>(&'a mut self) -> &'a mut BlockFlow {
debug!("called as_block() on a flow of type {}", self.class());
fail!("called as_block() on a non-block flow")
panic!("called as_block() on a non-block flow")
}
/// If this is an inline flow, returns the underlying object, borrowed immutably. Fails
/// otherwise.
fn as_immutable_inline<'a>(&'a self) -> &'a InlineFlow {
fail!("called as_immutable_inline() on a non-inline flow")
panic!("called as_immutable_inline() on a non-inline flow")
}
/// If this is an inline flow, returns the underlying object. Fails otherwise.
fn as_inline<'a>(&'a mut self) -> &'a mut InlineFlow {
fail!("called as_inline() on a non-inline flow")
panic!("called as_inline() on a non-inline flow")
}
/// If this is a table wrapper flow, returns the underlying object. Fails otherwise.
fn as_table_wrapper<'a>(&'a mut self) -> &'a mut TableWrapperFlow {
fail!("called as_table_wrapper() on a non-tablewrapper flow")
panic!("called as_table_wrapper() on a non-tablewrapper flow")
}
/// If this is a table wrapper flow, returns the underlying object, borrowed immutably. Fails
/// otherwise.
fn as_immutable_table_wrapper<'a>(&'a self) -> &'a TableWrapperFlow {
fail!("called as_immutable_table_wrapper() on a non-tablewrapper flow")
panic!("called as_immutable_table_wrapper() on a non-tablewrapper flow")
}
/// If this is a table flow, returns the underlying object. Fails otherwise.
fn as_table<'a>(&'a mut self) -> &'a mut TableFlow {
fail!("called as_table() on a non-table flow")
panic!("called as_table() on a non-table flow")
}
/// If this is a table flow, returns the underlying object, borrowed immutably. Fails otherwise.
fn as_immutable_table<'a>(&'a self) -> &'a TableFlow {
fail!("called as_table() on a non-table flow")
panic!("called as_table() on a non-table flow")
}
/// If this is a table colgroup flow, returns the underlying object. Fails otherwise.
fn as_table_colgroup<'a>(&'a mut self) -> &'a mut TableColGroupFlow {
fail!("called as_table_colgroup() on a non-tablecolgroup flow")
panic!("called as_table_colgroup() on a non-tablecolgroup flow")
}
/// If this is a table rowgroup flow, returns the underlying object. Fails otherwise.
fn as_table_rowgroup<'a>(&'a mut self) -> &'a mut TableRowGroupFlow {
fail!("called as_table_rowgroup() on a non-tablerowgroup flow")
panic!("called as_table_rowgroup() on a non-tablerowgroup flow")
}
/// If this is a table rowgroup flow, returns the underlying object, borrowed immutably. Fails
/// otherwise.
fn as_immutable_table_rowgroup<'a>(&'a self) -> &'a TableRowGroupFlow {
fail!("called as_table_rowgroup() on a non-tablerowgroup flow")
panic!("called as_table_rowgroup() on a non-tablerowgroup flow")
}
/// If this is a table row flow, returns the underlying object. Fails otherwise.
fn as_table_row<'a>(&'a mut self) -> &'a mut TableRowFlow {
fail!("called as_table_row() on a non-tablerow flow")
panic!("called as_table_row() on a non-tablerow flow")
}
/// If this is a table row flow, returns the underlying object, borrowed immutably. Fails
/// otherwise.
fn as_immutable_table_row<'a>(&'a self) -> &'a TableRowFlow {
fail!("called as_table_row() on a non-tablerow flow")
panic!("called as_table_row() on a non-tablerow flow")
}
/// If this is a table cell flow, returns the underlying object. Fails otherwise.
fn as_table_caption<'a>(&'a mut self) -> &'a mut TableCaptionFlow {
fail!("called as_table_caption() on a non-tablecaption flow")
panic!("called as_table_caption() on a non-tablecaption flow")
}
/// If this is a table cell flow, returns the underlying object. Fails otherwise.
fn as_table_cell<'a>(&'a mut self) -> &'a mut TableCellFlow {
fail!("called as_table_cell() on a non-tablecell flow")
panic!("called as_table_cell() on a non-tablecell flow")
}
/// If this is a table cell flow, returns the underlying object, borrowed immutably. Fails
/// otherwise.
fn as_immutable_table_cell<'a>(&'a self) -> &'a TableCellFlow {
fail!("called as_table_cell() on a non-tablecell flow")
panic!("called as_table_cell() on a non-tablecell flow")
}
/// If this is a table row or table rowgroup or table flow, returns column inline-sizes.
/// Fails otherwise.
fn column_inline_sizes<'a>(&'a mut self) -> &'a mut Vec<ColumnInlineSize> {
fail!("called column_inline_sizes() on non-table flow")
panic!("called column_inline_sizes() on non-table flow")
}
// Main methods
@ -179,17 +179,17 @@ pub trait Flow: fmt::Show + ToString + Sync {
/// This function must decide minimum/preferred inline-sizes based on its children's inline-
/// sizes and the dimensions of any boxes it is responsible for flowing.
fn bubble_inline_sizes(&mut self) {
fail!("bubble_inline_sizes not yet implemented")
panic!("bubble_inline_sizes not yet implemented")
}
/// Pass 2 of reflow: computes inline-size.
fn assign_inline_sizes(&mut self, _ctx: &LayoutContext) {
fail!("assign_inline_sizes not yet implemented")
panic!("assign_inline_sizes not yet implemented")
}
/// Pass 3a of reflow: computes block-size.
fn assign_block_size<'a>(&mut self, _ctx: &'a LayoutContext<'a>) {
fail!("assign_block_size not yet implemented")
panic!("assign_block_size not yet implemented")
}
/// Assigns block-sizes in-order; or, if this is a float, places the float. The default
@ -201,7 +201,7 @@ pub trait Flow: fmt::Show + ToString + Sync {
let impacted = base(&*self).flags.impacted_by_floats();
if impacted {
self.assign_block_size(layout_context);
mut_base(&mut *self).restyle_damage.remove(ReflowOutOfFlow | Reflow);
mut_base(&mut *self).restyle_damage.remove(REFLOW_OUT_OF_FLOW | REFLOW);
}
impacted
}
@ -285,7 +285,7 @@ pub trait Flow: fmt::Show + ToString + Sync {
/// Return the dimensions of the containing block generated by this flow for absolutely-
/// positioned descendants. For block flows, this is the padding box.
fn generated_containing_block_rect(&self) -> LogicalRect<Au> {
fail!("generated_containing_block_position not yet implemented for this flow")
panic!("generated_containing_block_position not yet implemented for this flow")
}
/// Returns a layer ID for the given fragment.
@ -301,26 +301,6 @@ pub trait Flow: fmt::Show + ToString + Sync {
fn repair_style(&mut self, new_style: &Arc<ComputedValues>);
}
impl<'a, E, S: Encoder<E>> Encodable<S, E> for &'a Flow + 'a {
fn encode(&self, e: &mut S) -> Result<(), E> {
e.emit_struct("flow", 0, |e| {
try!(e.emit_struct_field("class", 0, |e| self.class().encode(e)))
e.emit_struct_field("data", 1, |e| {
match self.class() {
BlockFlowClass => self.as_immutable_block().encode(e),
InlineFlowClass => self.as_immutable_inline().encode(e),
TableFlowClass => self.as_immutable_table().encode(e),
TableWrapperFlowClass => self.as_immutable_table_wrapper().encode(e),
TableRowGroupFlowClass => self.as_immutable_table_rowgroup().encode(e),
TableRowFlowClass => self.as_immutable_table_row().encode(e),
TableCellFlowClass => self.as_immutable_table_cell().encode(e),
_ => { Ok(()) } // TODO: Support captions
}
})
})
}
}
// Base access
#[inline(always)]
@ -832,7 +812,24 @@ impl<E, S: Encoder<E>> Encodable<S, E> for BaseFlow {
e.emit_struct_field("children", 4, |e| {
e.emit_seq(self.children.len(), |e| {
for (i, c) in self.children.iter().enumerate() {
try!(e.emit_seq_elt(i, |e| c.encode(e)))
try!(e.emit_seq_elt(i, |e| {
try!(e.emit_struct("flow", 0, |e| {
try!(e.emit_struct_field("class", 0, |e| c.class().encode(e)))
e.emit_struct_field("data", 1, |e| {
match c.class() {
BlockFlowClass => c.as_immutable_block().encode(e),
InlineFlowClass => c.as_immutable_inline().encode(e),
TableFlowClass => c.as_immutable_table().encode(e),
TableWrapperFlowClass => c.as_immutable_table_wrapper().encode(e),
TableRowGroupFlowClass => c.as_immutable_table_rowgroup().encode(e),
TableRowFlowClass => c.as_immutable_table_row().encode(e),
TableCellFlowClass => c.as_immutable_table_cell().encode(e),
_ => { Ok(()) } // TODO: Support captions
}
})
}))
Ok(())
}))
}
Ok(())
})
@ -846,7 +843,7 @@ impl<E, S: Encoder<E>> Encodable<S, E> for BaseFlow {
impl Drop for BaseFlow {
fn drop(&mut self) {
if self.ref_count.load(SeqCst) != 0 {
fail!("Flow destroyed before its ref count hit zero—this is unsafe!")
panic!("Flow destroyed before its ref count hit zero—this is unsafe!")
}
}
}
@ -884,7 +881,7 @@ impl BaseFlow {
// New flows start out as fully damaged.
let mut damage = RestyleDamage::all();
damage.remove(ReconstructFlow);
damage.remove(RECONSTRUCT_FLOW);
BaseFlow {
ref_count: AtomicUint::new(1),
@ -1057,7 +1054,7 @@ impl<'a> ImmutableFlowUtils for &'a Flow + 'a {
box TableCellFlow::from_node_and_fragment(node, fragment) as Box<Flow>
},
_ => {
fail!("no need to generate a missing child")
panic!("no need to generate a missing child")
}
};
FlowRef::new(flow)
@ -1283,7 +1280,7 @@ impl ContainingBlockLink {
#[inline]
pub fn generated_containing_block_rect(&mut self) -> LogicalRect<Au> {
match self.link {
None => fail!("haven't done it"),
None => panic!("haven't done it"),
Some(ref mut link) => link.generated_containing_block_rect(),
}
}

View File

@ -5,7 +5,7 @@
use flow::Flow;
use flow_ref::FlowRef;
use std::collections::{Deque, dlist, DList};
use std::collections::{dlist, DList};
// This needs to be reworked now that we have dynamically-sized types in Rust.
// Until then, it's just a wrapper around DList.
@ -22,19 +22,6 @@ pub struct MutFlowListIterator<'a> {
it: dlist::MutItems<'a, FlowRef>,
}
impl Collection for FlowList {
/// O(1)
#[inline]
fn is_empty(&self) -> bool {
self.flows.is_empty()
}
/// O(1)
#[inline]
fn len(&self) -> uint {
self.flows.len()
}
}
impl FlowList {
/// Provide a reference to the front element, or None if the list is empty
#[inline]
@ -78,7 +65,7 @@ impl FlowList {
///
/// O(1)
pub fn push_back(&mut self, new_tail: FlowRef) {
self.flows.push(new_tail);
self.flows.push_back(new_tail);
}
/// Create an empty list
@ -104,6 +91,18 @@ impl FlowList {
it: self.flows.iter_mut(),
}
}
/// O(1)
#[inline]
pub fn is_empty(&self) -> bool {
self.flows.is_empty()
}
/// O(1)
#[inline]
pub fn len(&self) -> uint {
self.flows.len()
}
}
impl<'a> Iterator<&'a Flow + 'a> for FlowListIterator<'a> {

View File

@ -12,7 +12,7 @@ use flow;
use std::mem;
use std::ptr;
use std::raw;
use std::sync::atomics::SeqCst;
use std::sync::atomic::SeqCst;
#[unsafe_no_drop_flag]
pub struct FlowRef {
@ -33,18 +33,18 @@ impl FlowRef {
}
}
impl Deref<Flow + 'static> for FlowRef {
fn deref<'a>(&'a self) -> &'a Flow + 'static {
impl<'a> Deref<Flow + 'a> for FlowRef {
fn deref(&self) -> &Flow + 'a {
unsafe {
mem::transmute_copy::<raw::TraitObject, &'a Flow + 'static>(&self.object)
mem::transmute_copy::<raw::TraitObject, &Flow + 'a>(&self.object)
}
}
}
impl DerefMut<Flow + 'static> for FlowRef {
fn deref_mut<'a>(&'a mut self) -> &'a mut Flow + 'static {
impl<'a> DerefMut<Flow + 'a> for FlowRef {
fn deref_mut<'a>(&mut self) -> &mut Flow + 'a {
unsafe {
mem::transmute_copy::<raw::TraitObject, &'a mut Flow + 'static>(&self.object)
mem::transmute_copy::<raw::TraitObject, &mut Flow + 'a>(&self.object)
}
}
}

View File

@ -4,7 +4,7 @@
//! The `Fragment` type, which represents the leaves of the layout tree.
#![deny(unsafe_block)]
#![deny(unsafe_blocks)]
use css::node_style::StyledNode;
use construct::FlowConstructor;
@ -639,18 +639,18 @@ impl Fragment {
QuantitiesIncludedInIntrinsicInlineSizes::all()
}
TableFragment | TableCellFragment => {
IntrinsicInlineSizeIncludesPadding |
IntrinsicInlineSizeIncludesBorder |
IntrinsicInlineSizeIncludesSpecified
INTRINSIC_INLINE_SIZE_INCLUDES_PADDING |
INTRINSIC_INLINE_SIZE_INCLUDES_BORDER |
INTRINSIC_INLINE_SIZE_INCLUDES_SPECIFIED
}
TableWrapperFragment => {
IntrinsicInlineSizeIncludesMargins |
IntrinsicInlineSizeIncludesBorder |
IntrinsicInlineSizeIncludesSpecified
INTRINSIC_INLINE_SIZE_INCLUDES_MARGINS |
INTRINSIC_INLINE_SIZE_INCLUDES_BORDER |
INTRINSIC_INLINE_SIZE_INCLUDES_SPECIFIED
}
TableRowFragment => {
IntrinsicInlineSizeIncludesBorder |
IntrinsicInlineSizeIncludesSpecified
INTRINSIC_INLINE_SIZE_INCLUDES_BORDER |
INTRINSIC_INLINE_SIZE_INCLUDES_SPECIFIED
}
ScannedTextFragment(_) | TableColumnFragment(_) | UnscannedTextFragment(_) |
InlineAbsoluteHypotheticalFragment(_) => {
@ -670,7 +670,7 @@ impl Fragment {
// FIXME(pcwalton): Percentages should be relative to any definite size per CSS-SIZING.
// This will likely need to be done by pushing down definite sizes during selector
// cascading.
let margin = if flags.contains(IntrinsicInlineSizeIncludesMargins) {
let margin = if flags.contains(INTRINSIC_INLINE_SIZE_INCLUDES_MARGINS) {
let margin = style.logical_margin();
(MaybeAuto::from_style(margin.inline_start, Au(0)).specified_or_zero() +
MaybeAuto::from_style(margin.inline_end, Au(0)).specified_or_zero())
@ -681,7 +681,7 @@ impl Fragment {
// FIXME(pcwalton): Percentages should be relative to any definite size per CSS-SIZING.
// This will likely need to be done by pushing down definite sizes during selector
// cascading.
let padding = if flags.contains(IntrinsicInlineSizeIncludesPadding) {
let padding = if flags.contains(INTRINSIC_INLINE_SIZE_INCLUDES_PADDING) {
let padding = style.logical_padding();
(model::specified(padding.inline_start, Au(0)) +
model::specified(padding.inline_end, Au(0)))
@ -689,7 +689,7 @@ impl Fragment {
Au(0)
};
let border = if flags.contains(IntrinsicInlineSizeIncludesBorder) {
let border = if flags.contains(INTRINSIC_INLINE_SIZE_INCLUDES_BORDER) {
self.border_width().inline_start_end()
} else {
Au(0)
@ -703,7 +703,7 @@ impl Fragment {
fn style_specified_intrinsic_inline_size(&self) -> IntrinsicISizesContribution {
let flags = self.quantities_included_in_intrinsic_inline_size();
let style = self.style();
let specified = if flags.contains(IntrinsicInlineSizeIncludesSpecified) {
let specified = if flags.contains(INTRINSIC_INLINE_SIZE_INCLUDES_SPECIFIED) {
MaybeAuto::from_style(style.content_inline_size(), Au(0)).specified_or_zero()
} else {
Au(0)
@ -983,7 +983,7 @@ impl Fragment {
})
}
UnscannedTextFragment(..) => {
fail!("Unscanned text fragments should have been scanned by now!")
panic!("Unscanned text fragments should have been scanned by now!")
}
};
@ -1021,8 +1021,8 @@ impl Fragment {
let text_bounds = run.metrics_for_range(range).bounding_box;
text_bounds.size.width
}
TableColumnFragment(_) => fail!("Table column fragments do not have inline_size"),
UnscannedTextFragment(_) => fail!("Unscanned text fragments should have been scanned by now!"),
TableColumnFragment(_) => panic!("Table column fragments do not have inline_size"),
UnscannedTextFragment(_) => panic!("Unscanned text fragments should have been scanned by now!"),
}
}
@ -1039,8 +1039,8 @@ impl Fragment {
// Compute the block-size based on the line-block-size and font size.
self.calculate_line_height(layout_context)
}
TableColumnFragment(_) => fail!("Table column fragments do not have block_size"),
UnscannedTextFragment(_) => fail!("Unscanned text fragments should have been scanned by now!"),
TableColumnFragment(_) => panic!("Table column fragments do not have block_size"),
UnscannedTextFragment(_) => panic!("Unscanned text fragments should have been scanned by now!"),
}
}
@ -1066,10 +1066,10 @@ impl Fragment {
match self.specific {
GenericFragment | IframeFragment(_) | ImageFragment(_) | TableFragment | TableCellFragment |
TableRowFragment | TableWrapperFragment => None,
TableColumnFragment(_) => fail!("Table column fragments do not need to split"),
UnscannedTextFragment(_) => fail!("Unscanned text fragments should have been scanned by now!"),
TableColumnFragment(_) => panic!("Table column fragments do not need to split"),
UnscannedTextFragment(_) => panic!("Unscanned text fragments should have been scanned by now!"),
InlineBlockFragment(_) | InlineAbsoluteHypotheticalFragment(_) => {
fail!("Inline blocks or inline absolute hypothetical fragments do not get split")
panic!("Inline blocks or inline absolute hypothetical fragments do not get split")
}
ScannedTextFragment(ref text_fragment_info) => {
let mut new_line_pos = text_fragment_info.new_line_pos.clone();
@ -1115,9 +1115,9 @@ impl Fragment {
GenericFragment | IframeFragment(_) | ImageFragment(_) | TableFragment |
TableCellFragment | TableRowFragment | TableWrapperFragment | InlineBlockFragment(_) |
InlineAbsoluteHypotheticalFragment(_) => None,
TableColumnFragment(_) => fail!("Table column fragments do not have inline_size"),
TableColumnFragment(_) => panic!("Table column fragments do not have inline_size"),
UnscannedTextFragment(_) => {
fail!("Unscanned text fragments should have been scanned by now!")
panic!("Unscanned text fragments should have been scanned by now!")
}
ScannedTextFragment(ref text_fragment_info) => {
let mut pieces_processed_count: uint = 0;
@ -1165,7 +1165,7 @@ impl Fragment {
// the inline-end chunk.
let inline_end_range_end = text_fragment_info.range.end() - slice_begin;
inline_end_range = Some(Range::new(slice_begin, inline_end_range_end));
debug!("split_to_inline_size: case=splitting remainder with inline_end range={:?}",
debug!("split_to_inline_size: case=splitting remainder with inline_end range={}",
inline_end_range);
}
}
@ -1218,9 +1218,9 @@ impl Fragment {
match self.specific {
GenericFragment | IframeFragment(_) | TableFragment | TableCellFragment |
TableRowFragment | TableWrapperFragment => return,
TableColumnFragment(_) => fail!("Table column fragments do not have inline_size"),
TableColumnFragment(_) => panic!("Table column fragments do not have inline_size"),
UnscannedTextFragment(_) => {
fail!("Unscanned text fragments should have been scanned by now!")
panic!("Unscanned text fragments should have been scanned by now!")
}
ImageFragment(_) | ScannedTextFragment(_) | InlineBlockFragment(_) |
InlineAbsoluteHypotheticalFragment(_) => {}
@ -1299,7 +1299,7 @@ impl Fragment {
self.border_box.size.inline = inline_size + noncontent_inline_size;
image_fragment_info.computed_inline_size = Some(inline_size);
}
_ => fail!("this case should have been handled above"),
_ => panic!("this case should have been handled above"),
}
}
@ -1311,9 +1311,9 @@ impl Fragment {
match self.specific {
GenericFragment | IframeFragment(_) | TableFragment | TableCellFragment |
TableRowFragment | TableWrapperFragment => return,
TableColumnFragment(_) => fail!("Table column fragments do not have block_size"),
TableColumnFragment(_) => panic!("Table column fragments do not have block_size"),
UnscannedTextFragment(_) => {
fail!("Unscanned text fragments should have been scanned by now!")
panic!("Unscanned text fragments should have been scanned by now!")
}
ImageFragment(_) | ScannedTextFragment(_) | InlineBlockFragment(_) |
InlineAbsoluteHypotheticalFragment(_) => {}
@ -1368,7 +1368,7 @@ impl Fragment {
let block_flow = info.flow_ref.as_block();
self.border_box.size.block = block_flow.base.position.size.block;
}
_ => fail!("should have been handled above"),
_ => panic!("should have been handled above"),
}
}
@ -1501,10 +1501,10 @@ impl fmt::Show for Fragment {
bitflags! {
flags QuantitiesIncludedInIntrinsicInlineSizes: u8 {
static IntrinsicInlineSizeIncludesMargins = 0x01,
static IntrinsicInlineSizeIncludesPadding = 0x02,
static IntrinsicInlineSizeIncludesBorder = 0x04,
static IntrinsicInlineSizeIncludesSpecified = 0x08,
const INTRINSIC_INLINE_SIZE_INCLUDES_MARGINS = 0x01,
const INTRINSIC_INLINE_SIZE_INCLUDES_PADDING = 0x02,
const INTRINSIC_INLINE_SIZE_INCLUDES_BORDER = 0x04,
const INTRINSIC_INLINE_SIZE_INCLUDES_SPECIFIED = 0x08,
}
}

View File

@ -14,25 +14,25 @@ bitflags! {
flags RestyleDamage: u8 {
#[doc = "Repaint the node itself."]
#[doc = "Currently unused; need to decide how this propagates."]
static Repaint = 0x01,
const REPAINT = 0x01,
#[doc = "Recompute intrinsic inline_sizes (minimum and preferred)."]
#[doc = "Propagates down the flow tree because the computation is"]
#[doc = "bottom-up."]
static BubbleISizes = 0x02,
const BUBBLE_ISIZES = 0x02,
#[doc = "Recompute actual inline-sizes and block-sizes, only taking out-of-flow children \
into account. \
Propagates up the flow tree because the computation is top-down."]
static ReflowOutOfFlow = 0x04,
const REFLOW_OUT_OF_FLOW = 0x04,
#[doc = "Recompute actual inline_sizes and block_sizes."]
#[doc = "Propagates up the flow tree because the computation is"]
#[doc = "top-down."]
static Reflow = 0x08,
const REFLOW = 0x08,
#[doc = "The entire flow needs to be reconstructed."]
static ReconstructFlow = 0x10
const RECONSTRUCT_FLOW = 0x10
}
}
@ -40,7 +40,7 @@ bitflags! {
flags SpecialRestyleDamage: u8 {
#[doc="If this flag is set, we need to reflow the entire document. This is more or less a \
temporary hack to deal with cases that we don't handle incrementally yet."]
static ReflowEntireDocument = 0x01,
const REFLOW_ENTIRE_DOCUMENT = 0x01,
}
}
@ -49,9 +49,9 @@ impl RestyleDamage {
/// we should add to the *parent* of this flow.
pub fn damage_for_parent(self, child_is_absolutely_positioned: bool) -> RestyleDamage {
if child_is_absolutely_positioned {
self & (Repaint | ReflowOutOfFlow)
self & (REPAINT | REFLOW_OUT_OF_FLOW)
} else {
self & (Repaint | Reflow | ReflowOutOfFlow)
self & (REPAINT | REFLOW | REFLOW_OUT_OF_FLOW)
}
}
@ -66,20 +66,20 @@ impl RestyleDamage {
// Absolute children are out-of-flow and therefore insulated from changes.
//
// FIXME(pcwalton): Au contraire, if the containing block dimensions change!
self & Repaint
self & REPAINT
}
(true, false) => {
// Changing the position of an absolutely-positioned block requires us to reflow
// its kids.
if self.contains(ReflowOutOfFlow) {
self | Reflow
if self.contains(REFLOW_OUT_OF_FLOW) {
self | REFLOW
} else {
self
}
}
_ => {
// TODO(pcwalton): Take floatedness into account.
self & (Repaint | Reflow)
self & (REPAINT | REFLOW)
}
}
}
@ -90,11 +90,11 @@ impl fmt::Show for RestyleDamage {
let mut first_elem = true;
let to_iter =
[ (Repaint, "Repaint")
, (BubbleISizes, "BubbleISizes")
, (ReflowOutOfFlow, "ReflowOutOfFlow")
, (Reflow, "Reflow")
, (ReconstructFlow, "ReconstructFlow")
[ (REPAINT, "Repaint")
, (BUBBLE_ISIZES, "BubbleISizes")
, (REFLOW_OUT_OF_FLOW, "ReflowOutOfFlow")
, (REFLOW, "Reflow")
, (RECONSTRUCT_FLOW, "ReconstructFlow")
];
for &(damage, damage_str) in to_iter.iter() {
@ -141,20 +141,20 @@ pub fn compute_damage(old: &Option<Arc<ComputedValues>>, new: &ComputedValues) -
// FIXME: We can short-circuit more of this.
add_if_not_equal!(old, new, damage,
[ Repaint ], [
[ REPAINT ], [
get_color.color, get_background.background_color,
get_border.border_top_color, get_border.border_right_color,
get_border.border_bottom_color, get_border.border_left_color
]);
add_if_not_equal!(old, new, damage,
[ Repaint, ReflowOutOfFlow ], [
[ REPAINT, REFLOW_OUT_OF_FLOW ], [
get_positionoffsets.top, get_positionoffsets.left,
get_positionoffsets.right, get_positionoffsets.bottom
]);
add_if_not_equal!(old, new, damage,
[ Repaint, BubbleISizes, ReflowOutOfFlow, Reflow ], [
[ REPAINT, BUBBLE_ISIZES, REFLOW_OUT_OF_FLOW, REFLOW ], [
get_border.border_top_width, get_border.border_right_width,
get_border.border_bottom_width, get_border.border_left_width,
get_margin.margin_top, get_margin.margin_right,
@ -167,7 +167,7 @@ pub fn compute_damage(old: &Option<Arc<ComputedValues>>, new: &ComputedValues) -
]);
add_if_not_equal!(old, new, damage,
[ Repaint, BubbleISizes, ReflowOutOfFlow, Reflow, ReconstructFlow ],
[ REPAINT, BUBBLE_ISIZES, REFLOW_OUT_OF_FLOW, REFLOW, RECONSTRUCT_FLOW ],
[ get_box.float, get_box.display, get_box.position ]);
// FIXME: test somehow that we checked every CSS property
@ -203,8 +203,8 @@ impl<'a> LayoutDamageComputation for &'a mut Flow+'a {
let self_base = flow::base(self);
if self_base.flags.float_kind() != float::none &&
self_base.restyle_damage.intersects(Reflow) {
special_damage.insert(ReflowEntireDocument);
self_base.restyle_damage.intersects(REFLOW) {
special_damage.insert(REFLOW_ENTIRE_DOCUMENT);
}
special_damage
@ -213,7 +213,7 @@ impl<'a> LayoutDamageComputation for &'a mut Flow+'a {
fn reflow_entire_document(self) {
let self_base = flow::mut_base(self);
self_base.restyle_damage.insert(RestyleDamage::all());
self_base.restyle_damage.remove(ReconstructFlow);
self_base.restyle_damage.remove(RECONSTRUCT_FLOW);
for kid in self_base.children.iter_mut() {
kid.reflow_entire_document();
}

View File

@ -2,7 +2,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#![deny(unsafe_block)]
#![deny(unsafe_blocks)]
use css::node_style::StyledNode;
use context::LayoutContext;
@ -13,12 +13,12 @@ use flow;
use fragment::{Fragment, InlineAbsoluteHypotheticalFragment, InlineBlockFragment};
use fragment::{FragmentBoundsIterator, ScannedTextFragment, ScannedTextFragmentInfo};
use fragment::SplitInfo;
use incremental::{Reflow, ReflowOutOfFlow};
use incremental::{REFLOW, REFLOW_OUT_OF_FLOW};
use layout_debug;
use model::IntrinsicISizesContribution;
use text;
use collections::{Deque, RingBuf};
use collections::{RingBuf};
use geom::{Rect, Size2D};
use gfx::display_list::ContentLevel;
use gfx::font::FontMetrics;
@ -273,7 +273,7 @@ impl LineBreaker {
}
fn flush_current_line(&mut self) {
debug!("LineBreaker: Flushing line {:u}: {:?}",
debug!("LineBreaker: Flushing line {:u}: {}",
self.lines.len(), self.pending_line);
// clear line and add line mapping
@ -325,7 +325,7 @@ impl LineBreaker {
let line_bounds = self.floats.place_between_floats(&info);
debug!("LineBreaker: found position for line: {} using placement_info: {:?}",
debug!("LineBreaker: found position for line: {} using placement_info: {}",
line_bounds,
info);
@ -623,7 +623,7 @@ impl InlineFragments {
/// A convenience function to return a mutable reference to the fragment at a given index.
pub fn get_mut<'a>(&'a mut self, index: uint) -> &'a mut Fragment {
self.fragments.get_mut(index)
&mut self.fragments[index]
}
/// This function merges previously-line-broken fragments back into their
@ -944,7 +944,7 @@ impl Flow for InlineFlow {
// TODO: Combine this with `LineBreaker`'s walk in the fragment list, or put this into
// `Fragment`.
debug!("InlineFlow::assign_inline_sizes: floats in: {:?}", self.base.floats);
debug!("InlineFlow::assign_inline_sizes: floats in: {}", self.base.floats);
self.base.position.size.inline = self.base.block_container_inline_size;
@ -984,7 +984,7 @@ impl Flow for InlineFlow {
// element to determine its block-size for computing the line's own block-size.
//
// TODO(pcwalton): Cache the line scanner?
debug!("assign_block_size_inline: floats in: {:?}", self.base.floats);
debug!("assign_block_size_inline: floats in: {}", self.base.floats);
// assign block-size for inline fragments
let containing_block_block_size =
@ -1028,11 +1028,11 @@ impl Flow for InlineFlow {
mut largest_block_size_for_bottom_fragments) = (Au(0), Au(0));
for fragment_index in range(line.range.begin(), line.range.end()) {
let fragment = self.fragments.fragments.get_mut(fragment_index.to_uint());
let fragment = &mut self.fragments.fragments[fragment_index.to_uint()];
let InlineMetrics {
block_size_above_baseline: mut block_size_above_baseline,
depth_below_baseline: mut depth_below_baseline,
mut block_size_above_baseline,
mut depth_below_baseline,
ascent
} = fragment.inline_metrics(layout_context);
@ -1131,7 +1131,7 @@ impl Flow for InlineFlow {
Au(0),
-self.base.position.size.block));
self.base.restyle_damage.remove(ReflowOutOfFlow | Reflow);
self.base.restyle_damage.remove(REFLOW_OUT_OF_FLOW | REFLOW);
}
fn compute_absolute_position(&mut self) {

View File

@ -8,10 +8,11 @@
#![macro_escape]
use flow_ref::FlowRef;
use flow;
use serialize::json;
use std::cell::RefCell;
use std::io::File;
use std::sync::atomics::{AtomicUint, SeqCst, INIT_ATOMIC_UINT};
use std::sync::atomic::{AtomicUint, SeqCst, INIT_ATOMIC_UINT};
local_data_key!(state_key: RefCell<State>)
@ -62,7 +63,7 @@ impl Scope {
match maybe_refcell {
Some(refcell) => {
let mut state = refcell.borrow_mut();
let flow_trace = json::encode(&state.flow_root.deref());
let flow_trace = json::encode(&flow::base(state.flow_root.deref()));
let data = box ScopeData::new(name, flow_trace);
state.scope_stack.push(data);
}
@ -80,7 +81,7 @@ impl Drop for Scope {
Some(refcell) => {
let mut state = refcell.borrow_mut();
let mut current_scope = state.scope_stack.pop().unwrap();
current_scope.post = json::encode(&state.flow_root.deref());
current_scope.post = json::encode(&flow::base(state.flow_root.deref()));
let previous_scope = state.scope_stack.last_mut().unwrap();
previous_scope.children.push(current_scope);
}
@ -101,7 +102,7 @@ pub fn generate_unique_debug_id() -> u16 {
pub fn begin_trace(flow_root: FlowRef) {
assert!(state_key.get().is_none());
let flow_trace = json::encode(&flow_root.deref());
let flow_trace = json::encode(&flow::base(flow_root.deref()));
let state = State {
scope_stack: vec![box ScopeData::new("root".to_string(), flow_trace)],
flow_root: flow_root,
@ -117,7 +118,7 @@ pub fn end_trace() {
let mut task_state = task_state_cell.borrow_mut();
assert!(task_state.scope_stack.len() == 1);
let mut root_scope = task_state.scope_stack.pop().unwrap();
root_scope.post = json::encode(&task_state.flow_root.deref());
root_scope.post = json::encode(&flow::base(task_state.flow_root.deref()));
let result = json::encode(&root_scope);
let path = Path::new("layout_trace.json");

View File

@ -11,7 +11,7 @@ use context::SharedLayoutContext;
use flow::{mod, Flow, ImmutableFlowUtils, MutableFlowUtils, MutableOwnedFlowUtils};
use flow_ref::FlowRef;
use fragment::{Fragment, FragmentBoundsIterator};
use incremental::{LayoutDamageComputation, Reflow, ReflowEntireDocument, Repaint};
use incremental::{LayoutDamageComputation, REFLOW, REFLOW_ENTIRE_DOCUMENT, REPAINT};
use layout_debug;
use parallel::UnsafeFlow;
use parallel;
@ -183,7 +183,7 @@ impl LayoutTaskFactory for LayoutTask {
time_profiler_chan: TimeProfilerChan,
shutdown_chan: Sender<()>) {
let ConstellationChan(con_chan) = constellation_chan.clone();
spawn_named_with_send_on_failure("LayoutTask", task_state::Layout, proc() {
spawn_named_with_send_on_failure("LayoutTask", task_state::LAYOUT, proc() {
{ // Ensures layout task is destroyed before we send shutdown message
let sender = chan.sender();
let layout =
@ -254,7 +254,7 @@ impl LayoutTask {
let screen_size = Size2D(Au(0), Au(0));
let device = Device::new(Screen, opts::get().initial_window_size.as_f32() * ScaleFactor(1.0));
let parallel_traversal = if opts::get().layout_threads != 1 {
Some(WorkQueue::new("LayoutWorker", task_state::Layout,
Some(WorkQueue::new("LayoutWorker", task_state::LAYOUT,
opts::get().layout_threads, ptr::null()))
} else {
None
@ -339,7 +339,7 @@ impl LayoutTask {
} else if ret == port2.id() {
Pipeline
} else {
fail!("invalid select result");
panic!("invalid select result");
}
};
@ -443,7 +443,7 @@ impl LayoutTask {
break
}
_ => {
fail!("layout: message that wasn't `ExitNowMsg` received after \
panic!("layout: message that wasn't `ExitNowMsg` received after \
`PrepareToExitMsg`")
}
}
@ -559,7 +559,7 @@ impl LayoutTask {
let _scope = layout_debug_scope!("solve_constraints_parallel");
match rw_data.parallel_traversal {
None => fail!("solve_contraints_parallel() called with no parallel traversal ready"),
None => panic!("solve_contraints_parallel() called with no parallel traversal ready"),
Some(ref mut traversal) => {
// NOTE: this currently computes borders, so any pruning should separate that
// operation out.
@ -665,12 +665,11 @@ impl LayoutTask {
.background_color)
.to_gfx_color()
};
match element_bg_color {
color::rgba(0., 0., 0., 0.) => {}
_ => {
color = element_bg_color;
break;
}
// FIXME: Add equality operators for azure color type.
if element_bg_color.r != 0.0 || element_bg_color.g != 0.0 ||
element_bg_color.b != 0.0 || element_bg_color.a != 0.0 {
color = element_bg_color;
break;
}
}
}
@ -798,8 +797,8 @@ impl LayoutTask {
self.time_profiler_chan.clone(),
|| {
if opts::get().nonincremental_layout ||
layout_root.compute_layout_damage().contains(ReflowEntireDocument) {
layout_root.reflow_entire_document()
layout_root.deref_mut().compute_layout_damage().contains(REFLOW_ENTIRE_DOCUMENT) {
layout_root.deref_mut().reflow_entire_document()
}
});
@ -884,7 +883,7 @@ impl LayoutTask {
}
fn reflow_all_nodes(flow: &mut Flow) {
flow::mut_base(flow).restyle_damage.insert(Reflow | Repaint);
flow::mut_base(flow).restyle_damage.insert(REFLOW | REPAINT);
for child in flow::child_iter(flow) {
LayoutTask::reflow_all_nodes(child);
@ -930,7 +929,7 @@ impl LayoutRPC for LayoutRPCImpl {
/// Requests the dimensions of all the content boxes, as in the `getClientRects()` call.
fn content_boxes(&self) -> ContentBoxesResponse {
let &LayoutRPCImpl(ref rw_data) = self;
let mut rw_data = rw_data.lock();
let rw_data = rw_data.lock();
ContentBoxesResponse(rw_data.content_boxes_response.clone())
}
@ -953,7 +952,7 @@ impl LayoutRPC for LayoutRPCImpl {
let &LayoutRPCImpl(ref rw_data) = self;
let rw_data = rw_data.lock();
match rw_data.display_list {
None => fail!("no display list!"),
None => panic!("no display list!"),
Some(ref display_list) => hit_test(point, display_list.list.iter().rev()),
}
};
@ -984,7 +983,7 @@ impl LayoutRPC for LayoutRPCImpl {
let &LayoutRPCImpl(ref rw_data) = self;
let rw_data = rw_data.lock();
match rw_data.display_list {
None => fail!("no display list!"),
None => panic!("no display list!"),
Some(ref display_list) => {
mouse_over_test(point, display_list.list.iter().rev(), &mut mouse_over_list);
}

View File

@ -7,14 +7,13 @@
#![feature(globs, macro_rules, phase, thread_local, unsafe_destructor)]
#![deny(unused_imports, unused_variable)]
#![deny(unused_imports)]
#![deny(unused_variables)]
#![allow(unrooted_must_root)]
#[phase(plugin, link)]
extern crate log;
extern crate debug;
extern crate geom;
extern crate gfx;
extern crate layout_traits;

View File

@ -4,7 +4,7 @@
//! Borders, padding, and margins.
#![deny(unsafe_block)]
#![deny(unsafe_blocks)]
use fragment::Fragment;
@ -217,7 +217,7 @@ impl MarginCollapseInfo {
(AccumulatingCollapsibleTopMargin, MarginsCollapse(..)) => {
// Can't happen because the state will have been replaced with
// `AccumulatingMarginIn` above.
fail!("should not be accumulating collapsible block_start margins anymore!")
panic!("should not be accumulating collapsible block_start margins anymore!")
}
(AccumulatingCollapsibleTopMargin, MarginsCollapseThrough(margin)) => {
self.block_start_margin.union(margin);

View File

@ -25,7 +25,7 @@ use servo_util::time;
use servo_util::workqueue::{WorkQueue, WorkUnit, WorkerProxy};
use std::mem;
use std::ptr;
use std::sync::atomics::{AtomicInt, Relaxed, SeqCst};
use std::sync::atomic::{AtomicInt, Relaxed, SeqCst};
#[allow(dead_code)]
fn static_assertion(node: UnsafeLayoutNode) {
@ -431,7 +431,7 @@ pub fn traverse_flow_tree_preorder(root: &mut FlowRef,
if opts::get().bubble_inline_sizes_separately {
let layout_context = LayoutContext::new(shared_layout_context);
let bubble_inline_sizes = BubbleISizes { layout_context: &layout_context };
root.traverse_postorder(&bubble_inline_sizes);
root.deref_mut().traverse_postorder(&bubble_inline_sizes);
}
queue.data = shared_layout_context as *const _;

View File

@ -4,7 +4,7 @@
//! CSS table formatting contexts.
#![deny(unsafe_block)]
#![deny(unsafe_blocks)]
use block::{BlockFlow, MarginsMayNotCollapse, ISizeAndMarginsComputer};
use block::{ISizeConstraintInput, ISizeConstraintSolution};

View File

@ -4,7 +4,7 @@
//! CSS table formatting contexts.
#![deny(unsafe_block)]
#![deny(unsafe_blocks)]
use block::BlockFlow;
use construct::FlowConstructor;

View File

@ -4,7 +4,7 @@
//! CSS table formatting contexts.
#![deny(unsafe_block)]
#![deny(unsafe_blocks)]
use block::{BlockFlow, MarginsMayNotCollapse, ISizeAndMarginsComputer};
use context::LayoutContext;

View File

@ -4,7 +4,7 @@
//! CSS table formatting contexts.
#![deny(unsafe_block)]
#![deny(unsafe_blocks)]
use context::LayoutContext;
use css::node_style::StyledNode;
@ -70,7 +70,7 @@ impl Flow for TableColGroupFlow {
let inline_size = fragment.style().content_inline_size();
let span: int = match fragment.specific {
TableColumnFragment(col_fragment) => max(col_fragment.span, 1),
_ => fail!("non-table-column fragment inside table column?!"),
_ => panic!("non-table-column fragment inside table column?!"),
};
for _ in range(0, span) {
self.inline_sizes.push(inline_size)

View File

@ -4,7 +4,7 @@
//! CSS table formatting contexts.
#![deny(unsafe_block)]
#![deny(unsafe_blocks)]
use block::BlockFlow;
use block::ISizeAndMarginsComputer;

View File

@ -4,7 +4,7 @@
//! CSS table formatting contexts.
#![deny(unsafe_block)]
#![deny(unsafe_blocks)]
use block::BlockFlow;
use block::ISizeAndMarginsComputer;

View File

@ -11,7 +11,7 @@
//!
//! Hereafter this document is referred to as INTRINSIC.
#![deny(unsafe_block)]
#![deny(unsafe_blocks)]
use block::{BlockFlow, BlockNonReplaced, FloatNonReplaced, ISizeAndMarginsComputer};
use block::{MarginsMayNotCollapse};

View File

@ -4,7 +4,7 @@
//! Text layout.
#![deny(unsafe_block)]
#![deny(unsafe_blocks)]
use fragment::{Fragment, ScannedTextFragmentInfo, UnscannedTextFragment};
use inline::InlineFragments;
@ -19,7 +19,7 @@ use servo_util::geometry::Au;
use servo_util::logical_geometry::{LogicalSize, WritingMode};
use servo_util::range::Range;
use servo_util::smallvec::{SmallVec, SmallVec1};
use std::collections::{DList, Deque};
use std::collections::DList;
use std::mem;
use style::ComputedValues;
use style::computed_values::{line_height, text_orientation, white_space};
@ -119,7 +119,7 @@ impl TextRunScanner {
for in_fragment in self.clump.iter() {
let in_fragment = match in_fragment.specific {
UnscannedTextFragment(ref text_fragment_info) => &text_fragment_info.text,
_ => fail!("Expected an unscanned text fragment!"),
_ => panic!("Expected an unscanned text fragment!"),
};
let mut new_line_pos = Vec::new();

View File

@ -11,7 +11,7 @@ use context::LayoutContext;
use flow::{Flow, MutableFlowUtils};
use flow::{PreorderFlowTraversal, PostorderFlowTraversal};
use flow;
use incremental::{RestyleDamage, BubbleISizes, Reflow, ReflowOutOfFlow};
use incremental::{RestyleDamage, BUBBLE_ISIZES, REFLOW, REFLOW_OUT_OF_FLOW};
use wrapper::{layout_node_to_unsafe_layout_node, LayoutNode};
use wrapper::{PostorderNodeMutTraversal, ThreadSafeLayoutNode, UnsafeLayoutNode};
use wrapper::{PreorderDomTraversal, PostorderDomTraversal};
@ -88,7 +88,7 @@ fn put_task_local_bloom_filter(bf: Box<BloomFilter>,
layout_context: &LayoutContext) {
match style_bloom.replace(Some((bf, *unsafe_node, layout_context.shared.generation))) {
None => {},
Some(_) => fail!("Putting into a never-taken task-local bloom filter"),
Some(_) => panic!("Putting into a never-taken task-local bloom filter"),
}
}
@ -272,7 +272,7 @@ impl PreorderFlow for FlowTreeVerification {
if !base.flags.is_leaf() && !base.flags.is_nonleaf() {
println!("flow tree verification failed: flow wasn't a leaf or a nonleaf!");
flow.dump();
fail!("flow tree verification failed")
panic!("flow tree verification failed")
}
}
}
@ -287,12 +287,12 @@ impl<'a> PostorderFlowTraversal for BubbleISizes<'a> {
#[inline]
fn process(&self, flow: &mut Flow) {
flow.bubble_inline_sizes();
flow::mut_base(flow).restyle_damage.remove(BubbleISizes);
flow::mut_base(flow).restyle_damage.remove(BUBBLE_ISIZES);
}
#[inline]
fn should_process(&self, flow: &mut Flow) -> bool {
flow::base(flow).restyle_damage.contains(BubbleISizes)
flow::base(flow).restyle_damage.contains(BUBBLE_ISIZES)
}
}
@ -309,7 +309,7 @@ impl<'a> PreorderFlowTraversal for AssignISizes<'a> {
#[inline]
fn should_process(&self, flow: &mut Flow) -> bool {
flow::base(flow).restyle_damage.intersects(ReflowOutOfFlow | Reflow)
flow::base(flow).restyle_damage.intersects(REFLOW_OUT_OF_FLOW | REFLOW)
}
}
@ -342,7 +342,7 @@ impl<'a> PostorderFlowTraversal for AssignBSizesAndStoreOverflow<'a> {
#[inline]
fn should_process(&self, flow: &mut Flow) -> bool {
flow::base(flow).restyle_damage.intersects(ReflowOutOfFlow | Reflow)
flow::base(flow).restyle_damage.intersects(REFLOW_OUT_OF_FLOW | REFLOW)
}
}

View File

@ -66,7 +66,7 @@ impl PrivateLayoutData {
bitflags! {
flags LayoutDataFlags: u8 {
#[doc="Whether a flow has been newly constructed."]
static HasNewlyConstructedFlow = 0x01
const HAS_NEWLY_CONSTRUCTED_FLOW = 0x01
}
}

View File

@ -49,7 +49,7 @@ use script::dom::htmlimageelement::LayoutHTMLImageElementHelpers;
use script::dom::htmlinputelement::LayoutHTMLInputElementHelpers;
use script::dom::node::{DocumentNodeTypeId, ElementNodeTypeId, Node, NodeTypeId};
use script::dom::node::{LayoutNodeHelpers, RawLayoutNodeHelpers, SharedLayoutData};
use script::dom::node::{HasChanged, IsDirty, HasDirtySiblings, HasDirtyDescendants};
use script::dom::node::{HAS_CHANGED, IS_DIRTY, HAS_DIRTY_SIBLINGS, HAS_DIRTY_DESCENDANTS};
use script::dom::text::Text;
use script::layout_interface::LayoutChan;
use servo_msg::constellation_msg::{PipelineId, SubpageId};
@ -102,7 +102,7 @@ pub trait TLayoutNode {
unsafe {
match HTMLImageElementCast::to_js(self.get_jsmanaged()) {
Some(elem) => elem.image().as_ref().map(|url| (*url).clone()),
None => fail!("not an image!")
None => panic!("not an image!")
}
}
}
@ -114,7 +114,7 @@ pub trait TLayoutNode {
let iframe_element: JS<HTMLIFrameElement> =
match HTMLIFrameElementCast::to_js(self.get_jsmanaged()) {
Some(elem) => elem,
None => fail!("not an iframe element!")
None => panic!("not an iframe element!")
};
let size = (*iframe_element.unsafe_get()).size().unwrap();
(*size.pipeline_id(), *size.subpage_id())
@ -187,7 +187,7 @@ impl<'ln> TLayoutNode for LayoutNode<'ln> {
Some(text) => (*text.unsafe_get()).characterdata().data_for_layout().to_string(),
None => match HTMLInputElementCast::to_js(self.get_jsmanaged()) {
Some(input) => input.get_value_for_layout(),
None => fail!("not text!")
None => panic!("not text!")
}
}
}
@ -342,7 +342,7 @@ impl<'ln> TNode<'ln, LayoutElement<'ln>> for LayoutNode<'ln> {
unsafe {
let elem: JS<Element> = match ElementCast::to_js(&self.node) {
Some(elem) => elem,
None => fail!("not an element")
None => panic!("not an element")
};
let element = &*elem.unsafe_get();
@ -390,35 +390,35 @@ impl<'ln> TNode<'ln, LayoutElement<'ln>> for LayoutNode<'ln> {
}
fn has_changed(self) -> bool {
unsafe { self.node.get_flag(HasChanged) }
unsafe { self.node.get_flag(HAS_CHANGED) }
}
unsafe fn set_changed(self, value: bool) {
self.node.set_flag(HasChanged, value)
self.node.set_flag(HAS_CHANGED, value)
}
fn is_dirty(self) -> bool {
unsafe { self.node.get_flag(IsDirty) }
unsafe { self.node.get_flag(IS_DIRTY) }
}
unsafe fn set_dirty(self, value: bool) {
self.node.set_flag(IsDirty, value)
self.node.set_flag(IS_DIRTY, value)
}
fn has_dirty_siblings(self) -> bool {
unsafe { self.node.get_flag(HasDirtySiblings) }
unsafe { self.node.get_flag(HAS_DIRTY_SIBLINGS) }
}
unsafe fn set_dirty_siblings(self, value: bool) {
self.node.set_flag(HasDirtySiblings, value);
self.node.set_flag(HAS_DIRTY_SIBLINGS, value);
}
fn has_dirty_descendants(self) -> bool {
unsafe { self.node.get_flag(HasDirtyDescendants) }
unsafe { self.node.get_flag(HAS_DIRTY_DESCENDANTS) }
}
unsafe fn set_dirty_descendants(self, value: bool) {
self.node.set_flag(HasDirtyDescendants, value)
self.node.set_flag(HAS_DIRTY_DESCENDANTS, value)
}
}
@ -752,7 +752,7 @@ impl<'ln> ThreadSafeLayoutNode<'ln> {
unsafe {
let element = match ElementCast::to_js(self.get_jsmanaged()) {
Some(e) => e.unsafe_get(),
None => fail!("not an element")
None => panic!("not an element")
};
// FIXME(pcwalton): Workaround until Rust gets multiple lifetime parameters on
// implementations.
@ -888,7 +888,7 @@ impl<'ln> ThreadSafeLayoutNode<'ln> {
unsafe {
match HTMLInputElementCast::to_js(self.get_jsmanaged()) {
Some(input) => input.get_value_for_layout(),
None => fail!("not an input element!")
None => panic!("not an input element!")
}
}
}
@ -897,7 +897,7 @@ impl<'ln> ThreadSafeLayoutNode<'ln> {
unsafe {
match HTMLInputElementCast::to_js(self.get_jsmanaged()) {
Some(input) => input.get_size_for_layout(),
None => fail!("not an input element!")
None => panic!("not an input element!")
}
}
}
@ -914,7 +914,7 @@ impl<'ln> ThreadSafeLayoutNode<'ln> {
let mut layout_data_ref = self.mutate_layout_data();
match &mut *layout_data_ref {
&Some(ref mut layout_data) => layout_data.data.restyle_damage = damage,
_ => fail!("no layout data for this node"),
_ => panic!("no layout data for this node"),
}
}
@ -922,7 +922,7 @@ impl<'ln> ThreadSafeLayoutNode<'ln> {
pub fn flags(self) -> LayoutDataFlags {
unsafe {
match *self.borrow_layout_data_unchecked() {
None => fail!(),
None => panic!(),
Some(ref layout_data) => layout_data.data.flags,
}
}
@ -933,7 +933,7 @@ impl<'ln> ThreadSafeLayoutNode<'ln> {
let mut layout_data_ref = self.mutate_layout_data();
match &mut *layout_data_ref {
&Some(ref mut layout_data) => layout_data.data.flags.insert(new_flags),
_ => fail!("no layout data for this node"),
_ => panic!("no layout data for this node"),
}
}
@ -942,7 +942,7 @@ impl<'ln> ThreadSafeLayoutNode<'ln> {
let mut layout_data_ref = self.mutate_layout_data();
match &mut *layout_data_ref {
&Some(ref mut layout_data) => layout_data.data.flags.remove(flags),
_ => fail!("no layout data for this node"),
_ => panic!("no layout data for this node"),
}
}
}

View File

@ -5,7 +5,8 @@
#![comment = "The Servo Parallel Browser Project"]
#![license = "MPL"]
#![deny(unused_imports, unused_variable)]
#![deny(unused_imports)]
#![deny(unused_variables)]
extern crate gfx;
extern crate script_traits;

View File

@ -7,7 +7,6 @@ use geom::point::Point2D;
use geom::rect::Rect;
use layers::platform::surface::NativeGraphicsMetadata;
use layers::layers::LayerBufferSet;
use serialize::{Encoder, Encodable};
use std::fmt::{Formatter, Show};
use std::fmt;
@ -33,7 +32,7 @@ pub enum ReadyState {
}
/// A newtype struct for denoting the age of messages; prevents race conditions.
#[deriving(PartialEq)]
#[deriving(PartialEq, Show)]
pub struct Epoch(pub uint);
impl Epoch {
@ -115,9 +114,3 @@ pub trait ScriptListener {
fn close(&mut self);
fn dup(&mut self) -> Box<ScriptListener+'static>;
}
impl<E, S: Encoder<E>> Encodable<S, E> for Box<ScriptListener+'static> {
fn encode(&self, _s: &mut S) -> Result<(), E> {
Ok(())
}
}

View File

@ -87,20 +87,20 @@ impl LoadData {
}
/// Represents the two different ways to which a page can be navigated
#[deriving(Clone, PartialEq, Hash)]
#[deriving(Clone, PartialEq, Hash, Show)]
pub enum NavigationType {
Load, // entered or clicked on a url
Navigate, // browser forward/back buttons
}
#[deriving(Clone, PartialEq, Hash)]
#[deriving(Clone, PartialEq, Hash, Show)]
pub enum NavigationDirection {
Forward,
Back,
}
#[deriving(Clone, PartialEq, Eq, Hash)]
#[deriving(Clone, PartialEq, Eq, Hash, Show)]
pub struct PipelineId(pub uint);
#[deriving(Clone, PartialEq, Eq, Hash)]
#[deriving(Clone, PartialEq, Eq, Hash, Show)]
pub struct SubpageId(pub uint);

View File

@ -2,7 +2,8 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#![deny(unused_imports, unused_variable)]
#![deny(unused_imports)]
#![deny(unused_variables)]
extern crate azure;
extern crate geom;

View File

@ -24,7 +24,7 @@ pub fn factory(mut load_data: LoadData, start_chan: Sender<LoadResponse>) {
chan.send(Done(Ok(())));
return
}
"crash" => fail!("Loading the about:crash URL."),
"crash" => panic!("Loading the about:crash URL."),
"failure" => {
let mut path = resources_dir_path();
path.push("failure.html");

View File

@ -28,7 +28,7 @@ fn load(load_data: LoadData, start_chan: Sender<LoadResponse>) {
// Split out content type and data.
let mut scheme_data = match url.scheme_data {
NonRelativeSchemeData(scheme_data) => scheme_data,
_ => fail!("Expected a non-relative scheme URL.")
_ => panic!("Expected a non-relative scheme URL.")
};
match url.query {
Some(query) => {

View File

@ -10,7 +10,7 @@
//! with CORSRequest being expanded into FetchRequest (etc)
use http::method::Method;
use std::ascii::StrAsciiExt;
use std::ascii::AsciiExt;
use std::comm::{Sender, Receiver, channel};
use time;
use time::{now, Timespec};

View File

@ -126,7 +126,7 @@ impl Request {
},
"blob" | "data" | "file" | "ftp" => {
// XXXManishearth handle these
fail!("Unimplemented scheme for Fetch")
panic!("Unimplemented scheme for Fetch")
},
_ => Response::network_error()

View File

@ -7,7 +7,7 @@ use http::status::{Status, UnregisteredStatus};
use http::status::Ok as StatusOk;
use http::headers::HeaderEnum;
use http::headers::response::HeaderCollection;
use std::ascii::OwnedStrAsciiExt;
use std::ascii::OwnedAsciiExt;
use std::comm::Receiver;
/// [Response type](http://fetch.spec.whatwg.org/#concept-response-type)

View File

@ -4,7 +4,8 @@
use resource_task::{Metadata, Payload, Done, LoadResponse, LoadData, start_sending_opt};
use std::collections::hashmap::HashSet;
use log;
use std::collections::HashSet;
use http::client::{RequestWriter, NetworkStream};
use http::headers::HeaderEnum;
use std::io::Reader;
@ -98,10 +99,11 @@ fn load(load_data: LoadData, start_chan: Sender<LoadResponse>) {
// Dump headers, but only do the iteration if info!() is enabled.
info!("got HTTP response {:s}, headers:", response.status.to_string());
info!("{:?}",
if log_enabled!(log::INFO) {
for header in response.headers.iter() {
info!(" - {:s}: {:s}", header.header_name(), header.header_value());
});
}
}
if 3 == (response.status.code() / 100) {
match response.headers.location {

View File

@ -9,7 +9,8 @@ use resource_task::{LoadData, ResourceTask};
use servo_util::task::spawn_named;
use servo_util::taskpool::TaskPool;
use std::comm::{channel, Receiver, Sender};
use std::collections::hashmap::HashMap;
use std::collections::HashMap;
use std::collections::hash_map::{Occupied, Vacant};
use std::mem::replace;
use std::result;
use sync::{Arc, Mutex};
@ -57,7 +58,7 @@ pub enum ImageResponseMsg {
impl PartialEq for ImageResponseMsg {
fn eq(&self, other: &ImageResponseMsg) -> bool {
match (self, other) {
(&ImageReady(..), &ImageReady(..)) => fail!("unimplemented comparison"),
(&ImageReady(..), &ImageReady(..)) => panic!("unimplemented comparison"),
(&ImageNotReady, &ImageNotReady) => true,
(&ImageFailed, &ImageFailed) => true,
@ -169,8 +170,6 @@ impl ImageCache {
loop {
let msg = self.port.recv();
debug!("image_cache_task: received: {:?}", msg);
match msg {
Prefetch(url) => self.prefetch(url),
StorePrefetchedImageData(url, data) => {
@ -231,7 +230,7 @@ impl ImageCache {
}
fn get_state(&self, url: &Url) -> ImageState {
match self.state_map.find(url) {
match self.state_map.get(url) {
Some(state) => state.clone(),
None => Init
}
@ -289,14 +288,14 @@ impl ImageCache {
| Decoding
| Decoded(..)
| Failed => {
fail!("wrong state for storing prefetched image")
panic!("wrong state for storing prefetched image")
}
}
}
fn decode(&mut self, url: Url) {
match self.get_state(&url) {
Init => fail!("decoding image before prefetch"),
Init => panic!("decoding image before prefetch"),
Prefetching(DoNotDecode) => {
// We don't have the data yet, queue up the decode
@ -350,16 +349,16 @@ impl ImageCache {
| Prefetched(..)
| Decoded(..)
| Failed => {
fail!("incorrect state in store_image")
panic!("incorrect state in store_image")
}
}
}
fn purge_waiters(&mut self, url: Url, f: || -> ImageResponseMsg) {
match self.wait_map.pop(&url) {
match self.wait_map.remove(&url) {
Some(waiters) => {
let mut items = waiters.lock();
let items = waiters.lock();
for response in items.iter() {
response.send(f());
}
@ -370,9 +369,9 @@ impl ImageCache {
fn get_image(&self, url: Url, response: Sender<ImageResponseMsg>) {
match self.get_state(&url) {
Init => fail!("request for image before prefetch"),
Init => panic!("request for image before prefetch"),
Prefetching(DoDecode) => response.send(ImageNotReady),
Prefetching(DoNotDecode) | Prefetched(..) => fail!("request for image before decode"),
Prefetching(DoNotDecode) | Prefetched(..) => panic!("request for image before decode"),
Decoding => response.send(ImageNotReady),
Decoded(image) => response.send(ImageReady(image)),
Failed => response.send(ImageFailed),
@ -381,15 +380,20 @@ impl ImageCache {
fn wait_for_image(&mut self, url: Url, response: Sender<ImageResponseMsg>) {
match self.get_state(&url) {
Init => fail!("request for image before prefetch"),
Init => panic!("request for image before prefetch"),
Prefetching(DoNotDecode) | Prefetched(..) => fail!("request for image before decode"),
Prefetching(DoNotDecode) | Prefetched(..) => panic!("request for image before decode"),
Prefetching(DoDecode) | Decoding => {
// We don't have this image yet
self.wait_map.find_with_or_insert_with(url, response,
|_, waiters, response| waiters.lock().push(response),
|_, response| Arc::new(Mutex::new(vec!(response))));
match self.wait_map.entry(url) {
Occupied(mut entry) => {
entry.get_mut().lock().push(response);
}
Vacant(entry) => {
entry.set(Arc::new(Mutex::new(vec!(response))));
}
}
}
Decoded(image) => {
@ -618,7 +622,7 @@ mod tests {
mock_resource_task.send(resource_task::Exit);
match url_requested.try_recv() {
Err(_) => (),
Ok(_) => fail!(),
Ok(_) => panic!(),
};
}
@ -660,7 +664,7 @@ mod tests {
image_cache_task.send(GetImage(url, response_chan));
match response_port.recv() {
ImageReady(_) => (),
_ => fail!("bleh")
_ => panic!("bleh")
}
image_cache_task.exit();
@ -687,7 +691,7 @@ mod tests {
image_cache_task.send(GetImage(url.clone(), response_chan));
match response_port.recv() {
ImageReady(_) => (),
_ => fail!("bleh")
_ => panic!("bleh")
}
}
@ -738,7 +742,7 @@ mod tests {
// because it's already cached
match image_bin_sent.try_recv() {
Err(_) => (),
Ok(_) => fail!(),
Ok(_) => panic!(),
}
}
@ -787,7 +791,7 @@ mod tests {
// because it's already cached
match image_bin_sent.try_recv() {
Err(_) => (),
Ok(_) => fail!(),
Ok(_) => panic!(),
}
}
@ -810,7 +814,7 @@ mod tests {
image_cache_task.send(GetImage(url, response_chan));
match response_port.recv() {
ImageFailed => (),
_ => fail!("bleh")
_ => panic!("bleh")
}
image_cache_task.exit();
@ -836,7 +840,7 @@ mod tests {
image_cache_task.send(GetImage(url.clone(), response_chan));
match response_port.recv() {
ImageFailed => (),
_ => fail!("bleh")
_ => panic!("bleh")
}
// And ask again, we should get the same response
@ -844,7 +848,7 @@ mod tests {
image_cache_task.send(GetImage(url, response_chan));
match response_port.recv() {
ImageFailed => (),
_ => fail!("bleh")
_ => panic!("bleh")
}
image_cache_task.exit();
@ -872,7 +876,7 @@ mod tests {
match response_port.recv() {
ImageFailed => (),
_ => fail!("bleh")
_ => panic!("bleh")
}
image_cache_task.exit();
@ -898,7 +902,7 @@ mod tests {
image_cache_task.send(WaitForImage(url, response_chan));
match response_port.recv() {
ImageReady(..) => (),
_ => fail!("bleh")
_ => panic!("bleh")
}
image_cache_task.exit();
@ -924,7 +928,7 @@ mod tests {
match response_port.recv() {
ImageReady(..) => (),
_ => fail!("bleh")
_ => panic!("bleh")
}
image_cache_task.exit();
@ -950,7 +954,7 @@ mod tests {
match response_port.recv() {
ImageFailed => (),
_ => fail!("bleh")
_ => panic!("bleh")
}
image_cache_task.exit();
@ -971,7 +975,7 @@ mod tests {
image_cache_task.send(GetImage(url, response_chan));
match response_port.recv() {
ImageReady(_) => (),
_ => fail!("bleh")
_ => panic!("bleh")
}
image_cache_task.exit();

View File

@ -4,9 +4,9 @@
#![feature(default_type_params, globs, phase)]
#![deny(unused_imports, unused_variable)]
#![deny(unused_imports)]
#![deny(unused_variables)]
extern crate debug;
extern crate collections;
extern crate geom;
extern crate http;

View File

@ -12,7 +12,8 @@ use image_cache_task::{Decode, GetImage, ImageCacheTask, ImageFailed, ImageNotRe
use image_cache_task::{ImageResponseMsg, Prefetch, WaitForImage};
use std::comm::{Receiver, channel};
use std::collections::hashmap::HashMap;
use std::collections::HashMap;
use std::collections::hash_map::{Occupied, Vacant};
use servo_util::task::spawn_named;
use url::Url;
@ -153,15 +154,15 @@ impl<NodeAddress: Send> LocalImageCache<NodeAddress> {
}
fn get_state<'a>(&'a mut self, url: &Url) -> &'a mut ImageState {
let state = self.state_map.find_or_insert_with(url.clone(), |_| {
let new_state = ImageState {
prefetched: false,
decoded: false,
last_request_round: 0,
last_response: ImageNotReady
};
new_state
});
state
match self.state_map.entry((*url).clone()) {
Occupied(entry) => entry.into_mut(),
Vacant(entry) =>
entry.set(ImageState {
prefetched: false,
decoded: false,
last_request_round: 0,
last_response: ImageNotReady,
})
}
}
}

View File

@ -90,9 +90,9 @@ impl Metadata {
pub fn set_content_type(&mut self, content_type: &Option<MediaType>) {
match *content_type {
None => (),
Some(MediaType { type_: ref type_,
subtype: ref subtype,
parameters: ref parameters }) => {
Some(MediaType { ref type_,
ref subtype,
ref parameters }) => {
self.content_type = Some((type_.clone(), subtype.clone()));
for &(ref k, ref v) in parameters.iter() {
if "charset" == k.as_slice() {
@ -266,7 +266,7 @@ fn test_bad_scheme() {
let response = start.recv();
match response.progress_port.recv() {
Done(result) => { assert!(result.is_err()) }
_ => fail!("bleh")
_ => panic!("bleh")
}
resource_task.send(Exit);
}

View File

@ -14,7 +14,8 @@
#![feature(macro_rules, plugin_registrar, quote, phase)]
#![deny(unused_imports, unused_variable)]
#![deny(unused_imports)]
#![deny(unused_variables)]
#[phase(plugin,link)]
extern crate syntax;

View File

@ -58,7 +58,7 @@ impl LintPass for TransmutePass {
cx.span_lint(TRANSMUTE_TYPE_LINT, ex.span,
format!("Transmute from {} to {} detected",
expr_ty(tcx, ex).repr(tcx),
expr_ty(tcx, &**args.get(0)).repr(tcx)
expr_ty(tcx, &**args.get(0).unwrap()).repr(tcx)
).as_slice());
}
}
@ -75,7 +75,7 @@ impl LintPass for TransmutePass {
// TODO (#3874, sort of): unwrap other types like Vec/Option/HashMap/etc
fn lint_unrooted_ty(cx: &Context, ty: &ast::Ty, warning: &str) {
match ty.node {
ast::TyBox(ref t) | ast::TyUniq(ref t) |
ast::TyUniq(ref t) |
ast::TyVec(ref t) | ast::TyFixedLengthVec(ref t, _) |
ast::TyPtr(ast::MutTy { ty: ref t, ..}) | ast::TyRptr(_, ast::MutTy { ty: ref t, ..}) => lint_unrooted_ty(cx, &**t, warning),
ast::TyPath(_, _, id) => {
@ -162,7 +162,7 @@ impl LintPass for UnrootedPass {
// We need not check arms individually since enum/struct fields are already
// linted in `check_struct_def` and `check_variant`
// (so there is no way of destructuring out a `#[must_root]` field)
ast::ExprMatch(ref e, _) |
ast::ExprMatch(ref e, _, _) |
// For loops allow you to bind a return value locally
ast::ExprForLoop(_, ref e, _, _) => &**e,
// XXXManishearth look into `if let` once it lands in our rustc

View File

@ -9,10 +9,9 @@
//! This library will eventually become the core of the Fetch crate
//! with CORSRequest being expanded into FetchRequest (etc)
use std::ascii::{StrAsciiExt, OwnedStrAsciiExt};
use std::ascii::{AsciiExt, OwnedAsciiExt};
use std::from_str::FromStr;
use std::io::BufReader;
use std::str::StrSlice;
use time;
use time::{now, Timespec};
@ -155,7 +154,7 @@ impl CORSRequest {
// Step 12
match response.status.code() {
200 .. 299 => {}
200 ... 299 => {}
_ => return error
}
cors_response.headers = response.headers.clone();

View File

@ -2,7 +2,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#![deny(missing_doc)]
#![deny(missing_docs)]
//! Base classes to work with IDL callbacks.

View File

@ -6,7 +6,7 @@ use dom::bindings::trace::JSTraceable;
use js::jsapi::{JSTracer};
use servo_util::task_state;
use servo_util::task_state::{Script, InGC};
use servo_util::task_state::{SCRIPT, IN_GC};
use std::cell::{Cell, UnsafeCell};
use std::kinds::marker;
@ -39,7 +39,7 @@ impl<T> DOMRefCell<T> {
/// This succeeds even if the object is mutably borrowed,
/// so you have to be careful in trace code!
pub unsafe fn borrow_for_gc_trace<'a>(&'a self) -> &'a T {
debug_assert!(task_state::get().contains(Script | InGC));
debug_assert!(task_state::get().contains(SCRIPT | IN_GC));
&*self.value.get()
}
@ -87,8 +87,8 @@ impl<T: JSTraceable> JSTraceable for DOMRefCell<T> {
// Values [1, MAX-1] represent the number of `Ref` active
// (will not outgrow its range since `uint` is the size of the address space)
type BorrowFlag = uint;
static UNUSED: BorrowFlag = 0;
static WRITING: BorrowFlag = -1;
const UNUSED: BorrowFlag = 0;
const WRITING: BorrowFlag = -1;
impl<T> DOMRefCell<T> {
pub fn new(value: T) -> DOMRefCell<T> {
@ -108,14 +108,14 @@ impl<T> DOMRefCell<T> {
pub fn borrow<'a>(&'a self) -> Ref<'a, T> {
match self.try_borrow() {
Some(ptr) => ptr,
None => fail!("DOMRefCell<T> already mutably borrowed")
None => panic!("DOMRefCell<T> already mutably borrowed")
}
}
pub fn borrow_mut<'a>(&'a self) -> RefMut<'a, T> {
match self.try_borrow_mut() {
Some(ptr) => ptr,
None => fail!("DOMRefCell<T> already borrowed")
None => panic!("DOMRefCell<T> already borrowed")
}
}
}

View File

@ -183,7 +183,7 @@ class CGMethodCall(CGThing):
nativeMethodName + '_'*signatureIndex,
static, descriptor,
method, argConversionStartsAt)
signatures = method.signatures()
if len(signatures) == 1:
@ -203,7 +203,7 @@ class CGMethodCall(CGThing):
"}" % (requiredArgs, methodName))
self.cgRoot.prepend(
CGWrapper(CGGeneric(code), pre="\n", post="\n"))
return
# Need to find the right overload
@ -277,7 +277,7 @@ class CGMethodCall(CGThing):
s[1][distinguishingIndex].type.isNonCallbackInterface()) ]
# There might be more than one of these; we need to check
# which ones we unwrap to.
if len(interfacesSigs) > 0:
# The spec says that we should check for "platform objects
# implementing an interface", but it's enough to guard on these
@ -381,7 +381,7 @@ class CGMethodCall(CGThing):
"return 0;\n" % methodName)))
#XXXjdm Avoid unreachable statement warnings
#overloadCGThings.append(
# CGGeneric('fail!("We have an always-returning default case");\n'
# CGGeneric('panic!("We have an always-returning default case");\n'
# 'return 0;'))
self.cgRoot = CGWrapper(CGList(overloadCGThings, "\n"),
pre="\n")
@ -686,7 +686,7 @@ def getJSToNativeConversionTemplate(type, descriptorProvider, failureCode=None,
value = "Some(%s)" % value
default = (
"static data: [u8, ..%s] = [ %s ];\n"
"const data: [u8, ..%s] = [ %s ];\n"
"%s" %
(len(defaultValue.value) + 1,
", ".join(["'" + char + "' as u8" for char in defaultValue.value] + ["0"]),
@ -724,7 +724,7 @@ def getJSToNativeConversionTemplate(type, descriptorProvider, failureCode=None,
handleInvalidEnumValueCode = exceptionCode
else:
handleInvalidEnumValueCode = "return 1;"
template = (
"match FindEnumStringIndex(cx, ${val}, %(values)s) {\n"
" Err(_) => { %(exceptionCode)s },\n"
@ -1146,7 +1146,7 @@ class PropertyDefiner:
if specTerminator:
specs.append(specTerminator)
return (("static %s: &'static [%s] = &[\n" +
return (("const %s: &'static [%s] = &[\n" +
",\n".join(specs) + "\n" +
"];\n\n") % (name, specType))
@ -1197,9 +1197,9 @@ class MethodDefiner(PropertyDefiner):
return (m["name"], accessor, jitinfo, m["length"], m["flags"])
def stringDecl(m):
return "static %s_name: [u8, ..%i] = %s;\n" % (m["name"], len(m["name"]) + 1,
return "const %s_name: [u8, ..%i] = %s;\n" % (m["name"], len(m["name"]) + 1,
str_to_const_array(m["name"]))
decls = ''.join([stringDecl(m) for m in array])
return decls + self.generatePrefableArray(
array, name,
@ -1265,9 +1265,9 @@ class AttrDefiner(PropertyDefiner):
def stringDecl(attr):
name = attr.identifier.name
return "static %s_name: [u8, ..%i] = %s;\n" % (name, len(name) + 1,
return "const %s_name: [u8, ..%i] = %s;\n" % (name, len(name) + 1,
str_to_const_array(name))
decls = ''.join([stringDecl(m) for m in array])
return decls + self.generatePrefableArray(
@ -1296,8 +1296,8 @@ class ConstDefiner(PropertyDefiner):
def stringDecl(const):
name = const.identifier.name
return "static %s_name: &'static [u8] = &%s;\n" % (name, str_to_const_array(name))
return "const %s_name: &'static [u8] = &%s;\n" % (name, str_to_const_array(name))
decls = ''.join([stringDecl(m) for m in array])
return decls + self.generatePrefableArray(
@ -1362,13 +1362,13 @@ class CGImports(CGWrapper):
# CallbackMember.getArgConversions.
'unreachable_code',
'non_camel_case_types',
'non_uppercase_statics',
'unnecessary_parens',
'non_upper_case_globals',
'unused_parens',
'unused_imports',
'unused_variable',
'unused_variables',
'unused_unsafe',
'unused_mut',
'dead_assignment',
'unused_assignments',
'dead_code',
]
@ -1442,7 +1442,7 @@ class CGDOMJSClass(CGThing):
flags = "0"
slots = "1"
return """
static Class_name: [u8, ..%i] = %s;
const Class_name: [u8, ..%i] = %s;
static Class: DOMJSClass = DOMJSClass {
base: js::Class {
name: &Class_name as *const u8 as *const libc::c_char,
@ -1526,7 +1526,7 @@ class CGPrototypeJSClass(CGThing):
def define(self):
return """
static PrototypeClassName__: [u8, ..%s] = %s;
const PrototypeClassName__: [u8, ..%s] = %s;
static PrototypeClass: JSClass = JSClass {
name: &PrototypeClassName__ as *const u8 as *const libc::c_char,
flags: (1 & JSCLASS_RESERVED_SLOTS_MASK) << JSCLASS_RESERVED_SLOTS_SHIFT as uint, //JSCLASS_HAS_RESERVED_SLOTS(1)
@ -1559,7 +1559,7 @@ class CGInterfaceObjectJSClass(CGThing):
ctorname = "0 as *const u8" if not self.descriptor.interface.ctor() else CONSTRUCT_HOOK_NAME
hasinstance = HASINSTANCE_HOOK_NAME
return """
static InterfaceObjectClass: JSClass = {
const InterfaceObjectClass: JSClass = {
%s, 0,
JS_PropertyStub,
JS_PropertyStub,
@ -2192,7 +2192,7 @@ class CGCallGenerator(CGThing):
call = CGGeneric(nativeMethodName)
if static:
call = CGWrapper(call, pre="%s::" % descriptorProvider.interface.identifier.name)
else:
else:
call = CGWrapper(call, pre="%s." % object)
call = CGList([call, CGWrapper(args, pre="(", post=")")])
@ -2348,7 +2348,7 @@ class CGCase(CGList):
bodyList = CGList([body], "\n")
if fallThrough:
raise TypeError("fall through required but unsupported")
#bodyList.append(CGGeneric('fail!("fall through unsupported"); /* Fall through */'))
#bodyList.append(CGGeneric('panic!("fall through unsupported"); /* Fall through */'))
self.append(CGIndenter(bodyList));
self.append(CGGeneric("}"))
@ -2683,7 +2683,7 @@ class CGMemberJITInfo(CGThing):
depth = self.descriptor.interface.inheritanceDepth()
failstr = "true" if infallible else "false"
return ("\n"
"static %s: JSJitInfo = JSJitInfo {\n"
"const %s: JSJitInfo = JSJitInfo {\n"
" op: %s as *const u8,\n"
" protoID: %s,\n"
" depth: %s,\n"
@ -2760,7 +2760,7 @@ pub enum valuelist {
%s
}
pub static strings: &'static [&'static str] = &[
pub const strings: &'static [&'static str] = &[
%s,
];
@ -2806,7 +2806,7 @@ class CGConstant(CGThing):
def stringDecl(const):
name = const.identifier.name
value = convertConstIDLValueToRust(const.value)
return CGGeneric("pub static %s: %s = %s;\n" % (name, builtinNames[const.value.type.tag()], value))
return CGGeneric("pub const %s: %s = %s;\n" % (name, builtinNames[const.value.type.tag()], value))
return CGIndenter(CGList(stringDecl(m) for m in self.constants)).define()
@ -3889,7 +3889,7 @@ class CGDOMJSProxyHandler_obj_toString(CGAbstractExternMethod):
return call.define() + """
JSString* jsresult;
return xpc_qsStringToJsstring(cx, result, &jsresult) ? jsresult : NULL;"""
return xpc_qsStringToJsstring(cx, result, &jsresult) ? jsresult : NULL;"""
return """let s = "%s".to_c_str();
_obj_toString(cx, s.as_ptr())""" % self.descriptor.name
@ -5166,7 +5166,7 @@ class CallbackMember(CGNativeMember):
if arg.optional and not arg.defaultValue:
argval += ".clone().unwrap()"
conversion = wrapForType("*argv.get_mut(%s)" % jsvalIndex,
conversion = wrapForType("argv[%s]" % jsvalIndex,
result=argval,
successCode="continue;" if arg.variadic else "break;")
if arg.variadic:
@ -5183,7 +5183,7 @@ class CallbackMember(CGNativeMember):
" // This is our current trailing argument; reduce argc\n"
" argc -= 1;\n"
"} else {\n"
" *argv.get_mut(%d) = UndefinedValue();\n"
" argv[%d] = UndefinedValue();\n"
"}" % (i+1, i))
return conversion
@ -5397,7 +5397,7 @@ class GlobalGenRoots():
return CGList([
CGGeneric(AUTOGENERATED_WARNING_COMMENT),
CGGeneric("pub static MAX_PROTO_CHAIN_LENGTH: uint = %d;\n\n" % config.maxProtoChainLength),
CGGeneric("pub const MAX_PROTO_CHAIN_LENGTH: uint = %d;\n\n" % config.maxProtoChainLength),
CGNamespacedEnum('id', 'ID', protos, [0], deriving="PartialEq"),
CGNamespacedEnum('proxies', 'Proxy', proxies, [0], deriving="PartialEq"),
])

View File

@ -2,7 +2,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#![deny(missing_doc)]
#![deny(missing_docs)]
//! Conversions of Rust values to and from `JSVal`.
@ -69,7 +69,7 @@ impl ToJSValConvertible for JSVal {
fn to_jsval(&self, cx: *mut JSContext) -> JSVal {
let mut value = *self;
if unsafe { JS_WrapValue(cx, &mut value) } == 0 {
fail!("JS_WrapValue failed.");
panic!("JS_WrapValue failed.");
}
value
}
@ -238,7 +238,7 @@ impl ToJSValConvertible for DOMString {
let string_utf16: Vec<u16> = self.as_slice().utf16_units().collect();
let jsstr = JS_NewUCStringCopyN(cx, string_utf16.as_ptr(), string_utf16.len() as libc::size_t);
if jsstr.is_null() {
fail!("JS_NewUCStringCopyN failed");
panic!("JS_NewUCStringCopyN failed");
}
StringValue(&*jsstr)
}
@ -304,7 +304,7 @@ impl ToJSValConvertible for ByteString {
let jsstr = JS_NewStringCopyN(cx, slice.as_ptr() as *const libc::c_char,
slice.len() as libc::size_t);
if jsstr.is_null() {
fail!("JS_NewStringCopyN failed");
panic!("JS_NewStringCopyN failed");
}
StringValue(&*jsstr)
}
@ -340,7 +340,7 @@ impl ToJSValConvertible for Reflector {
assert!(obj.is_not_null());
let mut value = ObjectValue(unsafe { &*obj });
if unsafe { JS_WrapValue(cx, &mut value) } == 0 {
fail!("JS_WrapValue failed.");
panic!("JS_WrapValue failed.");
}
value
}

View File

@ -61,7 +61,7 @@ impl<'a> GlobalRef<'a> {
pub fn as_window<'b>(&'b self) -> JSRef<'b, window::Window> {
match *self {
Window(window) => window,
Worker(_) => fail!("expected a Window scope"),
Worker(_) => panic!("expected a Window scope"),
}
}
@ -144,6 +144,6 @@ pub fn global_object_for_js_object(obj: *mut JSObject) -> GlobalField {
Err(_) => (),
}
fail!("found DOM global that doesn't unwrap to Window or WorkerGlobalScope")
panic!("found DOM global that doesn't unwrap to Window or WorkerGlobalScope")
}
}

View File

@ -94,7 +94,7 @@ impl<T: Reflectable> Temporary<T> {
pub fn root<'a, 'b>(self) -> Root<'a, 'b, T> {
let collection = StackRoots.get().unwrap();
unsafe {
(**collection).new_root(&self.inner)
Root::new(&**collection, &self.inner)
}
}
@ -171,7 +171,7 @@ impl<T: Reflectable> JS<T> {
pub fn root<'a, 'b>(&self) -> Root<'a, 'b, T> {
let collection = StackRoots.get().unwrap();
unsafe {
(**collection).new_root(self)
Root::new(&**collection, self)
}
}
}
@ -431,18 +431,12 @@ impl RootCollection {
}
}
/// Create a new stack-bounded root that will not outlive this collection
#[allow(unrooted_must_root)]
fn new_root<'b, 'a: 'b, T: Reflectable>(&'a self, unrooted: &JS<T>) -> Root<'a, 'b, T> {
Root::new(self, unrooted)
}
/// Track a stack-based root to ensure LIFO root ordering
fn root<'a, 'b, T: Reflectable>(&self, untracked: &Root<'a, 'b, T>) {
unsafe {
let roots = self.roots.get();
(*roots).push(untracked.js_ptr);
debug!(" rooting {:?}", untracked.js_ptr);
debug!(" rooting {}", untracked.js_ptr);
}
}
@ -450,7 +444,7 @@ impl RootCollection {
fn unroot<'a, 'b, T: Reflectable>(&self, rooted: &Root<'a, 'b, T>) {
unsafe {
let roots = self.roots.get();
debug!("unrooting {:?} (expecting {:?}",
debug!("unrooting {} (expecting {}",
(*roots).as_slice().last().unwrap(),
rooted.js_ptr);
assert!(*(*roots).as_slice().last().unwrap() == rooted.js_ptr);

View File

@ -6,7 +6,6 @@
use std::from_str::FromStr;
use std::hash::{Hash, sip};
use std::path::BytesContainer;
use std::str;
/// Encapsulates the IDL `ByteString` type.
@ -67,7 +66,7 @@ impl ByteString {
vec.iter().all(|&x| {
// http://tools.ietf.org/html/rfc2616#section-2.2
match x {
0..31 | 127 => false, // CTLs
0...31 | 127 => false, // CTLs
40 | 41 | 60 | 62 | 64 |
44 | 59 | 58 | 92 | 34 |
47 | 91 | 93 | 63 | 61 |
@ -132,7 +131,7 @@ impl ByteString {
false
}
},
0..31 | 127 => false, // CTLs
0...31 | 127 => false, // CTLs
x if x > 127 => false, // non ASCII
_ if prev == Other || prev == SPHT => {
prev = Other;
@ -153,6 +152,6 @@ impl Hash for ByteString {
impl FromStr for ByteString {
fn from_str(s: &str) -> Option<ByteString> {
Some(ByteString::new(s.container_into_owned_bytes()))
Some(ByteString::new(s.to_string().into_bytes()))
}
}

View File

@ -2,7 +2,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#![deny(missing_doc)]
#![deny(missing_docs)]
//! Utilities for tracing JS-managed values.
//!
@ -51,7 +51,7 @@ use servo_msg::constellation_msg::ConstellationChan;
use servo_util::smallvec::{SmallVec1, SmallVec};
use servo_util::str::LengthOrPercentageOrAuto;
use std::cell::{Cell, RefCell};
use std::collections::hashmap::HashMap;
use std::collections::HashMap;
use std::comm::{Receiver, Sender};
use std::io::timer::Timer;
use std::rc::Rc;

View File

@ -2,7 +2,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#![deny(missing_doc)]
#![deny(missing_docs)]
//! Various utilities to glue JavaScript and the DOM implementation together.
@ -19,7 +19,6 @@ use libc;
use libc::c_uint;
use std::cell::Cell;
use std::mem;
use std::cmp::PartialEq;
use std::ptr;
use js::glue::{js_IsObjectProxyClass, js_IsFunctionProxyClass, IsProxyHandlerFamily};
use js::glue::{UnwrapObject, GetProxyHandlerExtra};
@ -167,23 +166,23 @@ pub unsafe fn squirrel_away_unique<T>(x: Box<T>) -> *const T {
/// stored for non-proxy bindings.
// We use slot 0 for holding the raw object. This is safe for both
// globals and non-globals.
pub static DOM_OBJECT_SLOT: uint = 0;
static DOM_PROXY_OBJECT_SLOT: uint = js::JSSLOT_PROXY_PRIVATE as uint;
pub const DOM_OBJECT_SLOT: uint = 0;
const DOM_PROXY_OBJECT_SLOT: uint = js::JSSLOT_PROXY_PRIVATE as uint;
// NOTE: This is baked into the Ion JIT as 0 in codegen for LGetDOMProperty and
// LSetDOMProperty. Those constants need to be changed accordingly if this value
// changes.
static DOM_PROTO_INSTANCE_CLASS_SLOT: u32 = 0;
const DOM_PROTO_INSTANCE_CLASS_SLOT: u32 = 0;
/// The index of the slot that contains a reference to the ProtoOrIfaceArray.
// All DOM globals must have a slot at DOM_PROTOTYPE_SLOT.
pub static DOM_PROTOTYPE_SLOT: u32 = js::JSCLASS_GLOBAL_SLOT_COUNT;
pub const DOM_PROTOTYPE_SLOT: u32 = js::JSCLASS_GLOBAL_SLOT_COUNT;
/// The flag set on the `JSClass`es for DOM global objects.
// NOTE: This is baked into the Ion JIT as 0 in codegen for LGetDOMProperty and
// LSetDOMProperty. Those constants need to be changed accordingly if this value
// changes.
pub static JSCLASS_DOM_GLOBAL: u32 = js::JSCLASS_USERBIT1;
pub const JSCLASS_DOM_GLOBAL: u32 = js::JSCLASS_USERBIT1;
/// Representation of an IDL constant value.
#[deriving(Clone)]
@ -677,7 +676,7 @@ pub unsafe fn delete_property_by_id(cx: *mut JSContext, object: *mut JSObject,
/// Results of `xml_name_type`.
#[deriving(PartialEq)]
#[allow(missing_doc)]
#[allow(missing_docs)]
pub enum XMLName {
QName,
Name,
@ -690,21 +689,21 @@ pub fn xml_name_type(name: &str) -> XMLName {
fn is_valid_start(c: char) -> bool {
match c {
':' |
'A' .. 'Z' |
'A' ... 'Z' |
'_' |
'a' .. 'z' |
'\xC0' .. '\xD6' |
'\xD8' .. '\xF6' |
'\xF8' .. '\u02FF' |
'\u0370' .. '\u037D' |
'\u037F' .. '\u1FFF' |
'\u200C' .. '\u200D' |
'\u2070' .. '\u218F' |
'\u2C00' .. '\u2FEF' |
'\u3001' .. '\uD7FF' |
'\uF900' .. '\uFDCF' |
'\uFDF0' .. '\uFFFD' |
'\U00010000' .. '\U000EFFFF' => true,
'a' ... 'z' |
'\u00C0' ... '\u00D6' |
'\u00D8' ... '\u00F6' |
'\u00F8' ... '\u02FF' |
'\u0370' ... '\u037D' |
'\u037F' ... '\u1FFF' |
'\u200C' ... '\u200D' |
'\u2070' ... '\u218F' |
'\u2C00' ... '\u2FEF' |
'\u3001' ... '\uD7FF' |
'\uF900' ... '\uFDCF' |
'\uFDF0' ... '\uFFFD' |
'\U00010000' ... '\U000EFFFF' => true,
_ => false,
}
}
@ -713,10 +712,10 @@ pub fn xml_name_type(name: &str) -> XMLName {
is_valid_start(c) || match c {
'-' |
'.' |
'0' .. '9' |
'\xB7' |
'\u0300' .. '\u036F' |
'\u203F' .. '\u2040' => true,
'0' ... '9' |
'\u00B7' |
'\u0300' ... '\u036F' |
'\u203F' ... '\u2040' => true,
_ => false,
}
}

View File

@ -80,7 +80,7 @@ impl SessionHistoryEntry {
}
}
static proxy_handler: ProxyTraps = ProxyTraps {
static PROXY_HANDLER: ProxyTraps = ProxyTraps {
getPropertyDescriptor: None,
getOwnPropertyDescriptor: None,
defineProperty: None,
@ -114,6 +114,6 @@ static proxy_handler: ProxyTraps = ProxyTraps {
pub fn new_window_proxy_handler() -> WindowProxyHandler {
unsafe {
WindowProxyHandler(CreateWrapperProxyHandler(&proxy_handler))
WindowProxyHandler(CreateWrapperProxyHandler(&PROXY_HANDLER))
}
}

View File

@ -26,7 +26,7 @@ use script_task::StackRootTLS;
use servo_net::resource_task::{ResourceTask, load_whole_resource};
use servo_util::task::spawn_named_native;
use servo_util::task_state;
use servo_util::task_state::{Script, InWorker};
use servo_util::task_state::{SCRIPT, IN_WORKER};
use js::glue::JS_STRUCTURED_CLONE_VERSION;
use js::jsapi::{JSContext, JS_ReadStructuredClone, JS_WriteStructuredClone, JS_ClearPendingException};
@ -89,7 +89,7 @@ impl DedicatedWorkerGlobalScope {
receiver: Receiver<ScriptMsg>) {
spawn_named_native(format!("WebWorker for {}", worker_url.serialize()), proc() {
task_state::initialize(Script | InWorker);
task_state::initialize(SCRIPT | IN_WORKER);
let roots = RootCollection::new();
let _stack_roots_tls = StackRootTLS::new(&roots);
@ -148,7 +148,7 @@ impl DedicatedWorkerGlobalScope {
Ok(FireTimerMsg(FromWorker, timer_id)) => {
scope.handle_fire_timer(timer_id, js_context.ptr);
}
Ok(_) => fail!("Unexpected message"),
Ok(_) => panic!("Unexpected message"),
Err(_) => break,
}
}

View File

@ -62,8 +62,9 @@ use html5ever::tree_builder::{QuirksMode, NoQuirks, LimitedQuirks, Quirks};
use string_cache::{Atom, QualName};
use url::Url;
use std::collections::hashmap::HashMap;
use std::ascii::StrAsciiExt;
use std::collections::HashMap;
use std::collections::hash_map::{Vacant, Occupied};
use std::ascii::AsciiExt;
use std::cell::Cell;
use std::default::Default;
use time;
@ -233,7 +234,7 @@ impl<'a> DocumentHelpers<'a> for JSRef<'a, Document> {
to_unregister: JSRef<Element>,
id: Atom) {
let mut idmap = self.idmap.borrow_mut();
let is_empty = match idmap.find_mut(&id) {
let is_empty = match idmap.get_mut(&id) {
None => false,
Some(elements) => {
let position = elements.iter()
@ -262,29 +263,35 @@ impl<'a> DocumentHelpers<'a> for JSRef<'a, Document> {
let mut idmap = self.idmap.borrow_mut();
let root = self.GetDocumentElement().expect("The element is in the document, so there must be a document element.").root();
idmap.find_with_or_insert_with(id, element,
|_key, elements, element| {
match idmap.entry(id) {
Vacant(entry) => {
entry.set(vec!(element.unrooted()));
}
Occupied(entry) => {
let elements = entry.into_mut();
let new_node: JSRef<Node> = NodeCast::from_ref(element);
let mut head : uint = 0u;
let mut head: uint = 0u;
let root: JSRef<Node> = NodeCast::from_ref(*root);
for node in root.traverse_preorder() {
let elem: Option<JSRef<Element>> = ElementCast::to_ref(node);
match elem {
None => {},
Some(elem) => {
if *(*elements)[head].root() == elem {
head = head + 1;
head += 1;
}
if new_node == node || head == elements.len() {
break;
}
}
None => {}
}
}
elements.insert_unrooted(head, &element);
},
|_key, element| vec![element.unrooted()]
);
}
}
}
fn load_anchor_href(self, href: DOMString) {
@ -514,7 +521,7 @@ impl<'a> DocumentMethods for JSRef<'a, Document> {
// http://dom.spec.whatwg.org/#dom-nonelementparentnode-getelementbyid
fn GetElementById(self, id: DOMString) -> Option<Temporary<Element>> {
let id = Atom::from_slice(id.as_slice());
match self.idmap.borrow().find(&id) {
match self.idmap.borrow().get(&id) {
None => None,
Some(ref elements) => Some(Temporary::new((*elements)[0].clone())),
}
@ -660,7 +667,7 @@ impl<'a> DocumentMethods for JSRef<'a, Document> {
fn LastModified(self) -> DOMString {
match *self.last_modified.borrow() {
Some(ref t) => t.clone(),
None => time::now().strftime("%m/%d/%Y %H:%M:%S"),
None => time::now().strftime("%m/%d/%Y %H:%M:%S").unwrap(),
}
}

View File

@ -56,7 +56,7 @@ impl DOMErrorName {
error::Abort => AbortError,
error::Timeout => TimeoutError,
error::DataClone => DataCloneError,
error::FailureUnknown => fail!(),
error::FailureUnknown => panic!(),
}
}
}

View File

@ -10,7 +10,7 @@ use dom::bindings::js::{JSRef, Temporary};
use dom::bindings::utils::{Reflectable, Reflector, reflect_dom_object};
use servo_util::str::DOMString;
use std::collections::hashmap::HashMap;
use std::collections::HashMap;
#[dom_struct]
pub struct DOMStringMap {
@ -46,7 +46,7 @@ impl<'a> DOMStringMapMethods for JSRef<'a, DOMStringMap> {
}
fn NamedGetter(self, name: DOMString, found: &mut bool) -> DOMString {
match self.map.borrow().find(&name) {
match self.map.borrow().get(&name) {
Some(value) => {
*found = true;
value.clone()

View File

@ -40,7 +40,7 @@ use style;
use servo_util::namespace;
use servo_util::str::{DOMString, LengthOrPercentageOrAuto};
use std::ascii::StrAsciiExt;
use std::ascii::AsciiExt;
use std::default::Default;
use std::mem;
use string_cache::{Atom, Namespace, QualName};
@ -311,7 +311,7 @@ impl RawLayoutElementHelpers for Element {
match length_attribute {
WidthLengthAttribute => {
if !self.is_htmltablecellelement() {
fail!("I'm not a table cell!")
panic!("I'm not a table cell!")
}
let this: &HTMLTableCellElement = mem::transmute(self);
this.get_width()
@ -326,7 +326,7 @@ impl RawLayoutElementHelpers for Element {
match integer_attribute {
SizeIntegerAttribute => {
if !self.is_htmlinputelement() {
fail!("I'm not a form input!")
panic!("I'm not a form input!")
}
let this: &HTMLInputElement = mem::transmute(self);
Some(this.get_size_for_layout() as i32)
@ -624,7 +624,7 @@ impl<'a> AttributeHandlers for JSRef<'a, Element> {
Some(attribute) => {
match *attribute.value() {
UIntAttrValue(_, value) => value,
_ => fail!("Expected a UIntAttrValue"),
_ => panic!("Expected a UIntAttrValue"),
}
}
None => 0,
@ -1131,7 +1131,7 @@ impl<'a> style::TElement<'a> for JSRef<'a, Element> {
let attr = attr.root();
match *attr.value() {
AtomAttrValue(ref val) => val.clone(),
_ => fail!("`id` attribute should be AtomAttrValue"),
_ => panic!("`id` attribute should be AtomAttrValue"),
}
})
}

View File

@ -21,10 +21,11 @@ use js::jsapi::{JSContext, JSObject};
use servo_util::fnv::FnvHasher;
use servo_util::str::DOMString;
use libc::{c_char, size_t};
use std::collections::hash_map::{Occupied, Vacant};
use std::ptr;
use url::Url;
use std::collections::hashmap::HashMap;
use std::collections::HashMap;
#[deriving(PartialEq)]
#[jstraceable]
@ -83,14 +84,14 @@ impl EventTarget {
}
pub fn get_listeners(&self, type_: &str) -> Option<Vec<EventListener>> {
self.handlers.borrow().find_equiv(&type_).map(|listeners| {
self.handlers.borrow().find_equiv(type_).map(|listeners| {
listeners.iter().map(|entry| entry.listener.get_listener()).collect()
})
}
pub fn get_listeners_for(&self, type_: &str, desired_phase: ListenerPhase)
-> Option<Vec<EventListener>> {
self.handlers.borrow().find_equiv(&type_).map(|listeners| {
self.handlers.borrow().find_equiv(type_).map(|listeners| {
let filtered = listeners.iter().filter(|entry| entry.phase == desired_phase);
filtered.map(|entry| entry.listener.get_listener()).collect()
})
@ -137,7 +138,11 @@ impl<'a> EventTargetHelpers for JSRef<'a, EventTarget> {
ty: DOMString,
listener: Option<EventListener>) {
let mut handlers = self.handlers.borrow_mut();
let entries = handlers.find_or_insert_with(ty, |_| vec!());
let entries = match handlers.entry(ty) {
Occupied(entry) => entry.into_mut(),
Vacant(entry) => entry.set(vec!()),
};
let idx = entries.iter().position(|&entry| {
match entry.listener {
Inline(_) => true,
@ -148,7 +153,7 @@ impl<'a> EventTargetHelpers for JSRef<'a, EventTarget> {
match idx {
Some(idx) => {
match listener {
Some(listener) => entries.get_mut(idx).listener = Inline(listener),
Some(listener) => entries[idx].listener = Inline(listener),
None => {
entries.remove(idx);
}
@ -167,7 +172,7 @@ impl<'a> EventTargetHelpers for JSRef<'a, EventTarget> {
fn get_inline_event_listener(self, ty: DOMString) -> Option<EventListener> {
let handlers = self.handlers.borrow();
let entries = handlers.find(&ty);
let entries = handlers.get(&ty);
entries.and_then(|entries| entries.iter().find(|entry| {
match entry.listener {
Inline(_) => true,
@ -187,21 +192,21 @@ impl<'a> EventTargetHelpers for JSRef<'a, EventTarget> {
let lineno = 0; //XXXjdm need to get a real number here
let nargs = 1; //XXXjdm not true for onerror
static arg_name: [c_char, ..6] =
static ARG_NAME: [c_char, ..6] =
['e' as c_char, 'v' as c_char, 'e' as c_char, 'n' as c_char, 't' as c_char, 0];
static arg_names: [*const c_char, ..1] = [&arg_name as *const c_char];
static ARG_NAMES: [*const c_char, ..1] = [&ARG_NAME as *const c_char];
let source: Vec<u16> = source.as_slice().utf16_units().collect();
let handler = unsafe {
JS_CompileUCFunction(cx,
ptr::null_mut(),
name.as_ptr(),
nargs,
&arg_names as *const *const i8 as *mut *const i8,
source.as_ptr(),
source.len() as size_t,
url.as_ptr(),
lineno)
JS_CompileUCFunction(cx,
ptr::null_mut(),
name.as_ptr(),
nargs,
&ARG_NAMES as *const *const i8 as *mut *const i8,
source.as_ptr(),
source.len() as size_t,
url.as_ptr(),
lineno)
};
if handler.is_null() {
report_pending_exception(cx, self.reflector().get_jsobject());
@ -241,7 +246,11 @@ impl<'a> EventTargetMethods for JSRef<'a, EventTarget> {
match listener {
Some(listener) => {
let mut handlers = self.handlers.borrow_mut();
let entry = handlers.find_or_insert_with(ty, |_| vec!());
let entry = match handlers.entry(ty) {
Occupied(entry) => entry.into_mut(),
Vacant(entry) => entry.set(vec!()),
};
let phase = if capture { Capturing } else { Bubbling };
let new_entry = EventListenerEntry {
phase: phase,
@ -262,7 +271,7 @@ impl<'a> EventTargetMethods for JSRef<'a, EventTarget> {
match listener {
Some(listener) => {
let mut handlers = self.handlers.borrow_mut();
let mut entry = handlers.find_mut(&ty);
let mut entry = handlers.get_mut(&ty);
for entry in entry.iter_mut() {
let phase = if capture { Capturing } else { Bubbling };
let old_entry = EventListenerEntry {

View File

@ -15,7 +15,8 @@ use dom::blob::Blob;
use dom::file::File;
use dom::htmlformelement::HTMLFormElement;
use servo_util::str::DOMString;
use std::collections::hashmap::HashMap;
use std::collections::HashMap;
use std::collections::hash_map::{Occupied, Vacant};
#[deriving(Clone)]
#[jstraceable]
@ -57,13 +58,21 @@ impl<'a> FormDataMethods for JSRef<'a, FormData> {
#[allow(unrooted_must_root)]
fn Append(self, name: DOMString, value: JSRef<Blob>, filename: Option<DOMString>) {
let file = FileData(JS::from_rooted(self.get_file_from_blob(value, filename)));
self.data.borrow_mut().insert_or_update_with(name.clone(), vec!(file.clone()),
|_k, v| {v.push(file.clone());});
let mut data = self.data.borrow_mut();
match data.entry(name) {
Occupied(entry) => entry.into_mut().push(file),
Vacant(entry) => {
entry.set(vec!(file));
}
}
}
fn Append_(self, name: DOMString, value: DOMString) {
self.data.borrow_mut().insert_or_update_with(name, vec!(StringData(value.clone())),
|_k, v| {v.push(StringData(value.clone()));});
let mut data = self.data.borrow_mut();
match data.entry(name) {
Occupied(entry) => entry.into_mut().push(StringData(value)),
Vacant (entry) => { entry.set(vec!(StringData(value))); },
}
}
fn Delete(self, name: DOMString) {

View File

@ -72,7 +72,7 @@ impl<'a> VirtualMethods for JSRef<'a, HTMLBodyElement> {
let name = attr.local_name().as_slice();
if name.starts_with("on") {
static forwarded_events: &'static [&'static str] =
static FORWARDED_EVENTS: &'static [&'static str] =
&["onfocus", "onload", "onscroll", "onafterprint", "onbeforeprint",
"onbeforeunload", "onhashchange", "onlanguagechange", "onmessage",
"onoffline", "ononline", "onpagehide", "onpageshow", "onpopstate",
@ -82,7 +82,7 @@ impl<'a> VirtualMethods for JSRef<'a, HTMLBodyElement> {
window.get_url(),
window.reflector().get_jsobject());
let evtarget: JSRef<EventTarget> =
if forwarded_events.iter().any(|&event| name == event) {
if FORWARDED_EVENTS.iter().any(|&event| name == event) {
EventTargetCast::from_ref(*window)
} else {
EventTargetCast::from_ref(*self)

View File

@ -18,7 +18,7 @@ use dom::node::{DisabledStateHelpers, Node, NodeHelpers, ElementNodeTypeId, wind
use dom::validitystate::ValidityState;
use dom::virtualmethods::VirtualMethods;
use std::ascii::OwnedStrAsciiExt;
use std::ascii::OwnedAsciiExt;
use servo_util::str::DOMString;
use string_cache::Atom;

View File

@ -26,8 +26,8 @@ use geom::size::Size2D;
use std::cell::Cell;
use std::default::Default;
static DefaultWidth: u32 = 300;
static DefaultHeight: u32 = 150;
const DEFAULT_WIDTH: u32 = 300;
const DEFAULT_HEIGHT: u32 = 150;
#[dom_struct]
pub struct HTMLCanvasElement {
@ -48,8 +48,8 @@ impl HTMLCanvasElement {
HTMLCanvasElement {
htmlelement: HTMLElement::new_inherited(HTMLCanvasElementTypeId, localName, prefix, document),
context: Default::default(),
width: Cell::new(DefaultWidth),
height: Cell::new(DefaultHeight),
width: Cell::new(DEFAULT_WIDTH),
height: Cell::new(DEFAULT_HEIGHT),
}
}
@ -108,11 +108,11 @@ impl<'a> VirtualMethods for JSRef<'a, HTMLCanvasElement> {
let recreate = match attr.local_name() {
&atom!("width") => {
self.width.set(DefaultWidth);
self.width.set(DEFAULT_WIDTH);
true
}
&atom!("height") => {
self.height.set(DefaultHeight);
self.height.set(DEFAULT_HEIGHT);
true
}
_ => false,
@ -136,11 +136,11 @@ impl<'a> VirtualMethods for JSRef<'a, HTMLCanvasElement> {
let value = attr.value();
let recreate = match attr.local_name() {
&atom!("width") => {
self.width.set(parse_unsigned_integer(value.as_slice().chars()).unwrap_or(DefaultWidth));
self.width.set(parse_unsigned_integer(value.as_slice().chars()).unwrap_or(DEFAULT_WIDTH));
true
}
&atom!("height") => {
self.height.set(parse_unsigned_integer(value.as_slice().chars()).unwrap_or(DefaultHeight));
self.height.set(parse_unsigned_integer(value.as_slice().chars()).unwrap_or(DEFAULT_HEIGHT));
true
}
_ => false,

View File

@ -15,11 +15,11 @@ use dom::window::Window;
use servo_util::namespace;
use servo_util::str::{DOMString, split_html_space_chars};
use std::ascii::StrAsciiExt;
use std::ascii::AsciiExt;
use string_cache::{Atom, Namespace};
pub trait CollectionFilter : JSTraceable {
fn filter(&self, elem: JSRef<Element>, root: JSRef<Node>) -> bool;
fn filter<'a>(&self, elem: JSRef<'a, Element>, root: JSRef<'a, Node>) -> bool;
}
#[jstraceable]

View File

@ -54,11 +54,11 @@ impl<'a> HTMLFieldSetElementMethods for JSRef<'a, HTMLFieldSetElement> {
#[jstraceable]
struct ElementsFilter;
impl CollectionFilter for ElementsFilter {
fn filter(&self, elem: JSRef<Element>, root: JSRef<Node>) -> bool {
static tag_names: StaticStringVec = &["button", "fieldset", "input",
fn filter<'a>(&self, elem: JSRef<'a, Element>, root: JSRef<'a, Node>) -> bool {
static TAG_NAMES: StaticStringVec = &["button", "fieldset", "input",
"keygen", "object", "output", "select", "textarea"];
let root: JSRef<Element> = ElementCast::to_ref(root).unwrap();
elem != root && tag_names.iter().any(|&tag_name| tag_name == elem.local_name().as_slice())
elem != root && TAG_NAMES.iter().any(|&tag_name| tag_name == elem.local_name().as_slice())
}
}
let node: JSRef<Node> = NodeCast::from_ref(self);

View File

@ -24,8 +24,7 @@ use http::method::Post;
use servo_msg::constellation_msg::LoadData;
use servo_util::str::DOMString;
use script_task::{ScriptChan, TriggerLoadMsg};
use std::ascii::OwnedStrAsciiExt;
use std::str::StrSlice;
use std::ascii::OwnedAsciiExt;
use url::UrlParser;
use url::form_urlencoded::serialize;
use string_cache::Atom;
@ -200,26 +199,26 @@ impl<'a> HTMLFormElementHelpers for JSRef<'a, HTMLFormElement> {
for ch in s.chars() {
match ch {
'\n' if prev != '\r' => {
buf.push_char('\r');
buf.push_char('\n');
buf.push('\r');
buf.push('\n');
},
'\n' => {
buf.push_char('\n');
buf.push('\n');
},
// This character isn't LF but is
// preceded by CR
_ if prev == '\r' => {
buf.push_char('\r');
buf.push_char('\n');
buf.push_char(ch);
buf.push('\r');
buf.push('\n');
buf.push(ch);
},
_ => buf.push_char(ch)
_ => buf.push(ch)
};
prev = ch;
}
// In case the last character was CR
if prev == '\r' {
buf.push_char('\n');
buf.push('\n');
}
buf
}

View File

@ -25,7 +25,7 @@ use servo_msg::constellation_msg::{IFrameSandboxed, IFrameUnsandboxed};
use servo_msg::constellation_msg::{ConstellationChan, ScriptLoadedURLInIFrameMsg};
use servo_util::str::DOMString;
use std::ascii::StrAsciiExt;
use std::ascii::AsciiExt;
use std::cell::Cell;
use url::{Url, UrlParser};

Some files were not shown because too many files have changed in this diff Show More