Esempio n. 1
0
void CSSDocument::add_sheet(CSSSheetOrigin origin, const std::string &filename, const FileSystem &fs)
{
	// Load the css document:
	IODevice file = fs.open_file(filename);
	DataBuffer file_data(file.get_size());
	file.read(file_data.get_data(), file_data.get_size());
	std::string css_text(file_data.get_data(), file_data.get_size());

	// Find the base URI for this css document:
	std::string base_uri = PathHelp::get_fullpath(filename);

	// Find import directives and load those first:
	std::vector<std::string> import_urls = CSSTokenizer(css_text).read_import_urls();
	for (size_t i = 0; i < import_urls.size(); i++)
	{
		add_sheet(origin, PathHelp::combine(base_uri, import_urls[i]), fs);
	}

	// Add the css sheet:
	CSSTokenizer tokenizer(css_text);
	impl->sheets.push_back(std::shared_ptr<CSSDocumentSheet>(new CSSDocumentSheet(origin, tokenizer, base_uri)));
}
Esempio n. 2
0
void litehtml::document::add_stylesheet(const wchar_t* str,
					const wchar_t* baseurl) {
     if (str && str[0]) {
	  m_css.push_back(css_text(str, baseurl));
     }
}