Skip to content

Commit 7050e2d

Browse files
author
p01
committed
Review fixes + word-break and word-wrap to the Font preview
1 parent 5246813 commit 7050e2d

File tree

3 files changed

+77
-68
lines changed

3 files changed

+77
-68
lines changed

src/resource-manager/resource_service.js

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -128,12 +128,12 @@ cls.ResourceInspector = function(network_logger)
128128
// populate document_id_index
129129
document_id_index[d.documentID] = i;
130130

131-
// set depth, pivot_id and sameOrigin
131+
// set depth, pivot_id and same_origin
132132
var p = a[document_id_index[d.parentDocumentID]] || {pivot_id: d.windowID, depth: 0};
133133
var id = p.pivot_id + "_" + d.documentID;
134134
d.depth = p.depth + 1;
135135
d.pivot_id = id;
136-
d.sameOrigin = cls.ResourceUtil.sameOrigin(p.url, d.url);
136+
d.same_origin = cls.ResourceUtil.sameOrigin(p.url, d.url);
137137

138138
// set the default collapsed flag
139139
var hash = this._collapsed_hash;
@@ -152,7 +152,7 @@ cls.ResourceInspector = function(network_logger)
152152
// set unknown_document_id flag,
153153
// assign top resource to the right document,
154154
// add group to each resource,
155-
// sameOrigin flag to each resource,
155+
// same_origin flag to each resource,
156156
// full_id ( pivot_id + group + uid ),
157157
// pivot_id
158158
ctx.resource_list = ctx.resource_list.filter(function(r) {
@@ -171,7 +171,7 @@ cls.ResourceInspector = function(network_logger)
171171
this._populate_document_resources(r);
172172

173173
r.group = TYPE_GROUP_MAPPING[r.type] || TYPE_GROUP_MAPPING["*"];
174-
r.sameOrigin = cls.ResourceUtil.sameOrigin(d.url, r);
174+
r.same_origin = cls.ResourceUtil.sameOrigin(d.url, r);
175175

176176
r.full_id = d.pivot_id + "_" + ctx.group_order.indexOf(r.group) + r.group + "_" + r.uid;
177177
r.pivot_id = d.pivot_id + "_" + r.group;
@@ -270,7 +270,7 @@ cls.ResourceInspector = function(network_logger)
270270

271271
this._selected_resource_uid = uid;
272272
if (this._context)
273-
this._context.selectedResourceUID = uid;
273+
this._context.selected_resource_uid = uid;
274274

275275
e = document.querySelector("[" + RESOURCE_UID_ATTRIBUTE + "='" + this._selected_resource_uid + "']");
276276
if (e)
@@ -387,16 +387,16 @@ cls.ResourceInspector = function(network_logger)
387387
return this._get_resource_by_key_value('url', url);
388388
};
389389

390-
this.request_resource_data = function(url, callback, data, resourceInfo)
390+
this.request_resource_data = function(url, callback, data, resource_info)
391391
{
392392
this._suppress_updates_url = url;
393-
new cls.ResourceRequest(url, callback, data, resourceInfo);
393+
new cls.ResourceRequest(url, callback, data, resource_info);
394394
};
395395

396396
this._init();
397397
};
398398

399-
cls.ResourceRequest = function(url, callback, data, resourceInfo)
399+
cls.ResourceRequest = function(url, callback, data, resource_info)
400400
{
401401
var SUCCESS = 0;
402402
var TRANSPORT_STRING = 1;
@@ -407,10 +407,10 @@ cls.ResourceRequest = function(url, callback, data, resourceInfo)
407407

408408
var MAX_RETRIES = 3;
409409

410-
this._init = function(url, callback, data, resourceInfo)
410+
this._init = function(url, callback, data, resource_info)
411411
{
412412
this.url = url;
413-
this.resourceInfo = resourceInfo;
413+
this.resource_info = resource_info;
414414
this._data = data||{};
415415
this._callback = callback;
416416
this._retries = 0;
@@ -434,9 +434,9 @@ cls.ResourceRequest = function(url, callback, data, resourceInfo)
434434
{
435435
if (this._resource_manager.requestCreateRequest)
436436
{
437-
var windowID = this._data.window_id || window.window_manager_data.get_debug_context();
437+
var window_id = this._data.window_id || window.window_manager_data.get_debug_context();
438438
var tag = window.tag_manager.set_callback(this, this._on_request_resource_id);
439-
this._resource_manager.requestCreateRequest(tag, [windowID, this.url, "GET"]);
439+
this._resource_manager.requestCreateRequest(tag, [window_id, this.url, "GET"]);
440440
}
441441
else
442442
this._fallback();
@@ -474,27 +474,27 @@ cls.ResourceRequest = function(url, callback, data, resourceInfo)
474474
{
475475
if (status == SUCCESS && this._retries < MAX_RETRIES)
476476
{
477-
var resourceData = new cls.ResourceManager["1.2"].ResourceData(message);
478-
if (resourceData.content)
477+
var resource_data = new cls.ResourceManager["1.2"].ResourceData(message);
478+
if (resource_data.content)
479479
{
480480
// content -> mock a cls.NetworkLoggerEntry and instanciate a cls.ResourceInfo
481-
this.requests_responses = [{responsebody: resourceData}];
482-
var resourceInfo = new cls.ResourceInfo(this);
483-
if (!this.resourceInfo)
484-
this.resourceInfo = resourceInfo;
481+
this.requests_responses = [{responsebody: resource_data}];
482+
var resource_info = new cls.ResourceInfo(this);
483+
if (!this.resource_info)
484+
this.resource_info = resource_info;
485485
else
486-
this.resourceInfo.data = resourceInfo.data;
486+
this.resource_info.data = resource_info.data;
487487

488488
// broadcast that we got payload of the resource
489489
window.messages.post("resource-request-resource", {resource_id: this.resource_id});
490490

491491
// aaaand callback
492-
this._callback(this.resourceInfo, this._data);
492+
this._callback(this.resource_info, this._data);
493493
}
494494
else
495495
{
496496
// no content -> guess the type and request using the appropriate transport mode
497-
this.type = cls.ResourceUtil.guess_type(resourceData.mimeType, this.extension);
497+
this.type = cls.ResourceUtil.guess_type(resource_data.mimeType, this.extension);
498498
this._request_get_resource();
499499
this._retries++;
500500
}
@@ -503,7 +503,7 @@ cls.ResourceRequest = function(url, callback, data, resourceInfo)
503503
this._fallback();
504504
};
505505

506-
this._init(url, callback, data, resourceInfo);
506+
this._init(url, callback, data, resource_info);
507507
};
508508

509509
cls.ResourceRequest.prototype = new URIPrototype("url");

src/resource-manager/resource_templates.js

Lines changed: 51 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ window.templates.resource_tree || (window.templates.resource_tree = new function
8282
extras.tpl.button,
8383
["span",
8484
window_info.title,
85-
"class","resource-tree-window-label"
85+
"class", "resource-tree-window-label"
8686
]
8787
].concat(extras.tpl.h2),
8888
].concat(extras.tpl.li)
@@ -107,36 +107,39 @@ window.templates.resource_tree || (window.templates.resource_tree = new function
107107
return document_resources.contains(r.uid);
108108
});
109109

110-
var depth = d.depth;
111-
var extras = this._expander_extras(context, d.pivot_id, depth);
112-
113-
this.flat_list.push(
114-
["li",
115-
["h2",
116-
extras.tpl.button,
117-
["span",
118-
this._get_short_distinguisher(d.url),
119-
"class", "resource-tree-document-label",
120-
"data-tooltip"," js-script-select",
121-
"data-tooltip-text", d.original_url
122-
],
123-
" ",
124-
d.sameOrigin ? [] : ["span", d.url.host, "class", "resource-domain"],
125-
" ",
126-
["span",
127-
String(resources.length),
128-
"class", "resource-tree-count"
129-
]
130-
].concat(extras.tpl.h2),
131-
].concat(extras.tpl.li)
132-
);
133-
134-
if (!extras.collapsed )
110+
if (resources.length > 0)
135111
{
136-
if (resources.length)
137-
this.resource_groups(context, resources, d);
138-
139-
this.documents(context, d.windowID, d.documentID);
112+
var depth = d.depth;
113+
var extras = this._expander_extras(context, d.pivot_id, depth);
114+
115+
this.flat_list.push(
116+
["li",
117+
["h2",
118+
extras.tpl.button,
119+
["span",
120+
this._get_short_distinguisher(d.url),
121+
"class", "resource-tree-document-label",
122+
"data-tooltip", " js-script-select",
123+
"data-tooltip-text", d.original_url
124+
],
125+
" ",
126+
d.same_origin ? [] : ["span", d.url.host, "class", "resource-domain"],
127+
" ",
128+
["span",
129+
String(resources.length),
130+
"class", "resource-tree-count"
131+
]
132+
].concat(extras.tpl.h2),
133+
].concat(extras.tpl.li)
134+
);
135+
136+
if (!extras.collapsed )
137+
{
138+
if (resources.length)
139+
this.resource_groups(context, resources, d);
140+
141+
this.documents(context, d.windowID, d.documentID);
142+
}
140143
}
141144
};
142145

@@ -179,7 +182,7 @@ window.templates.resource_tree || (window.templates.resource_tree = new function
179182
this.resources(context, resources, depth+1);
180183
};
181184

182-
this.resources = function(context, resources,depth)
185+
this.resources = function(context, resources, depth)
183186
{
184187
resources.forEach(this.resource.bind(this, context, depth));
185188
};
@@ -209,7 +212,7 @@ window.templates.resource_tree || (window.templates.resource_tree = new function
209212
"data-tooltip-text", r.url
210213
],
211214
" ",
212-
r.sameOrigin ? [] : ["span", r.host, "class", "resource-domain"],
215+
r.same_origin ? [] : ["span", r.host, "class", "resource-domain"],
213216
"class", "resource-tree-resource"
214217
],
215218
"class", (context.selected_resource_uid == r.uid ? "resource-highlight" : ""),
@@ -282,12 +285,12 @@ window.templates.resource_detail || (window.templates.resource_detail = new func
282285
{
283286
var info =
284287
{
285-
"responseCode": resource.responsecode + " " + cls.ResourceUtil.http_status_codes[resource.responsecode],
288+
"response_code": resource.responsecode + " " + cls.ResourceUtil.http_status_codes[resource.responsecode],
286289
"size": resource.size || resource.data.contentLength || resource.data.content.length,
287-
"characterEncoding": resource.encoding || resource.data.characterEncoding
290+
"character_encoding": resource.encoding || resource.data.characterEncoding
288291
};
289292

290-
var isError = resource.responsecode && ![200, 304].contains(resource.responsecode);
293+
var is_error = resource.responsecode && ![200, 304].contains(resource.responsecode);
291294

292295
return (
293296
["div",
@@ -302,12 +305,12 @@ window.templates.resource_detail || (window.templates.resource_detail = new func
302305
"class", "resource-detail-overview-url"
303306
],
304307
["span",
305-
(isError ? info.responseCode + " - " : "") +
308+
(is_error ? info.response_code + " - " : "") +
306309
ui_strings.S_RESOURCE_SENT_AND_GUESSED_TYPE
307310
.replace("%(SENT)s", resource.data.mimeType)
308311
.replace("%(GUESSED)s", resource.type) +
309-
(info.characterEncoding && " " + ui_strings.S_RESOURCE_ENCODING.replace("%s", info.characterEncoding)),
310-
"class", "resource-detail-overview-type" + (isError ? " resource-detail-error" : "")
312+
(info.character_encoding && " " + ui_strings.S_RESOURCE_ENCODING.replace("%s", info.character_encoding)),
313+
"class", "resource-detail-overview-type" + (is_error ? " resource-detail-error" : "")
311314
],
312315
["span",
313316
cls.ResourceUtil.bytes_to_human_readable(info.size) +
@@ -373,18 +376,24 @@ window.templates.resource_detail || (window.templates.resource_detail = new func
373376

374377
this.font = function(resource)
375378
{
376-
var font_face = "@font-face{font-family:\"resource-" + resource.uid + "\";src:url(\"" + resource.data.content.stringData + "\");}";
377-
var inline_style = "font-size:64px;font-family:resource-" + resource.uid + ";";
379+
var font_family_name = "font" + resource.uid;
380+
var style_sheet = "@font-face { font-family: \"" + font_family_name + "\";" +
381+
"src: url(\"" + resource.data.content.stringData + "\"); }";
382+
var inline_style = "font-size: 64px; font-family: " + font_family_name + ";" +
383+
"white-space: pre; word-break: break-all; " +
384+
"word-wrap: break-word; overflow-wrap: break-word;";
378385
var sample_string = "The quick brown fox jumps over the lazy dog 0123456789";
379386

380387
return(
381388
["object",
382389
["div",
383390
sample_string,
384-
["style", font_face],
391+
["style", style_sheet],
385392
"style", inline_style,
386393
],
387-
"data", "data:text/html;base64," + btoa("<!doctype html><style>" + font_face + "</style><div contenteditable=\"true\" style=\"" + inline_style + "\">" + sample_string),
394+
"data", "data:text/html;base64," +
395+
btoa("<!doctype html><style>" + style_sheet + "</style>" +
396+
"<div contenteditable=\"true\" style=\"" + inline_style + "\">" + sample_string),
388397
"class", "resource-detail-font"
389398
]);
390399
};

src/resource-manager/resource_tree_view.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ cls.ResourceTreeView = function(id, name, container_class, html, default_handler
3737
{
3838
var ctx = this.service.get_resource_context();
3939
var target = container.firstElementChild;
40-
var scrollTop = target?target.scrollTop:0;
41-
var scrollLeft = target?target.scrollLeft:0;
40+
var scroll_top = target?target.scrollTop:0;
41+
var scroll_left = target?target.scrollLeft:0;
4242
var tpl;
4343

4444
if (ctx)
@@ -80,8 +80,8 @@ cls.ResourceTreeView = function(id, name, container_class, html, default_handler
8080
target = container.firstElementChild;
8181
if (target)
8282
{
83-
target.scrollTop = scrollTop;
84-
target.scrollLeft = scrollLeft;
83+
target.scrollTop = scroll_top;
84+
target.scrollLeft = scroll_left;
8585
}
8686
};
8787

0 commit comments

Comments
 (0)