Page info: Get URL scheme on creation.

This commit is contained in:
Michael Drake 2020-05-20 10:37:56 +01:00
parent 6fe2f7de47
commit b2f4f278be

View File

@ -241,6 +241,7 @@ struct page_info {
struct browser_window *bw; struct browser_window *bw;
lwc_string *domain; lwc_string *domain;
enum nsurl_scheme_type scheme;
browser_window_page_info_state state; browser_window_page_info_state state;
unsigned cookies; unsigned cookies;
@ -447,6 +448,7 @@ static nserror page_info__create_from_bw(
pi->state = browser_window_get_page_info_state(bw); pi->state = browser_window_get_page_info_state(bw);
pi->cookies = browser_window_get_cookie_count(bw); pi->cookies = browser_window_get_cookie_count(bw);
pi->domain = nsurl_get_component(url, NSURL_HOST); pi->domain = nsurl_get_component(url, NSURL_HOST);
pi->scheme = nsurl_get_scheme_type(url);
return page_info__set_text(pi); return page_info__set_text(pi);
} }
@ -462,15 +464,12 @@ static nserror page_info__layout(
{ {
int cur_y = 0; int cur_y = 0;
int max_x = 0; int max_x = 0;
enum nsurl_scheme_type scheme;
scheme = nsurl_get_scheme_type(browser_window_access_url(pi->bw));
cur_y += pi->window_padding; cur_y += pi->window_padding;
for (unsigned i = 0; i < PI_ENTRY__COUNT; i++) { for (unsigned i = 0; i < PI_ENTRY__COUNT; i++) {
struct page_info_entry *entry = pi->entries + i; struct page_info_entry *entry = pi->entries + i;
if (i == PI_ENTRY_CERT && scheme != NSURL_SCHEME_HTTPS) { if (i == PI_ENTRY_CERT && pi->scheme != NSURL_SCHEME_HTTPS) {
continue; continue;
} }
@ -583,7 +582,6 @@ nserror page_info_redraw(
const struct redraw_context *ctx) const struct redraw_context *ctx)
{ {
struct redraw_context new_ctx = *ctx; struct redraw_context new_ctx = *ctx;
enum nsurl_scheme_type scheme;
struct rect r = { struct rect r = {
.x0 = clip->x0 + x, .x0 = clip->x0 + x,
.y0 = clip->y0 + y, .y0 = clip->y0 + y,
@ -593,8 +591,6 @@ nserror page_info_redraw(
int cur_y = 0; int cur_y = 0;
nserror err; nserror err;
scheme = nsurl_get_scheme_type(browser_window_access_url(pi->bw));
/* Start knockout rendering if it's available for this plotter. */ /* Start knockout rendering if it's available for this plotter. */
if (ctx->plot->option_knockout) { if (ctx->plot->option_knockout) {
bool res = knockout_plot_start(ctx, &new_ctx); bool res = knockout_plot_start(ctx, &new_ctx);
@ -612,7 +608,7 @@ nserror page_info_redraw(
const struct page_info_entry *entry = pi->entries + i; const struct page_info_entry *entry = pi->entries + i;
int cur_x = pi->window_padding; int cur_x = pi->window_padding;
if (i == PI_ENTRY_CERT && scheme != NSURL_SCHEME_HTTPS) { if (i == PI_ENTRY_CERT && pi->scheme != NSURL_SCHEME_HTTPS) {
continue; continue;
} }
@ -718,19 +714,16 @@ nserror page_info_mouse_action(
int y, int y,
bool *did_something) bool *did_something)
{ {
enum nsurl_scheme_type scheme;
int cur_y = 0; int cur_y = 0;
nserror err; nserror err;
scheme = nsurl_get_scheme_type(browser_window_access_url(pi->bw));
cur_y += pi->window_padding; cur_y += pi->window_padding;
for (unsigned i = 0; i < PI_ENTRY__COUNT; i++) { for (unsigned i = 0; i < PI_ENTRY__COUNT; i++) {
struct page_info_entry *entry = pi->entries + i; struct page_info_entry *entry = pi->entries + i;
bool hovering = false; bool hovering = false;
int height; int height;
if (i == PI_ENTRY_CERT && scheme != NSURL_SCHEME_HTTPS) { if (i == PI_ENTRY_CERT && pi->scheme != NSURL_SCHEME_HTTPS) {
continue; continue;
} }