Changeset 35406 in webkit


Ignore:
Timestamp:
Jul 27, 2008 3:03:41 PM (16 years ago)
Author:
weinig@apple.com
Message:

WebCore:

2008-07-27 Sam Weinig <sam@webkit.org>

Reviewed by Oliver Hunt.

Fix for https://bugs.webkit.org/show_bug.cgi?id=20176
querySelectorAll id optimization no longer working

Turn the querySelector/querySelectorAll id optimization back on
for only strict and almost strict mode. In quirks mode, the optimiztion
won't work as the id match is not case sensitive.

Tests: fast/dom/SelectorAPI/caseID-almost-strict.html

fast/dom/SelectorAPI/caseID-strict.html
fast/dom/SelectorAPI/caseID.html

  • dom/Node.cpp: (WebCore::Node::querySelector): (WebCore::Node::querySelectorAll):
  • dom/SelectorNodeList.cpp: (WebCore::createSelectorNodeList):
  • dom/SelectorNodeList.h:

LayoutTests:

2008-07-27 Sam Weinig <sam@webkit.org>

Reviewed by Oliver Hunt.

Tests for https://bugs.webkit.org/show_bug.cgi?id=20176
querySelectorAll id optimization no longer working

  • fast/dom/SelectorAPI/caseID-almost-strict-expected.txt: Added.
  • fast/dom/SelectorAPI/caseID-almost-strict.html: Added.
  • fast/dom/SelectorAPI/caseID-expected.txt: Added.
  • fast/dom/SelectorAPI/caseID-strict-expected.txt: Added.
  • fast/dom/SelectorAPI/caseID-strict.html: Added.
  • fast/dom/SelectorAPI/caseID.html: Added.
Location:
trunk
Files:
6 added
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r35403 r35406  
     12008-07-27  Sam Weinig  <sam@webkit.org>
     2
     3        Reviewed by Oliver Hunt.
     4
     5        Tests for https://bugs.webkit.org/show_bug.cgi?id=20176
     6        querySelectorAll id optimization no longer working
     7
     8        * fast/dom/SelectorAPI/caseID-almost-strict-expected.txt: Added.
     9        * fast/dom/SelectorAPI/caseID-almost-strict.html: Added.
     10        * fast/dom/SelectorAPI/caseID-expected.txt: Added.
     11        * fast/dom/SelectorAPI/caseID-strict-expected.txt: Added.
     12        * fast/dom/SelectorAPI/caseID-strict.html: Added.
     13        * fast/dom/SelectorAPI/caseID.html: Added.
     14
    1152008-07-27  Anatoli Papirovski  <apapirovski@mac.com>
    216
  • trunk/WebCore/ChangeLog

    r35403 r35406  
     12008-07-27  Sam Weinig  <sam@webkit.org>
     2
     3        Reviewed by Oliver Hunt.
     4
     5        Fix for https://bugs.webkit.org/show_bug.cgi?id=20176
     6        querySelectorAll id optimization no longer working
     7
     8        Turn the querySelector/querySelectorAll id optimization back on
     9        for only strict and almost strict mode.  In quirks mode, the optimiztion
     10        won't work as the id match is not case sensitive.
     11
     12        Tests: fast/dom/SelectorAPI/caseID-almost-strict.html
     13               fast/dom/SelectorAPI/caseID-strict.html
     14               fast/dom/SelectorAPI/caseID.html
     15
     16        * dom/Node.cpp:
     17        (WebCore::Node::querySelector):
     18        (WebCore::Node::querySelectorAll):
     19        * dom/SelectorNodeList.cpp:
     20        (WebCore::createSelectorNodeList):
     21        * dom/SelectorNodeList.h:
     22
    1232008-07-27  Anatoli Papirovski  <apapirovski@mac.com>
    224
  • trunk/WebCore/dom/Node.cpp

    r35375 r35406  
    13301330        return 0;
    13311331    }
    1332     CSSParser p(!document()->inCompatMode());
     1332    bool strictParsing = !document()->inCompatMode();
     1333    CSSParser p(strictParsing);
    13331334    if (resolver) {
    13341335        String defaultNamespace = resolver->lookupNamespaceURI(exec, String());
    13351336        if (exec && exec->hadException())
    1336             return false;
     1337            return 0;
    13371338        if (!defaultNamespace.isEmpty())
    13381339            p.m_defaultNamespace = defaultNamespace;
     
    13571358    }
    13581359
    1359     if (inDocument() && !querySelector->next() && querySelector->m_match == CSSSelector::Id
    1360             && !querySelector->hasTag() && !querySelector->hasAttribute()
    1361             && !querySelector->m_tagHistory && !querySelector->m_simpleSelector) {
     1360    // FIXME: we could also optimize for the the [id="foo"] case
     1361    if (strictParsing && inDocument() && !querySelector->next() && querySelector->m_match == CSSSelector::Id
     1362            && !querySelector->hasTag() && !querySelector->m_tagHistory && !querySelector->m_simpleSelector) {
     1363        ASSERT(querySelector->m_attr == idAttr);
    13621364        Element* element = document()->getElementById(querySelector->m_value);
    13631365        if (element && (isDocumentNode() || element->isDescendantOf(this)))
     
    13661368    }
    13671369
    1368     CSSStyleSelector::SelectorChecker selectorChecker(document(), !document()->inCompatMode());
     1370    CSSStyleSelector::SelectorChecker selectorChecker(document(), strictParsing);
    13691371
    13701372    // FIXME: We can speed this up by implementing caching similar to the one use by getElementById
     
    13881390        return 0;
    13891391    }
    1390     CSSParser p(!document()->inCompatMode());
     1392    bool strictParsing = !document()->inCompatMode();
     1393    CSSParser p(strictParsing);
    13911394    if (resolver) {
    13921395        String defaultNamespace = resolver->lookupNamespaceURI(exec, String());
  • trunk/WebCore/dom/SelectorNodeList.cpp

    r35145 r35406  
    3434#include "Document.h"
    3535#include "Element.h"
     36#include "HTMLNames.h"
    3637
    3738namespace WebCore {
    3839
    39 PassRefPtr<StaticNodeList> createSelectorNodeList(PassRefPtr<Node> rootNode, CSSSelector* querySelector)
     40using namespace HTMLNames;
     41
     42PassRefPtr<StaticNodeList> createSelectorNodeList(Node* rootNode, CSSSelector* querySelector)
    4043{
    4144    Vector<RefPtr<Node> > nodes;
    4245    Document* document = rootNode->document();
    4346    AtomicString selectorValue = querySelector->m_value;
     47    bool strictParsing = !document->inCompatMode();
    4448
    45     if (rootNode->inDocument() && !querySelector->next() && querySelector->m_match == CSSSelector::Id
    46             && !querySelector->hasTag() && !querySelector->hasAttribute()
    47             && !querySelector->m_tagHistory && !querySelector->m_simpleSelector
     49    if (strictParsing && rootNode->inDocument() && !querySelector->next() && querySelector->m_match == CSSSelector::Id
     50            && !querySelector->hasTag() && !querySelector->m_tagHistory && !querySelector->m_simpleSelector
    4851            && !document->containsMultipleElementsWithId(selectorValue)) {
     52        ASSERT(querySelector->m_attr == idAttr);
    4953        Element* element = document->getElementById(selectorValue);
    50         if (element && (rootNode->isDocumentNode() || element->isDescendantOf(rootNode.get())))
     54        if (element && (rootNode->isDocumentNode() || element->isDescendantOf(rootNode)))
    5155            nodes.append(element);
    5256    } else {
    53         CSSStyleSelector::SelectorChecker selectorChecker(document, !document->inCompatMode());
    54        
    55         for (Node* n = rootNode->firstChild(); n; n = n->traverseNextNode(rootNode.get())) {
     57        CSSStyleSelector::SelectorChecker selectorChecker(document, strictParsing);
     58        for (Node* n = rootNode->firstChild(); n; n = n->traverseNextNode(rootNode)) {
    5659            if (n->isElementNode()) {
    5760                Element* element = static_cast<Element*>(n);
  • trunk/WebCore/dom/SelectorNodeList.h

    r34432 r35406  
    3636    class CSSSelector;
    3737
    38     PassRefPtr<StaticNodeList> createSelectorNodeList(PassRefPtr<Node> rootNode, CSSSelector*);
     38    PassRefPtr<StaticNodeList> createSelectorNodeList(Node* rootNode, CSSSelector*);
    3939
    4040} // namespace WebCore
Note: See TracChangeset for help on using the changeset viewer.