Skip to content

Commit

Permalink
Try to load directly at first
Browse files Browse the repository at this point in the history
  • Loading branch information
kou committed Jul 11, 2017
1 parent b0941ac commit cf0c40a
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions lib/chupa-text/decomposers/webkit.rb
Original file line number Diff line number Diff line change
Expand Up @@ -68,19 +68,31 @@ def create_screenshot(data)

status = {
finished: false,
load_failed: false,
screenshot: nil,
}
prepare_screenshot(data, view, status)
debug do
"#{log_tag}[load][html] #{data.uri}"
end
view.load_html(data.body, data.uri.to_s)

main_context = GLib::MainContext.default
timeout(compute_timeout_second, view, main_context, status) do
debug do
"#{log_tag}[load][URI] #{data.uri}"
end
view.load_uri(data.uri.to_s)
until status[:finished]
main_context.iteration(true)
end

if status[:load_failed]
status[:finished] = false
debug do
"#{log_tag}[load][HTML] #{data.uri}"
end
view.load_html(data.body, data.uri.to_s)
until status[:finished]
main_context.iteration(true)
end
end
end

window.destroy
Expand Down Expand Up @@ -138,6 +150,7 @@ def prepare_screenshot(data, view, status)
end
view.signal_connect("load-failed") do |_, _, failed_uri, error|
status[:finished] = true
status[:load_failed] = true
error do
message = "failed to load URI: #{failed_uri}: "
message << "#{error.class}(#{error.code}): #{error.message}"
Expand Down

0 comments on commit cf0c40a

Please sign in to comment.