Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(283)

Side by Side Diff: Source/core/css/CSSSelector.cpp

Issue 14846002: Implement the Custom Elements :unresolved pseudoclass (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Adds a test and fixes style sharing. Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
11 * modify it under the terms of the GNU Library General Public 11 * modify it under the terms of the GNU Library General Public
12 * License as published by the Free Software Foundation; either 12 * License as published by the Free Software Foundation; either
13 * version 2 of the License, or (at your option) any later version. 13 * version 2 of the License, or (at your option) any later version.
14 * 14 *
15 * This library is distributed in the hope that it will be useful, 15 * This library is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 * Library General Public License for more details. 18 * Library General Public License for more details.
19 * 19 *
20 * You should have received a copy of the GNU Library General Public License 20 * You should have received a copy of the GNU Library General Public License
21 * along with this library; see the file COPYING.LIB. If not, write to 21 * along with this library; see the file COPYING.LIB. If not, write to
22 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 22 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
23 * Boston, MA 02110-1301, USA. 23 * Boston, MA 02110-1301, USA.
24 */ 24 */
25 25
26 #include "config.h" 26 #include "config.h"
27 #include "core/css/CSSSelector.h" 27 #include "core/css/CSSSelector.h"
28 28
29 #include "HTMLNames.h" 29 #include "HTMLNames.h"
30 #include "RuntimeEnabledFeatures.h"
30 #include "core/css/CSSOMUtils.h" 31 #include "core/css/CSSOMUtils.h"
31 #include "core/css/CSSSelectorList.h" 32 #include "core/css/CSSSelectorList.h"
32 #include <wtf/Assertions.h> 33 #include <wtf/Assertions.h>
33 #include <wtf/HashMap.h> 34 #include <wtf/HashMap.h>
34 #include <wtf/StdLibExtras.h> 35 #include <wtf/StdLibExtras.h>
35 #include <wtf/text/StringBuilder.h> 36 #include <wtf/text/StringBuilder.h>
36 #include <wtf/Vector.h> 37 #include <wtf/Vector.h>
37 38
38 namespace WebCore { 39 namespace WebCore {
39 40
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 case PseudoRightPage: 240 case PseudoRightPage:
240 case PseudoInRange: 241 case PseudoInRange:
241 case PseudoOutOfRange: 242 case PseudoOutOfRange:
242 case PseudoUserAgentCustomElement: 243 case PseudoUserAgentCustomElement:
243 case PseudoWebKitCustomElement: 244 case PseudoWebKitCustomElement:
244 case PseudoCue: 245 case PseudoCue:
245 case PseudoFutureCue: 246 case PseudoFutureCue:
246 case PseudoPastCue: 247 case PseudoPastCue:
247 case PseudoSeamlessDocument: 248 case PseudoSeamlessDocument:
248 case PseudoDistributed: 249 case PseudoDistributed:
250 case PseudoUnresolved:
249 return NOPSEUDO; 251 return NOPSEUDO;
250 case PseudoNotParsed: 252 case PseudoNotParsed:
251 ASSERT_NOT_REACHED(); 253 ASSERT_NOT_REACHED();
252 return NOPSEUDO; 254 return NOPSEUDO;
253 } 255 }
254 256
255 ASSERT_NOT_REACHED(); 257 ASSERT_NOT_REACHED();
256 return NOPSEUDO; 258 return NOPSEUDO;
257 } 259 }
258 260
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
327 DEFINE_STATIC_LOCAL(AtomicString, fullScreenAncestor, ("-webkit-full-screen- ancestor", AtomicString::ConstructFromLiteral)); 329 DEFINE_STATIC_LOCAL(AtomicString, fullScreenAncestor, ("-webkit-full-screen- ancestor", AtomicString::ConstructFromLiteral));
328 DEFINE_STATIC_LOCAL(AtomicString, animatingFullScreenTransition, ("-webkit-a nimating-full-screen-transition", AtomicString::ConstructFromLiteral)); 330 DEFINE_STATIC_LOCAL(AtomicString, animatingFullScreenTransition, ("-webkit-a nimating-full-screen-transition", AtomicString::ConstructFromLiteral));
329 DEFINE_STATIC_LOCAL(AtomicString, cue, ("cue(", AtomicString::ConstructFromL iteral)); 331 DEFINE_STATIC_LOCAL(AtomicString, cue, ("cue(", AtomicString::ConstructFromL iteral));
330 DEFINE_STATIC_LOCAL(AtomicString, futureCue, ("future", AtomicString::Constr uctFromLiteral)); 332 DEFINE_STATIC_LOCAL(AtomicString, futureCue, ("future", AtomicString::Constr uctFromLiteral));
331 DEFINE_STATIC_LOCAL(AtomicString, pastCue, ("past", AtomicString::ConstructF romLiteral)); 333 DEFINE_STATIC_LOCAL(AtomicString, pastCue, ("past", AtomicString::ConstructF romLiteral));
332 DEFINE_STATIC_LOCAL(AtomicString, seamlessDocument, ("-webkit-seamless-docum ent", AtomicString::ConstructFromLiteral)); 334 DEFINE_STATIC_LOCAL(AtomicString, seamlessDocument, ("-webkit-seamless-docum ent", AtomicString::ConstructFromLiteral));
333 DEFINE_STATIC_LOCAL(AtomicString, distributed, ("-webkit-distributed(", Atom icString::ConstructFromLiteral)); 335 DEFINE_STATIC_LOCAL(AtomicString, distributed, ("-webkit-distributed(", Atom icString::ConstructFromLiteral));
334 DEFINE_STATIC_LOCAL(AtomicString, inRange, ("in-range", AtomicString::Constr uctFromLiteral)); 336 DEFINE_STATIC_LOCAL(AtomicString, inRange, ("in-range", AtomicString::Constr uctFromLiteral));
335 DEFINE_STATIC_LOCAL(AtomicString, outOfRange, ("out-of-range", AtomicString: :ConstructFromLiteral)); 337 DEFINE_STATIC_LOCAL(AtomicString, outOfRange, ("out-of-range", AtomicString: :ConstructFromLiteral));
336 DEFINE_STATIC_LOCAL(AtomicString, scope, ("scope", AtomicString::ConstructFr omLiteral)); 338 DEFINE_STATIC_LOCAL(AtomicString, scope, ("scope", AtomicString::ConstructFr omLiteral));
339 DEFINE_STATIC_LOCAL(AtomicString, unresolved, ("unresolved", AtomicString::C onstructFromLiteral));
337 340
338 static HashMap<AtomicStringImpl*, CSSSelector::PseudoType>* nameToPseudoType = 0; 341 static HashMap<AtomicStringImpl*, CSSSelector::PseudoType>* nameToPseudoType = 0;
339 if (!nameToPseudoType) { 342 if (!nameToPseudoType) {
340 nameToPseudoType = new HashMap<AtomicStringImpl*, CSSSelector::PseudoTyp e>; 343 nameToPseudoType = new HashMap<AtomicStringImpl*, CSSSelector::PseudoTyp e>;
341 nameToPseudoType->set(active.impl(), CSSSelector::PseudoActive); 344 nameToPseudoType->set(active.impl(), CSSSelector::PseudoActive);
342 nameToPseudoType->set(after.impl(), CSSSelector::PseudoAfter); 345 nameToPseudoType->set(after.impl(), CSSSelector::PseudoAfter);
343 nameToPseudoType->set(anyLink.impl(), CSSSelector::PseudoAnyLink); 346 nameToPseudoType->set(anyLink.impl(), CSSSelector::PseudoAnyLink);
344 nameToPseudoType->set(any.impl(), CSSSelector::PseudoAny); 347 nameToPseudoType->set(any.impl(), CSSSelector::PseudoAny);
345 nameToPseudoType->set(autofill.impl(), CSSSelector::PseudoAutofill); 348 nameToPseudoType->set(autofill.impl(), CSSSelector::PseudoAutofill);
346 nameToPseudoType->set(before.impl(), CSSSelector::PseudoBefore); 349 nameToPseudoType->set(before.impl(), CSSSelector::PseudoBefore);
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
406 nameToPseudoType->set(fullScreenDocument.impl(), CSSSelector::PseudoFull ScreenDocument); 409 nameToPseudoType->set(fullScreenDocument.impl(), CSSSelector::PseudoFull ScreenDocument);
407 nameToPseudoType->set(fullScreenAncestor.impl(), CSSSelector::PseudoFull ScreenAncestor); 410 nameToPseudoType->set(fullScreenAncestor.impl(), CSSSelector::PseudoFull ScreenAncestor);
408 nameToPseudoType->set(animatingFullScreenTransition.impl(), CSSSelector: :PseudoAnimatingFullScreenTransition); 411 nameToPseudoType->set(animatingFullScreenTransition.impl(), CSSSelector: :PseudoAnimatingFullScreenTransition);
409 nameToPseudoType->set(cue.impl(), CSSSelector::PseudoCue); 412 nameToPseudoType->set(cue.impl(), CSSSelector::PseudoCue);
410 nameToPseudoType->set(futureCue.impl(), CSSSelector::PseudoFutureCue); 413 nameToPseudoType->set(futureCue.impl(), CSSSelector::PseudoFutureCue);
411 nameToPseudoType->set(pastCue.impl(), CSSSelector::PseudoPastCue); 414 nameToPseudoType->set(pastCue.impl(), CSSSelector::PseudoPastCue);
412 nameToPseudoType->set(seamlessDocument.impl(), CSSSelector::PseudoSeamle ssDocument); 415 nameToPseudoType->set(seamlessDocument.impl(), CSSSelector::PseudoSeamle ssDocument);
413 nameToPseudoType->set(distributed.impl(), CSSSelector::PseudoDistributed ); 416 nameToPseudoType->set(distributed.impl(), CSSSelector::PseudoDistributed );
414 nameToPseudoType->set(inRange.impl(), CSSSelector::PseudoInRange); 417 nameToPseudoType->set(inRange.impl(), CSSSelector::PseudoInRange);
415 nameToPseudoType->set(outOfRange.impl(), CSSSelector::PseudoOutOfRange); 418 nameToPseudoType->set(outOfRange.impl(), CSSSelector::PseudoOutOfRange);
419 if (RuntimeEnabledFeatures::customDOMElementsEnabled())
420 nameToPseudoType->set(unresolved.impl(), CSSSelector::PseudoUnresolv ed);
416 } 421 }
417 return nameToPseudoType; 422 return nameToPseudoType;
418 } 423 }
419 424
420 CSSSelector::PseudoType CSSSelector::parsePseudoType(const AtomicString& name) 425 CSSSelector::PseudoType CSSSelector::parsePseudoType(const AtomicString& name)
421 { 426 {
422 if (name.isNull()) 427 if (name.isNull())
423 return PseudoUnknown; 428 return PseudoUnknown;
424 HashMap<AtomicStringImpl*, CSSSelector::PseudoType>* nameToPseudoType = name ToPseudoTypeMap(); 429 HashMap<AtomicStringImpl*, CSSSelector::PseudoType>* nameToPseudoType = name ToPseudoTypeMap();
425 HashMap<AtomicStringImpl*, CSSSelector::PseudoType>::iterator slot = nameToP seudoType->find(name.impl()); 430 HashMap<AtomicStringImpl*, CSSSelector::PseudoType>::iterator slot = nameToP seudoType->find(name.impl());
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
526 case PseudoNotParsed: 531 case PseudoNotParsed:
527 case PseudoFullScreen: 532 case PseudoFullScreen:
528 case PseudoFullScreenDocument: 533 case PseudoFullScreenDocument:
529 case PseudoFullScreenAncestor: 534 case PseudoFullScreenAncestor:
530 case PseudoAnimatingFullScreenTransition: 535 case PseudoAnimatingFullScreenTransition:
531 case PseudoSeamlessDocument: 536 case PseudoSeamlessDocument:
532 case PseudoInRange: 537 case PseudoInRange:
533 case PseudoOutOfRange: 538 case PseudoOutOfRange:
534 case PseudoFutureCue: 539 case PseudoFutureCue:
535 case PseudoPastCue: 540 case PseudoPastCue:
541 case PseudoUnresolved:
536 break; 542 break;
537 case PseudoFirstPage: 543 case PseudoFirstPage:
538 case PseudoLeftPage: 544 case PseudoLeftPage:
539 case PseudoRightPage: 545 case PseudoRightPage:
540 isPagePseudoClass = true; 546 isPagePseudoClass = true;
541 break; 547 break;
542 } 548 }
543 549
544 bool matchPagePseudoClass = (m_match == PagePseudoClass); 550 bool matchPagePseudoClass = (m_match == PagePseudoClass);
545 if (matchPagePseudoClass != isPagePseudoClass) 551 if (matchPagePseudoClass != isPagePseudoClass)
546 m_pseudoType = PseudoUnknown; 552 m_pseudoType = PseudoUnknown;
547 else if (m_match == PseudoClass && element) { 553 else if (m_match == PseudoClass && element) {
548 if (!compat) 554 if (!compat)
549 m_pseudoType = PseudoUnknown; 555 m_pseudoType = PseudoUnknown;
550 else 556 else
551 m_match = PseudoElement; 557 m_match = PseudoElement;
552 } else if (m_match == PseudoElement && !element) 558 } else if (m_match == PseudoElement && !element)
553 m_pseudoType = PseudoUnknown; 559 m_pseudoType = PseudoUnknown;
554 } 560 }
555 561
556 bool CSSSelector::operator==(const CSSSelector& other) const 562 bool CSSSelector::operator==(const CSSSelector& other) const
557 { 563 {
558 const CSSSelector* sel1 = this; 564 const CSSSelector* sel1 = this;
559 const CSSSelector* sel2 = &other; 565 const CSSSelector* sel2 = &other;
560 566
561 while (sel1 && sel2) { 567 while (sel1 && sel2) {
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after
804 return false; 810 return false;
805 return (count - m_b) % m_a == 0; 811 return (count - m_b) % m_a == 0;
806 } else { 812 } else {
807 if (count > m_b) 813 if (count > m_b)
808 return false; 814 return false;
809 return (m_b - count) % (-m_a) == 0; 815 return (m_b - count) % (-m_a) == 0;
810 } 816 }
811 } 817 }
812 818
813 } // namespace WebCore 819 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698