From 13bfaeb97d61a153d00c34f648ec260fb0632241 Mon Sep 17 00:00:00 2001 From: Bryan Bell Date: Wed, 21 May 2014 16:30:15 -0700 Subject: [PATCH] Double border support --- src/components/gfx/render_context.rs | 18 ++++++++++++++++++ src/components/style/properties.rs.mako | 3 +-- src/test/html/test_border.html | 6 ++++++ src/test/ref/borders.png | Bin 2993 -> 3027 bytes src/test/ref/borders_a.html | 6 ++++++ 5 files changed, 31 insertions(+), 2 deletions(-) diff --git a/src/components/gfx/render_context.rs b/src/components/gfx/render_context.rs index 494a9952302..6d4d62d79bc 100644 --- a/src/components/gfx/render_context.rs +++ b/src/components/gfx/render_context.rs @@ -159,6 +159,9 @@ impl<'a> RenderContext<'a> { border_style::solid => { self.draw_solid_border_segment(direction,bounds,border,color_select); } + border_style::double => { + self.draw_double_border_segment(direction, bounds, border, color_select); + } border_style::groove | border_style::ridge => { self.draw_groove_ridge_border_segment(direction, bounds, border, color_select, style_select); } @@ -182,6 +185,9 @@ impl<'a> RenderContext<'a> { border_style::solid => { self.draw_solid_border_segment(Right,bounds,border,color); } + border_style::double => { + self.draw_double_border_segment(Right, bounds, border, color); + } border_style::groove | border_style::ridge => { self.draw_groove_ridge_border_segment(Right, bounds, border, color, style); } @@ -329,6 +335,18 @@ impl<'a> RenderContext<'a> { return Color(color.r * scale_factor, color.g * scale_factor, color.b * scale_factor, color.a); } + fn draw_double_border_segment(&self, direction: Direction, bounds: &Rect, border: SideOffsets2D, color: Color) { + let scaled_border = SideOffsets2D::new((1.0/3.0) * border.top, + (1.0/3.0) * border.right, + (1.0/3.0) * border.bottom, + (1.0/3.0) * border.left); + let inner_scaled_bounds = self.get_scaled_bounds(bounds, border, 2.0/3.0); + // draw the outer portion of the double border. + self.draw_solid_border_segment(direction, bounds, scaled_border, color); + // draw the inner portion of the double border. + self.draw_border_path(inner_scaled_bounds, direction, scaled_border, color); + } + fn draw_groove_ridge_border_segment(&self, direction: Direction, bounds: &Rect, diff --git a/src/components/style/properties.rs.mako b/src/components/style/properties.rs.mako index 184a0f58f0e..2f928bfa812 100644 --- a/src/components/style/properties.rs.mako +++ b/src/components/style/properties.rs.mako @@ -221,8 +221,7 @@ pub mod longhands { ${predefined_type("border-%s-color" % side, "CSSColor", "CurrentColor")} % endfor - // double - ${single_keyword("border-top-style", values="none solid dotted dashed hidden groove ridge inset outset")} + ${single_keyword("border-top-style", values="none solid double dotted dashed hidden groove ridge inset outset")} % for side in ["right", "bottom", "left"]: <%self:longhand name="border-${side}-style", no_super="True"> diff --git a/src/test/html/test_border.html b/src/test/html/test_border.html index 3b81f02982d..6e8d60f5d1a 100755 --- a/src/test/html/test_border.html +++ b/src/test/html/test_border.html @@ -16,6 +16,11 @@ border-width: 10px; border-color: yellow green red black; } +#double{ + border-style: double; + border-width: 10px; + border-color: yellow green red black; +} #dashed{ border-style: dashed; border-width: 10px; @@ -67,6 +72,7 @@
none test.
hidden test.
solid test
+
double test
dashed test
dotted test
groove test
diff --git a/src/test/ref/borders.png b/src/test/ref/borders.png index 7de3f724b7c18f0bdd4bd05bdd21077e7196e122..7d7ee68b35a18a8523764fe14dc807dcbe294682 100644 GIT binary patch literal 3027 zcmeAS@N?(olHy`uVBq!ia0y~yU{+vYV2a>i0*Z)=h^jL%aL@8|aSW-L^Y-pRUl~UM zhl`onixuVP@J;CJY_GU=-SHEj&Y!Ox*Q&!~7S;S-6}$cToML8%1)pEPVP#+lQ{KS9 zki^8zprD4qDBJmO@yGw$7#My`{P%a>3T`n52cHB+h9fLAW9ZHQVf^`BGy}sQmB&Ah z>qRgy7&fvp2nYii8_(CUXTNXumtkZOD?PmZQY?mZ!5-NDPupqzE@pY6H?z!{&vXAxqo0aF!RhQk{{CVEo?{D^e7cTpE zstv9K}zk7Hplle*2>J zDu^j-A~(N2yNlTPJoc^N8!!!K7an9{=-||0Xqa&T%D9pGyB3$!(~oc8h%zu-d(;Gt zMR=$I1M8+X1H+o5DA5Ft!sKeZYF37ZtvfK>_GZ)GxqF!y4n$#k-RzkSE=`|)RpD~q z4Y~7ij0_37Bt$VTS7Qb{NW^U0^UdK53=!Q#$M~n`4{-z;JnT>z(#7XCmjkWnBGw8T z=V98F4x=X1wD27b-qGNtbp=0~#zxcF2ufpb^rx;7*&JG@Dhq6^GkCiCxvXi0*Z)=h^jL%a94P`IEGZrd3*PuuZ*LB z!^O<(MT+us_;Re&Na_s+S{MoO|z_4%W{{8B&nphbGgd-Rj3>&G)xP9JEqJRCblRu62znFbI zx#ptz?Vl&kxtG~(`aE%N|C^eW=ZoKO`0Q?0a*&CkgHwm0Va5Ucj9yFsdzP}(-%p$8 z`}g(v`2VNW=lqMEpY~kYTK*=I$ziu{vT`#hsBK_iNMgdzDEl?(cSX$JN~`#F_o7U* zudRvPoOX6rY|1z1|F@43ZOFe#zn|`2TJIOTuV7c~-o;r^V@!A7Tf>bt^s&T8j(_=j z28In{;uzuZ_V)SR;S3BB-I!*5d;T4l)Ui3Z%ta4nA1*K7Iwt~CRL4$*ERCf$vy!JjWj!)G*n2o~O>iDWd9j3$!NTtJIl@J*Vx XT5$DBrI)~#3j>3vtDnm{r-UW|gJNOy diff --git a/src/test/ref/borders_a.html b/src/test/ref/borders_a.html index ee7bd78db7b..42657346f47 100644 --- a/src/test/ref/borders_a.html +++ b/src/test/ref/borders_a.html @@ -12,6 +12,11 @@ border-width: 10px; border-color: green red yellow black; } +#double{ + border-style: double; + border-width: 10px; + border-color: yellow; +} #solid{ border-style: solid; border-width: 10px; @@ -65,6 +70,7 @@
+