Skip to content

import_css blocks the main thread #296

Open
@memecode

Description

@memecode

To implement the litehtml::document_container::import_css function:

void import_css(litehtml::string& text, const litehtml::string& url, litehtml::string& baseurl);

The application has to go out to the network and get the CSS and then at some later time, fill out 'text' with the content. That doesn't work if the network is slow to respond, taking seconds to complete...

A better way of doing it would be to pass a callback for the first parmeter... like:

void import_css(std::function<void(litehtml::string& text)> callback, const litehtml::string& url, litehtml::string& baseurl);

Then the implementor can go out setup a thread... pass the callback... do the network stuff... get the file... THEN call the callback. Maybe with some extra glue to make it run in the same thread as the caller.

litehtml just waits for the callback and applies the changes. No waiting around.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions