Reviewed by Hyatt.
Test case for our CSS seletorText serialization.
* fast/dom/css-selectorText-expected.checksum: Added.
* fast/dom/css-selectorText-expected.png: Added.
* fast/dom/css-selectorText-expected.txt: Added.
* fast/dom/css-selectorText.html: Added.
WebCore:
Reviewed by Dave Hyatt.
Test: fast/dom/css-selectorText.html
Fixes selecotrText serialization to only print "*"
when it is stand alone. Fixes the attribute set selector,
along with general cleanup. Also print chained selectors.
* khtml/css/css_base.cpp:
(CSSSelector::extractPseudoType):
(CSSSelector::selectorText):
* khtml/css/css_ruleimpl.cpp:
(DOM::CSSStyleRuleImpl::selectorText):
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@11545
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2005-12-12 Timothy Hatcher <timothy@apple.com>
+
+ Reviewed by Hyatt.
+
+ Test case for our CSS seletorText serialization.
+
+ * fast/dom/css-selectorText-expected.checksum: Added.
+ * fast/dom/css-selectorText-expected.png: Added.
+ * fast/dom/css-selectorText-expected.txt: Added.
+ * fast/dom/css-selectorText.html: Added.
+
2005-12-12 Eric Seidel <eseidel@apple.com>
Reviewed by ggaren.
--- /dev/null
+640609fe21178e25fe100e7b1622f885
\ No newline at end of file
--- /dev/null
+layer at (0,0) size 800x600
+ RenderCanvas at (0,0) size 800x600
+layer at (2,2) size 796x596
+ RenderBlock {HTML} at (2,2) size 796x596
+ RenderBody {BODY} at (2,2) size 792x592
+ RenderBlock {PRE} at (2,0) size 788x270
+ RenderText {TEXT} at (0,0) size 208x270
+ text run at (0,0) width 8: "*"
+ text run at (0,15) width 24: "div"
+ text run at (0,30) width 64: "div span"
+ text run at (0,45) width 80: "div ~ span"
+ text run at (0,60) width 80: "div > span"
+ text run at (0,75) width 80: "div + span"
+ text run at (0,90) width 40: "#temp"
+ text run at (0,105) width 64: "div#temp"
+ text run at (0,120) width 176: "div.test[title=\"test\"]"
+ text run at (0,135) width 160: ".test[title~=\"test\"]"
+ text run at (0,150) width 168: "div > [title|=\"test\"]"
+ text run at (0,165) width 184: "div.test[title^=\"test\"]"
+ text run at (0,180) width 192: "span#test[title$=\"test\"]"
+ text run at (0,195) width 208: "span[title*=\"test\"]::after"
+ text run at (0,210) width 80: "div[title]"
+ text run at (0,225) width 56: "[title]"
+ text run at (0,240) width 48: "a:link"
+ text run at (0,255) width 192: "div, span > div:hover, a"
--- /dev/null
+<html>
+<head>
+<style>
+* { margin: 2px; }
+div { margin: 2px; }
+div span { margin 2px; }
+div ~ span { margin 2px; }
+div > span { margin 2px; }
+div + span { margin 2px; }
+#temp { margin 2px; }
+div#temp { margin 2px; }
+div.test[title="test"] { margin: 2px; }
+.test[title~="test"] { margin: 2px; }
+div > [title|="test"] { margin: 2px; }
+div.test[title^="test"] { margin: 2px; }
+span#test[title$="test"] { margin: 2px; }
+span[title*="test"]::after { margin: 2px; }
+div[title] { margin: 2px; }
+[title] { margin: 2px; }
+a:link { margin: 2px; }
+div, span > div:hover, a { margin: 2px; }
+</style>
+</head>
+<body>
+<pre id="result"></pre>
+<script>
+var styleSheet = document.styleSheets.item(0);
+var s = "";
+for (var i = 0; i < styleSheet.cssRules.length; i++) {
+ var rule = styleSheet.cssRules[i];
+ s += rule.selectorText + "\n";
+}
+document.getElementById("result").innerText = s;
+</script>
+</body>
+</html>
+2005-12-12 Timothy Hatcher <timothy@apple.com>
+
+ Reviewed by Dave Hyatt.
+
+ Test: fast/dom/css-selectorText.html
+
+ Fixes selecotrText serialization to only print "*"
+ when it is stand alone. Fixes the attribute set selector,
+ along with general cleanup. Also print chained selectors.
+
+ * khtml/css/css_base.cpp:
+ (CSSSelector::extractPseudoType):
+ (CSSSelector::selectorText):
+ * khtml/css/css_ruleimpl.cpp:
+ (DOM::CSSStyleRuleImpl::selectorText):
+
2005-12-12 Eric Seidel <eseidel@apple.com>
Reviewed by ggaren.
match = PseudoElement;
else if (match == PseudoElement && !element)
_pseudoType = PseudoOther;
- value = nullAtom;
}
DOMString str;
const CSSSelector* cs = this;
const AtomicString& localName = cs->tag.localName();
- if (localName == starAtom && cs->match == CSSSelector::Id)
- {
- str = "#";
+ if (cs->match == CSSSelector::None || localName != starAtom)
+ str = localName;
+ if (cs->match == CSSSelector::Id) {
+ str += "#";
str += cs->value.qstring();
- }
- else if (localName == starAtom && cs->match == CSSSelector::Class)
- {
- str = ".";
+ } else if (cs->match == CSSSelector::Class) {
+ str += ".";
str += cs->value.qstring();
- }
- else if (localName == starAtom && cs->match == CSSSelector::PseudoClass)
- {
- str = ":";
+ } else if (cs->match == CSSSelector::PseudoClass) {
+ str += ":";
str += cs->value.qstring();
- }
- else if (localName == starAtom && cs->match == CSSSelector::PseudoElement)
- {
- str = "::";
+ } else if (cs->match == CSSSelector::PseudoElement) {
+ str += "::";
str += cs->value.qstring();
- }
- else
- {
- if (localName == starAtom)
- str = "*";
- else
- str = localName;
- if (cs->match == CSSSelector::Id)
- {
- str += "#";
- str += cs->value.qstring();
- }
- else if (cs->match == CSSSelector::Class)
- {
- str += ".";
- str += cs->value.qstring();
- }
- else if (cs->match == CSSSelector::PseudoClass)
- {
- str += ":";
- str += cs->value.qstring();
- }
- else if (cs->match == CSSSelector::PseudoElement)
- {
- str += "::";
- str += cs->value.qstring();
- }
- // optional attribute
- if (cs->hasAttribute()) {
- // FIXME: Add support for dumping namespaces.
- DOMString attrName = cs->attr.localName();
- str += "[";
- str += attrName;
- switch (cs->match) {
+ } else if (cs->hasAttribute()) {
+ // FIXME: Add support for dumping namespaces.
+ DOMString attrName = cs->attr.localName();
+ str += "[";
+ str += attrName;
+ switch (cs->match) {
case CSSSelector::Exact:
str += "=";
break;
case CSSSelector::Set:
- str += " "; /// ## correct?
+ // set has no operator or value, just the attrName
+ str += "]";
break;
case CSSSelector::List:
str += "~=";
break;
default:
kdWarning(6080) << "Unhandled case in CSSStyleRuleImpl::selectorText : match=" << cs->match << endl;
- }
+ }
+ if (cs->match != CSSSelector::Set) {
str += "\"";
str += cs->value.qstring();
str += "\"]";
}
}
- if ( cs->tagHistory ) {
+ if (cs->tagHistory) {
DOMString tagHistoryText = cs->tagHistory->selectorText();
- if ( cs->relation == DirectAdjacent )
+ if (cs->relation == CSSSelector::DirectAdjacent)
str = tagHistoryText + " + " + str;
- else if ( cs->relation == IndirectAdjacent )
+ else if (cs->relation == CSSSelector::IndirectAdjacent)
str = tagHistoryText + " ~ " + str;
- else if ( cs->relation == Child )
+ else if (cs->relation == CSSSelector::Child)
str = tagHistoryText + " > " + str;
- else if ( cs->relation == SubSelector )
+ else if (cs->relation == CSSSelector::SubSelector)
str += tagHistoryText; // the ":" is provided by selectorText()
else // Descendant
str = tagHistoryText + " " + str;
DOM::DOMString CSSStyleRuleImpl::selectorText() const
{
- // FIXME: Handle all the selectors in the chain for comma-separated selectors.
- if (m_selector)
- return m_selector->selectorText();
+ if (m_selector) {
+ DOMString str;
+ for (CSSSelector *s = m_selector; s; s = s->next()) {
+ if (s != m_selector)
+ str += ", ";
+ str += s->selectorText();
+ }
+ return str;
+ }
return DOMString();
}