Changeset 29933 in webkit


Ignore:
Timestamp:
Feb 2, 2008 2:46:36 AM (16 years ago)
Author:
hyatt@apple.com
Message:

WebCore:

Fix for bug 4812. Support last-child and last-of-type CSS3 selectors. Brings Acid3 score up to 68/100.

Reviewed by olliej

Added fast/css/last-child-pseudo-class.html, fast/css/last-of-type-pseudo-class.html

  • css/CSSGrammar.y:
  • css/CSSSelector.cpp: (WebCore::CSSSelector::extractPseudoType):
  • css/CSSSelector.h: (WebCore::CSSSelector::):
  • css/CSSStyleSelector.cpp: (WebCore::CSSStyleSelector::checkOneSelector):

LayoutTests:

Fix for bug 4812. Support last-child and last-of-type (and make sure they are properly dynamic).

Reviewed by olliej

  • fast/css/last-child-pseudo-class.html: Added.
  • fast/css/last-of-type-pseudo-class.html: Added.
  • platform/mac/fast/css/last-child-pseudo-class-expected.checksum: Added.
  • platform/mac/fast/css/last-child-pseudo-class-expected.png: Added.
  • platform/mac/fast/css/last-child-pseudo-class-expected.txt: Added.
  • platform/mac/fast/css/last-of-type-pseudo-class-expected.checksum: Added.
  • platform/mac/fast/css/last-of-type-pseudo-class-expected.png: Added.
  • platform/mac/fast/css/last-of-type-pseudo-class-expected.txt: Added.
Location:
trunk
Files:
8 added
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r29932 r29933  
     12008-02-02  David Hyatt  <hyatt@apple.com>
     2
     3        Fix for bug 4812.  Support last-child and last-of-type (and make sure they are properly dynamic).
     4
     5        Reviewed by olliej
     6
     7        * fast/css/last-child-pseudo-class.html: Added.
     8        * fast/css/last-of-type-pseudo-class.html: Added.
     9        * platform/mac/fast/css/last-child-pseudo-class-expected.checksum: Added.
     10        * platform/mac/fast/css/last-child-pseudo-class-expected.png: Added.
     11        * platform/mac/fast/css/last-child-pseudo-class-expected.txt: Added.
     12        * platform/mac/fast/css/last-of-type-pseudo-class-expected.checksum: Added.
     13        * platform/mac/fast/css/last-of-type-pseudo-class-expected.png: Added.
     14        * platform/mac/fast/css/last-of-type-pseudo-class-expected.txt: Added.
     15
    1162008-02-01  David Hyatt  <hyatt@apple.com>
    217
  • trunk/WebCore/ChangeLog

    r29932 r29933  
     12008-02-02  David Hyatt  <hyatt@apple.com>
     2
     3        Fix for bug 4812. Support last-child and last-of-type CSS3 selectors.  Brings Acid3 score up to 68/100.
     4
     5        Reviewed by olliej
     6
     7        Added fast/css/last-child-pseudo-class.html, fast/css/last-of-type-pseudo-class.html
     8
     9        * css/CSSGrammar.y:
     10        * css/CSSSelector.cpp:
     11        (WebCore::CSSSelector::extractPseudoType):
     12        * css/CSSSelector.h:
     13        (WebCore::CSSSelector::):
     14        * css/CSSStyleSelector.cpp:
     15        (WebCore::CSSStyleSelector::checkOneSelector):
     16
    1172008-02-01  David Hyatt  <hyatt@apple.com>
    218
  • trunk/WebCore/css/CSSGrammar.y

    r29932 r29933  
    857857        else if (type == CSSSelector::PseudoEmpty ||
    858858                 type == CSSSelector::PseudoFirstChild ||
    859                  type == CSSSelector::PseudoFirstOfType) {
     859                 type == CSSSelector::PseudoFirstOfType ||
     860                 type == CSSSelector::PseudoLastChild ||
     861                 type == CSSSelector::PseudoLastOfType) {
    860862            CSSParser* p = static_cast<CSSParser*>(parser);
    861863            Document* doc = p->document();
  • trunk/WebCore/css/CSSSelector.cpp

    r29257 r29933  
    8888    static AtomicString hover("hover");
    8989    static AtomicString indeterminate("indeterminate");
     90    static AtomicString lastChild("last-child");
     91    static AtomicString lastOfType("last-of-type");
    9092    static AtomicString link("link");
    9193    static AtomicString lang("lang(");
     
    142144    else if (m_value == firstChild)
    143145        m_pseudoType = PseudoFirstChild;
     146    else if (m_value == lastChild)
     147        m_pseudoType = PseudoLastChild;
     148    else if (m_value == lastOfType)
     149        m_pseudoType = PseudoLastOfType;
    144150    else if (m_value == firstLetter) {
    145151        m_pseudoType = PseudoFirstLetter;
  • trunk/WebCore/css/CSSSelector.h

    r29257 r29933  
    122122            PseudoFirstChild,
    123123            PseudoFirstOfType,
     124            PseudoLastChild,
     125            PseudoLastOfType,
    124126            PseudoFirstLine,
    125127            PseudoFirstLetter,
     
    182184        unsigned m_relation           : 3; // enum Relation
    183185        mutable unsigned m_match      : 4; // enum Match
    184         mutable unsigned m_pseudoType : 6; // PseudoType
     186        mutable unsigned m_pseudoType : 8; // PseudoType
    185187
    186188    private:
  • trunk/WebCore/css/CSSStyleSelector.cpp

    r29932 r29933  
    16331633                            break;
    16341634                        n = n->previousSibling();
     1635                    }
     1636                    if (!n)
     1637                        result = true;
     1638                    if (!m_collectRulesOnly) {
     1639                        RenderStyle* parentStyle = (m_element == e) ? m_parentStyle : e->parentNode()->renderStyle();
     1640                        if (parentStyle)
     1641                            parentStyle->setChildrenAffectedByPositionalRules();
     1642                    }
     1643                    return result;
     1644                }
     1645                break;
     1646            }
     1647            case CSSSelector::PseudoLastChild: {
     1648                // first-child matches the first child that is an element
     1649                if (e->parentNode() && e->parentNode()->isElementNode()) {
     1650                    bool result = false;
     1651                    Node* n = e->nextSibling();
     1652                    while (n && !n->isElementNode())
     1653                        n = n->nextSibling();
     1654                    if (!n)
     1655                        result = true;
     1656                    if (!m_collectRulesOnly) {
     1657                        RenderStyle* childStyle = (m_element == e) ? m_style : e->renderStyle();
     1658                        RenderStyle* parentStyle = (m_element == e) ? m_parentStyle : e->parentNode()->renderStyle();
     1659                        if (parentStyle)
     1660                            parentStyle->setChildrenAffectedByLastChildRules();
     1661                        if (result && childStyle)
     1662                            childStyle->setLastChildState();
     1663                    }
     1664                    return result;
     1665                }
     1666                break;
     1667            }
     1668            case CSSSelector::PseudoLastOfType: {
     1669                // first-of-type matches the first element of its type
     1670                if (e->parentNode() && e->parentNode()->isElementNode()) {
     1671                    bool result = false;
     1672                    const QualifiedName& type = e->tagQName();
     1673                    Node* n = e->nextSibling();
     1674                    while (n) {
     1675                        if (n->isElementNode() && static_cast<Element*>(n)->hasTagName(type))
     1676                            break;
     1677                        n = n->nextSibling();
    16351678                    }
    16361679                    if (!n)
Note: See TracChangeset for help on using the changeset viewer.