| 240 | } |
| 241 | |
| 242 | std::string StyleSheetParser::importCSS( std::string path, |
| 243 | std::vector<std::string>& importedList ) { |
| 244 | if ( String::startsWith( path, "file://" ) ) { |
| 245 | path = path.substr( 7 ); |
| 246 | } |
| 247 | |
| 248 | if ( FileSystem::fileExists( path ) ) { |
| 249 | ScopedBuffer buffer; |
| 250 | |
| 251 | if ( FileSystem::fileGet( path, buffer ) ) { |
| 252 | importedList.push_back( path ); |
| 253 | return std::string( reinterpret_cast<const char*>( buffer.get() ), buffer.size() ); |
| 254 | } |
| 255 | } else if ( String::startsWith( path, "http://" ) || String::startsWith( path, "https://" ) ) { |
| 256 | Http::Response response = Http::get( URI( path ), Seconds( 5 ) ); |
| 257 | if ( response.getStatus() == Http::Response::Status::Ok ) { |
| 258 | importedList.push_back( path ); |
| 259 | return response.getBody(); |
| 260 | } |
| 261 | } else if ( VFS::instance()->fileExists( path ) ) { |
| 262 | IOStream* stream = VFS::instance()->getFileFromPath( path ); |
| 263 | ScopedBuffer buffer( stream->getSize() ); |
| 264 | stream->read( reinterpret_cast<char*>( buffer.get() ), buffer.size() ); |
| 265 | importedList.push_back( path ); |
| 266 | return std::string( reinterpret_cast<const char*>( buffer.get() ) ); |
| 267 | } else { |
| 268 | if ( PackManager::instance()->isFallbackToPacksActive() ) { |
| 269 | Pack* pack = PackManager::instance()->exists( path ); |
| 270 | |
| 271 | if ( std::find( importedList.begin(), importedList.end(), path ) == |
| 272 | importedList.end() ) { |
| 273 | if ( NULL != pack ) { |
| 274 | Log::debug( "Loading css from pack: %s", path.c_str() ); |
| 275 | ScopedBuffer buffer; |
| 276 | if ( pack->isOpen() && pack->extractFileToMemory( path, buffer ) ) { |
| 277 | importedList.push_back( path ); |
| 278 | return std::string( reinterpret_cast<const char*>( buffer.get() ) ); |
| 279 | } |
| 280 | } |
| 281 | } |
| 282 | } |
| 283 | } |
| 284 | |
| 285 | return std::string(); |
| 286 | } |
| 287 | |
| 288 | void StyleSheetParser::mediaParse( std::string& css, ReadState& rs, std::size_t& pos, |
| 289 | std::string& buffer, std::vector<std::string>& importedList ) { |
nothing calls this directly
no test coverage detected