Changeset 125697 in webkit


Ignore:
Timestamp:
Aug 15, 2012 12:38:35 PM (12 years ago)
Author:
benjamin@webkit.org
Message:

Use literal initialization for CSS's pseudo types
https://bugs.webkit.org/show_bug.cgi?id=94066

Patch by Benjamin Poulain <bpoulain@apple.com> on 2012-08-15
Reviewed by Kenneth Rohde Christiansen.

Initialize CSS pseudo type strings with the new initialization from literal.

The first invocation of nameToPseudoTypeMap() becomes 20% faster and we use
less memory to store the strings.

  • css/CSSSelector.cpp:

(WebCore::nameToPseudoTypeMap):

Location:
trunk/Source/WebCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r125695 r125697  
     12012-08-15  Benjamin Poulain  <bpoulain@apple.com>
     2
     3        Use literal initialization for CSS's pseudo types
     4        https://bugs.webkit.org/show_bug.cgi?id=94066
     5
     6        Reviewed by Kenneth Rohde Christiansen.
     7
     8        Initialize CSS pseudo type strings with the new initialization from literal.
     9
     10        The first invocation of nameToPseudoTypeMap() becomes 20% faster and we use
     11        less memory to store the strings.
     12
     13        * css/CSSSelector.cpp:
     14        (WebCore::nameToPseudoTypeMap):
     15
    1162012-08-15  Brady Eidson  <beidson@apple.com>
    217
  • trunk/Source/WebCore/css/CSSSelector.cpp

    r118703 r125697  
    218218static HashMap<AtomicStringImpl*, CSSSelector::PseudoType>* nameToPseudoTypeMap()
    219219{
    220     DEFINE_STATIC_LOCAL(AtomicString, active, ("active"));
    221     DEFINE_STATIC_LOCAL(AtomicString, after, ("after"));
    222     DEFINE_STATIC_LOCAL(AtomicString, any, ("-webkit-any("));
    223     DEFINE_STATIC_LOCAL(AtomicString, anyLink, ("-webkit-any-link"));
    224     DEFINE_STATIC_LOCAL(AtomicString, autofill, ("-webkit-autofill"));
    225     DEFINE_STATIC_LOCAL(AtomicString, before, ("before"));
    226     DEFINE_STATIC_LOCAL(AtomicString, checked, ("checked"));
    227     DEFINE_STATIC_LOCAL(AtomicString, defaultString, ("default"));
    228     DEFINE_STATIC_LOCAL(AtomicString, disabled, ("disabled"));
    229     DEFINE_STATIC_LOCAL(AtomicString, readOnly, ("read-only"));
    230     DEFINE_STATIC_LOCAL(AtomicString, readWrite, ("read-write"));
    231     DEFINE_STATIC_LOCAL(AtomicString, valid, ("valid"));
    232     DEFINE_STATIC_LOCAL(AtomicString, invalid, ("invalid"));
    233     DEFINE_STATIC_LOCAL(AtomicString, drag, ("-webkit-drag"));
    234     DEFINE_STATIC_LOCAL(AtomicString, dragAlias, ("-khtml-drag")); // was documented with this name in Apple documentation, so keep an alia
    235     DEFINE_STATIC_LOCAL(AtomicString, empty, ("empty"));
    236     DEFINE_STATIC_LOCAL(AtomicString, enabled, ("enabled"));
    237     DEFINE_STATIC_LOCAL(AtomicString, firstChild, ("first-child"));
    238     DEFINE_STATIC_LOCAL(AtomicString, firstLetter, ("first-letter"));
    239     DEFINE_STATIC_LOCAL(AtomicString, firstLine, ("first-line"));
    240     DEFINE_STATIC_LOCAL(AtomicString, firstOfType, ("first-of-type"));
    241     DEFINE_STATIC_LOCAL(AtomicString, fullPageMedia, ("-webkit-full-page-media"));
    242     DEFINE_STATIC_LOCAL(AtomicString, nthChild, ("nth-child("));
    243     DEFINE_STATIC_LOCAL(AtomicString, nthOfType, ("nth-of-type("));
    244     DEFINE_STATIC_LOCAL(AtomicString, nthLastChild, ("nth-last-child("));
    245     DEFINE_STATIC_LOCAL(AtomicString, nthLastOfType, ("nth-last-of-type("));
    246     DEFINE_STATIC_LOCAL(AtomicString, focus, ("focus"));
    247     DEFINE_STATIC_LOCAL(AtomicString, hover, ("hover"));
    248     DEFINE_STATIC_LOCAL(AtomicString, indeterminate, ("indeterminate"));
    249     DEFINE_STATIC_LOCAL(AtomicString, lastChild, ("last-child"));
    250     DEFINE_STATIC_LOCAL(AtomicString, lastOfType, ("last-of-type"));
    251     DEFINE_STATIC_LOCAL(AtomicString, link, ("link"));
    252     DEFINE_STATIC_LOCAL(AtomicString, lang, ("lang("));
    253     DEFINE_STATIC_LOCAL(AtomicString, notStr, ("not("));
    254     DEFINE_STATIC_LOCAL(AtomicString, onlyChild, ("only-child"));
    255     DEFINE_STATIC_LOCAL(AtomicString, onlyOfType, ("only-of-type"));
    256     DEFINE_STATIC_LOCAL(AtomicString, optional, ("optional"));
    257     DEFINE_STATIC_LOCAL(AtomicString, required, ("required"));
    258     DEFINE_STATIC_LOCAL(AtomicString, resizer, ("-webkit-resizer"));
    259     DEFINE_STATIC_LOCAL(AtomicString, root, ("root"));
    260     DEFINE_STATIC_LOCAL(AtomicString, scrollbar, ("-webkit-scrollbar"));
    261     DEFINE_STATIC_LOCAL(AtomicString, scrollbarButton, ("-webkit-scrollbar-button"));
    262     DEFINE_STATIC_LOCAL(AtomicString, scrollbarCorner, ("-webkit-scrollbar-corner"));
    263     DEFINE_STATIC_LOCAL(AtomicString, scrollbarThumb, ("-webkit-scrollbar-thumb"));
    264     DEFINE_STATIC_LOCAL(AtomicString, scrollbarTrack, ("-webkit-scrollbar-track"));
    265     DEFINE_STATIC_LOCAL(AtomicString, scrollbarTrackPiece, ("-webkit-scrollbar-track-piece"));
    266     DEFINE_STATIC_LOCAL(AtomicString, selection, ("selection"));
    267     DEFINE_STATIC_LOCAL(AtomicString, scope, ("scope"));
    268     DEFINE_STATIC_LOCAL(AtomicString, target, ("target"));
    269     DEFINE_STATIC_LOCAL(AtomicString, visited, ("visited"));
    270     DEFINE_STATIC_LOCAL(AtomicString, windowInactive, ("window-inactive"));
    271     DEFINE_STATIC_LOCAL(AtomicString, decrement, ("decrement"));
    272     DEFINE_STATIC_LOCAL(AtomicString, increment, ("increment"));
    273     DEFINE_STATIC_LOCAL(AtomicString, start, ("start"));
    274     DEFINE_STATIC_LOCAL(AtomicString, end, ("end"));
    275     DEFINE_STATIC_LOCAL(AtomicString, horizontal, ("horizontal"));
    276     DEFINE_STATIC_LOCAL(AtomicString, vertical, ("vertical"));
    277     DEFINE_STATIC_LOCAL(AtomicString, doubleButton, ("double-button"));
    278     DEFINE_STATIC_LOCAL(AtomicString, singleButton, ("single-button"));
    279     DEFINE_STATIC_LOCAL(AtomicString, noButton, ("no-button"));
    280     DEFINE_STATIC_LOCAL(AtomicString, cornerPresent, ("corner-present"));
     220    DEFINE_STATIC_LOCAL(AtomicString, active, ("active", AtomicString::ConstructFromLiteral));
     221    DEFINE_STATIC_LOCAL(AtomicString, after, ("after", AtomicString::ConstructFromLiteral));
     222    DEFINE_STATIC_LOCAL(AtomicString, any, ("-webkit-any(", AtomicString::ConstructFromLiteral));
     223    DEFINE_STATIC_LOCAL(AtomicString, anyLink, ("-webkit-any-link", AtomicString::ConstructFromLiteral));
     224    DEFINE_STATIC_LOCAL(AtomicString, autofill, ("-webkit-autofill", AtomicString::ConstructFromLiteral));
     225    DEFINE_STATIC_LOCAL(AtomicString, before, ("before", AtomicString::ConstructFromLiteral));
     226    DEFINE_STATIC_LOCAL(AtomicString, checked, ("checked", AtomicString::ConstructFromLiteral));
     227    DEFINE_STATIC_LOCAL(AtomicString, defaultString, ("default", AtomicString::ConstructFromLiteral));
     228    DEFINE_STATIC_LOCAL(AtomicString, disabled, ("disabled", AtomicString::ConstructFromLiteral));
     229    DEFINE_STATIC_LOCAL(AtomicString, readOnly, ("read-only", AtomicString::ConstructFromLiteral));
     230    DEFINE_STATIC_LOCAL(AtomicString, readWrite, ("read-write", AtomicString::ConstructFromLiteral));
     231    DEFINE_STATIC_LOCAL(AtomicString, valid, ("valid", AtomicString::ConstructFromLiteral));
     232    DEFINE_STATIC_LOCAL(AtomicString, invalid, ("invalid", AtomicString::ConstructFromLiteral));
     233    DEFINE_STATIC_LOCAL(AtomicString, drag, ("-webkit-drag", AtomicString::ConstructFromLiteral));
     234    DEFINE_STATIC_LOCAL(AtomicString, dragAlias, ("-khtml-drag", AtomicString::ConstructFromLiteral)); // was documented with this name in Apple documentation, so keep an alia
     235    DEFINE_STATIC_LOCAL(AtomicString, empty, ("empty", AtomicString::ConstructFromLiteral));
     236    DEFINE_STATIC_LOCAL(AtomicString, enabled, ("enabled", AtomicString::ConstructFromLiteral));
     237    DEFINE_STATIC_LOCAL(AtomicString, firstChild, ("first-child", AtomicString::ConstructFromLiteral));
     238    DEFINE_STATIC_LOCAL(AtomicString, firstLetter, ("first-letter", AtomicString::ConstructFromLiteral));
     239    DEFINE_STATIC_LOCAL(AtomicString, firstLine, ("first-line", AtomicString::ConstructFromLiteral));
     240    DEFINE_STATIC_LOCAL(AtomicString, firstOfType, ("first-of-type", AtomicString::ConstructFromLiteral));
     241    DEFINE_STATIC_LOCAL(AtomicString, fullPageMedia, ("-webkit-full-page-media", AtomicString::ConstructFromLiteral));
     242    DEFINE_STATIC_LOCAL(AtomicString, nthChild, ("nth-child(", AtomicString::ConstructFromLiteral));
     243    DEFINE_STATIC_LOCAL(AtomicString, nthOfType, ("nth-of-type(", AtomicString::ConstructFromLiteral));
     244    DEFINE_STATIC_LOCAL(AtomicString, nthLastChild, ("nth-last-child(", AtomicString::ConstructFromLiteral));
     245    DEFINE_STATIC_LOCAL(AtomicString, nthLastOfType, ("nth-last-of-type(", AtomicString::ConstructFromLiteral));
     246    DEFINE_STATIC_LOCAL(AtomicString, focus, ("focus", AtomicString::ConstructFromLiteral));
     247    DEFINE_STATIC_LOCAL(AtomicString, hover, ("hover", AtomicString::ConstructFromLiteral));
     248    DEFINE_STATIC_LOCAL(AtomicString, indeterminate, ("indeterminate", AtomicString::ConstructFromLiteral));
     249    DEFINE_STATIC_LOCAL(AtomicString, lastChild, ("last-child", AtomicString::ConstructFromLiteral));
     250    DEFINE_STATIC_LOCAL(AtomicString, lastOfType, ("last-of-type", AtomicString::ConstructFromLiteral));
     251    DEFINE_STATIC_LOCAL(AtomicString, link, ("link", AtomicString::ConstructFromLiteral));
     252    DEFINE_STATIC_LOCAL(AtomicString, lang, ("lang(", AtomicString::ConstructFromLiteral));
     253    DEFINE_STATIC_LOCAL(AtomicString, notStr, ("not(", AtomicString::ConstructFromLiteral));
     254    DEFINE_STATIC_LOCAL(AtomicString, onlyChild, ("only-child", AtomicString::ConstructFromLiteral));
     255    DEFINE_STATIC_LOCAL(AtomicString, onlyOfType, ("only-of-type", AtomicString::ConstructFromLiteral));
     256    DEFINE_STATIC_LOCAL(AtomicString, optional, ("optional", AtomicString::ConstructFromLiteral));
     257    DEFINE_STATIC_LOCAL(AtomicString, required, ("required", AtomicString::ConstructFromLiteral));
     258    DEFINE_STATIC_LOCAL(AtomicString, resizer, ("-webkit-resizer", AtomicString::ConstructFromLiteral));
     259    DEFINE_STATIC_LOCAL(AtomicString, root, ("root", AtomicString::ConstructFromLiteral));
     260    DEFINE_STATIC_LOCAL(AtomicString, scrollbar, ("-webkit-scrollbar", AtomicString::ConstructFromLiteral));
     261    DEFINE_STATIC_LOCAL(AtomicString, scrollbarButton, ("-webkit-scrollbar-button", AtomicString::ConstructFromLiteral));
     262    DEFINE_STATIC_LOCAL(AtomicString, scrollbarCorner, ("-webkit-scrollbar-corner", AtomicString::ConstructFromLiteral));
     263    DEFINE_STATIC_LOCAL(AtomicString, scrollbarThumb, ("-webkit-scrollbar-thumb", AtomicString::ConstructFromLiteral));
     264    DEFINE_STATIC_LOCAL(AtomicString, scrollbarTrack, ("-webkit-scrollbar-track", AtomicString::ConstructFromLiteral));
     265    DEFINE_STATIC_LOCAL(AtomicString, scrollbarTrackPiece, ("-webkit-scrollbar-track-piece", AtomicString::ConstructFromLiteral));
     266    DEFINE_STATIC_LOCAL(AtomicString, selection, ("selection", AtomicString::ConstructFromLiteral));
     267    DEFINE_STATIC_LOCAL(AtomicString, scope, ("scope", AtomicString::ConstructFromLiteral));
     268    DEFINE_STATIC_LOCAL(AtomicString, target, ("target", AtomicString::ConstructFromLiteral));
     269    DEFINE_STATIC_LOCAL(AtomicString, visited, ("visited", AtomicString::ConstructFromLiteral));
     270    DEFINE_STATIC_LOCAL(AtomicString, windowInactive, ("window-inactive", AtomicString::ConstructFromLiteral));
     271    DEFINE_STATIC_LOCAL(AtomicString, decrement, ("decrement", AtomicString::ConstructFromLiteral));
     272    DEFINE_STATIC_LOCAL(AtomicString, increment, ("increment", AtomicString::ConstructFromLiteral));
     273    DEFINE_STATIC_LOCAL(AtomicString, start, ("start", AtomicString::ConstructFromLiteral));
     274    DEFINE_STATIC_LOCAL(AtomicString, end, ("end", AtomicString::ConstructFromLiteral));
     275    DEFINE_STATIC_LOCAL(AtomicString, horizontal, ("horizontal", AtomicString::ConstructFromLiteral));
     276    DEFINE_STATIC_LOCAL(AtomicString, vertical, ("vertical", AtomicString::ConstructFromLiteral));
     277    DEFINE_STATIC_LOCAL(AtomicString, doubleButton, ("double-button", AtomicString::ConstructFromLiteral));
     278    DEFINE_STATIC_LOCAL(AtomicString, singleButton, ("single-button", AtomicString::ConstructFromLiteral));
     279    DEFINE_STATIC_LOCAL(AtomicString, noButton, ("no-button", AtomicString::ConstructFromLiteral));
     280    DEFINE_STATIC_LOCAL(AtomicString, cornerPresent, ("corner-present", AtomicString::ConstructFromLiteral));
    281281    // Paged Media pseudo-classes
    282     DEFINE_STATIC_LOCAL(AtomicString, firstPage, ("first"));
    283     DEFINE_STATIC_LOCAL(AtomicString, leftPage, ("left"));
    284     DEFINE_STATIC_LOCAL(AtomicString, rightPage, ("right"));
     282    DEFINE_STATIC_LOCAL(AtomicString, firstPage, ("first", AtomicString::ConstructFromLiteral));
     283    DEFINE_STATIC_LOCAL(AtomicString, leftPage, ("left", AtomicString::ConstructFromLiteral));
     284    DEFINE_STATIC_LOCAL(AtomicString, rightPage, ("right", AtomicString::ConstructFromLiteral));
    285285#if ENABLE(FULLSCREEN_API)
    286     DEFINE_STATIC_LOCAL(AtomicString, fullScreen, ("-webkit-full-screen"));
    287     DEFINE_STATIC_LOCAL(AtomicString, fullScreenDocument, ("-webkit-full-screen-document"));
    288     DEFINE_STATIC_LOCAL(AtomicString, fullScreenAncestor, ("-webkit-full-screen-ancestor"));
    289     DEFINE_STATIC_LOCAL(AtomicString, animatingFullScreenTransition, ("-webkit-animating-full-screen-transition"));
     286    DEFINE_STATIC_LOCAL(AtomicString, fullScreen, ("-webkit-full-screen", AtomicString::ConstructFromLiteral));
     287    DEFINE_STATIC_LOCAL(AtomicString, fullScreenDocument, ("-webkit-full-screen-document", AtomicString::ConstructFromLiteral));
     288    DEFINE_STATIC_LOCAL(AtomicString, fullScreenAncestor, ("-webkit-full-screen-ancestor", AtomicString::ConstructFromLiteral));
     289    DEFINE_STATIC_LOCAL(AtomicString, animatingFullScreenTransition, ("-webkit-animating-full-screen-transition", AtomicString::ConstructFromLiteral));
    290290#endif
    291     DEFINE_STATIC_LOCAL(AtomicString, inRange, ("in-range"));
    292     DEFINE_STATIC_LOCAL(AtomicString, outOfRange, ("out-of-range"));
     291    DEFINE_STATIC_LOCAL(AtomicString, inRange, ("in-range", AtomicString::ConstructFromLiteral));
     292    DEFINE_STATIC_LOCAL(AtomicString, outOfRange, ("out-of-range", AtomicString::ConstructFromLiteral));
    293293
    294294    static HashMap<AtomicStringImpl*, CSSSelector::PseudoType>* nameToPseudoType = 0;
Note: See TracChangeset for help on using the changeset viewer.