https://bugs.webkit.org/show_bug.cgi?id=52736
authorhyatt@apple.com <hyatt@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 14 Sep 2011 22:24:23 +0000 (22:24 +0000)
committerhyatt@apple.com <hyatt@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 14 Sep 2011 22:24:23 +0000 (22:24 +0000)
Tiles were not being properly centered within border image sides for the "repeat"
keyword. This patch fixes the buggy math behind the pattern tiling to actually get
the initial phases correct.

Source/WebCore:

Reviewed by Sam Weinig.

Added new tests in fast/borders and updated broken existing tests.

* platform/graphics/Image.cpp:
(WebCore::Image::drawTiled):

LayoutTests:

Reviewed by Sam Weinig.

* fast/borders/border-image-massive-scale.html: Added.
* fast/borders/border-image-scaled-gradient.html: Added.
* platform/mac/fast/borders/border-image-massive-scale-expected.png: Added.
* platform/mac/fast/borders/border-image-massive-scale-expected.txt: Added.
* platform/mac/fast/borders/border-image-outset-expected.png:
* platform/mac/fast/borders/border-image-outset-in-shorthand-expected.png:
* platform/mac/fast/borders/border-image-outset-split-inline-expected.png:
* platform/mac/fast/borders/border-image-outset-split-inline-vertical-lr-expected.png:
* platform/mac/fast/borders/border-image-scaled-gradient-expected.png: Added.
* platform/mac/fast/borders/border-image-scaled-gradient-expected.txt: Added.
* platform/mac/fast/borders/border-image-side-reduction-expected.png:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@95129 268f45cc-cd09-0410-ab3c-d52691b4dbfc

14 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/borders/border-image-massive-scale.html [new file with mode: 0644]
LayoutTests/fast/borders/border-image-scaled-gradient.html [new file with mode: 0644]
LayoutTests/platform/mac/fast/borders/border-image-massive-scale-expected.png [new file with mode: 0644]
LayoutTests/platform/mac/fast/borders/border-image-massive-scale-expected.txt [new file with mode: 0644]
LayoutTests/platform/mac/fast/borders/border-image-outset-expected.png
LayoutTests/platform/mac/fast/borders/border-image-outset-in-shorthand-expected.png
LayoutTests/platform/mac/fast/borders/border-image-outset-split-inline-expected.png
LayoutTests/platform/mac/fast/borders/border-image-outset-split-inline-vertical-lr-expected.png
LayoutTests/platform/mac/fast/borders/border-image-scaled-gradient-expected.png [new file with mode: 0644]
LayoutTests/platform/mac/fast/borders/border-image-scaled-gradient-expected.txt [new file with mode: 0644]
LayoutTests/platform/mac/fast/borders/border-image-side-reduction-expected.png
Source/WebCore/ChangeLog
Source/WebCore/platform/graphics/Image.cpp

index 6f93df0..6615b9c 100644 (file)
@@ -1,3 +1,25 @@
+2011-09-14  David Hyatt  <hyatt@apple.com>
+
+        https://bugs.webkit.org/show_bug.cgi?id=52736
+
+        Tiles were not being properly centered within border image sides for the "repeat"
+        keyword. This patch fixes the buggy math behind the pattern tiling to actually get
+        the initial phases correct.
+
+        Reviewed by Sam Weinig.
+
+        * fast/borders/border-image-massive-scale.html: Added.
+        * fast/borders/border-image-scaled-gradient.html: Added.
+        * platform/mac/fast/borders/border-image-massive-scale-expected.png: Added.
+        * platform/mac/fast/borders/border-image-massive-scale-expected.txt: Added.
+        * platform/mac/fast/borders/border-image-outset-expected.png:
+        * platform/mac/fast/borders/border-image-outset-in-shorthand-expected.png:
+        * platform/mac/fast/borders/border-image-outset-split-inline-expected.png:
+        * platform/mac/fast/borders/border-image-outset-split-inline-vertical-lr-expected.png:
+        * platform/mac/fast/borders/border-image-scaled-gradient-expected.png: Added.
+        * platform/mac/fast/borders/border-image-scaled-gradient-expected.txt: Added.
+        * platform/mac/fast/borders/border-image-side-reduction-expected.png:
+
 2011-09-14  Jeremy Apthorp  <jeremya@chromium.org>
 
         Change mousedown events to keydown events, since eventSender.mouseDown
diff --git a/LayoutTests/fast/borders/border-image-massive-scale.html b/LayoutTests/fast/borders/border-image-massive-scale.html
new file mode 100644 (file)
index 0000000..1ac13e2
--- /dev/null
@@ -0,0 +1,36 @@
+<html>
+<head>
+    <style>
+        div {
+            border-width: 105px 150px 150px 105px;
+            width: 75px;
+            height: 75px;
+            margin: 10px;
+            display: inline-block;
+        }
+
+        div.rr {
+            -webkit-border-image: url("resources/border-image.png") 21 30 30 21 repeat repeat;
+        }
+
+        div.rs {
+            -webkit-border-image: url("resources/border-image.png") 21 30 30 21 repeat stretch;
+        }
+
+        div.sr {
+            -webkit-border-image: url("resources/border-image.png") 21 30 30 21 stretch repeat;
+        }
+
+        div.ss {
+            -webkit-border-image: url("resources/border-image.png") 21 30 30 21 stretch stretch;
+        }
+    </style>
+</head>
+<body>
+    <div class="rr"></div>
+    <div class="rs"></div>
+    <br>
+    <div class="sr"></div>
+    <div class="ss"></div>
+</body>
+</html>
diff --git a/LayoutTests/fast/borders/border-image-scaled-gradient.html b/LayoutTests/fast/borders/border-image-scaled-gradient.html
new file mode 100644 (file)
index 0000000..17bf963
--- /dev/null
@@ -0,0 +1,20 @@
+<!DOCTYPE html>
+
+<html>
+<head>
+  <style>
+    div {
+      width: 300px;
+      height: 300px;
+      -webkit-border-image: -webkit-linear-gradient(30deg, black, white) 1 repeat;
+      border-image: -webkit-linear-gradient(30deg, black, white) 1 fill repeat;
+      border: 2px solid red;
+    }
+      
+  </style>
+</head>
+<body>
+  <div>
+  </div>
+</body>
+</html>
diff --git a/LayoutTests/platform/mac/fast/borders/border-image-massive-scale-expected.png b/LayoutTests/platform/mac/fast/borders/border-image-massive-scale-expected.png
new file mode 100644 (file)
index 0000000..b52a386
Binary files /dev/null and b/LayoutTests/platform/mac/fast/borders/border-image-massive-scale-expected.png differ
diff --git a/LayoutTests/platform/mac/fast/borders/border-image-massive-scale-expected.txt b/LayoutTests/platform/mac/fast/borders/border-image-massive-scale-expected.txt
new file mode 100644 (file)
index 0000000..cb99b88
--- /dev/null
@@ -0,0 +1,17 @@
+layer at (0,0) size 785x724
+  RenderView at (0,0) size 785x600
+layer at (0,0) size 785x724
+  RenderBlock {HTML} at (0,0) size 785x724
+    RenderBody {BODY} at (8,8) size 769x708
+      RenderBlock {DIV} at (10,10) size 330x330 [border: (105px none #000000) (150px none #000000) (105px none #000000)]
+      RenderText {#text} at (350,336) size 4x18
+        text run at (350,336) width 4: " "
+      RenderBlock {DIV} at (364,10) size 330x330 [border: (105px none #000000) (150px none #000000) (105px none #000000)]
+      RenderText {#text} at (704,336) size 4x18
+        text run at (704,336) width 4: " "
+      RenderBR {BR} at (0,0) size 0x0
+      RenderBlock {DIV} at (10,364) size 330x330 [border: (105px none #000000) (150px none #000000) (105px none #000000)]
+      RenderText {#text} at (350,690) size 4x18
+        text run at (350,690) width 4: " "
+      RenderBlock {DIV} at (364,364) size 330x330 [border: (105px none #000000) (150px none #000000) (105px none #000000)]
+      RenderText {#text} at (0,0) size 0x0
index aaed6d6..80f2547 100644 (file)
Binary files a/LayoutTests/platform/mac/fast/borders/border-image-outset-expected.png and b/LayoutTests/platform/mac/fast/borders/border-image-outset-expected.png differ
index aaed6d6..80f2547 100644 (file)
Binary files a/LayoutTests/platform/mac/fast/borders/border-image-outset-in-shorthand-expected.png and b/LayoutTests/platform/mac/fast/borders/border-image-outset-in-shorthand-expected.png differ
index 5418719..dd264a8 100644 (file)
Binary files a/LayoutTests/platform/mac/fast/borders/border-image-outset-split-inline-expected.png and b/LayoutTests/platform/mac/fast/borders/border-image-outset-split-inline-expected.png differ
index 92863bf..5395905 100644 (file)
Binary files a/LayoutTests/platform/mac/fast/borders/border-image-outset-split-inline-vertical-lr-expected.png and b/LayoutTests/platform/mac/fast/borders/border-image-outset-split-inline-vertical-lr-expected.png differ
diff --git a/LayoutTests/platform/mac/fast/borders/border-image-scaled-gradient-expected.png b/LayoutTests/platform/mac/fast/borders/border-image-scaled-gradient-expected.png
new file mode 100644 (file)
index 0000000..c13e88e
Binary files /dev/null and b/LayoutTests/platform/mac/fast/borders/border-image-scaled-gradient-expected.png differ
diff --git a/LayoutTests/platform/mac/fast/borders/border-image-scaled-gradient-expected.txt b/LayoutTests/platform/mac/fast/borders/border-image-scaled-gradient-expected.txt
new file mode 100644 (file)
index 0000000..ac31e2a
--- /dev/null
@@ -0,0 +1,6 @@
+layer at (0,0) size 800x600
+  RenderView at (0,0) size 800x600
+layer at (0,0) size 800x320
+  RenderBlock {HTML} at (0,0) size 800x320
+    RenderBody {BODY} at (8,8) size 784x304
+      RenderBlock {DIV} at (0,0) size 304x304 [border: (2px solid #FF0000)]
index 72c4380..885264f 100644 (file)
Binary files a/LayoutTests/platform/mac/fast/borders/border-image-side-reduction-expected.png and b/LayoutTests/platform/mac/fast/borders/border-image-side-reduction-expected.png differ
index 53b34f7..99e2914 100644 (file)
@@ -1,3 +1,18 @@
+2011-09-14  David Hyatt  <hyatt@apple.com>
+
+        https://bugs.webkit.org/show_bug.cgi?id=52736
+
+        Tiles were not being properly centered within border image sides for the "repeat"
+        keyword. This patch fixes the buggy math behind the pattern tiling to actually get
+        the initial phases correct.
+
+        Reviewed by Sam Weinig.
+        
+        Added new tests in fast/borders and updated broken existing tests.
+
+        * platform/graphics/Image.cpp:
+        (WebCore::Image::drawTiled):
+
 2011-09-14  Anders Carlsson  <andersca@apple.com>
 
         Remove DocTypeStrings.gperf
index 7bc6e19..3c9c576 100644 (file)
@@ -153,10 +153,12 @@ void Image::drawTiled(GraphicsContext* ctxt, const FloatRect& dstRect, const Flo
     // set for a particular rule).
     float hPhase = tileScaleFactor.width() * srcRect.x();
     float vPhase = tileScaleFactor.height() * srcRect.y();
+    float scaledTileWidth = tileScaleFactor.width() * srcRect.width();
+    float scaledTileHeight = tileScaleFactor.height() * srcRect.height();
     if (hRule == Image::RepeatTile)
-        hPhase -= fmodf(dstRect.width(), tileScaleFactor.width() * srcRect.width()) / 2.0f;
+        hPhase -= (dstRect.width() - scaledTileWidth) / 2;
     if (vRule == Image::RepeatTile)
-        vPhase -= fmodf(dstRect.height(), tileScaleFactor.height() * srcRect.height()) / 2.0f;
+        vPhase -= (dstRect.height() - scaledTileHeight) / 2; 
     FloatPoint patternPhase(dstRect.x() - hPhase, dstRect.y() - vPhase);
     
     drawPattern(ctxt, srcRect, patternTransform, patternPhase, styleColorSpace, op, dstRect);