| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 1999-2003 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 1999-2003 Lars Knoll (knoll@kde.org) |
| 3 * 1999 Waldo Bastian (bastian@kde.org) | 3 * 1999 Waldo Bastian (bastian@kde.org) |
| 4 * 2001 Andreas Schlapbach (schlpbch@iam.unibe.ch) | 4 * 2001 Andreas Schlapbach (schlpbch@iam.unibe.ch) |
| 5 * 2001-2003 Dirk Mueller (mueller@kde.org) | 5 * 2001-2003 Dirk Mueller (mueller@kde.org) |
| 6 * Copyright (C) 2002, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserv
ed. | 6 * Copyright (C) 2002, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserv
ed. |
| 7 * Copyright (C) 2008 David Smith (catfish.man@gmail.com) | 7 * Copyright (C) 2008 David Smith (catfish.man@gmail.com) |
| 8 * Copyright (C) 2010 Google Inc. All rights reserved. | 8 * Copyright (C) 2010 Google Inc. All rights reserved. |
| 9 * | 9 * |
| 10 * This library is free software; you can redistribute it and/or | 10 * This library is free software; you can redistribute it and/or |
| (...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 267 ASSERT_NOT_REACHED(); | 267 ASSERT_NOT_REACHED(); |
| 268 return NOPSEUDO; | 268 return NOPSEUDO; |
| 269 } | 269 } |
| 270 | 270 |
| 271 // Could be made smaller and faster by replacing pointer with an | 271 // Could be made smaller and faster by replacing pointer with an |
| 272 // offset into a string buffer and making the bit fields smaller but | 272 // offset into a string buffer and making the bit fields smaller but |
| 273 // that could not be maintained by hand. | 273 // that could not be maintained by hand. |
| 274 struct NameToPseudoStruct { | 274 struct NameToPseudoStruct { |
| 275 const char* string; | 275 const char* string; |
| 276 unsigned type:8; | 276 unsigned type:8; |
| 277 unsigned requirement:8; | |
| 278 }; | 277 }; |
| 279 | 278 |
| 280 const static NameToPseudoStruct pseudoTypeMap[] = { | 279 const static NameToPseudoStruct pseudoTypeMap[] = { |
| 281 {"active", CSSSelector::PseudoActive, 0}, | 280 {"active", CSSSelector::PseudoActive}, |
| 282 {"after", CSSSelector::PseudoAfter, 0}, | 281 {"after", CSSSelector::PseudoAfter}, |
| 283 {"-webkit-any(", CSSSelector::PseudoAny, 0}, | 282 {"-webkit-any(", CSSSelector::PseudoAny}, |
| 284 {"-webkit-any-link", CSSSelector::PseudoAnyLink, 0}, | 283 {"-webkit-any-link", CSSSelector::PseudoAnyLink}, |
| 285 {"-webkit-autofill", CSSSelector::PseudoAutofill, 0}, | 284 {"-webkit-autofill", CSSSelector::PseudoAutofill}, |
| 286 {"backdrop", CSSSelector::PseudoBackdrop, 0}, | 285 {"backdrop", CSSSelector::PseudoBackdrop}, |
| 287 {"before", CSSSelector::PseudoBefore, 0}, | 286 {"before", CSSSelector::PseudoBefore}, |
| 288 {"checked", CSSSelector::PseudoChecked, 0}, | 287 {"checked", CSSSelector::PseudoChecked}, |
| 289 {"default", CSSSelector::PseudoDefault, 0}, | 288 {"default", CSSSelector::PseudoDefault}, |
| 290 {"disabled", CSSSelector::PseudoDisabled, 0}, | 289 {"disabled", CSSSelector::PseudoDisabled}, |
| 291 {"read-only", CSSSelector::PseudoReadOnly, 0}, | 290 {"read-only", CSSSelector::PseudoReadOnly}, |
| 292 {"read-write", CSSSelector::PseudoReadWrite, 0}, | 291 {"read-write", CSSSelector::PseudoReadWrite}, |
| 293 {"valid", CSSSelector::PseudoValid, 0}, | 292 {"valid", CSSSelector::PseudoValid}, |
| 294 {"invalid", CSSSelector::PseudoInvalid, 0}, | 293 {"invalid", CSSSelector::PseudoInvalid}, |
| 295 {"-webkit-drag", CSSSelector::PseudoDrag, 0}, | 294 {"-webkit-drag", CSSSelector::PseudoDrag}, |
| 296 {"empty", CSSSelector::PseudoEmpty, 0}, | 295 {"empty", CSSSelector::PseudoEmpty}, |
| 297 {"enabled", CSSSelector::PseudoEnabled, 0}, | 296 {"enabled", CSSSelector::PseudoEnabled}, |
| 298 {"first-child", CSSSelector::PseudoFirstChild, 0}, | 297 {"first-child", CSSSelector::PseudoFirstChild}, |
| 299 {"first-letter", CSSSelector::PseudoFirstLetter, 0}, | 298 {"first-letter", CSSSelector::PseudoFirstLetter}, |
| 300 {"first-line", CSSSelector::PseudoFirstLine, 0}, | 299 {"first-line", CSSSelector::PseudoFirstLine}, |
| 301 {"first-of-type", CSSSelector::PseudoFirstOfType, 0}, | 300 {"first-of-type", CSSSelector::PseudoFirstOfType}, |
| 302 {"-webkit-full-page-media", CSSSelector::PseudoFullPageMedia, 0}, | 301 {"-webkit-full-page-media", CSSSelector::PseudoFullPageMedia}, |
| 303 {"nth-child(", CSSSelector::PseudoNthChild, 0}, | 302 {"nth-child(", CSSSelector::PseudoNthChild}, |
| 304 {"nth-of-type(", CSSSelector::PseudoNthOfType, 0}, | 303 {"nth-of-type(", CSSSelector::PseudoNthOfType}, |
| 305 {"nth-last-child(", CSSSelector::PseudoNthLastChild, 0}, | 304 {"nth-last-child(", CSSSelector::PseudoNthLastChild}, |
| 306 {"nth-last-of-type(", CSSSelector::PseudoNthLastOfType, 0}, | 305 {"nth-last-of-type(", CSSSelector::PseudoNthLastOfType}, |
| 307 {"focus", CSSSelector::PseudoFocus, 0}, | 306 {"focus", CSSSelector::PseudoFocus}, |
| 308 {"hover", CSSSelector::PseudoHover, 0}, | 307 {"hover", CSSSelector::PseudoHover}, |
| 309 {"indeterminate", CSSSelector::PseudoIndeterminate, 0}, | 308 {"indeterminate", CSSSelector::PseudoIndeterminate}, |
| 310 {"last-child", CSSSelector::PseudoLastChild, 0}, | 309 {"last-child", CSSSelector::PseudoLastChild}, |
| 311 {"last-of-type", CSSSelector::PseudoLastOfType, 0}, | 310 {"last-of-type", CSSSelector::PseudoLastOfType}, |
| 312 {"link", CSSSelector::PseudoLink, 0}, | 311 {"link", CSSSelector::PseudoLink}, |
| 313 {"lang(", CSSSelector::PseudoLang, 0}, | 312 {"lang(", CSSSelector::PseudoLang}, |
| 314 {"not(", CSSSelector::PseudoNot, 0}, | 313 {"not(", CSSSelector::PseudoNot}, |
| 315 {"only-child", CSSSelector::PseudoOnlyChild, 0}, | 314 {"only-child", CSSSelector::PseudoOnlyChild}, |
| 316 {"only-of-type", CSSSelector::PseudoOnlyOfType, 0}, | 315 {"only-of-type", CSSSelector::PseudoOnlyOfType}, |
| 317 {"optional", CSSSelector::PseudoOptional, 0}, | 316 {"optional", CSSSelector::PseudoOptional}, |
| 318 {"required", CSSSelector::PseudoRequired, 0}, | 317 {"required", CSSSelector::PseudoRequired}, |
| 319 {"-webkit-resizer", CSSSelector::PseudoResizer, 0}, | 318 {"-webkit-resizer", CSSSelector::PseudoResizer}, |
| 320 {"root", CSSSelector::PseudoRoot, 0}, | 319 {"root", CSSSelector::PseudoRoot}, |
| 321 {"-webkit-scrollbar", CSSSelector::PseudoScrollbar, 0}, | 320 {"-webkit-scrollbar", CSSSelector::PseudoScrollbar}, |
| 322 {"-webkit-scrollbar-button", CSSSelector::PseudoScrollbarButton, 0}, | 321 {"-webkit-scrollbar-button", CSSSelector::PseudoScrollbarButton}, |
| 323 {"-webkit-scrollbar-corner", CSSSelector::PseudoScrollbarCorner, 0}, | 322 {"-webkit-scrollbar-corner", CSSSelector::PseudoScrollbarCorner}, |
| 324 {"-webkit-scrollbar-thumb", CSSSelector::PseudoScrollbarThumb, 0}, | 323 {"-webkit-scrollbar-thumb", CSSSelector::PseudoScrollbarThumb}, |
| 325 {"-webkit-scrollbar-track", CSSSelector::PseudoScrollbarTrack, 0}, | 324 {"-webkit-scrollbar-track", CSSSelector::PseudoScrollbarTrack}, |
| 326 {"-webkit-scrollbar-track-piece", CSSSelector::PseudoScrollbarTrackPiece, 0}, | 325 {"-webkit-scrollbar-track-piece", CSSSelector::PseudoScrollbarTrackPiece}, |
| 327 {"selection", CSSSelector::PseudoSelection, 0}, | 326 {"selection", CSSSelector::PseudoSelection}, |
| 328 {"target", CSSSelector::PseudoTarget, 0}, | 327 {"target", CSSSelector::PseudoTarget}, |
| 329 {"visited", CSSSelector::PseudoVisited, 0}, | 328 {"visited", CSSSelector::PseudoVisited}, |
| 330 {"window-inactive", CSSSelector::PseudoWindowInactive, 0}, | 329 {"window-inactive", CSSSelector::PseudoWindowInactive}, |
| 331 {"decrement", CSSSelector::PseudoDecrement, 0}, | 330 {"decrement", CSSSelector::PseudoDecrement}, |
| 332 {"increment", CSSSelector::PseudoIncrement, 0}, | 331 {"increment", CSSSelector::PseudoIncrement}, |
| 333 {"start", CSSSelector::PseudoStart, 0}, | 332 {"start", CSSSelector::PseudoStart}, |
| 334 {"end", CSSSelector::PseudoEnd, 0}, | 333 {"end", CSSSelector::PseudoEnd}, |
| 335 {"horizontal", CSSSelector::PseudoHorizontal, 0}, | 334 {"horizontal", CSSSelector::PseudoHorizontal}, |
| 336 {"vertical", CSSSelector::PseudoVertical, 0}, | 335 {"vertical", CSSSelector::PseudoVertical}, |
| 337 {"double-button", CSSSelector::PseudoDoubleButton, 0}, | 336 {"double-button", CSSSelector::PseudoDoubleButton}, |
| 338 {"single-button", CSSSelector::PseudoSingleButton, 0}, | 337 {"single-button", CSSSelector::PseudoSingleButton}, |
| 339 {"no-button", CSSSelector::PseudoNoButton, 0}, | 338 {"no-button", CSSSelector::PseudoNoButton}, |
| 340 {"corner-present", CSSSelector::PseudoCornerPresent, 0}, | 339 {"corner-present", CSSSelector::PseudoCornerPresent}, |
| 341 {"first", CSSSelector::PseudoFirstPage, 0}, | 340 {"first", CSSSelector::PseudoFirstPage}, |
| 342 {"left", CSSSelector::PseudoLeftPage, 0}, | 341 {"left", CSSSelector::PseudoLeftPage}, |
| 343 {"right", CSSSelector::PseudoRightPage, 0}, | 342 {"right", CSSSelector::PseudoRightPage}, |
| 344 {"-webkit-full-screen", CSSSelector::PseudoFullScreen, 0}, | 343 {"-webkit-full-screen", CSSSelector::PseudoFullScreen}, |
| 345 {"-webkit-full-screen-document", CSSSelector::PseudoFullScreenDocument, 0}, | 344 {"-webkit-full-screen-document", CSSSelector::PseudoFullScreenDocument}, |
| 346 {"-webkit-full-screen-ancestor", CSSSelector::PseudoFullScreenAncestor, 0}, | 345 {"-webkit-full-screen-ancestor", CSSSelector::PseudoFullScreenAncestor}, |
| 347 {"cue(", CSSSelector::PseudoCue, 0}, | 346 {"cue(", CSSSelector::PseudoCue}, |
| 348 {"cue", CSSSelector::PseudoWebKitCustomElement, 0}, | 347 {"cue", CSSSelector::PseudoWebKitCustomElement}, |
| 349 {"future", CSSSelector::PseudoFutureCue, 0}, | 348 {"future", CSSSelector::PseudoFutureCue}, |
| 350 {"past", CSSSelector::PseudoPastCue, 0}, | 349 {"past", CSSSelector::PseudoPastCue}, |
| 351 {"-webkit-distributed(", CSSSelector::PseudoDistributed, 0}, | 350 {"-webkit-distributed(", CSSSelector::PseudoDistributed}, |
| 352 {"in-range", CSSSelector::PseudoInRange, 0}, | 351 {"in-range", CSSSelector::PseudoInRange}, |
| 353 {"out-of-range", CSSSelector::PseudoOutOfRange, 0}, | 352 {"out-of-range", CSSSelector::PseudoOutOfRange}, |
| 354 {"scope", CSSSelector::PseudoScope, 0}, | 353 {"scope", CSSSelector::PseudoScope}, |
| 355 {"unresolved", CSSSelector::PseudoUnresolved, 0}, | 354 {"unresolved", CSSSelector::PseudoUnresolved}, |
| 356 {"host", CSSSelector::PseudoHost, CSSSel
ector::RequiresShadowDOM}, | 355 {"host", CSSSelector::PseudoHost}, |
| 357 {"host(", CSSSelector::PseudoHost, CSSSel
ector::RequiresShadowDOM}, | 356 {"host(", CSSSelector::PseudoHost}, |
| 358 {"ancestor", CSSSelector::PseudoAncestor, CSSSel
ector::RequiresShadowDOM}, | 357 {"ancestor", CSSSelector::PseudoAncestor}, |
| 359 {"ancestor(", CSSSelector::PseudoAncestor, CSSSel
ector::RequiresShadowDOM}, | 358 {"ancestor(", CSSSelector::PseudoAncestor}, |
| 360 {"content", CSSSelector::PseudoContent, CSSSel
ector::RequiresShadowDOM}, | 359 {"content", CSSSelector::PseudoContent}, |
| 361 }; | 360 }; |
| 362 | 361 |
| 363 static HashMap<StringImpl*, CSSSelector::PseudoType>* nameToPseudoTypeMap() | 362 static HashMap<StringImpl*, CSSSelector::PseudoType>* nameToPseudoTypeMap() |
| 364 { | 363 { |
| 365 static HashMap<StringImpl*, CSSSelector::PseudoType>* nameToPseudoType = 0; | 364 static HashMap<StringImpl*, CSSSelector::PseudoType>* nameToPseudoType = 0; |
| 366 if (!nameToPseudoType) { | 365 if (!nameToPseudoType) { |
| 367 nameToPseudoType = new HashMap<StringImpl*, CSSSelector::PseudoType>; | 366 nameToPseudoType = new HashMap<StringImpl*, CSSSelector::PseudoType>; |
| 368 | 367 |
| 369 size_t pseudoCount = WTF_ARRAY_LENGTH(pseudoTypeMap); | 368 size_t pseudoCount = WTF_ARRAY_LENGTH(pseudoTypeMap); |
| 370 for (size_t i = 0; i < pseudoCount; i++) { | 369 for (size_t i = 0; i < pseudoCount; i++) { |
| 371 if (pseudoTypeMap[i].requirement == CSSSelector::RequiresShadowDOM)
{ | |
| 372 if (!RuntimeEnabledFeatures::shadowDOMEnabled()) | |
| 373 continue; | |
| 374 } | |
| 375 const char* str = pseudoTypeMap[i].string; | 370 const char* str = pseudoTypeMap[i].string; |
| 376 CSSSelector::PseudoType type; | 371 CSSSelector::PseudoType type; |
| 377 type = static_cast<CSSSelector::PseudoType>(pseudoTypeMap[i].type); | 372 type = static_cast<CSSSelector::PseudoType>(pseudoTypeMap[i].type); |
| 378 // This is a one-time leak. | 373 // This is a one-time leak. |
| 379 AtomicString* name = new AtomicString(str, strlen(str), AtomicString
::ConstructFromLiteral); | 374 AtomicString* name = new AtomicString(str, strlen(str), AtomicString
::ConstructFromLiteral); |
| 380 nameToPseudoType->set(name->impl(), type); | 375 nameToPseudoType->set(name->impl(), type); |
| 381 } | 376 } |
| 382 } | 377 } |
| 383 | 378 |
| 384 return nameToPseudoType; | 379 return nameToPseudoType; |
| (...skipping 503 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 888 return false; | 883 return false; |
| 889 return (count - m_b) % m_a == 0; | 884 return (count - m_b) % m_a == 0; |
| 890 } else { | 885 } else { |
| 891 if (count > m_b) | 886 if (count > m_b) |
| 892 return false; | 887 return false; |
| 893 return (m_b - count) % (-m_a) == 0; | 888 return (m_b - count) % (-m_a) == 0; |
| 894 } | 889 } |
| 895 } | 890 } |
| 896 | 891 |
| 897 } // namespace WebCore | 892 } // namespace WebCore |
| OLD | NEW |