Title: [116389] trunk
Revision
116389
Author
[email protected]
Date
2012-05-07 20:49:57 -0700 (Mon, 07 May 2012)

Log Message

width/height attributes of input element cannot be accessed by _javascript_.
https://bugs.webkit.org/show_bug.cgi?id=70304

Patch by Dongwoo Im <[email protected]> on 2012-05-07
Reviewed by Darin Adler.

If the type of input element is image button, width/height attributes should be supported.
These attributes are defined in HTML5 spec.
http://www.w3.org/TR/html5/the-map-element.html#attr-dim-width

Source/WebCore:

Tests: fast/forms/input-width-height-attributes-without-renderer-loaded-image.html
       fast/forms/input-width-height-attributes-without-renderer-not-loaded-image.html
       fast/forms/input-width-height-attributes-without-renderer.html
       fast/forms/input-width-height-attributes.html

* html/HTMLInputElement.cpp: Add setter/getter functions to query/set width/height of input element.
(WebCore):
(WebCore::HTMLInputElement::height): Gets height of input element.
(WebCore::HTMLInputElement::width): Gets width of input element.
(WebCore::HTMLInputElement::setHeight): Sets height of input element.
(WebCore::HTMLInputElement::setWidth): Sets width of input element.
* html/HTMLInputElement.h: Add public prototype.
(HTMLInputElement):
* html/HTMLInputElement.idl: Add width/height attributes.
* html/ImageInputType.cpp: Add getter functions if the element is an image button.
(WebCore):
(WebCore::ImageInputType::height): Gets height of input element.
(WebCore::ImageInputType::width): Gets width of input element.
* html/ImageInputType.h: Add prototype.
(ImageInputType):
* html/InputType.cpp: Add getter functions.
(WebCore::InputType::height): Returns zero.
(WebCore):
(WebCore::InputType::width): Returns zero.
* html/InputType.h: Add prototype.
(InputType):

LayoutTests:

* fast/forms/input-width-height-attributes-expected.txt: Added.
* fast/forms/input-width-height-attributes-without-renderer-expected.txt: Added.
* fast/forms/input-width-height-attributes-without-renderer-loaded-image-expected.txt: Added.
* fast/forms/input-width-height-attributes-without-renderer-loaded-image.html: Added.
* fast/forms/input-width-height-attributes-without-renderer-not-loaded-image-expected.txt: Added.
* fast/forms/input-width-height-attributes-without-renderer-not-loaded-image.html: Added.
* fast/forms/input-width-height-attributes-without-renderer.html: Added.
* fast/forms/input-width-height-attributes.html: Added.
* fast/forms/resources/green.jpg: Added.
* fast/forms/resources/image-slow.pl: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (116388 => 116389)


--- trunk/LayoutTests/ChangeLog	2012-05-08 03:34:47 UTC (rev 116388)
+++ trunk/LayoutTests/ChangeLog	2012-05-08 03:49:57 UTC (rev 116389)
@@ -1,3 +1,25 @@
+2012-05-07  Dongwoo Im  <[email protected]>
+
+        width/height attributes of input element cannot be accessed by _javascript_.
+        https://bugs.webkit.org/show_bug.cgi?id=70304
+
+        Reviewed by Darin Adler.
+
+        If the type of input element is image button, width/height attributes should be supported.
+        These attributes are defined in HTML5 spec.
+        http://www.w3.org/TR/html5/the-map-element.html#attr-dim-width
+
+        * fast/forms/input-width-height-attributes-expected.txt: Added.
+        * fast/forms/input-width-height-attributes-without-renderer-expected.txt: Added.
+        * fast/forms/input-width-height-attributes-without-renderer-loaded-image-expected.txt: Added.
+        * fast/forms/input-width-height-attributes-without-renderer-loaded-image.html: Added.
+        * fast/forms/input-width-height-attributes-without-renderer-not-loaded-image-expected.txt: Added.
+        * fast/forms/input-width-height-attributes-without-renderer-not-loaded-image.html: Added.
+        * fast/forms/input-width-height-attributes-without-renderer.html: Added.
+        * fast/forms/input-width-height-attributes.html: Added.
+        * fast/forms/resources/green.jpg: Added.
+        * fast/forms/resources/image-slow.pl: Added.
+
 2012-05-07  Kinuko Yasuda  <[email protected]>
 
         Support cross-filesystem operations in FileSystem API

Added: trunk/LayoutTests/fast/forms/input-width-height-attributes-expected.txt (0 => 116389)


--- trunk/LayoutTests/fast/forms/input-width-height-attributes-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/forms/input-width-height-attributes-expected.txt	2012-05-08 03:49:57 UTC (rev 116389)
@@ -0,0 +1,65 @@
+width and height attributes of HTMLInputElement.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+Test case #1 : Image, HTML inline setting as "160", "80"
+PASS ('width' in image1) is true
+PASS ('height' in image1) is true
+PASS image1.width,image1.height is 160,80
+Test case #2 : Image, Setting by _javascript_ API as "260", "130"
+PASS ('width' in image1) is true
+PASS ('height' in image1) is true
+PASS image2.width,image2.height is 260,130
+Test case #3 : Image, Setting by _javascript_ API as "120px", "60px"
+PASS ('width' in image1) is true
+PASS ('height' in image1) is true
+PASS image3.width,image3.height is 0,0
+Test case #4 : Image, Setting by _javascript_ API as "120.99", "60.55"
+PASS ('width' in image1) is true
+PASS ('height' in image1) is true
+PASS image4.width,image4.height is 120,60
+Test case #5 : Text, Setting by _javascript_ API as "100", "50"
+PASS ('width' in text1) is true
+PASS ('height' in text1) is true
+PASS text1.width,text1.height is 0,0
+PASS text1.width,text1.height is 100,50
+PASS text1.width,text1.height is 60,40
+Test case #6 : File, Setting by _javascript_ API as "100", "50"
+PASS ('width' in file1) is true
+PASS ('height' in file1) is true
+PASS file1.width,file1.height is 0,0
+PASS file1.width,file1.height is 100,50
+PASS file1.width,file1.height is 60,40
+Test case #7 : Date, Setting by _javascript_ API as "100", "50"
+PASS ('width' in date1) is true
+PASS ('height' in date1) is true
+PASS date1.width,date1.height is 0,0
+PASS date1.width,date1.height is 100,50
+PASS date1.width,date1.height is 60,40
+Test case #8 : Button, Setting by _javascript_ API as "100", "50"
+PASS ('width' in button1) is true
+PASS ('height' in button1) is true
+PASS button1.width,button1.height is 0,0
+PASS button1.width,button1.height is 100,50
+PASS button1.width,button1.height is 60,40
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+

Added: trunk/LayoutTests/fast/forms/input-width-height-attributes-without-renderer-expected.txt (0 => 116389)


--- trunk/LayoutTests/fast/forms/input-width-height-attributes-without-renderer-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/forms/input-width-height-attributes-without-renderer-expected.txt	2012-05-08 03:49:57 UTC (rev 116389)
@@ -0,0 +1,6 @@
+PASS inputElement.width is 50
+PASS inputElement.height is 50
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/fast/forms/input-width-height-attributes-without-renderer-loaded-image-expected.txt (0 => 116389)


--- trunk/LayoutTests/fast/forms/input-width-height-attributes-without-renderer-loaded-image-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/forms/input-width-height-attributes-without-renderer-loaded-image-expected.txt	2012-05-08 03:49:57 UTC (rev 116389)
@@ -0,0 +1,7 @@
+
+PASS e.width is 16
+PASS e.height is 16
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/fast/forms/input-width-height-attributes-without-renderer-loaded-image.html (0 => 116389)


--- trunk/LayoutTests/fast/forms/input-width-height-attributes-without-renderer-loaded-image.html	                        (rev 0)
+++ trunk/LayoutTests/fast/forms/input-width-height-attributes-without-renderer-loaded-image.html	2012-05-08 03:49:57 UTC (rev 116389)
@@ -0,0 +1,26 @@
+<html>
+<head>
+<script src=""
+<script>
+jsTestIsAsync = true;
+</script>
+</head>
+<body>
+<input type="image" id="imageElement" src=""
+<div id="console"></div>
+<script language="_javascript_">
+    document._onreadystatechange_ = function() {
+        readyState = document.readyState;
+        if (readyState == 'complete') {
+            e = document.getElementById("imageElement");
+            e.style = "display:none";
+            shouldBe('e.width', '16');
+            shouldBe('e.height', '16');
+            finishJSTest();
+        }
+    }
+</script>
+<script src=""
+</body>
+</html>
+

Added: trunk/LayoutTests/fast/forms/input-width-height-attributes-without-renderer-not-loaded-image-expected.txt (0 => 116389)


--- trunk/LayoutTests/fast/forms/input-width-height-attributes-without-renderer-not-loaded-image-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/forms/input-width-height-attributes-without-renderer-not-loaded-image-expected.txt	2012-05-08 03:49:57 UTC (rev 116389)
@@ -0,0 +1,6 @@
+PASS e.width is 0
+PASS e.height is 0
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/fast/forms/input-width-height-attributes-without-renderer-not-loaded-image.html (0 => 116389)


--- trunk/LayoutTests/fast/forms/input-width-height-attributes-without-renderer-not-loaded-image.html	                        (rev 0)
+++ trunk/LayoutTests/fast/forms/input-width-height-attributes-without-renderer-not-loaded-image.html	2012-05-08 03:49:57 UTC (rev 116389)
@@ -0,0 +1,20 @@
+<html>
+<head>
+<script src=""
+<script>
+jsTestIsAsync = true;
+</script>
+</head>
+<body>
+<input type="image" id="imageSlow" src="" style="display:none">
+<div id="console"></div>
+<script language="_javascript_">
+    var e = document.getElementById("imageSlow");
+    shouldBe('e.width', '0');
+    shouldBe('e.height', '0');
+    finishJSTest();
+</script>
+<script src=""
+</body>
+</html>
+

Added: trunk/LayoutTests/fast/forms/input-width-height-attributes-without-renderer.html (0 => 116389)


--- trunk/LayoutTests/fast/forms/input-width-height-attributes-without-renderer.html	                        (rev 0)
+++ trunk/LayoutTests/fast/forms/input-width-height-attributes-without-renderer.html	2012-05-08 03:49:57 UTC (rev 116389)
@@ -0,0 +1,21 @@
+<html>
+<head>
+<head>
+<script src=""
+<script>
+jsTestIsAsync = true;
+function test()
+{
+    inputElement = document.getElementById("inputElement");
+    shouldBe('inputElement.width', '50');
+    shouldBe('inputElement.height', '50');
+    finishJSTest();
+
+}
+</script>
+</head>
+<body _onload_="test()">
+<input id="inputElement" type="image" width="50" height="50" style="display:none">
+<script src=""
+</body>
+</html>

Added: trunk/LayoutTests/fast/forms/input-width-height-attributes.html (0 => 116389)


--- trunk/LayoutTests/fast/forms/input-width-height-attributes.html	                        (rev 0)
+++ trunk/LayoutTests/fast/forms/input-width-height-attributes.html	2012-05-08 03:49:57 UTC (rev 116389)
@@ -0,0 +1,156 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+<script src=""
+</head>
+<body>
+<script>
+description('width and height attributes of HTMLInputElement.');
+</script>
+
+<p id="description"></p>
+
+<div id="div1">
+    <input type="image" id="image1" src="" width="160" height="80px">
+</div>
+<br>
+
+<div id="div2">
+    <input type="image" id="image2" src=""
+</div>
+<br>
+
+<div id="div3">
+    <input type="image" id="image3" src=""
+</div>
+<br>
+
+<div id="div4">
+    <input type="image" id="image4" src=""
+</div>
+<br>
+
+<div id="div5">
+    <input type="text" id="text1">
+</div>
+<br>
+
+<div id="div6">
+    <input type="file" id="file1">
+</div>
+<br>
+
+<div id="div7">
+    <input type="date" id="date1">
+</div>
+<br>
+
+<div id="div8">
+    <input type="button" id="button1">
+</div>
+<br>
+
+<script>
+var div = document.getElementById("div1");
+var image1 = document.getElementById("image1");
+debug('Test case #1 : Image, HTML inline setting as \"160\", \"80\"');
+shouldBeTrue("('width' in image1)");
+shouldBeTrue("('height' in image1)");
+shouldBe('image1.width,image1.height', '160,80');
+
+div = document.getElementById("div2");
+var image2 = document.getElementById("image2");
+debug('Test case #2 : Image, Setting by _javascript_ API as \"260\", \"130\"');
+shouldBeTrue("('width' in image1)");
+shouldBeTrue("('height' in image1)");
+image2.width = 260;
+image2.height = 130;
+shouldBe('image2.width,image2.height', '260,130');
+
+div = document.getElementById("div3");
+var image3 = document.getElementById("image3");
+debug('Test case #3 : Image, Setting by _javascript_ API as \"120px\", \"60px\"');
+shouldBeTrue("('width' in image1)");
+shouldBeTrue("('height' in image1)");
+image3.width = "120px";
+image3.height = "60px";
+shouldBe('image3.width,image3.height', '0,0');
+
+div = document.getElementById("div4");
+var image4 = document.getElementById("image4");
+debug('Test case #4 : Image, Setting by _javascript_ API as \"120.99\", \"60.55\"');
+shouldBeTrue("('width' in image1)");
+shouldBeTrue("('height' in image1)");
+image4.width = 120.99;
+image4.height = 60.99;
+shouldBe('image4.width,image4.height', '120,60');
+
+div = document.getElementById("div5");
+var text1 = document.getElementById("text1");
+debug('Test case #5 : Text, Setting by _javascript_ API as \"100\", \"50\"');
+shouldBeTrue("('width' in text1)");
+shouldBeTrue("('height' in text1)");
+text1.width = 100;
+text1.height = 50;
+shouldBe('text1.width,text1.height', '0,0');
+
+text1.type = 'image';
+text1.src = ""
+shouldBe('text1.width,text1.height', '100,50');
+text1.width = 60;
+text1.height = 40;
+shouldBe('text1.width,text1.height', '60,40');
+
+div = document.getElementById("div6");
+var file1 = document.getElementById("file1");
+debug('Test case #6 : File, Setting by _javascript_ API as \"100\", \"50\"');
+shouldBeTrue("('width' in file1)");
+shouldBeTrue("('height' in file1)");
+file1.width = 100;
+file1.height = 50;
+shouldBe('file1.width,file1.height', '0,0');
+
+file1.type = 'image';
+file1.src = ""
+shouldBe('file1.width,file1.height', '100,50');
+file1.width = 60;
+file1.height = 40;
+shouldBe('file1.width,file1.height', '60,40');
+
+div = document.getElementById("div7");
+var date1 = document.getElementById("date1");
+debug('Test case #7 : Date, Setting by _javascript_ API as \"100\", \"50\"');
+shouldBeTrue("('width' in date1)");
+shouldBeTrue("('height' in date1)");
+date1.width = 100;
+date1.height = 50;
+shouldBe('date1.width,date1.height', '0,0');
+
+date1.type = 'image';
+date1.src = ""
+shouldBe('date1.width,date1.height', '100,50');
+date1.width = 60;
+date1.height = 40;
+shouldBe('date1.width,date1.height', '60,40');
+
+div = document.getElementById("div8");
+var button1 = document.getElementById("button1");
+debug('Test case #8 : Button, Setting by _javascript_ API as \"100\", \"50\"');
+shouldBeTrue("('width' in button1)");
+shouldBeTrue("('height' in button1)");
+button1.width = 100;
+button1.height = 50;
+shouldBe('button1.width,button1.height', '0,0');
+
+button1.type = 'image';
+button1.src = ""
+shouldBe('button1.width,button1.height', '100,50');
+button1.width = 60;
+button1.height = 40;
+shouldBe('button1.width,button1.height', '60,40');
+
+var successfullyParsed = true;
+</script>
+<script src=""
+</body>
+</html>

Added: trunk/LayoutTests/fast/forms/resources/green.jpg (0 => 116389)


--- trunk/LayoutTests/fast/forms/resources/green.jpg	                        (rev 0)
+++ trunk/LayoutTests/fast/forms/resources/green.jpg	2012-05-08 03:49:57 UTC (rev 116389)
@@ -0,0 +1,10 @@
+\xFF\xD8\xFF\xE0JFIF``\xFF\xE1\x80ExifMM*JR(\x87iZ``\xA0\xA0\xFF\xDBC	
+	
+	
+	
+
+\xFF\xDBC\xFF\xC0"\xFF\xC4	
+\xFF\xC4\xB5}!1AQa"q2\x81\x91\xA1#B\xB1\xC1R\xD1\xF0$3br\x82	
+%&'()*456789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz\x83\x84\x85\x86\x87\x88\x89\x8A\x92\x93\x94\x95\x96\x97\x98\x99\x9A\xA2\xA3\xA4\xA5\xA6\xA7\xA8\xA9\xAA\xB2\xB3\xB4\xB5\xB6\xB7\xB8\xB9\xBA\xC2\xC3\xC4\xC5\xC6\xC7\xC8\xC9\xCA\xD2\xD3\xD4\xD5\xD6\xD7\xD8\xD9\xDA\xE1\xE2\xE3\xE4\xE5\xE6\xE7\xE8\xE9\xEA\xF1\xF2\xF3\xF4\xF5\xF6\xF7\xF8\xF9\xFA\xFF\xC4	
+\xFF\xC4\xB5w!1AQaq"2\x81B\x91\xA1\xB1\xC1	#3R\xF0br\xD1
+$4\xE1%\xF1&'()*56789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz\x82\x83\x84\x85\x86\x87\x88\x89\x8A\x92\x93\x94\x95\x96\x97\x98\x99\x9A\xA2\xA3\xA4\xA5\xA6\xA7\xA8\xA9\xAA\xB2\xB3\xB4\xB5\xB6\xB7\xB8\xB9\xBA\xC2\xC3\xC4\xC5\xC6\xC7\xC8\xC9\xCA\xD2\xD3\xD4\xD5\xD6\xD7\xD8\xD9\xDA\xE2\xE3\xE4\xE5\xE6\xE7\xE8\xE9\xEA\xF2\xF3\xF4\xF5\xF6\xF7\xF8\xF9\xFA\xFF\xDA?\xF7J(\xA2\xBF\x8A\xCF\xF0\xFC\xFF\xD9
\ No newline at end of file

Added: trunk/LayoutTests/fast/forms/resources/image-slow.pl (0 => 116389)


--- trunk/LayoutTests/fast/forms/resources/image-slow.pl	                        (rev 0)
+++ trunk/LayoutTests/fast/forms/resources/image-slow.pl	2012-05-08 03:49:57 UTC (rev 116389)
@@ -0,0 +1,19 @@
+#!/usr/bin/perl -w
+
+# flush the buffers after each print
+select (STDOUT);
+$| = 1;
+
+print "Content-Type: image/jpeg\r\n";
+print "Expires: Thu, 01 Dec 2003 16:00:00 GMT\r\n";
+print "Cache-Control: no-store, no-cache, must-revalidate\r\n";
+print "Pragma: no-cache\r\n";
+print "\r\n";
+
+sleep 2;
+
+open(FILE, "green.jpg");
+while (<FILE>) {
+  print $_;
+}
+close(FILE);

Modified: trunk/Source/WebCore/ChangeLog (116388 => 116389)


--- trunk/Source/WebCore/ChangeLog	2012-05-08 03:34:47 UTC (rev 116388)
+++ trunk/Source/WebCore/ChangeLog	2012-05-08 03:49:57 UTC (rev 116389)
@@ -1,3 +1,41 @@
+2012-05-07  Dongwoo Im  <[email protected]>
+
+        width/height attributes of input element cannot be accessed by _javascript_.
+        https://bugs.webkit.org/show_bug.cgi?id=70304
+
+        Reviewed by Darin Adler.
+
+        If the type of input element is image button, width/height attributes should be supported.
+        These attributes are defined in HTML5 spec.
+        http://www.w3.org/TR/html5/the-map-element.html#attr-dim-width
+
+        Tests: fast/forms/input-width-height-attributes-without-renderer-loaded-image.html
+               fast/forms/input-width-height-attributes-without-renderer-not-loaded-image.html
+               fast/forms/input-width-height-attributes-without-renderer.html
+               fast/forms/input-width-height-attributes.html
+
+        * html/HTMLInputElement.cpp: Add setter/getter functions to query/set width/height of input element.
+        (WebCore):
+        (WebCore::HTMLInputElement::height): Gets height of input element.
+        (WebCore::HTMLInputElement::width): Gets width of input element.
+        (WebCore::HTMLInputElement::setHeight): Sets height of input element.
+        (WebCore::HTMLInputElement::setWidth): Sets width of input element.
+        * html/HTMLInputElement.h: Add public prototype.
+        (HTMLInputElement):
+        * html/HTMLInputElement.idl: Add width/height attributes.
+        * html/ImageInputType.cpp: Add getter functions if the element is an image button.
+        (WebCore):
+        (WebCore::ImageInputType::height): Gets height of input element.
+        (WebCore::ImageInputType::width): Gets width of input element.
+        * html/ImageInputType.h: Add prototype.
+        (ImageInputType):
+        * html/InputType.cpp: Add getter functions.
+        (WebCore::InputType::height): Returns zero.
+        (WebCore):
+        (WebCore::InputType::width): Returns zero.
+        * html/InputType.h: Add prototype.
+        (InputType):
+
 2012-05-07  Kinuko Yasuda  <[email protected]>
 
         Support cross-filesystem operations in FileSystem API

Modified: trunk/Source/WebCore/html/HTMLInputElement.cpp (116388 => 116389)


--- trunk/Source/WebCore/html/HTMLInputElement.cpp	2012-05-08 03:34:47 UTC (rev 116388)
+++ trunk/Source/WebCore/html/HTMLInputElement.cpp	2012-05-08 03:49:57 UTC (rev 116389)
@@ -7,6 +7,7 @@
  * Copyright (C) 2007 Samuel Weinig ([email protected])
  * Copyright (C) 2010 Google Inc. All rights reserved.
  * Copyright (C) 2008 Torch Mobile Inc. All rights reserved. (http://www.torchmobile.com/)
+ * Copyright (C) 2012 Samsung Electronics. 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
@@ -1843,4 +1844,25 @@
     if (CheckedRadioButtons* buttons = checkedRadioButtons())
         buttons->removeButton(this);
 }
+
+unsigned HTMLInputElement::height() const
+{
+    return m_inputType->height();
+}
+
+unsigned HTMLInputElement::width() const
+{
+    return m_inputType->width();
+}
+
+void HTMLInputElement::setHeight(unsigned height)
+{
+    setAttribute(heightAttr, String::number(height));
+}
+
+void HTMLInputElement::setWidth(unsigned width)
+{
+    setAttribute(widthAttr, String::number(width));
+}
+
 } // namespace

Modified: trunk/Source/WebCore/html/HTMLInputElement.h (116388 => 116389)


--- trunk/Source/WebCore/html/HTMLInputElement.h	2012-05-08 03:34:47 UTC (rev 116388)
+++ trunk/Source/WebCore/html/HTMLInputElement.h	2012-05-08 03:49:57 UTC (rev 116389)
@@ -3,6 +3,7 @@
  *           (C) 1999 Antti Koivisto ([email protected])
  *           (C) 2000 Dirk Mueller ([email protected])
  * Copyright (C) 2004, 2005, 2006, 2007, 2010 Apple Inc. All rights reserved.
+ * Copyright (C) 2012 Samsung Electronics. 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
@@ -236,6 +237,11 @@
 
     static const int maximumLength;
 
+    unsigned height() const;
+    unsigned width() const;
+    void setHeight(unsigned);
+    void setWidth(unsigned);
+
 protected:
     HTMLInputElement(const QualifiedName&, Document*, HTMLFormElement*, bool createdByParser);
     void createShadowSubtree();

Modified: trunk/Source/WebCore/html/HTMLInputElement.idl (116388 => 116389)


--- trunk/Source/WebCore/html/HTMLInputElement.idl	2012-05-08 03:34:47 UTC (rev 116388)
+++ trunk/Source/WebCore/html/HTMLInputElement.idl	2012-05-08 03:49:57 UTC (rev 116389)
@@ -1,6 +1,7 @@
 /*
  * Copyright (C) 2006, 2010 Apple Inc. All rights reserved.
  * Copyright (C) 2006 Samuel Weinig <[email protected]>
+ * Copyright (C) 2012 Samsung Electronics. 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
@@ -36,6 +37,7 @@
         attribute [TreatNullAs=NullString] DOMString formMethod;
         attribute [Reflect] boolean formNoValidate;
         attribute [Reflect] DOMString formTarget;
+        attribute unsigned long height;
         attribute boolean indeterminate;
         readonly attribute [Conditional=DATALIST] HTMLElement list;
         attribute [Reflect] DOMString max;
@@ -65,6 +67,7 @@
         void stepUp(in [Optional] long n) raises(DOMException);
         void stepDown(in [Optional] long n) raises(DOMException);
 
+        attribute unsigned long width;
         readonly attribute boolean willValidate;
         readonly attribute ValidityState validity;
         readonly attribute DOMString validationMessage;

Modified: trunk/Source/WebCore/html/ImageInputType.cpp (116388 => 116389)


--- trunk/Source/WebCore/html/ImageInputType.cpp	2012-05-08 03:34:47 UTC (rev 116388)
+++ trunk/Source/WebCore/html/ImageInputType.cpp	2012-05-08 03:49:57 UTC (rev 116389)
@@ -1,6 +1,7 @@
 /*
  * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserved.
  * Copyright (C) 2010 Google Inc. All rights reserved.
+ * Copyright (C) 2012 Samsung Electronics. 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
@@ -26,12 +27,16 @@
 #include "HTMLFormElement.h"
 #include "HTMLImageLoader.h"
 #include "HTMLInputElement.h"
+#include "HTMLNames.h"
+#include "HTMLParserIdioms.h"
 #include "MouseEvent.h"
 #include "RenderImage.h"
 #include <wtf/PassOwnPtr.h>
 
 namespace WebCore {
 
+using namespace HTMLNames;
+
 inline ImageInputType::ImageInputType(HTMLInputElement* element)
     : BaseButtonInputType(element)
 {
@@ -174,4 +179,46 @@
     return true;
 }
 
+unsigned ImageInputType::height() const
+{
+    RefPtr<HTMLInputElement> element = this->element();
+
+    if (!element->renderer()) {
+        // Check the attribute first for an explicit pixel value.
+        unsigned height;
+        if (parseHTMLNonNegativeInteger(element->fastGetAttribute(heightAttr), height))
+            return height;
+
+        // If the image is available, use its height.
+        if (m_imageLoader->image())
+            return m_imageLoader->image()->imageSizeForRenderer(element->renderer(), 1).height();
+    }
+
+    element->document()->updateLayout();
+
+    RenderBox* box = element->renderBox();
+    return box ? adjustForAbsoluteZoom(box->contentHeight(), box) : 0;
+}
+
+unsigned ImageInputType::width() const
+{
+    RefPtr<HTMLInputElement> element = this->element();
+
+    if (!element->renderer()) {
+        // Check the attribute first for an explicit pixel value.
+        unsigned width;
+        if (parseHTMLNonNegativeInteger(element->fastGetAttribute(widthAttr), width))
+            return width;
+
+        // If the image is available, use its width.
+        if (m_imageLoader->image())
+            return m_imageLoader->image()->imageSizeForRenderer(element->renderer(), 1).width();
+    }
+
+    element->document()->updateLayout();
+
+    RenderBox* box = element->renderBox();
+    return box ? adjustForAbsoluteZoom(box->contentWidth(), box) : 0;
+}
+
 } // namespace WebCore

Modified: trunk/Source/WebCore/html/ImageInputType.h (116388 => 116389)


--- trunk/Source/WebCore/html/ImageInputType.h	2012-05-08 03:34:47 UTC (rev 116388)
+++ trunk/Source/WebCore/html/ImageInputType.h	2012-05-08 03:49:57 UTC (rev 116389)
@@ -1,6 +1,7 @@
 /*
  * Copyright (C) 2010 Google Inc. All rights reserved.
  * Copyright (C) 2011 Apple Inc. All rights reserved.
+ * Copyright (C) 2012 Samsung Electronics. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions are
@@ -61,6 +62,8 @@
     virtual bool isImageButton() const OVERRIDE;
     virtual bool isEnumeratable() OVERRIDE;
     virtual bool shouldRespectHeightAndWidthAttributes() OVERRIDE;
+    virtual unsigned height() const OVERRIDE;
+    virtual unsigned width() const OVERRIDE;
 
     OwnPtr<HTMLImageLoader> m_imageLoader;
     IntPoint m_clickLocation; // Valid only during HTMLFormElement::prepareForSubmission().

Modified: trunk/Source/WebCore/html/InputType.cpp (116388 => 116389)


--- trunk/Source/WebCore/html/InputType.cpp	2012-05-08 03:34:47 UTC (rev 116388)
+++ trunk/Source/WebCore/html/InputType.cpp	2012-05-08 03:49:57 UTC (rev 116389)
@@ -6,6 +6,7 @@
  *           (C) 2006 Alexey Proskuryakov ([email protected])
  * Copyright (C) 2007 Samuel Weinig ([email protected])
  * Copyright (C) 2010 Google Inc. All rights reserved.
+ * Copyright (C) 2012 Samsung Electronics. 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
@@ -42,6 +43,8 @@
 #include "FormDataList.h"
 #include "HTMLFormElement.h"
 #include "HTMLInputElement.h"
+#include "HTMLNames.h"
+#include "HTMLParserIdioms.h"
 #include "HTMLShadowElement.h"
 #include "HiddenInputType.h"
 #include "ImageInputType.h"
@@ -772,6 +775,16 @@
     return false;
 }
 
+unsigned InputType::height() const
+{
+    return 0;
+}
+
+unsigned InputType::width() const
+{
+    return 0;
+}
+
 namespace InputTypeNames {
 
 // The type names must be lowercased because they will be the return values of

Modified: trunk/Source/WebCore/html/InputType.h (116388 => 116389)


--- trunk/Source/WebCore/html/InputType.h	2012-05-08 03:34:47 UTC (rev 116388)
+++ trunk/Source/WebCore/html/InputType.h	2012-05-08 03:49:57 UTC (rev 116389)
@@ -1,6 +1,7 @@
 /*
  * Copyright (C) 2010 Google Inc. All rights reserved.
  * Copyright (C) 2011 Apple Inc. All rights reserved.
+ * Copyright (C) 2012 Samsung Electronics. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions are
@@ -275,6 +276,11 @@
 
     virtual bool supportsIndeterminateAppearance() const;
 
+    // Gets width and height of the input element if the type of the
+    // element is image. It returns 0 if the element is not image type.
+    virtual unsigned height() const;
+    virtual unsigned width() const;
+
 protected:
     InputType(HTMLInputElement* element) : m_element(element) { }
     HTMLInputElement* element() const { return m_element; }
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to