from KHTML tree by Nick Shanks.
Reviewed by hyatt
Test cases added: fast/selectors/046.html
* khtml/css/css_base.cpp:
(CSSSelector::selectorText):
* khtml/css/css_base.h:
(DOM::CSSSelector::):
* khtml/css/cssstyleselector.cpp:
(khtml::CSSStyleSelector::checkSelector):
* khtml/css/parser.y:
* layout-tests/fast/selectors/046-expected.txt: Added.
* layout-tests/fast/selectors/046.html: Added.
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@9358
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
--- /dev/null
+layer at (0,0) size 800x600
+ RenderCanvas at (0,0) size 800x600
+layer at (0,0) size 800x186
+ RenderBlock {HTML} at (0,0) size 800x186
+ RenderBody {BODY} at (8,16) size 784x154
+ RenderBlock {DIV} at (0,0) size 784x154
+ RenderBlock {P} at (0,0) size 784x18
+ RenderText {TEXT} at (0,0) size 221x18
+ text run at (0,0) width 221: "This paragraph should be unstyled."
+ RenderBlock {P} at (0,34) size 784x18 [bgcolor=#00FF00]
+ RenderText {TEXT} at (0,0) size 285x18
+ text run at (0,0) width 285: "But this one should have a green background"
+ RenderBlock {P} at (0,68) size 784x18 [bgcolor=#00FF00]
+ RenderText {TEXT} at (0,0) size 319x18
+ text run at (0,0) width 319: "And this one should also have a green background"
+ RenderBlock {ADDRESS} at (0,102) size 784x18
+ RenderText {TEXT} at (0,0) size 431x18
+ text run at (0,0) width 431: "This address is only here to fill some space between two paragraphs"
+ RenderBlock {P} at (0,136) size 784x18 [bgcolor=#00FF00]
+ RenderText {TEXT} at (0,0) size 304x18
+ text run at (0,0) width 304: "This paragraph should have a green background"
--- /dev/null
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">
+<html>
+ <head>
+ <title>Indirect adjacent combinator</title>
+ <style type="text/css">.red { background-color : red }
+div.stub > p ~ p { background-color : lime }</style>
+ <link rel="first" href="css3-modsel-1.html" title="Groups of selectors">
+ <link rel="prev" href="css3-modsel-45c.html" title="Direct adjacent combinator and classes">
+ <link rel="next" href="css3-modsel-46b.html" title="Indirect adjacent combinator">
+ <link rel="last" href="css3-modsel-d5e.html" title="NEGATED :indeterminate with :checked">
+ <link rel="up" href="./index.html">
+ <link rel="top" href="../../index.html">
+ </head>
+ <body>
+ <div class="stub">
+ <p>This paragraph should be unstyled.</p>
+ <p class="red">But this one should have a green background</p>
+ <p class="red">And this one should also have a green background</p>
+ <address>This address is only here to fill some space between two paragraphs</address>
+ <p class="red">This paragraph should have a green background</p>
+ </div>
+</body>
+</html>
\ No newline at end of file
+2005-06-10 David Hyatt <hyatt@apple.com>
+
+ Fix for bugzilla bug 3335, add support for the CSS3 indirect adjacent sibling selector. Patch merge
+ from KHTML tree by Nick Shanks.
+
+ Reviewed by hyatt
+
+ Test cases added: fast/selectors/046.html
+
+ * khtml/css/css_base.cpp:
+ (CSSSelector::selectorText):
+ * khtml/css/css_base.h:
+ (DOM::CSSSelector::):
+ * khtml/css/cssstyleselector.cpp:
+ (khtml::CSSStyleSelector::checkSelector):
+ * khtml/css/parser.y:
+ * layout-tests/fast/selectors/046-expected.txt: Added.
+ * layout-tests/fast/selectors/046.html: Added.
+
2005-06-10 David Hyatt <hyatt@apple.com>
Fix for 3237, background image repeats when it shouldn't. The Radar bug is 4005553. Patch from
}
if ( cs->tagHistory ) {
DOMString tagHistoryText = cs->tagHistory->selectorText();
- if ( cs->relation == Sibling )
+ if ( cs->relation == DirectAdjacent )
str = tagHistoryText + " + " + str;
+ else if ( cs->relation == IndirectAdjacent )
+ str = tagHistoryText + " ~ " + str;
else if ( cs->relation == Child )
str = tagHistoryText + " > " + str;
else if ( cs->relation == SubSelector )
{
Descendant = 0,
Child,
- Sibling,
- SubSelector
+ DirectAdjacent,
+ IndirectAdjacent,
+ SubSelector
};
enum PseudoType
Q_UINT32 attr;
Q_UINT32 tag;
- Relation relation : 2;
+ Relation relation : 3;
Match match : 4;
unsigned int pseudoId : 3;
mutable PseudoType _pseudoType : 5;
if (!checkOneSelector(sel, elem)) return false;
break;
}
- case CSSSelector::Sibling:
+ case CSSSelector::DirectAdjacent:
{
n = n->previousSibling();
- while( n && !n->isElementNode() )
- n = n->previousSibling();
- if( !n ) return false;
- ElementImpl *elem = static_cast<ElementImpl *>(n);
- if (!checkOneSelector(sel, elem)) return false;
+ while (n && !n->isElementNode())
+ n = n->previousSibling();
+ if (!n) return false;
+ ElementImpl *elem = static_cast<ElementImpl*>(n);
+ if (!checkOneSelector(sel, elem))
+ return false;
+ break;
+ }
+ case CSSSelector::IndirectAdjacent:
+ {
+ // FIXME: This match needs to know how to backtrack and be non-deterministic.
+ ElementImpl *elem = 0;
+ do {
+ n = n->previousSibling();
+ while (n && !n->isElementNode())
+ n = n->previousSibling();
+ if (!n)
+ return false;
+ elem = static_cast<ElementImpl*>(n);
+ } while (!checkOneSelector(sel, elem));
break;
}
- case CSSSelector::SubSelector:
+ case CSSSelector::SubSelector:
{
if (onlyHoverActive)
onlyHoverActive = (sel->match == CSSSelector::Pseudo &&
;
combinator:
- '+' maybe_space { $$ = CSSSelector::Sibling; }
+ '+' maybe_space { $$ = CSSSelector::DirectAdjacent; }
+ | '~' maybe_space { $$ = CSSSelector::IndirectAdjacent; }
| '>' maybe_space { $$ = CSSSelector::Child; }
| /* empty */ { $$ = CSSSelector::Descendant; }
;
if ( doc )
doc->setUsesDescendantRules(true);
}
- else if ($2 == CSSSelector::Sibling) {
+ else if ($2 == CSSSelector::DirectAdjacent ||
+ $2 == CSSSelector::IndirectAdjacent) {
CSSParser *p = static_cast<CSSParser *>(parser);
DOM::DocumentImpl *doc = p->document();
if (doc)