MCPcopy Create free account
hub / github.com/SpartanJ/eepp / registerDefaultNodeSelectors

Method registerDefaultNodeSelectors

src/eepp/ui/css/stylesheetspecification.cpp:534–647  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

532}
533
534void StyleSheetSpecification::registerDefaultNodeSelectors() {
535 mNodeSelectors["empty"] = []( const UIWidget* node, int, int, const FunctionString& ) -> bool {
536 return node->getFirstChild() == NULL;
537 };
538 mNodeSelectors["first-child"] = []( const UIWidget* node, int, int,
539 const FunctionString& ) -> bool {
540 return NULL != node->getParent() && node->getParent()->getFirstChild() == node;
541 };
542 mNodeSelectors["enabled"] = []( const UIWidget* node, int, int,
543 const FunctionString& ) -> bool { return node->isEnabled(); };
544 mNodeSelectors["disabled"] = []( const UIWidget* node, int, int,
545 const FunctionString& ) -> bool { return !node->isEnabled(); };
546 mNodeSelectors["first-of-type"] = []( const UIWidget* node, int, int,
547 const FunctionString& ) -> bool {
548 Node* child = NULL != node->getParent() ? node->getParent()->getFirstChild() : NULL;
549 Uint32 type = node->getType();
550 while ( NULL != child ) {
551 if ( type == child->getType() ) {
552 return child == node;
553 }
554 child = child->getNextNode();
555 };
556 return false;
557 };
558 mNodeSelectors["last-child"] = []( const UIWidget* node, int, int,
559 const FunctionString& ) -> bool {
560 return NULL != node->getParent() && node->getParent()->getLastChild() == node;
561 };
562 mNodeSelectors["last-of-type"] = []( const UIWidget* node, int, int,
563 const FunctionString& ) -> bool {
564 Node* child = NULL != node->getParent() ? node->getParent()->getLastChild() : NULL;
565 Uint32 type = node->getType();
566 while ( NULL != child ) {
567 if ( type == child->getType() ) {
568 return child == node;
569 }
570 child = child->getPrevNode();
571 };
572 return false;
573 };
574 mNodeSelectors["only-child"] = []( const UIWidget* node, int, int,
575 const FunctionString& ) -> bool {
576 return NULL != node->getParent() && node->getParent()->getChildCount() == 1;
577 };
578 mNodeSelectors["only-of-type"] = []( const UIWidget* node, int, int,
579 const FunctionString& ) -> bool {
580 Node* child = NULL != node->getParent() ? node->getParent()->getFirstChild() : NULL;
581 Uint32 type = node->getType();
582 Uint32 typeCount = 0;
583 while ( NULL != child ) {
584 if ( child->getType() == type ) {
585 typeCount++;
586 }
587 if ( typeCount > 1 )
588 return false;
589 child = child->getNextNode();
590 };
591 return typeCount == 1;

Callers

nothing calls this directly

Calls 15

isNthFunction · 0.85
getFirstChildMethod · 0.80
getNextNodeMethod · 0.80
getLastChildMethod · 0.80
getPrevNodeMethod · 0.80
getNodeIndexMethod · 0.80
getNodeOfTypeIndexMethod · 0.80
getChildOfTypeCountMethod · 0.80
getFlagsMethod · 0.80
substrMethod · 0.80
getIdMethod · 0.65
getParentMethod · 0.45

Tested by

no test coverage detected