WebCore:
Fix for http://bugs.webkit.org/show_bug.cgi?id=14975
Computed size of padding is incorrect because we default padding to auto. This is a made-up value that
was only used to implement cellpadding on tables. We needed this made-up value in order to tell that
padding wasn't set so that we could then apply cellpadding.
This patch rewrites cellpadding to be like other browsers. Instead of being a setting on the table
renderer that applies to all cells (even ones that were not <td>s), cellpadding is now mapped into the
style of <td>s. With this change it effectively becomes a content model feature and not a rendering
feature.
For example, a <td> will pick up cellpadding even when it is not a cell and/or the enclosing <table> is
not a table. Anonymous cells and CSS-display-type cells will now never pick up cellpadding. This behavior
is all consistent with other browsers.
Reviewed by Antti
Added fast/css/padding-no-renderer.html
* css/CSSStyleSelector.cpp:
(WebCore::CSSStyleSelector::canShareStyleWithElement):
(WebCore::CSSStyleSelector::styleForElement):
* css/CSSStyleSelector.h:
* dom/StyledElement.cpp:
* dom/StyledElement.h:
(WebCore::StyledElement::canHaveAdditionalAttributeStyleDecls):
(WebCore::StyledElement::additionalAttributeStyleDecls):
* html/HTMLTableCellElement.cpp:
(WebCore::HTMLTableCellElement::additionalAttributeStyleDecls):
* html/HTMLTableCellElement.h:
(WebCore::HTMLTableCellElement::canHaveAdditionalAttributeStyleDecls):
* html/HTMLTableColElement.cpp:
(WebCore::HTMLTableColElement::additionalAttributeStyleDecls):
* html/HTMLTableColElement.h:
(WebCore::HTMLTableColElement::canHaveAdditionalAttributeStyleDecls):
* html/HTMLTableElement.cpp:
(WebCore::HTMLTableElement::parseMappedAttribute):
(WebCore::HTMLTableElement::additionalAttributeStyleDecls):
(WebCore::HTMLTableElement::addSharedCellDecls):
(WebCore::HTMLTableElement::addSharedCellBordersDecl):
(WebCore::HTMLTableElement::addSharedCellPaddingDecl):
(WebCore::HTMLTableElement::addSharedGroupDecls):
(WebCore::HTMLTableElement::attach):
* html/HTMLTableElement.h:
(WebCore::HTMLTableElement::canHaveAdditionalAttributeStyleDecls):
* html/HTMLTableSectionElement.cpp:
(WebCore::HTMLTableSectionElement::additionalAttributeStyleDecls):
* html/HTMLTableSectionElement.h:
(WebCore::HTMLTableSectionElement::canHaveAdditionalAttributeStyleDecls):
* rendering/AutoTableLayout.cpp:
(WebCore::AutoTableLayout::recalcColumn):
* rendering/RenderObject.cpp:
(WebCore::RenderObject::paddingTop):
(WebCore::RenderObject::paddingBottom):
(WebCore::RenderObject::paddingLeft):
(WebCore::RenderObject::paddingRight):
* rendering/RenderStyle.cpp:
(WebCore::StyleSurroundData::StyleSurroundData):
* rendering/RenderStyle.h:
(WebCore::RenderStyle::initialPadding):
* rendering/RenderTable.cpp:
(WebCore::RenderTable::RenderTable):
* rendering/RenderTable.h:
LayoutTests:
Updated results for http://bugs.webkit.org/show_bug.cgi?id=14975
Reviewed by Antti
* fast/css/computed-style-without-renderer-expected.txt:
* fast/css/padding-no-renderer-expected.txt: Added.
* fast/css/padding-no-renderer.html: Added.
* platform/mac/fast/css/acid2-expected.checksum:
* platform/mac/fast/css/acid2-expected.png:
* platform/mac/fast/css/acid2-expected.txt:
* platform/mac/fast/css/acid2-pixel-expected.checksum:
* platform/mac/fast/css/acid2-pixel-expected.png:
* platform/mac/fast/css/acid2-pixel-expected.txt:
* platform/mac/fast/frames/viewsource-attribute-expected.checksum:
* platform/mac/fast/frames/viewsource-attribute-expected.png:
* platform/mac/fast/frames/viewsource-attribute-expected.txt:
* platform/mac/fast/lists/ordered-list-with-no-ol-tag-expected.checksum:
* platform/mac/fast/lists/ordered-list-with-no-ol-tag-expected.png:
* platform/mac/fast/lists/ordered-list-with-no-ol-tag-expected.txt:
* platform/mac/fast/table/add-before-anonymous-child-expected.checksum:
* platform/mac/fast/table/add-before-anonymous-child-expected.png:
* platform/mac/fast/table/add-before-anonymous-child-expected.txt:
* platform/mac/fast/table/cell-absolute-child-expected.checksum:
* platform/mac/fast/table/cell-absolute-child-expected.png:
* platform/mac/fast/table/cell-absolute-child-expected.txt:
* platform/mac/fast/table/frame-and-rules-expected.checksum:
* platform/mac/fast/table/frame-and-rules-expected.png:
* platform/mac/fast/table/frame-and-rules-expected.txt:
* platform/mac/http/tests/misc/acid2-expected.checksum:
* platform/mac/http/tests/misc/acid2-expected.png:
* platform/mac/http/tests/misc/acid2-expected.txt:
* platform/mac/http/tests/misc/acid2-pixel-expected.checksum:
* platform/mac/http/tests/misc/acid2-pixel-expected.png:
* platform/mac/http/tests/misc/acid2-pixel-expected.txt:
* platform/mac/tables/mozilla/bugs/bug30985-expected.checksum:
* platform/mac/tables/mozilla/bugs/bug30985-expected.png:
* platform/mac/tables/mozilla/bugs/bug30985-expected.txt:
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@29647 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/LayoutTests/fast/css/padding-no-renderer.html b/LayoutTests/fast/css/padding-no-renderer.html
new file mode 100644
index 0000000..0486756
--- /dev/null
+++ b/LayoutTests/fast/css/padding-no-renderer.html
@@ -0,0 +1,67 @@
+<!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>
+<style>
+ #test1 { padding: 10px; display: none; }
+</style>
+</head>
+<body>
+<p id="description"></p>
+<div id="console"></div>
+
+<div id="tests_container">
+
+<div id="test0" style="display: none"></div>
+<div id="test1"></div>
+<div id="test2" style="padding: 10px; display: none;"></div>
+<table id="test_table" cellpadding="10">
+ <tr>
+ <td id="test3" style="display: none">FOO</td>
+ <td id="test4">BAR</td>
+ <tr>
+</table>
+
+<div style="position: relative; width: 100px; height: 100px">
+ <div id="test5" style="padding: 10%; width: 50px; height: 50px">BAR</div>
+</div>
+
+<div style="position: relative; width: 100px; height: 100px">
+ <div id="test6" style="display: none; padding: 10%; width: 50px; height: 50px">BAR</div>
+</div>
+
+<div style="display: none; position: relative; width: 100px; height: 100px">
+ <div id="test7" style="padding: 10%; width: 50px; height: 50px">BAR</div>
+</div>
+
+</div>
+
+<script>
+ var test0 = document.getElementById("test0");
+ var test1 = document.getElementById("test1");
+ var test2 = document.getElementById("test2");
+ var test3 = document.getElementById("test3");
+ var test4 = document.getElementById("test4");
+ var test5 = document.getElementById("test5");
+ var test6 = document.getElementById("test6");
+ var test7 = document.getElementById("test7");
+
+ shouldBeEqualToString("window.getComputedStyle(test0, null).paddingTop", "0px");
+ shouldBeEqualToString("window.getComputedStyle(test1, null).paddingTop", "10px");
+ shouldBeEqualToString("window.getComputedStyle(test2, null).paddingTop", "10px");
+ shouldBeEqualToString("window.getComputedStyle(test3, null).paddingTop", "10px");
+ shouldBeEqualToString("window.getComputedStyle(test4, null).paddingTop", "10px");
+ shouldBeEqualToString("window.getComputedStyle(test5, null).paddingTop", "10px");
+ shouldBeEqualToString("window.getComputedStyle(test6, null).paddingTop", "10%");
+ shouldBeEqualToString("window.getComputedStyle(test7, null).paddingTop", "10%");
+
+ // clean up after ourselves
+ var tests_container = document.getElementById("tests_container");
+ tests_container.parentNode.removeChild(tests_container);
+
+ var successfullyParsed = true;
+</script>
+<script src="../js/resources/js-test-post.js"></script>
+</body>
+</html>