WebCore:
authordarin@apple.com <darin@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 5 Jan 2008 01:11:12 +0000 (01:11 +0000)
committerdarin@apple.com <darin@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 5 Jan 2008 01:11:12 +0000 (01:11 +0000)
        Reviewed by Maciej and Alice.

        - fix <rdar://problem/4404302> Borders where there should be none (canadasmountains.com)

        Test: fast/images/border.html

        * html/HTMLImageElement.cpp:
        (WebCore::HTMLImageElement::parseMappedAttribute): Change the code that handles cases
        where the border value is not a number to use the value "0" for the border width instead
        of not setting the border width and style at all. This matches other browsers, and makes
        more sense.

LayoutTests:

        Reviewed by Maciej and Alice.

        - test for <rdar://problem/4404302> Borders where there should be none (canadasmountains.com)

        * fast/images/border.html: Added.
        * fast/images/resources/TEMPLATE.html: Copied from fast/js/resources/TEMPLATE.html.
        * fast/images/resources/border.js: Added.

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

LayoutTests/ChangeLog
LayoutTests/fast/images/border.html [new file with mode: 0644]
LayoutTests/fast/images/resources/TEMPLATE.html [new file with mode: 0644]
LayoutTests/fast/images/resources/border.js [new file with mode: 0644]
WebCore/ChangeLog
WebCore/html/HTMLImageElement.cpp

index 26c2942..58ca271 100644 (file)
@@ -1,3 +1,13 @@
+2008-01-04  Darin Adler  <darin@apple.com>
+
+        Reviewed by Maciej and Alice.
+
+        - test for <rdar://problem/4404302> Borders where there should be none (canadasmountains.com)
+
+        * fast/images/border.html: Added.
+        * fast/images/resources/TEMPLATE.html: Copied from fast/js/resources/TEMPLATE.html.
+        * fast/images/resources/border.js: Added.
+
 2008-01-04  Alice Liu  <alice.liu@apple.com>
 
         Reviewed by Alexey and Darin.
diff --git a/LayoutTests/fast/images/border.html b/LayoutTests/fast/images/border.html
new file mode 100644 (file)
index 0000000..c5b9e3d
--- /dev/null
@@ -0,0 +1,13 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<link rel="stylesheet" href="../js/resources/js-test-style.css">
+<script src="../js/resources/js-test-pre.js"></script>
+</head>
+<body>
+<p id="description"></p>
+<div id="console"></div>
+<script src="resources/border.js"></script>
+<script src="../js/resources/js-test-post.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/fast/images/resources/TEMPLATE.html b/LayoutTests/fast/images/resources/TEMPLATE.html
new file mode 100644 (file)
index 0000000..1936e0d
--- /dev/null
@@ -0,0 +1,13 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<link rel="stylesheet" href="../js/resources/js-test-style.css">
+<script src="../js/resources/js-test-pre.js"></script>
+</head>
+<body>
+<p id="description"></p>
+<div id="console"></div>
+<script src="YOUR_JS_FILE_HERE"></script>
+<script src="../js/resources/js-test-post.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/fast/images/resources/border.js b/LayoutTests/fast/images/resources/border.js
new file mode 100644 (file)
index 0000000..0ba30cf
--- /dev/null
@@ -0,0 +1,39 @@
+description(
+"This tests the HTMLImageElement border property."
+);
+
+function imageBorderWidth(borderValue, style)
+{
+    var image = document.createElement("img");
+    if (borderValue !== undefined)
+        image.setAttribute("border", borderValue);
+    image.setAttribute("style", style);
+    image.setAttribute("width", "0");
+    document.body.appendChild(image);
+    var borderBoxWidth = image.offsetWidth;
+    document.body.removeChild(image);
+    return borderBoxWidth / 2;
+}
+
+shouldBe("imageBorderWidth()", "0");
+shouldBe("imageBorderWidth(null)", "0");
+shouldBe("imageBorderWidth('')", "0");
+shouldBe("imageBorderWidth(0)", "0");
+shouldBe("imageBorderWidth('x')", "0");
+shouldBe("imageBorderWidth(undefined, 'border-width: 20px')", "0");
+
+shouldBe("imageBorderWidth(null, 'border-width: 20px')", "20");
+shouldBe("imageBorderWidth('', 'border-width: 20px')", "20");
+shouldBe("imageBorderWidth('x', 'border-width: 20px')", "20");
+shouldBe("imageBorderWidth(0, 'border-width: 20px')", "20");
+
+shouldBe("imageBorderWidth(10)", "10");
+shouldBe("imageBorderWidth(' 10')", "10");
+shouldBe("imageBorderWidth('10 ')", "10");
+shouldBe("imageBorderWidth(' 10 ')", "10");
+shouldBe("imageBorderWidth('10q')", "10");
+shouldBe("imageBorderWidth(' 10q')", "10");
+shouldBe("imageBorderWidth('10q ')", "10");
+shouldBe("imageBorderWidth(' 10q ')", "10");
+
+var successfullyParsed = true;
index 18f0a6d..51f1a95 100644 (file)
@@ -1,3 +1,17 @@
+2008-01-04  Darin Adler  <darin@apple.com>
+
+        Reviewed by Maciej and Alice.
+
+        - fix <rdar://problem/4404302> Borders where there should be none (canadasmountains.com)
+
+        Test: fast/images/border.html
+
+        * html/HTMLImageElement.cpp:
+        (WebCore::HTMLImageElement::parseMappedAttribute): Change the code that handles cases
+        where the border value is not a number to use the value "0" for the border width instead
+        of not setting the border width and style at all. This matches other browsers, and makes
+        more sense.
+
 2008-01-04  Antti Koivisto  <antti@apple.com>
 
         Try to fix 64-bit build
index ff4858d..b214b8f 100644 (file)
@@ -1,9 +1,7 @@
-/**
- * This file is part of the DOM implementation for KDE.
- *
+/*
  * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
  *           (C) 1999 Antti Koivisto (koivisto@kde.org)
- * Copyright (C) 2004, 2005, 2006 Apple Computer, Inc.
+ * Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public
@@ -99,13 +97,11 @@ void HTMLImageElement::parseMappedAttribute(MappedAttribute* attr)
         addCSSLength(attr, CSS_PROP_HEIGHT, attr->value());
     else if (attrName == borderAttr) {
         // border="noborder" -> border="0"
-        if(attr->value().toInt()) {
-            addCSSLength(attr, CSS_PROP_BORDER_WIDTH, attr->value());
-            addCSSProperty(attr, CSS_PROP_BORDER_TOP_STYLE, CSS_VAL_SOLID);
-            addCSSProperty(attr, CSS_PROP_BORDER_RIGHT_STYLE, CSS_VAL_SOLID);
-            addCSSProperty(attr, CSS_PROP_BORDER_BOTTOM_STYLE, CSS_VAL_SOLID);
-            addCSSProperty(attr, CSS_PROP_BORDER_LEFT_STYLE, CSS_VAL_SOLID);
-        }
+        addCSSLength(attr, CSS_PROP_BORDER_WIDTH, attr->value().toInt() ? attr->value() : "0");
+        addCSSProperty(attr, CSS_PROP_BORDER_TOP_STYLE, CSS_VAL_SOLID);
+        addCSSProperty(attr, CSS_PROP_BORDER_RIGHT_STYLE, CSS_VAL_SOLID);
+        addCSSProperty(attr, CSS_PROP_BORDER_BOTTOM_STYLE, CSS_VAL_SOLID);
+        addCSSProperty(attr, CSS_PROP_BORDER_LEFT_STYLE, CSS_VAL_SOLID);
     } else if (attrName == vspaceAttr) {
         addCSSLength(attr, CSS_PROP_MARGIN_TOP, attr->value());
         addCSSLength(attr, CSS_PROP_MARGIN_BOTTOM, attr->value());