Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Added the InfoToolTip to Cookie Panel #33

Merged
merged 7 commits into from

3 participants

@bharaththiruveedula

No description provided.

@SebastianZ
Owner

According to my comment at issue 5834 the infotip should contain info about the raw and decoded cookie size.

Also please note that when you're fixing an issue that is listed inside our issue tracker, you should refer to it by giving the commit a comment like this:

Issue 5834 (Add infotip for cookie size)
http://code.google.com/p/fbug/issues/detail?id=5834

Sebastian

@janodvarko
Owner

Good, just wanted to do the review (I promised that to Bharath yesterday when helping him to implement that)

Couple of additional comments:

  • cookie.sizeinfo.Cookie_Size string needs to be created in cookies.properties file
  • The cookie object (in cookie.js module) should have getSize() method as we discussed yesterday.

Honza

@SebastianZ
Owner
  • cookie.sizeinfo.Cookie_Size string needs to be created in cookies.properties file

Also the key should be renamed to cookies.sizeinfo.Size because "Size" is enough.

Honza, there is already a cookies.header.size in cookies.properties. Should that be renamed to e.g. cookies.size or cookies.data.size instead, so it can be used for both, the header and the infotip?

Sebastian

@janodvarko
Owner

Honza, there is already a cookies.header.size in cookies.properties. Should that be renamed to e.g.
cookies.size or cookies.data.size instead, so it can be used for both, the header and the infotip?
No, let's have two different string keys. They are using in different contexts and it could happen
that we want to slightly modify the label in one of them.

Honza

@janodvarko
Owner

1) Use yet cookie name to generate the infoTipCookieId (something like "cookiesize-" + cookie.name)
2) this.infoTipFile should be this.infoTipCookie
3) the descTag is still in the code, it should be removed
4) Sebastian pointed that sizeInfo needs to include the raw size of the cookie as well as the decoded size (but just when it differs from the raw size). I don't see this.

Honza

@SebastianZ
Owner

Also the translation should just be "Size", not "Cookie Size". And for the decoded value size it should be "Decoded Size".

Sebastian

@janodvarko
Owner

1) Bharath, you need to pay more attention to the changes. If you change this.infoTipFile to this.infoTipCookie, you need to change all occurrences (see line 494)

2) Please do not create lines longer than 100 characters
sizeInfo.push({label: Locale.$STR("cookie.sizeinfo.Size"), size: size},{label: Locale.$STR("cookie.sizeinfo.RawSize"), size: rawSize});
see: https://getfirebug.com/wiki/index.php/Firebug_Coding_Style

3) > And for the decoded value size it should be "Decoded Size".
Since the data tab says "Raw Data" I think the size label should use "Raw Size"

4) As Sebastian mentioned the getCookie should look like:

getSize: function()
{
    return this.cookie.name.length + this.cookie.value.length;
},

Bharath, is the difference clear?

The same for getRawSize()

Honza

@janodvarko janodvarko merged commit 243d583 into firebug:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Aug 20, 2012
  1. Added the InfoToolTip to Firebug

    bharath authored
Commits on Aug 21, 2012
  1. Improved the code according to the comments

    bharath authored
  2. Added getSize() to cookie.js

    bharath authored
Commits on Aug 22, 2012
  1. Merge remote-tracking branch 'upstream/master'

    bharath authored
Commits on Aug 24, 2012
  1. Displayed the raw size of the cookie

    bharath authored
  2. Modified the getSize() and getRawSize()

    bharath authored
  3. Modified sizeInfo

    bharath authored
This page is out of date. Refresh to see the latest.
View
13 extension/content/firebug/cookies/cookie.js
@@ -3,6 +3,7 @@
define([
"firebug/lib/xpcom",
"firebug/lib/json",
+ "firebug/lib/string",
],
function(Xpcom, Json) {
@@ -140,7 +141,17 @@ Cookie.prototype =
}
return null;
- }
+ },
+
+ getSize: function()
+ {
+ return this.cookie.name.length + this.cookie.value.length;
+ },
+
+ getRawSize: function()
+ {
+ return this.cookie.name.length + this.cookie.rawValue.length
+ },
};
// ********************************************************************************************* //
View
28 extension/content/firebug/cookies/cookiePanel.js
@@ -481,6 +481,34 @@ CookiePanel.prototype = Obj.extend(Firebug.ActivablePanel,
Firebug.Console.removeListener(Firebug.CookieModule.ConsoleListener);
}
},
+
+ // Support for info tips.
+ showInfoTip: function(infoTip, target, x, y)
+ {
+ var row = Dom.getAncestorByClass(target, "cookieRow");
+ if (row && row.repObject)
+ {
+ if (Dom.getAncestorByClass(target, "cookieSizeCol"))
+ {
+ var infoTipCookieId = "cookiesize-"+row.repObject.name;
+ if (infoTipCookieId == this.infoTipCookieId && row.repObject == this.infoTipCookie)
+ return true;
+
+ this.infoTipCookieId = infoTipCookieId;
+ this.infoTipCookie = row.repObject;
+ return this.populateSizeInfoTip(infoTip, row.repObject);
+ }
+ }
+
+ delete this.infoTipCookieId;
+ return false;
+ },
+
+ populateSizeInfoTip: function(infoTip, cookie)
+ {
+ CookieReps.SizeInfoTip.render(cookie, infoTip);
+ return true;
+ },
});
// ********************************************************************************************* //
View
56 extension/content/firebug/cookies/cookieReps.js
@@ -928,6 +928,62 @@ CookieReps.CookieCleared = domplate(CookieReps.Rep,
}
});
+
+CookieReps.SizeInfoTip = domplate(Firebug.Rep,
+{
+ tag:
+ TABLE({"class": "sizeInfoTip", "id": "cookiesSizeInfoTip", role:"presentation"},
+ TBODY(
+ FOR("size", "$sizeInfo",
+ TAG("$size|getRowTag", {size: "$size"})
+ )
+ )
+ ),
+
+ sizeTag:
+ TR({"class": "sizeInfoRow", $collapsed: "$size|hideRow"},
+ TD({"class": "sizeInfoLabelCol"}, "$size.label"),
+ TD({"class": "sizeInfoSizeCol"}, "$size|formatSize"),
+ TD({"class": "sizeInfoDetailCol"}, "$size|formatNumber")
+ ),
+
+ getRowTag: function(size)
+ {
+ return (size.label == "-") ? this.separatorTag : this.sizeTag;
+ },
+
+ hideRow: function(size)
+ {
+ return size.size < 0;
+ },
+
+ formatSize: function(size)
+ {
+ size = Str.formatSize(size.size);
+ return size;
+ },
+
+ formatNumber: function(size)
+ {
+ return size.size && size.size >= 1024 ? "(" + Str.formatNumber(size.size) + " B)" : "";
+ },
+
+ render: function(cookie, parentNode)
+ {
+ var size = cookie.getSize();
+ var rawSize = cookie.getRawSize();
+ var sizeInfo = [];
+ if (size == rawSize)
+ sizeInfo.push({label: Locale.$STR("cookie.sizeinfo.Size"), size: size});
+ else
+ {
+ sizeInfo.push({label: Locale.$STR("cookie.sizeinfo.Size"), size: size});
+ sizeInfo.push({label: Locale.$STR("cookie.sizeinfo.RawSize"), size: rawSize});
+ }
+ this.tag.replace({sizeInfo: sizeInfo}, parentNode);
+ },
+});
+
// ********************************************************************************************* //
// Header Template (domplate)
View
3  extension/locale/en-US/cookies.properties
@@ -316,3 +316,6 @@ cookies.console.Filter_By_Cookies=Filter By Cookies
# LOCALIZATION NOTE (firebug.shortcut.removeAllCookies.label) Label used by the
# Customize Shortcuts dialog (Firebug menu)
firebug.shortcut.removeAllCookies.label=Remove All Cookies
+
+cookie.sizeinfo.Size=Size
+cookie.sizeinfo.RawSize=Raw Size
Something went wrong with that request. Please try again.