Reviewed by Darin.
authorantti@apple.com <antti@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 27 Nov 2007 23:27:13 +0000 (23:27 +0000)
committerantti@apple.com <antti@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 27 Nov 2007 23:27:13 +0000 (23:27 +0000)
        - Don't use hasPseudoId() optimization for pseudo styles used in shadow trees. These styles
          generally exist when asked for so the optimization does not do much. This reverses the continuing
          growth of the _pseudoBits bitfield in RenderStyle.
        - Add some pseudo elements for media controls

        * css/CSSSelector.cpp:
        (WebCore::CSSSelector::extractPseudoType):
        * css/CSSSelector.h:
        (WebCore::CSSSelector::):
        * css/CSSStyleSelector.cpp:
        (WebCore::CSSStyleSelector::matchRulesForList):
        (WebCore::CSSStyleSelector::checkOneSelector):
        * rendering/RenderObject.cpp:
        (WebCore::RenderObject::getPseudoStyle):
        * rendering/RenderStyle.cpp:
        (WebCore::pseudoBit):
        (WebCore::RenderStyle::hasPseudoStyle):
        (WebCore::RenderStyle::setHasPseudoStyle):
        * rendering/RenderStyle.h:
        (WebCore::RenderStyle::):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@28084 268f45cc-cd09-0410-ab3c-d52691b4dbfc

WebCore/ChangeLog
WebCore/css/CSSSelector.cpp
WebCore/css/CSSSelector.h
WebCore/css/CSSStyleSelector.cpp
WebCore/rendering/RenderObject.cpp
WebCore/rendering/RenderStyle.cpp
WebCore/rendering/RenderStyle.h

index 89f488b9a059de7bb02b956b7ce9bcf52001a68f..49a548a6d950aea1a1636fa30d554469cba2ef24 100644 (file)
@@ -1,3 +1,28 @@
+2007-11-27  Antti Koivisto  <antti@apple.com>
+
+        Reviewed by Darin.
+
+        - Don't use hasPseudoId() optimization for pseudo styles used in shadow trees. These styles
+          generally exist when asked for so the optimization does not do much. This reverses the continuing
+          growth of the _pseudoBits bitfield in RenderStyle.
+        - Add some pseudo elements for media controls
+
+        * css/CSSSelector.cpp:
+        (WebCore::CSSSelector::extractPseudoType):
+        * css/CSSSelector.h:
+        (WebCore::CSSSelector::):
+        * css/CSSStyleSelector.cpp:
+        (WebCore::CSSStyleSelector::matchRulesForList):
+        (WebCore::CSSStyleSelector::checkOneSelector):
+        * rendering/RenderObject.cpp:
+        (WebCore::RenderObject::getPseudoStyle):
+        * rendering/RenderStyle.cpp:
+        (WebCore::pseudoBit):
+        (WebCore::RenderStyle::hasPseudoStyle):
+        (WebCore::RenderStyle::setHasPseudoStyle):
+        * rendering/RenderStyle.h:
+        (WebCore::RenderStyle::):
+
 2007-11-27  Timothy Hatcher  <timothy@apple.com>
 
         Reviewed by Kevin McCullough.
index faf85b7c1dc7402571b7d7ea3e994bce07d01399..62e907751a4d6de4a66d623bdd9046f6b517471d 100644 (file)
@@ -89,6 +89,11 @@ void CSSSelector::extractPseudoType() const
     static AtomicString indeterminate("indeterminate");
     static AtomicString link("link");
     static AtomicString lang("lang(");
+    static AtomicString mediaControlsPanel("-webkit-media-controls-panel");
+    static AtomicString mediaControlsMuteButton("-webkit-media-controls-mute-button");
+    static AtomicString mediaControlsPlayButton("-webkit-media-controls-play-button");
+    static AtomicString mediaControlsTimeDisplay("-webkit-media-controls-time-display");
+    static AtomicString mediaControlsTimeline("-webkit-media-controls-timeline");
     static AtomicString notStr("not(");
     static AtomicString root("root");
     static AtomicString searchCancelButton("-webkit-search-cancel-button");
@@ -153,7 +158,22 @@ void CSSSelector::extractPseudoType() const
         m_pseudoType = PseudoLink;
     else if (m_value == lang)
         m_pseudoType = PseudoLang;
-    else if (m_value == notStr)
+    else if (m_value == mediaControlsPanel) {
+        m_pseudoType = PseudoMediaControlsPanel;
+        element = true;
+    } else if (m_value == mediaControlsMuteButton) {
+        m_pseudoType = PseudoMediaControlsMuteButton;
+        element = true;
+    } else if (m_value == mediaControlsPlayButton) {
+        m_pseudoType = PseudoMediaControlsPlayButton;
+        element = true;
+    } else if (m_value == mediaControlsTimeDisplay) {
+        m_pseudoType = PseudoMediaControlsTimeDisplay;
+        element = true;
+    } else if (m_value == mediaControlsTimeline) {
+        m_pseudoType = PseudoMediaControlsTimeline;
+        element = true;
+    } else if (m_value == notStr)
         m_pseudoType = PseudoNot;
     else if (m_value == root)
         m_pseudoType = PseudoRoot;
index 7534f45cc4c0f93d44155eb6b8f2a0eb0af59bf0..6eb0cc82f3c5b3c056a6365ec8d3fc955fb3e503 100644 (file)
@@ -147,7 +147,12 @@ namespace WebCore {
             PseudoSearchCancelButton,
             PseudoSearchDecoration,
             PseudoSearchResultsDecoration,
-            PseudoSearchResultsButton
+            PseudoSearchResultsButton,
+            PseudoMediaControlsPanel,
+            PseudoMediaControlsMuteButton,
+            PseudoMediaControlsPlayButton,
+            PseudoMediaControlsTimeDisplay,
+            PseudoMediaControlsTimeline
         };
 
         PseudoType pseudoType() const
index 119284d070ec2aa6c4074da4ee623cd48c60a538..c0115ef14d1c354683ffe6fdc9421184b74ea5db 100644 (file)
@@ -439,7 +439,8 @@ void CSSStyleSelector::matchRulesForList(CSSRuleDataList* rules, int& firstRuleI
             if (dynamicPseudo != RenderStyle::NOPSEUDO && pseudoStyle == RenderStyle::NOPSEUDO) {
                 if (m_collectRulesOnly)
                     return;
-                style->setHasPseudoStyle(dynamicPseudo);
+                if (dynamicPseudo < RenderStyle::FIRST_INTERNAL_PSEUDOID)
+                    style->setHasPseudoStyle(dynamicPseudo);
             } else {
                 // Update our first/last rule indices in the matched rules array.
                 lastRuleIndex = m_matchedDecls.size() + m_matchedRules.size();
@@ -1609,6 +1610,21 @@ bool CSSStyleSelector::checkOneSelector(CSSSelector* sel, Element* e, bool isAnc
             case CSSSelector::PseudoSearchResultsButton:
                 dynamicPseudo = RenderStyle::SEARCH_RESULTS_BUTTON;
                 return true;
+            case CSSSelector::PseudoMediaControlsPanel:
+                dynamicPseudo = RenderStyle::MEDIA_CONTROLS_PANEL;
+                return true;
+            case CSSSelector::PseudoMediaControlsMuteButton:
+                dynamicPseudo = RenderStyle::MEDIA_CONTROLS_MUTE_BUTTON;
+                return true;
+            case CSSSelector::PseudoMediaControlsPlayButton:
+                dynamicPseudo = RenderStyle::MEDIA_CONTROLS_PLAY_BUTTON;
+                return true;
+            case CSSSelector::PseudoMediaControlsTimeDisplay:
+                dynamicPseudo = RenderStyle::MEDIA_CONTROLS_TIME_DISPLAY;
+                return true;
+            case CSSSelector::PseudoMediaControlsTimeline:
+                dynamicPseudo = RenderStyle::MEDIA_CONTROLS_TIMELINE;
+                return true;
             case CSSSelector::PseudoUnknown:
             case CSSSelector::PseudoNotParsed:
             default:
index d8366dfb104a2c35ac9dbbfa043e8c9ee1982d95..8e1eb1b90f709d99b0e095b4d6e9eea5d81fcea7 100644 (file)
@@ -2790,7 +2790,7 @@ RenderStyle* RenderObject::firstLineStyle() const
 
 RenderStyle* RenderObject::getPseudoStyle(RenderStyle::PseudoId pseudo, RenderStyle* parentStyle) const
 {
-    if (!style()->hasPseudoStyle(pseudo))
+    if (pseudo < RenderStyle::FIRST_INTERNAL_PSEUDOID && !style()->hasPseudoStyle(pseudo))
         return 0;
 
     if (!parentStyle)
index 7a3b85fe5779a8312be8ca1a93740c1868b502f2..4f62e9b578517c4ec487fc59a78e633528ad5c54 100644 (file)
@@ -1038,50 +1038,22 @@ bool RenderStyle::isStyleAvailable() const
     return this != CSSStyleSelector::styleNotYetAvailable;
 }
 
-enum EPseudoBit { NO_BIT = 0x0, BEFORE_BIT = 0x1, AFTER_BIT = 0x2, FIRST_LINE_BIT = 0x4,
-                  FIRST_LETTER_BIT = 0x8, SELECTION_BIT = 0x10, FIRST_LINE_INHERITED_BIT = 0x20,
-                  FILE_UPLOAD_BUTTON_BIT = 0x40, SLIDER_THUMB_BIT = 0x80, SEARCH_CANCEL_BUTTON_BIT = 0x100, SEARCH_DECORATION_BIT = 0x200, 
-                  SEARCH_RESULTS_DECORATION_BIT = 0x400, SEARCH_RESULTS_BUTTON_BIT = 0x800 };
-
 static inline int pseudoBit(RenderStyle::PseudoId pseudo)
 {
-    switch (pseudo) {
-        case RenderStyle::BEFORE:
-            return BEFORE_BIT;
-        case RenderStyle::AFTER:
-            return AFTER_BIT;
-        case RenderStyle::FIRST_LINE:
-            return FIRST_LINE_BIT;
-        case RenderStyle::FIRST_LETTER:
-            return FIRST_LETTER_BIT;
-        case RenderStyle::SELECTION:
-            return SELECTION_BIT;
-        case RenderStyle::FIRST_LINE_INHERITED:
-            return FIRST_LINE_INHERITED_BIT;
-        case RenderStyle::FILE_UPLOAD_BUTTON:
-            return FILE_UPLOAD_BUTTON_BIT;
-        case RenderStyle::SLIDER_THUMB:
-            return SLIDER_THUMB_BIT;
-        case RenderStyle::SEARCH_CANCEL_BUTTON:
-            return SEARCH_CANCEL_BUTTON_BIT;        
-        case RenderStyle::SEARCH_DECORATION:
-            return SEARCH_DECORATION_BIT;
-        case RenderStyle::SEARCH_RESULTS_DECORATION:
-            return SEARCH_RESULTS_DECORATION_BIT;
-        case RenderStyle::SEARCH_RESULTS_BUTTON:
-            return SEARCH_RESULTS_BUTTON_BIT;
-        default:
-            return NO_BIT;
-    }
+    return 1 << (pseudo - 1);
 }
 
 bool RenderStyle::hasPseudoStyle(PseudoId pseudo) const
 {
+    ASSERT(pseudo > NOPSEUDO);
+    ASSERT(pseudo < FIRST_INTERNAL_PSEUDOID);
     return pseudoBit(pseudo) & noninherited_flags._pseudoBits;
 }
 
 void RenderStyle::setHasPseudoStyle(PseudoId pseudo)
 {
+    ASSERT(pseudo > NOPSEUDO);
+    ASSERT(pseudo < FIRST_INTERNAL_PSEUDOID);
     noninherited_flags._pseudoBits |= pseudoBit(pseudo);
 }
 
index 795391ece95dd052f564cd5fba54beea81a406ab..39c4f014753f9f059fdc1a35cce04d8680477d86 100644 (file)
@@ -1325,7 +1325,9 @@ class RenderStyle {
 public:
     // static pseudo styles. Dynamic ones are produced on the fly.
     enum PseudoId { NOPSEUDO, FIRST_LINE, FIRST_LETTER, BEFORE, AFTER, SELECTION, FIRST_LINE_INHERITED, FILE_UPLOAD_BUTTON, SLIDER_THUMB, 
-                    SEARCH_CANCEL_BUTTON, SEARCH_DECORATION, SEARCH_RESULTS_DECORATION, SEARCH_RESULTS_BUTTON };
+                    SEARCH_CANCEL_BUTTON, SEARCH_DECORATION, SEARCH_RESULTS_DECORATION, SEARCH_RESULTS_BUTTON, MEDIA_CONTROLS_PANEL,
+                    MEDIA_CONTROLS_PLAY_BUTTON, MEDIA_CONTROLS_MUTE_BUTTON, MEDIA_CONTROLS_TIMELINE, MEDIA_CONTROLS_TIME_DISPLAY };
+    static const int FIRST_INTERNAL_PSEUDOID = FILE_UPLOAD_BUTTON;
 
     void ref() { m_ref++;  }
     void deref(RenderArena* arena) { 
@@ -1437,11 +1439,11 @@ protected:
         unsigned _page_break_before : 2; // EPageBreak
         unsigned _page_break_after : 2; // EPageBreak
 
-        unsigned _styleType : 4; // PseudoId
+        unsigned _styleType : 5; // PseudoId
         bool _affectedByHover : 1;
         bool _affectedByActive : 1;
         bool _affectedByDrag : 1;
-        unsigned _pseudoBits : 12;
+        unsigned _pseudoBits : 6;
         unsigned _unicodeBidi : 2; // EUnicodeBidi
     } noninherited_flags;