Changeset 47444 in webkit


Ignore:
Timestamp:
Aug 18, 2009 12:50:04 PM (15 years ago)
Author:
pkasting@chromium.org
Message:

WebCore: https://bugs.webkit.org/show_bug.cgi?id=27357
Support for :valid and :invalid CSS selectors, from HTML5 specs.
http://www.whatwg.org/specs/web-apps/current-work/#selector-valid

Patch by Michelangelo De Simone <micdesim@gmail.com> on 2009-08-18
Reviewed by Adele Peterson.

Tests: fast/css/pseudo-invalid-001.html

fast/css/pseudo-invalid-002.html
fast/css/pseudo-valid-001.html
fast/css/pseudo-valid-002.html
fast/css/pseudo-valid-003.html
fast/css/pseudo-valid-004.html
fast/css/pseudo-valid-005.html
fast/css/pseudo-valid-006.html
fast/css/pseudo-valid-007.html

  • css/CSSSelector.cpp:

(WebCore::CSSSelector::extractPseudoType): extracts new pseudo-classes

  • css/CSSSelector.h:

(WebCore::CSSSelector::):

  • css/CSSStyleSelector.cpp:

(WebCore::CSSStyleSelector::canShareStyleWithElement): Make sure we don't share style between

LayoutTests: https://bugs.webkit.org/show_bug.cgi?id=27357
Tests for :valid and :invalid CSS selectors, from HTML5 specs.
http://www.whatwg.org/specs/web-apps/current-work/#selector-valid

Patch by Michelangelo De Simone <micdesim@gmail.com> on 2009-08-18
Reviewed by Adele Peterson.

  • fast/css/pseudo-invalid-001-expected.txt: Added.
  • fast/css/pseudo-invalid-001.html: Added.
  • fast/css/pseudo-invalid-002-expected.txt: Added.
  • fast/css/pseudo-invalid-002.html: Added.
  • fast/css/pseudo-valid-001-expected.txt: Added.
  • fast/css/pseudo-valid-001.html: Added.
  • fast/css/pseudo-valid-002-expected.txt: Added.
  • fast/css/pseudo-valid-002.html: Added.
  • fast/css/pseudo-valid-003-expected.txt: Added.
  • fast/css/pseudo-valid-003.html: Added.
  • fast/css/pseudo-valid-004-expected.txt: Added.
  • fast/css/pseudo-valid-004.html: Added.
  • fast/css/pseudo-valid-005-expected.txt: Added.
  • fast/css/pseudo-valid-005.html: Added.
  • fast/css/pseudo-valid-006-expected.txt: Added.
  • fast/css/pseudo-valid-006.html: Added.
  • fast/css/pseudo-valid-007-expected.txt: Added.
  • fast/css/pseudo-valid-007.html: Added.
  • fast/dom/plugin-attributes-enumeration-expected.txt:
Location:
trunk
Files:
18 added
12 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r47440 r47444  
     12009-08-18  Michelangelo De Simone  <micdesim@gmail.com>
     2
     3        Reviewed by Adele Peterson.
     4
     5        https://bugs.webkit.org/show_bug.cgi?id=27357
     6        Tests for :valid and :invalid CSS selectors, from HTML5 specs.
     7        http://www.whatwg.org/specs/web-apps/current-work/#selector-valid
     8
     9        * fast/css/pseudo-invalid-001-expected.txt: Added.
     10        * fast/css/pseudo-invalid-001.html: Added.
     11        * fast/css/pseudo-invalid-002-expected.txt: Added.
     12        * fast/css/pseudo-invalid-002.html: Added.
     13        * fast/css/pseudo-valid-001-expected.txt: Added.
     14        * fast/css/pseudo-valid-001.html: Added.
     15        * fast/css/pseudo-valid-002-expected.txt: Added.
     16        * fast/css/pseudo-valid-002.html: Added.
     17        * fast/css/pseudo-valid-003-expected.txt: Added.
     18        * fast/css/pseudo-valid-003.html: Added.
     19        * fast/css/pseudo-valid-004-expected.txt: Added.
     20        * fast/css/pseudo-valid-004.html: Added.
     21        * fast/css/pseudo-valid-005-expected.txt: Added.
     22        * fast/css/pseudo-valid-005.html: Added.
     23        * fast/css/pseudo-valid-006-expected.txt: Added.
     24        * fast/css/pseudo-valid-006.html: Added.
     25        * fast/css/pseudo-valid-007-expected.txt: Added.
     26        * fast/css/pseudo-valid-007.html: Added.
     27        * fast/dom/plugin-attributes-enumeration-expected.txt:
     28
    1292009-08-16  David Hyatt  <hyatt@apple.com>
    230
  • trunk/LayoutTests/fast/dom/plugin-attributes-enumeration-expected.txt

    r32664 r47444  
    2020useMap
    2121vspace
     22willValidate
    2223----------
    2324EMBED also has:
  • trunk/WebCore/ChangeLog

    r47443 r47444  
     12009-08-18  Michelangelo De Simone  <micdesim@gmail.com>
     2
     3        Reviewed by Adele Peterson.
     4
     5        https://bugs.webkit.org/show_bug.cgi?id=27357
     6        Support for :valid and :invalid CSS selectors, from HTML5 specs.
     7        http://www.whatwg.org/specs/web-apps/current-work/#selector-valid
     8
     9        Tests: fast/css/pseudo-invalid-001.html
     10               fast/css/pseudo-invalid-002.html
     11               fast/css/pseudo-valid-001.html
     12               fast/css/pseudo-valid-002.html
     13               fast/css/pseudo-valid-003.html
     14               fast/css/pseudo-valid-004.html
     15               fast/css/pseudo-valid-005.html
     16               fast/css/pseudo-valid-006.html
     17               fast/css/pseudo-valid-007.html
     18
     19        * css/CSSSelector.cpp:
     20        (WebCore::CSSSelector::extractPseudoType): extracts new pseudo-classes
     21        * css/CSSSelector.h:
     22        (WebCore::CSSSelector::):
     23        * css/CSSStyleSelector.cpp:
     24        (WebCore::CSSStyleSelector::canShareStyleWithElement): Make sure we don't share style between
     25form controls that have different validity states.
     26        (WebCore::CSSStyleSelector::SelectorChecker::checkOneSelector): applies
     27        style associated to new pseudo-classes
     28        * dom/Element.h:
     29        (WebCore::Element::willValidate): pushed up in hierarchy
     30        (WebCore::Element::isValidFormControlElement): checks for valid form
     31        control elements (wraps ValidityState::valid())
     32        * html/HTMLFormControlElement.cpp:
     33        (WebCore::HTMLFormControlElement::willValidate): minor clean up
     34        (WebCore::HTMLFormControlElement::isValidFormControlElement): ditto
     35        * html/HTMLFormControlElement.h:
     36        * html/HTMLKeygenElement.h:
     37        (WebCore::HTMLKeygenElement::willValidate): added
     38        * html/HTMLObjectElement.h:
     39        (WebCore::HTMLObjectElement::willValidate): added
     40        * html/HTMLObjectElement.idl:
     41
    1422009-08-18  Pavel Feldman  <pfeldman@chromium.org>
    243
  • trunk/WebCore/css/CSSSelector.cpp

    r47155 r47444  
    8282    DEFINE_STATIC_LOCAL(AtomicString, readOnly, ("read-only"));
    8383    DEFINE_STATIC_LOCAL(AtomicString, readWrite, ("read-write"));
     84    DEFINE_STATIC_LOCAL(AtomicString, valid, ("valid"));
     85    DEFINE_STATIC_LOCAL(AtomicString, invalid, ("invalid"));
    8486    DEFINE_STATIC_LOCAL(AtomicString, drag, ("-webkit-drag"));
    8587    DEFINE_STATIC_LOCAL(AtomicString, dragAlias, ("-khtml-drag")); // was documented with this name in Apple documentation, so keep an alia
     
    180182    else if (m_value == readWrite)
    181183        m_pseudoType = PseudoReadWrite;
     184    else if (m_value == valid)
     185        m_pseudoType = PseudoValid;
     186    else if (m_value == invalid)
     187        m_pseudoType = PseudoInvalid;
    182188    else if (m_value == drag || m_value == dragAlias)
    183189        m_pseudoType = PseudoDrag;
  • trunk/WebCore/css/CSSSelector.h

    r47155 r47444  
    134134            PseudoReadOnly,
    135135            PseudoReadWrite,
     136            PseudoValid,
     137            PseudoInvalid,
    136138            PseudoIndeterminate,
    137139            PseudoTarget,
  • trunk/WebCore/css/CSSStyleSelector.cpp

    r47229 r47444  
    999999                if (s->isDefaultButtonForForm() != m_element->isDefaultButtonForForm())
    10001000                    return false;
     1001
     1002                if ((s->willValidate() && s->isValidFormControlElement()) !=
     1003                    (m_element->willValidate() && m_element->isValidFormControlElement()))
     1004                    return false;
    10011005            }
    10021006
     
    23902394            case CSSSelector::PseudoRequired:
    23912395                return e && e->isRequiredFormControl();
     2396            case CSSSelector::PseudoValid:
     2397                return e && e->willValidate() && e->isValidFormControlElement();
     2398            case CSSSelector::PseudoInvalid:
     2399                return e && e->willValidate() && !e->isValidFormControlElement();
    23922400            case CSSSelector::PseudoChecked: {
    23932401                if (!e || !e->isFormControlElement())
  • trunk/WebCore/dom/Element.h

    r47165 r47444  
    194194    virtual bool isRequiredFormControl() const { return false; }
    195195    virtual bool isDefaultButtonForForm() const { return false; }
     196    virtual bool willValidate() const { return false; }
     197    virtual bool isValidFormControlElement() { return false; }
    196198
    197199    virtual bool formControlValueMatchesRenderer() const { return false; }
  • trunk/WebCore/html/HTMLFormControlElement.cpp

    r47155 r47444  
    261261    //      The control does not have a datalist element as an ancestor.
    262262    //      The control is not an output element.
    263     return form() && name().length() && !disabled() && !isReadOnlyFormControl();
     263    return form() && !name().isEmpty() && !disabled() && !isReadOnlyFormControl();
    264264}
    265265
     
    298298{
    299299    return isSuccessfulSubmitButton() && m_form && m_form->defaultButton() == this;
     300}
     301
     302bool HTMLFormControlElement::isValidFormControlElement()
     303{
     304    return validity()->valid();
    300305}
    301306
  • trunk/WebCore/html/HTMLFormControlElement.h

    r47155 r47444  
    119119    virtual HTMLFormElement* virtualForm() const;
    120120    virtual bool isDefaultButtonForForm() const;
     121    virtual bool isValidFormControlElement();
    121122
    122123    HTMLFormElement* m_form;
  • trunk/WebCore/html/HTMLKeygenElement.h

    r43367 r47444  
    3939    virtual bool appendFormData(FormDataList&, bool);
    4040
     41    virtual bool willValidate() const { return false; }
     42
    4143private:
    4244    AtomicString m_challenge;
  • trunk/WebCore/html/HTMLObjectElement.h

    r39065 r47444  
    105105    virtual void addSubresourceAttributeURLs(ListHashSet<KURL>&) const;
    106106
     107    virtual bool willValidate() const { return false; }
     108
    107109private:
    108110    void updateDocNamedItem();
  • trunk/WebCore/html/HTMLObjectElement.idl

    r47352 r47444  
    4747                 attribute long            vspace;
    4848                 attribute [ConvertNullToNullString, Reflect] DOMString       width;
     49        readonly attribute boolean         willValidate;
    4950
    5051        // Introduced in DOM Level 2:
Note: See TracChangeset for help on using the changeset viewer.