Skip to content

Commit 99da2b6

Browse files
author
p01
committed
Review fixes + flat template for the resource_tree
1 parent 28b26ee commit 99da2b6

File tree

4 files changed

+320
-345
lines changed

4 files changed

+320
-345
lines changed

src/resource-manager/resource_service.js

Lines changed: 64 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ cls.ResourceManagerService = function(view, network_logger)
6868
if (r && r.url == this._suppress_updates_url)
6969
this._suppress_uids[msg.id] = true;
7070

71-
// skip the update if it is about a suppressed uid
71+
// skip the update if it is about a suppressed uid
7272
if (this._suppress_uids[msg.id])
7373
return;
7474
}
@@ -78,24 +78,19 @@ cls.ResourceManagerService = function(view, network_logger)
7878
var ctx = {};
7979

8080
// get the order of the groups of resources
81-
ctx.groupOrder = this._view.get_group_order();
81+
ctx.group_order = this._view.get_group_order();
8282

8383
// get list of window_contexts for which we saw the main_document
84-
ctx.windowList = (this._network_logger.get_window_contexts() || [])
85-
.filter(function(w) {
86-
return w.saw_main_document;
87-
});
84+
ctx.windowList = (this._network_logger.get_window_contexts() || []).filter(function(w) {
85+
return w.saw_main_document;
86+
});
8887

8988
if (ctx.windowList.length)
9089
{
91-
// get all the (non-suppressed) resources with content, sorted by uid
92-
ctx.resourceList = (this._network_logger.get_resources() || [])
93-
.filter(function(v) {
94-
return !this._suppress_uids.hasOwnProperty(v.uid) && v.responsecode != 204;
95-
}, this)
96-
.sort(function(a, b) {
97-
return a.uid > b.uid ? 1 : a.uid == b.uid ? 0 : -1;
98-
});
90+
// get all the (non-suppressed) resources with content
91+
ctx.resourceList = (this._network_logger.get_resources() || []).filter(function(v) {
92+
return !this._suppress_uids.hasOwnProperty(v.uid) && v.responsecode != 204;
93+
}, this);
9994

10095
ctx.document_resource_hash = {};
10196

@@ -110,71 +105,76 @@ cls.ResourceManagerService = function(view, network_logger)
110105
// set null_document_id flag,
111106
// augment the document objects,
112107
// set the default collapsed flags
113-
ctx.documentList = this._document_list
114-
.filter(function(d, i, a) {
115-
var inContext = window_id_index.hasOwnProperty(d.windowID);
116-
117-
if (inContext)
108+
ctx.documentList = this._document_list.filter(function(d, i, a) {
109+
var inContext = window_id_index.hasOwnProperty(d.windowID);
110+
111+
if (inContext)
112+
{
113+
if (!null_document_id && !d.documentID)
114+
null_document_id = true;
115+
116+
if (d.resourceID != null)
117+
ctx.document_resource_hash[d.resourceID] = d.documentID;
118+
119+
// populate document_id_index
120+
document_id_index[d.documentID] = i;
121+
122+
// set depth, pivotID and sameOrigin
123+
var p = a[document_id_index[d.parentDocumentID]] || {pivotID:d.windowID, depth:0};
124+
var id = p.pivotID + "_" + d.documentID;
125+
d.depth = p.depth + 1;
126+
d.pivotID = id;
127+
d.sameOrigin = cls.ResourceUtil.sameOrigin(p.url, d.url);
128+
129+
// set the default collapsed flag
130+
var hash = this._collapsed_hash;
131+
if (!hash.hasOwnProperty(id))
118132
{
119-
if (!null_document_id && !d.documentID)
120-
null_document_id = true;
121-
122-
if (d.resourceID != null)
123-
ctx.document_resource_hash[d.resourceID] = d.documentID;
124-
125-
// populate document_id_index
126-
document_id_index[d.documentID] = i;
127-
128-
// set depth, pivotID and sameOrigin
129-
var p = a[document_id_index[d.parentDocumentID]] || {pivotID:d.windowID, depth:0};
130-
var id = p.pivotID + "_" + d.documentID;
131-
d.depth = p.depth + 1;
132-
d.pivotID = id;
133-
d.sameOrigin = cls.ResourceUtil.sameOrigin(p.url, d.url);
134-
135-
// set the default collapsed flag
136-
var hash = this._collapsed_hash;
137-
if (!hash.hasOwnProperty(id))
138-
{
139-
hash[id] = d.depth > 1;
140-
ctx.groupOrder.forEach(function(g) { hash[id + "_" + g] = true; });
141-
}
133+
hash[id] = d.depth > 1;
134+
ctx.group_order.forEach(function(g) { hash[id + "_" + g] = true; });
142135
}
136+
}
143137

144-
return inContext;
145-
}, this);
138+
return inContext;
139+
}, this);
146140

147141
var unknown_document_id = false;
148142

149143
// set unknown_document_id flag,
150144
// assign top resource to the right document,
151145
// add group to each resource,
152146
// sameOrigin flag to each resource
153-
ctx.resourceList
154-
.forEach(function(r) {
155-
if (!unknown_document_id && !document_id_index.hasOwnProperty(r.document_id))
156-
unknown_document_id = true;
147+
// full_id ( pivot_ID + uid )
148+
ctx.resourceList.forEach(function(r) {
149+
if (!unknown_document_id && !document_id_index.hasOwnProperty(r.document_id))
150+
unknown_document_id = true;
151+
152+
// check if this is the top resource of a document
153+
var documentID = ctx.document_resource_hash[r.resource_id];
154+
if (documentID != null && documentID != r.document_id)
155+
r.document_id = documentID;
157156

158-
// check if this is the top resource of a document
159-
var documentID = ctx.document_resource_hash[r.resource_id];
160-
if (documentID != null && documentID != r.document_id)
161-
r.document_id = documentID;
157+
this._populate_document_resources(r);
162158

163-
this._populate_document_resources(r);
159+
r.group = TYPE_GROUP_MAPPING[r.type] || TYPE_GROUP_MAPPING["*"];
160+
var d = this._document_list[document_id_index[r.document_id]];
161+
r.sameOrigin = cls.ResourceUtil.sameOrigin(d && d.url, r);
162+
r.full_id = ( d && d.pivotID ) + "_" + ctx.group_order.indexOf(r.group) + r.group + "_" + r.uid;
164163

165-
r.group = TYPE_GROUP_MAPPING[r.type] || TYPE_GROUP_MAPPING["*"];
166-
var d = this._document_list[document_id_index[r.document_id]];
167-
r.sameOrigin = cls.ResourceUtil.sameOrigin(d && d.url, r);
168-
}, this);
164+
}, this);
165+
166+
// sort the resource by their full_id ( pivot + uid )
167+
ctx.resourceList = ctx.resourceList.sort(function(a, b) {
168+
return a.full_uid > b.full_uid ? 1 : a.full_uid == b.full_uid ? 0 : -1;
169+
});
169170

170171
// filter the list of window. Purge the ones with no documents
171-
ctx.windowList = ctx.windowList
172-
.filter(function(v) {
173-
return ctx.documentList
174-
.some(function(w) {
175-
return v.id == w.windowID;
176-
});
172+
ctx.windowList = ctx.windowList.filter(function(v) {
173+
return ctx.documentList.some(function(w) {
174+
return v.id == w.windowID;
177175
});
176+
});
177+
178178

179179
// request the list of documents if we have
180180
// an empty documentList
@@ -448,7 +448,7 @@ cls.ResourceRequest = function(url, callback, data, resourceInfo)
448448
{
449449
if (status == SUCCESS && this._retries < MAX_RETRIES)
450450
{
451-
var resourceData = new cls.ResourceManager["1.2"].ResourceData(message);
451+
var resourceData = new cls.ResourceManager["1.2"].ResourceData(message);
452452
if (resourceData.content)
453453
{
454454
// content -> mock a cls.NetworkLoggerEntry and instanciate a cls.ResourceInfo

src/resource-manager/resource_style.css

Lines changed: 35 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -110,9 +110,9 @@
110110

111111
.highlighted-line
112112
{
113-
background-image: linear-gradient(0deg,
114-
#d4e3f4,
115-
#d4e3f4);
113+
background-image: -o-linear-gradient(top, #d4e3f4, #d4e3f4);
114+
background-image: linear-gradient(0deg, #d4e3f4, #d4e3f4);
115+
116116
background-repeat: no-repeat;
117117
}
118118

@@ -150,7 +150,8 @@
150150
display: none;
151151
}
152152

153-
.button-expand-collapse
153+
.button-expand-collapse,
154+
.button-expand-collapse-close
154155
{
155156
background: url("../ui-images/expand-collapse.png") 1px -14px no-repeat transparent;
156157
border: 0 none currentColor;
@@ -161,13 +162,16 @@
161162
width: 13px;
162163
}
163164

164-
.button-expand-collapse:focus
165+
.button-expand-collapse:focus,
166+
.button-expand-collapse-close:focus
165167
{
166168
outline: 2px solid #598BEC;
167169
outline-offset: -2px;
168170
}
169171

170-
.resource-tree-expand-collapse.close .button-expand-collapse
172+
/*.resource-tree-expand-collapse.close .button-expand-collapse*/
173+
/*.button-expand-collapse.close*/
174+
.button-expand-collapse-close
171175
{
172176
background-position: 1px 1px;
173177
}
@@ -183,6 +187,7 @@
183187
}
184188
.resource-detail-container
185189
{
190+
background-image: -o-linear-gradient(left, #eee 54px, #e9e9e9 55px);
186191
background-image: linear-gradient(180deg, #eee 54px, #e9e9e9 55px);
187192
background-size: 100% 55px;
188193
background-repeat: repeat-x;
@@ -195,9 +200,9 @@
195200
{
196201
position: absolute;
197202
top: 55px;
198-
left: 0px;
199-
right: 0px;
200-
bottom: 0px;
203+
left: 0;
204+
right: 0;
205+
bottom: 0;
201206
}
202207

203208
.resource-detail-container-empty
@@ -336,7 +341,7 @@ h2 .resource-tree-count
336341
display: inline-block;
337342
line-height: 16px;
338343
border-radius: 3px;
339-
padding: 0px 5px;
344+
padding: 0 5px;
340345
margin-left: 4px;
341346
vertical-align: middle;
342347
}
@@ -375,9 +380,14 @@ h2.resource-highlight:hover .resource-domain
375380
content: " – ";
376381
}
377382

378-
span.resource-tree-window-label,
379-
span.resource-tree-document-label,
380-
span.resource-tree-group-label
383+
.resource-tree-window-label,
384+
.resource-tree-document-label,
385+
.resource-tree-group-markup-label,
386+
.resource-tree-group-stylesheets-label,
387+
.resource-tree-group-scripts-label,
388+
.resource-tree-group-images-label,
389+
.resource-tree-group-fonts-label,
390+
.resource-tree-group-other-label
381391
{
382392
font-weight: bold;
383393
padding: 0 0 0 21px;
@@ -386,45 +396,47 @@ span.resource-tree-group-label
386396
background-position: 1px 1px;
387397
background-repeat: no-repeat;
388398
background-size: 16px 16px;
389-
background-image: url("../ui-images/type_folder.png");
399+
text-transform: capitalize;
390400
}
391401

392-
h2.resource-tree-group
402+
.resource-tree-window-label
393403
{
394-
text-transform: capitalize;
404+
text-transform: none;
405+
background-image: url("../ui-images/type_folder.png");
395406
}
396407

397-
span.resource-tree-document-label
408+
.resource-tree-document-label
398409
{
410+
text-transform: none;
399411
background-image: url("../ui-images/type_document.png");
400412
}
401413

402-
h2.resource-tree-group-markup > span.resource-tree-group-label
414+
.resource-tree-group-markup-label
403415
{
404416
background-image: url("../ui-images/type_markup.png");
405417
}
406418

407-
h2.resource-tree-group-stylesheets > span.resource-tree-group-label
419+
.resource-tree-group-stylesheets-label
408420
{
409421
background-image: url("../ui-images/type_style.png");
410422
}
411423

412-
h2.resource-tree-group-scripts > span.resource-tree-group-label
424+
.resource-tree-group-scripts-label
413425
{
414426
background-image: url("../ui-images/type_script.png");
415427
}
416428

417-
h2.resource-tree-group-images > span.resource-tree-group-label
429+
.resource-tree-group-images-label
418430
{
419431
background-image: url("../ui-images/type_picture.png");
420432
}
421433

422-
h2.resource-tree-group-fonts > span.resource-tree-group-label
434+
.resource-tree-group-fonts-label
423435
{
424436
background-image: url("../ui-images/type_font.png");
425437
}
426438

427-
h2.resource-tree-group-other > span.resource-tree-group-label
439+
.resource-tree-group-other-label
428440
{
429441
background-image: url("../ui-images/type_other.png");
430442
}

0 commit comments

Comments
 (0)