| 372 | } |
| 373 | |
| 374 | void Engine::ParseTheme( const parser::theme::Theme& theme_to_parse ) { |
| 375 | // Iterate over all rules |
| 376 | for( const auto& rule : theme_to_parse ) { |
| 377 | Selector::Ptr selector; |
| 378 | |
| 379 | // Iterate over all simple selectors |
| 380 | for( const auto& simple_selector : rule.m_selector.m_simple_selectors ) { |
| 381 | auto hierarchy = Selector::HierarchyType::ROOT; |
| 382 | |
| 383 | if( simple_selector.m_combinator == ">" ) { |
| 384 | hierarchy = Selector::HierarchyType::CHILD; |
| 385 | } |
| 386 | else if( simple_selector.m_combinator == " " ) { |
| 387 | hierarchy = Selector::HierarchyType::DESCENDANT; |
| 388 | } |
| 389 | else if( simple_selector.m_combinator == "," ) { |
| 390 | // Grouping combinator detected. Stop eating simple selectors and set the properties now. |
| 391 | // Iterate over all declarations |
| 392 | for( const auto& declaration : rule.m_declarations ) { |
| 393 | auto property_name = declaration.m_property_name; |
| 394 | auto property_value = declaration.m_property_value; |
| 395 | |
| 396 | // Finally set the property |
| 397 | SetProperty( selector, property_name, property_value ); |
| 398 | } |
| 399 | |
| 400 | // Reset the current simple selector to be the root of a new chain. |
| 401 | selector = Selector::Ptr(); |
| 402 | } |
| 403 | |
| 404 | selector = Selector::Create( |
| 405 | simple_selector.m_type_selector, |
| 406 | simple_selector.m_id_selector, |
| 407 | simple_selector.m_class_selector, |
| 408 | simple_selector.m_state_selector, |
| 409 | hierarchy, |
| 410 | selector |
| 411 | ); |
| 412 | } |
| 413 | |
| 414 | // Iterate over all declarations |
| 415 | for( const auto& declaration : rule.m_declarations ) { |
| 416 | auto property_name = declaration.m_property_name; |
| 417 | auto property_value = declaration.m_property_value; |
| 418 | |
| 419 | // Finally set the property |
| 420 | SetProperty( selector, property_name, property_value ); |
| 421 | } |
| 422 | } |
| 423 | } |
| 424 | |
| 425 | } |
nothing calls this directly
no outgoing calls
no test coverage detected