[webkit-changes] cvs commit: WebCore/layout-tests/fast/dom
css-dom-read-2-expected.txt css-dom-read-2.html
Darin
darin at opensource.apple.com
Sat Jul 30 14:19:47 PDT 2005
darin 05/07/30 14:19:46
Modified: . ChangeLog
khtml/css css_computedstyle.cpp css_ruleimpl.cpp
css_ruleimpl.h css_stylesheetimpl.cpp
Added: layout-tests/fast/dom css-dom-read-2-expected.txt
css-dom-read-2.html
Log:
Reviewed and landed by Darin Adler.
- Fixes <http://bugzilla.opendarwin.org/show_bug.cgi?id=3893>
Test cases added:
* layout-tests/fast/dom/css-dom-read-2.html: Added.
* layout-tests/fast/dom/css-dom-read-2-expected.txt: Added.
* khtml/css/css_computedstyle.cpp:
(DOM::CSSComputedStyleDeclarationImpl::cssText):
Implement.
(DOM::CSSComputedStyleDeclarationImpl::item):
Return the item name, not its value.
* khtml/css/css_ruleimpl.cpp:
(CSSImportRuleImpl::cssText):
(CSSMediaRuleImpl::cssText):
(CSSStyleRuleImpl::cssText):
* khtml/css/css_ruleimpl.h:
Implement.
* khtml/css/css_stylesheetimpl.cpp:
(MediaListImpl::mediaText):
Don't put a trailing comma after lists.
Revision Changes Path
1.4506 +28 -0 WebCore/ChangeLog
Index: ChangeLog
===================================================================
RCS file: /cvs/root/WebCore/ChangeLog,v
retrieving revision 1.4505
retrieving revision 1.4506
diff -u -r1.4505 -r1.4506
--- ChangeLog 30 Jul 2005 20:41:58 -0000 1.4505
+++ ChangeLog 30 Jul 2005 21:19:41 -0000 1.4506
@@ -1,3 +1,31 @@
+2005-07-30 Anders Carlsson <andersca at mac.com>
+
+ Reviewed and landed by Darin Adler.
+
+ - Fixes <http://bugzilla.opendarwin.org/show_bug.cgi?id=3893>
+
+ Test cases added:
+ * layout-tests/fast/dom/css-dom-read-2.html: Added.
+ * layout-tests/fast/dom/css-dom-read-2-expected.txt: Added.
+
+ * khtml/css/css_computedstyle.cpp:
+ (DOM::CSSComputedStyleDeclarationImpl::cssText):
+ Implement.
+
+ (DOM::CSSComputedStyleDeclarationImpl::item):
+ Return the item name, not its value.
+
+ * khtml/css/css_ruleimpl.cpp:
+ (CSSImportRuleImpl::cssText):
+ (CSSMediaRuleImpl::cssText):
+ (CSSStyleRuleImpl::cssText):
+ * khtml/css/css_ruleimpl.h:
+ Implement.
+
+ * khtml/css/css_stylesheetimpl.cpp:
+ (MediaListImpl::mediaText):
+ Don't put a trailing comma after lists.
+
2005-07-30 Darin Adler <darin at apple.com>
- rolled back a test that has been failing since we rolled back the <script/> quirk
1.34 +16 -3 WebCore/khtml/css/css_computedstyle.cpp
Index: css_computedstyle.cpp
===================================================================
RCS file: /cvs/root/WebCore/khtml/css/css_computedstyle.cpp,v
retrieving revision 1.33
retrieving revision 1.34
diff -u -r1.33 -r1.34
--- css_computedstyle.cpp 11 May 2005 00:58:27 -0000 1.33
+++ css_computedstyle.cpp 30 Jul 2005 21:19:45 -0000 1.34
@@ -50,6 +50,8 @@
using khtml::ShadowData;
using khtml::StyleDashboardRegion;
+extern DOM::DOMString getPropertyName(unsigned short id);
+
namespace DOM {
// List of all properties we know how to compute, omitting shorthands.
@@ -286,8 +288,18 @@
DOMString CSSComputedStyleDeclarationImpl::cssText() const
{
- ERROR("unimplemented");
- return DOMString();
+ DOMString result;
+
+ for (unsigned i = 0; i < numComputedProperties; i++) {
+ if (i != 0)
+ result += " ";
+ result += getPropertyName(computedProperties[i]);
+ result += ": ";
+ result += getPropertyValue(computedProperties[i]);
+ result += ";";
+ }
+
+ return result;
}
void CSSComputedStyleDeclarationImpl::setCssText(const DOMString &, int &exceptionCode)
@@ -1256,7 +1268,8 @@
{
if (i >= numComputedProperties)
return DOMString();
- return getPropertyValue(computedProperties[i]);
+
+ return getPropertyName(computedProperties[i]);
}
CSSMutableStyleDeclarationImpl *CSSComputedStyleDeclarationImpl::copyInheritableProperties() const
1.21 +48 -0 WebCore/khtml/css/css_ruleimpl.cpp
Index: css_ruleimpl.cpp
===================================================================
RCS file: /cvs/root/WebCore/khtml/css/css_ruleimpl.cpp,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -r1.20 -r1.21
--- css_ruleimpl.cpp 18 Jul 2005 21:44:13 -0000 1.20
+++ css_ruleimpl.cpp 30 Jul 2005 21:19:45 -0000 1.21
@@ -197,6 +197,21 @@
}
}
+DOMString CSSImportRuleImpl::cssText() const
+{
+ DOMString result = "@import url(\"";
+ result += m_strHref;
+ result += "\")";
+
+ if (m_lstMedia) {
+ result += " ";
+ result += m_lstMedia->mediaText();
+ }
+ result += ";";
+
+ return result;
+}
+
// --------------------------------------------------------------------------
CSSMediaRuleImpl::CSSMediaRuleImpl( StyleBaseImpl *parent, MediaListImpl *mediaList, CSSRuleListImpl *ruleList )
: CSSRuleImpl( parent )
@@ -265,6 +280,28 @@
return m_lstCSSRules->insertRule( newRule, index );
}
+DOMString CSSMediaRuleImpl::cssText() const
+{
+ DOMString result = "@media ";
+ if (m_lstMedia) {
+ result += m_lstMedia->mediaText();
+ result += " ";
+ }
+ result += "{ \n";
+
+ if (m_lstCSSRules) {
+ unsigned long len = m_lstCSSRules->length();
+ for (unsigned long i = 0; i < len; i++) {
+ result += " ";
+ result += m_lstCSSRules->item(i)->cssText();
+ result += "\n";
+ }
+ }
+
+ result += "}";
+ return result;
+}
+
// ---------------------------------------------------------------------------
CSSRuleListImpl::CSSRuleListImpl(StyleListImpl *lst)
@@ -343,6 +380,17 @@
// ###
}
+DOMString CSSStyleRuleImpl::cssText() const
+{
+ DOMString result = selectorText();
+
+ result += " { ";
+ result += m_style->cssText();
+ result += "}";
+
+ return result;
+}
+
bool CSSStyleRuleImpl::parseString( const DOMString &/*string*/, bool )
{
// ###
1.16 +7 -3 WebCore/khtml/css/css_ruleimpl.h
Index: css_ruleimpl.h
===================================================================
RCS file: /cvs/root/WebCore/khtml/css/css_ruleimpl.h,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -r1.15 -r1.16
--- css_ruleimpl.h 9 Jul 2005 20:19:00 -0000 1.15
+++ css_ruleimpl.h 30 Jul 2005 21:19:45 -0000 1.16
@@ -20,7 +20,7 @@
* the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*
- * $Id: css_ruleimpl.h,v 1.15 2005/07/09 20:19:00 hyatt Exp $
+ * $Id: css_ruleimpl.h,v 1.16 2005/07/30 21:19:45 darin Exp $
*/
#ifndef _CSS_css_ruleimpl_h_
#define _CSS_css_ruleimpl_h_
@@ -59,7 +59,7 @@
CSSStyleSheetImpl *parentStyleSheet() const;
CSSRuleImpl *parentRule() const;
- DOM::DOMString cssText() const;
+ virtual DOMString cssText() const;
void setCssText(DOM::DOMString str);
virtual void init() {}
@@ -77,6 +77,7 @@
MAIN_THREAD_ALLOCATED;
virtual bool isCharsetRule() { return true; }
+ virtual DOMString cssText() const;
DOMString encoding() const { return m_encoding; }
void setEncoding(DOMString _encoding) { m_encoding = _encoding; }
@@ -119,7 +120,8 @@
CSSStyleSheetImpl *styleSheet() const { return m_styleSheet; }
virtual bool isImportRule() { return true; }
-
+ virtual DOMString cssText() const;
+
// from CachedObjectClient
virtual void setStyleSheet(const DOM::DOMString &url, const DOM::DOMString &sheet);
@@ -174,6 +176,7 @@
void deleteRule ( unsigned long index ) { m_lstCSSRules->deleteRule( index ); }
virtual bool isMediaRule() { return true; }
+ virtual DOMString cssText() const;
/* Not part of the DOM */
unsigned long append( CSSRuleImpl *rule );
@@ -215,6 +218,7 @@
CSSMutableStyleDeclarationImpl *style() const { return m_style; }
virtual bool isStyleRule() { return true; }
+ virtual DOMString cssText() const;
DOM::DOMString selectorText() const;
void setSelectorText(DOM::DOMString str);
1.15 +5 -4 WebCore/khtml/css/css_stylesheetimpl.cpp
Index: css_stylesheetimpl.cpp
===================================================================
RCS file: /cvs/root/WebCore/khtml/css/css_stylesheetimpl.cpp,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- css_stylesheetimpl.cpp 18 Jul 2005 21:44:13 -0000 1.14
+++ css_stylesheetimpl.cpp 30 Jul 2005 21:19:45 -0000 1.15
@@ -19,7 +19,7 @@
* the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*
- * $Id: css_stylesheetimpl.cpp,v 1.14 2005/07/18 21:44:13 hyatt Exp $
+ * $Id: css_stylesheetimpl.cpp,v 1.15 2005/07/30 21:19:45 darin Exp $
*/
//#define CSS_STYLESHEET_DEBUG
@@ -380,10 +380,11 @@
DOM::DOMString MediaListImpl::mediaText() const
{
- DOMString text;
- for ( QValueList<DOMString>::ConstIterator it = m_lstMedia.begin(); it != m_lstMedia.end(); ++it ) {
+ DOMString text = "";
+ for (QValueList<DOMString>::ConstIterator it = m_lstMedia.begin(); it != m_lstMedia.end(); ++it) {
+ if (text.length() > 0)
+ text += ", ";
text += *it;
- text += ", ";
}
return text;
}
1.1 WebCore/layout-tests/fast/dom/css-dom-read-2-expected.txt
Index: css-dom-read-2-expected.txt
===================================================================
This tests different ways of deserializing css stylesheets. The first item below is the style as specified in the document. The second is serialized using the different rule accessors. The third just uses rule.cssText. If the test is successful, all three should be the same.
@import url("fancyfonts.css") screen;
@media print {
body { font-size: 10pt }
}
@media screen {
body { font-size: 13px }
}
@media screen, print {
body { line-height: 1.2 }
}
.one {display: block;}
.two {display: inline;}
.three {display: list-item; list-style-type: square; margin-left: 3em;}
.four {display: none; color: red;}
I {display: block;}
@import url("fancyfonts.css") screen;
@media print {
body { font-size: 10pt; }
}
@media screen {
body { font-size: 13px; }
}
@media screen, print {
body { line-height: 1.2; }
}
.one { display: block; }
.two { display: inline; }
.three { display: list-item; list-style-type: square; margin-left: 3em; }
.four { display: none; color: red; }
i { display: block; }
@import url("fancyfonts.css") screen;
@media print {
body { font-size: 10pt; }
}
@media screen {
body { font-size: 13px; }
}
@media screen, print {
body { line-height: 1.2; }
}
.one { display: block; }
.two { display: inline; }
.three { display: list-item; list-style-type: square; margin-left: 3em; }
.four { display: none; color: red; }
i { display: block; }
1.1 WebCore/layout-tests/fast/dom/css-dom-read-2.html
Index: css-dom-read-2.html
===================================================================
<html>
<head>
<style id="style">@import url("fancyfonts.css") screen;
@media print {
body { font-size: 10pt }
}
@media screen {
body { font-size: 13px }
}
@media screen, print {
body { line-height: 1.2 }
}
.one {display: block;}
.two {display: inline;}
.three {display: list-item; list-style-type: square; margin-left: 3em;}
.four {display: none; color: red;}
I {display: block;}
</style>
</head>
<body onload="runTests();">
<script>
function dumpRuleList(cssRules)
{
var s = '';
var i;
for (i = 0; i < cssRules.length; i++) {
rule = cssRules.item(i);
switch (rule.type) {
case CSSRule.IMPORT_RULE:
s += '@import url("' + rule.href + '") ' + rule.media.mediaText;
s += ';\n';
break;
case CSSRule.STYLE_RULE:
s += rule.selectorText + ' { ';
style = rule.style;
for (j = 0; j < style.length; j++) {
s += style.item(j) + ': ' + style.getPropertyValue(style.item(j))+ '; ';
}
s += '} \n';
break;
case CSSRule.MEDIA_RULE:
s += '@media ' + rule.media.mediaText + ' {\n';
s += ' ' + dumpRuleList(rule.cssRules);
s += '}\n';
break;
case CSSRule.PAGE_RULE:
s += '@page ';
break;
}
}
return s;
}
function debug(s) {
console = document.getElementById('console');
li = document.createElement('li');
console.appendChild(li);
pre = document.createElement('pre');
li.appendChild(pre);
t = document.createTextNode(s + '\n');
pre.appendChild(t);
}
function runTests() {
if (window.layoutTestController)
layoutTestController.dumpAsText();
originalStyle = document.getElementById('style').firstChild.nodeValue;
debug(originalStyle);
styleSheet = document.styleSheets.item(0)
s = dumpRuleList(styleSheet.cssRules);
debug(s);
s = ""
for (i = 0; i < styleSheet.cssRules.length; i++) {
rule = styleSheet.cssRules.item(i);
s += rule.cssText + '\n';
}
debug(s);
}
</script>
This tests different ways of deserializing css stylesheets. The first item below is the style as specified in the document. The second is serialized using the different rule accessors. The third just uses rule.cssText. If the test is successful, all three should be the same.
<ul id="console">
</ul>
</body>
</html>
More information about the webkit-changes
mailing list