[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc

commit-queue at webkit.org commit-queue at webkit.org
Wed Dec 22 11:54:26 UTC 2010


The following commit has been merged in the debian/experimental branch:
commit dc719acdb5e2c98dc1fe971e4d928a4bcfa6b453
Author: commit-queue at webkit.org <commit-queue at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Wed Aug 11 05:20:47 2010 +0000

    2010-08-10  Hayato Ito  <hayato at chromium.org>
    
            Reviewed by Kent Tamura.
    
            Make CSSSelector::specificity() non-recursive.
            https://bugs.webkit.org/show_bug.cgi?id=43784
    
            This change is one of the required changes to fix the following master bug:
            https://bugs.webkit.org/show_bug.cgi?id=42806
    
            No functional change, thus no tests.
    
            * css/CSSSelector.cpp:
            (WebCore::CSSSelector::specificity):
            (WebCore::CSSSelector::specificityForOneSelector):
            (WebCore::CSSSelector::specificityForPage):
            * css/CSSSelector.h:
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@65123 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 9101279..9641517 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,21 @@
+2010-08-10  Hayato Ito  <hayato at chromium.org>
+
+        Reviewed by Kent Tamura.
+
+        Make CSSSelector::specificity() non-recursive.
+        https://bugs.webkit.org/show_bug.cgi?id=43784
+
+        This change is one of the required changes to fix the following master bug:
+        https://bugs.webkit.org/show_bug.cgi?id=42806
+
+        No functional change, thus no tests.
+
+        * css/CSSSelector.cpp:
+        (WebCore::CSSSelector::specificity):
+        (WebCore::CSSSelector::specificityForOneSelector):
+        (WebCore::CSSSelector::specificityForPage):
+        * css/CSSSelector.h:
+
 2010-08-10  Matthew Delaney  <mdelaney at apple.com>
 
         Reviewed by Darin Adler.
diff --git a/WebCore/css/CSSSelector.cpp b/WebCore/css/CSSSelector.cpp
index 03974d9..3a6a448 100644
--- a/WebCore/css/CSSSelector.cpp
+++ b/WebCore/css/CSSSelector.cpp
@@ -67,42 +67,46 @@ private:
     Vector<CSSSelector*, 16> m_stack;
 };
 
-unsigned int CSSSelector::specificity()
+unsigned CSSSelector::specificity() const
 {
-    if (m_isForPage)
-        return specificityForPage();
+    // make sure the result doesn't overflow
+    static const unsigned maxValueMask = 0xffffff;
+    unsigned total = 0;
+    for (const CSSSelector* selector = this; selector; selector = selector->tagHistory()) {
+        if (selector->m_isForPage)
+            return (total + selector->specificityForPage()) & maxValueMask;
+        total = (total + selector->specificityForOneSelector()) & maxValueMask;
+    }
+    return total;
+}
 
+inline unsigned CSSSelector::specificityForOneSelector() const
+{
     // FIXME: Pseudo-elements and pseudo-classes do not have the same specificity. This function
     // isn't quite correct.
-    int s = (m_tag.localName() == starAtom ? 0 : 1);
+    unsigned s = (m_tag.localName() == starAtom ? 0 : 1);
     switch (m_match) {
-        case Id:
-            s += 0x10000;
-            break;
-        case Exact:
-        case Class:
-        case Set:
-        case List:
-        case Hyphen:
-        case PseudoClass:
-        case PseudoElement:
-        case Contain:
-        case Begin:
-        case End:
-            s += 0x100;
-        case None:
-            break;
+    case Id:
+        s += 0x10000;
+        break;
+    case Exact:
+    case Class:
+    case Set:
+    case List:
+    case Hyphen:
+    case PseudoClass:
+    case PseudoElement:
+    case Contain:
+    case Begin:
+    case End:
+        s += 0x100;
+    case None:
+        break;
     }
-
-    // FIXME: Avoid recursive calls to prevent possible stack overflow.
-    if (CSSSelector* tagHistory = this->tagHistory())
-        s += tagHistory->specificity();
-
-    // make sure it doesn't overflow
-    return s & 0xffffff;
+    return s;
 }
 
-unsigned CSSSelector::specificityForPage()
+unsigned CSSSelector::specificityForPage() const
 {
     // See http://dev.w3.org/csswg/css3-page/#cascading-and-page-context
     unsigned s = (m_tag.localName() == starAtom ? 0 : 4);
diff --git a/WebCore/css/CSSSelector.h b/WebCore/css/CSSSelector.h
index 34e4af0..e253949 100644
--- a/WebCore/css/CSSSelector.h
+++ b/WebCore/css/CSSSelector.h
@@ -85,7 +85,7 @@ namespace WebCore {
 
         // tag == -1 means apply to all elements (Selector = *)
 
-        unsigned specificity();
+        unsigned specificity() const;
 
         /* how the attribute value has to match.... Default is Exact */
         enum Match {
@@ -294,7 +294,8 @@ namespace WebCore {
         void releaseOwnedSelectorsToBag(CSSSelectorBag&);
         void deleteReachableSelectors();
 
-        unsigned specificityForPage();
+        unsigned specificityForOneSelector() const;
+        unsigned specificityForPage() const;
         void extractPseudoType() const;
 
         struct RareData : Noncopyable {

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list