int main(int argc, char** argv) { css::CSSStyleSheet defaultStyleSheet; Document document; // Load the default CSS file if (1 < argc) { std::ifstream stream(argv[1]); if (!stream) { std::cerr << "error: cannot open " << argv[1] << ".\n"; return EXIT_FAILURE; } defaultStyleSheet = loadStyleSheet(stream); getDOMImplementation()->setDefaultStyleSheet(defaultStyleSheet); } document = loadDocument(htmlDocument); assert(document); // create the default view WindowPtr window = std::make_shared<WindowImp>(); window->setDocument(std::static_pointer_cast<bootstrap::DocumentImp>(document.self())); ViewCSSImp* view = new ViewCSSImp(window); view->constructComputedStyles(); view->calculateComputedStyles(); printComputedValues(document, view); std::cout << "done.\n"; return 0; }
int main(int argc, char** argv) { css::CSSStyleSheet defaultStyleSheet(0); Document document(0); // Load the default CSS file if (1 < argc) { std::ifstream stream(argv[1]); if (!stream) { std::cerr << "error: cannot open " << argv[1] << ".\n"; return EXIT_FAILURE; } defaultStyleSheet = loadStyleSheet(stream); getDOMImplementation()->setDefaultStyleSheet(defaultStyleSheet); } document = loadDocument(htmlDocument); assert(document); // Each HTML element will have a style attribute if there's the style content attribute. // Each HTML style element will have a style sheet. eval(document); dumpTree(std::cout, document); // create the default view DocumentWindowPtr window = new(std::nothrow) DocumentWindow; window->setDocument(document); ViewCSSImp* view = new ViewCSSImp(window); view->setSize(8.5f * 96, 11.0f * 96); // US letter size, 96 DPI view->constructComputedStyles(); view->calculateComputedStyles(); Box* boxTree = view->constructBlocks(); if (!boxTree) return EXIT_FAILURE; boxTree->dump(); std::cout << "done.\n"; return 0; }