| 1166 | } |
| 1167 | |
| 1168 | void UISceneNode::loadCSS( URI uri ) { |
| 1169 | uri = solveRelativePath( uri ); |
| 1170 | std::string url = uri.toString(); |
| 1171 | Log::debug( "UISceneNode::loadCSS: %s", url ); |
| 1172 | |
| 1173 | if ( "file" == uri.getScheme() || |
| 1174 | ( uri.getScheme().empty() && FileSystem::fileExists( uri.getFSPath() ) ) ) { |
| 1175 | std::string filePath( uri.getFSPath() ); |
| 1176 | std::string css; |
| 1177 | if ( FileSystem::fileExists( filePath ) && FileSystem::fileGet( filePath, css ) ) { |
| 1178 | combineStyleSheet( css, true, String::hash( url ), getURIFromURL( url ) ); |
| 1179 | Log::debug( "UISceneNode::loadCSS: Loaded - %s", url ); |
| 1180 | } |
| 1181 | } else if ( "http" == uri.getScheme() || "https" == uri.getScheme() ) { |
| 1182 | Http::getAsync( |
| 1183 | [this, url]( const Http&, Http::Request&, Http::Response& response ) { |
| 1184 | if ( !response.getBody().empty() && |
| 1185 | response.getStatus() == Http::Response::Status::Ok ) { |
| 1186 | std::string css( response.getBody() ); |
| 1187 | runOnMainThread( [css = std::move( css ), url = std::move( url ), this] { |
| 1188 | combineStyleSheet( css, true, String::hash( url ), getURIFromURL( url ) ); |
| 1189 | Log::debug( "UISceneNode::loadCSS: Loaded - %s", url ); |
| 1190 | } ); |
| 1191 | } else { |
| 1192 | Log::debug( "UISceneNode::loadCSS: Failed to load %s - %s", url, |
| 1193 | response.getStatusDescription() ); |
| 1194 | } |
| 1195 | }, |
| 1196 | uri, Seconds( 5 ) ); |
| 1197 | } else if ( VFS::instance()->fileExists( uri.getPath() ) ) { |
| 1198 | IOStream* stream = VFS::instance()->getFileFromPath( uri.getPath() ); |
| 1199 | CSS::StyleSheetParser parser; |
| 1200 | if ( parser.loadFromStream( *stream ) ) { |
| 1201 | parser.getStyleSheet().setMarker( String::hash( url ) ); |
| 1202 | combineStyleSheet( parser.getStyleSheet() ); |
| 1203 | Log::debug( "UISceneNode::loadCSS: Loaded - %s", url ); |
| 1204 | } |
| 1205 | } else { |
| 1206 | Log::debug( "UISceneNode::loadCSS: Failed to load %s - Unknown scheme", url ); |
| 1207 | } |
| 1208 | } |
| 1209 | |
| 1210 | void UISceneNode::setInternalPixelsSize( const Sizef& size ) { |
| 1211 | Sizef s( size ); |
nothing calls this directly
no test coverage detected