Skip to content

Commit

Permalink
Update Web Browser sample, display error description when a network e…
Browse files Browse the repository at this point in the history
…rror is encountered while loading.
  • Loading branch information
adamjs committed Oct 28, 2020
1 parent 982539f commit 5350360
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 4 deletions.
4 changes: 2 additions & 2 deletions samples/Sample 8 - Web Browser/assets/chrome-tabs.css
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@
top: 11px;
}
.chrome-tabs .chrome-tab-close::before {
content: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 14 14'><path stroke='%235a5a5a' stroke-linecap='round' stroke-width='1.125' d='M4 4 L10 10 M10 4 L4 10'></path></svg>");
content: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 14 14'><path stroke='%235a5a5a' stroke-width='1.3' d='M4 4 L10 10 M10 4 L4 10'></path></svg>");
position: absolute;
display: block;
top: 0;
Expand All @@ -166,7 +166,7 @@
}
.chrome-tabs .chrome-tab-close:hover::before,
.chrome-tabs .chrome-tab-close:hover:active::before {
content: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 14 14'><path stroke='%23fff' stroke-linecap='round' stroke-width='1.2' d='M4 4 L10 10 M10 4 L4 10'></path></svg>");
content: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 14 14'><path stroke='%23fff' stroke-width='1.3' d='M4 4 L10 10 M10 4 L4 10'></path></svg>");
}
.chrome-tabs .chrome-tab-close:hover {
background: #e25c4b;
Expand Down
1 change: 0 additions & 1 deletion samples/Sample 8 - Web Browser/assets/release_notes.html
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@
<h2>Ultralight v1.2.0 Release Notes</h2>

<h3>Changelog</h3>
This is one of our biggest releases yet!

<h4>Overview of Major Changes</h4>
<ul>
Expand Down
20 changes: 19 additions & 1 deletion samples/Sample 8 - Web Browser/src/Tab.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,25 @@ void Tab::OnFinishLoading(View* caller, uint64_t frame_id, bool is_main_frame, c

void Tab::OnFailLoading(View* caller, uint64_t frame_id, bool is_main_frame, const String& url,
const String& description, const String& error_domain, int error_code) {

if (is_main_frame) {
char error_code_str[16];
sprintf(error_code_str,"%d", error_code);

String html_string = "<html><head><style>";
html_string += "* { font-family: sans-serif; }";
html_string += "body { background-color: #CCC; color: #555; padding: 4em; }";
html_string += "dt { font-weight: bold; padding: 1em; }";
html_string += "</style></head><body>";
html_string += "<h2>A Network Error was Encountered</h2>";
html_string += "<dl>";
html_string += "<dt>URL</dt><dd>" + url + "</dd>";
html_string += "<dt>Description</dt><dd>" + description + "</dd>";
html_string += "<dt>Error Domain</dt><dd>" + error_domain + "</dd>";
html_string += "<dt>Error Code</dt><dd>" + String(error_code_str) + "</dd>";
html_string += "</dl></body></html>";

view()->LoadHTML(html_string);
}
}

void Tab::OnUpdateHistory(View* caller) {
Expand Down

0 comments on commit 5350360

Please sign in to comment.