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

Method getStyleFromSelector

src/eepp/ui/css/stylesheet.cpp:295–322  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

293}
294
295std::shared_ptr<StyleSheetStyle>
296StyleSheet::getStyleFromSelector( const std::string& selector, bool searchBySpecificity ) const {
297 if ( !searchBySpecificity ) {
298 for ( const auto& node : mNodes )
299 if ( node->getSelector().getName() == selector )
300 return node;
301 } else {
302 std::vector<std::shared_ptr<StyleSheetStyle>> found;
303 for ( const auto& node : mNodes )
304 if ( node->isMediaValid() && node->getSelector().getName() == selector )
305 found.push_back( node );
306 if ( !found.empty() ) {
307 std::sort( found.begin(), found.end(),
308 []( const std::shared_ptr<StyleSheetStyle>& lhs,
309 const std::shared_ptr<StyleSheetStyle>& rhs ) {
310 if ( ( lhs->getMediaQueryList() == nullptr ) !=
311 ( rhs->getMediaQueryList() == nullptr ) ) {
312 return ( lhs->getMediaQueryList() == nullptr ) >
313 ( rhs->getMediaQueryList() == nullptr );
314 }
315 return lhs->getSelector().getSpecificity() <
316 rhs->getSelector().getSpecificity();
317 } );
318 return found.back();
319 }
320 }
321 return {};
322}
323
324bool StyleSheet::updateMediaLists( const MediaFeatures& features ) {
325 if ( mMediaQueryList.empty() )

Callers 2

setThemeMethod · 0.80
tintTitleBarMethod · 0.80

Calls 7

sortFunction · 0.85
isMediaValidMethod · 0.80
push_backMethod · 0.80
getNameMethod · 0.45
emptyMethod · 0.45
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected