| 166 | } |
| 167 | |
| 168 | bool StyleSheet::addStyleToNodeIndex( StyleSheetStyle* style ) { |
| 169 | const std::string& id = style->getSelector().getSelectorId(); |
| 170 | const std::string& tag = style->getSelector().getSelectorTagName(); |
| 171 | if ( style->hasProperties() || style->hasVariables() ) { |
| 172 | size_t nodeHash = this->nodeHash( "*" == tag ? "" : tag, id ); |
| 173 | StyleSheetStyleVector& nodes = mNodeIndex[nodeHash]; |
| 174 | auto it = std::find( nodes.begin(), nodes.end(), style ); |
| 175 | if ( it == nodes.end() ) { |
| 176 | nodes.push_back( style ); |
| 177 | return true; |
| 178 | } else { |
| 179 | Log::debug( "Ignored style %s", style->getSelector().getName().c_str() ); |
| 180 | } |
| 181 | } |
| 182 | return false; |
| 183 | } |
| 184 | |
| 185 | void StyleSheet::addStyle( std::shared_ptr<StyleSheetStyle> node ) { |
| 186 | if ( addStyleToNodeIndex( node.get() ) ) { |
nothing calls this directly
no test coverage detected