Closed
Bug 517755
Opened 17 years ago
Closed 17 years ago
use smart getters in View Source window
Categories
(Toolkit :: View Source, defect)
Toolkit
View Source
Tracking
()
RESOLVED
FIXED
mozilla1.9.3a1
People
(Reporter: dao, Assigned: dao)
Details
Attachments
(1 file, 2 obsolete files)
|
28.16 KB,
patch
|
neil
:
review+
|
Details | Diff | Splinter Review |
just like browser.js
Attachment #401699 -
Flags: review?(neil)
Comment 1•17 years ago
|
||
Comment on attachment 401699 [details] [diff] [review]
patch
>diff --git a/browser/components/privatebrowsing/test/browser/browser_privatebrowsing_viewsource.js b/browser/components/privatebrowsing/test/browser/browser_privatebrowsing_viewsource.js
[I'm not a browser peer]
>+ gBrowser.docShell
>+ .QueryInterface(Ci.nsIInterfaceRequestor)
>+ .getInterface(Ci.nsISelectionDisplay)
>+ .QueryInterface(Ci.nsISelectionController)
>+ .scrollSelectionIntoView(Ci.nsISelectionController.SELECTION_NORMAL,
>+ Ci.nsISelectionController.SELECTION_ANCHOR_REGION,
>+ true);
Could this use getSelectionController() ?
>+function getNavToolbox() document.getElementById("appcontent");
This is not my idea of readability... do we have precedent for this?
| Assignee | ||
Comment 2•17 years ago
|
||
(In reply to comment #1)
> (From update of attachment 401699 [details] [diff] [review])
> >diff --git a/browser/components/privatebrowsing/test/browser/browser_privatebrowsing_viewsource.js b/browser/components/privatebrowsing/test/browser/browser_privatebrowsing_viewsource.js
> [I'm not a browser peer]
Yeah, feel free to ignore that change.
> >+ gBrowser.docShell
> >+ .QueryInterface(Ci.nsIInterfaceRequestor)
> >+ .getInterface(Ci.nsISelectionDisplay)
> >+ .QueryInterface(Ci.nsISelectionController)
> >+ .scrollSelectionIntoView(Ci.nsISelectionController.SELECTION_NORMAL,
> >+ Ci.nsISelectionController.SELECTION_ANCHOR_REGION,
> >+ true);
> Could this use getSelectionController() ?
yep
> >+function getNavToolbox() document.getElementById("appcontent");
> This is not my idea of readability... do we have precedent for this?
Not in toolkit, afaik.
I've also added a getter for the string bundle.
Attachment #401699 -
Attachment is obsolete: true
Attachment #403200 -
Flags: review?(neil)
Attachment #401699 -
Flags: review?(neil)
| Assignee | ||
Updated•17 years ago
|
Summary: use smart getter for the view-source browser → use smart getters in View Source
Comment 3•17 years ago
|
||
(In reply to comment #2)
> (In reply to comment #1)
> > >+function getNavToolbox() document.getElementById("appcontent");
> > This is not my idea of readability... do we have precedent for this?
> Not in toolkit, afaik.
You then removed that particular one only, but unfortunately I had just picked on that one as being easiest to find in what Bugzilla thinks is a reasonably sized textarea on the machine I was using to review.
Comment 4•17 years ago
|
||
Comment on attachment 403200 [details] [diff] [review]
patch v2
>+ var webnav = getWebNavigation();
>+ if (webnav) {
>+ delete this.gPageLoader;
>+ return this.gPageLoader = webnav.QueryInterface(Ci.nsIWebPageDescriptor);
>+ }
>+ return null;
Nit: inconsistent with the code above which uses if (!foo) return null;
>+ gBrowser.addProgressListener(gViewSourceProgressListener,
>+ Ci.nsIWebProgress.NOTIFY_ALL);
Nit: this is a lie, it's only interested in location changes.
>+function isHistoryEnabled()
>+ !gBrowser.hasAttribute("disablehistory");
Ah, now this was the ugliest one, but not forgetting...
>-function getPPBrowser()
>-{
>- return document.getElementById("content");
>-}
>+function getPPBrowser() gBrowser;
>
>+// printUtils.js uses this
... printUtils uses getPPBrowser() too ;-)
>+ var viewSourceBundle = gViewSourceBundle;
This seems somewhat pointless?
>+ selCon.setDisplaySelection(selCon.SELECTION_ON);
I know why this works, but I'd still prefer Ci.nsISelectionController
| Assignee | ||
Comment 5•17 years ago
|
||
(In reply to comment #4)
> >+function isHistoryEnabled()
> >+ !gBrowser.hasAttribute("disablehistory");
> Ah, now this was the ugliest one, but not forgetting...
I'm not sure I see your point. Are you saying that we shouldn't use that language feature at all? Maybe it doesn't immediately match your sense of readability just because it's a fairly new feature?
> >+function getPPBrowser() gBrowser;
> >
> >+// printUtils.js uses this
> ... printUtils uses getPPBrowser() too ;-)
Yeah, but it has PP in its name, which makes that somewhat more discoverable.
> >+ selCon.setDisplaySelection(selCon.SELECTION_ON);
> I know why this works, but I'd still prefer Ci.nsISelectionController
I prefer it this way (less XPCOM foo), but ok.
| Assignee | ||
Comment 6•17 years ago
|
||
Attachment #403200 -
Attachment is obsolete: true
Attachment #404199 -
Flags: review?(neil)
Attachment #403200 -
Flags: review?(neil)
Comment 7•17 years ago
|
||
(In reply to comment #5)
> (In reply to comment #4)
> > >+function isHistoryEnabled()
> > >+ !gBrowser.hasAttribute("disablehistory");
> > Ah, now this was the ugliest one, but not forgetting...
> I'm not sure I see your point. Are you saying that we shouldn't use that
> language feature at all?
Oh, I can see its usefulness in 1-line anonymous callbacks, because the idea there is that removing the braces improves readability.
Comment 8•17 years ago
|
||
Comment on attachment 404199 [details] [diff] [review]
patch v3
>@@ -289,34 +245,37 @@ function onLoadContent()
>+ if (isHistoryEnabled())
>+ UpdateBackForwardCommands();
Does that actually work with bfcache, or does bfcache not apply here?
| Assignee | ||
Comment 9•17 years ago
|
||
(In reply to comment #8)
> (From update of attachment 404199 [details] [diff] [review])
> >@@ -289,34 +245,37 @@ function onLoadContent()
> >+ if (isHistoryEnabled())
> >+ UpdateBackForwardCommands();
> Does that actually work with bfcache, or does bfcache not apply here?
It does apply here, as far as I can tell, and onLoadContent gets called correctly.
Comment 10•17 years ago
|
||
(In reply to comment #9)
>(In reply to comment #8)
>>(From update of attachment 404199 [details] [diff] [review] [details])
>>>@@ -289,34 +245,37 @@ function onLoadContent()
>>>+ if (isHistoryEnabled())
>>>+ UpdateBackForwardCommands();
>>Does that actually work with bfcache, or does bfcache not apply here?
>It does apply here, as far as I can tell, and onLoadContent gets called
>correctly.
I'm not seeing bfcache get invoked, which is why onLoadContent gets called.
Comment 11•17 years ago
|
||
To be specific, the first call to CanSavePresentation (from InternalLoad) returns true, but the second call (from CreateContentViewer) returns false, ostensibly because of a pending request for console.properties!
Comment 12•17 years ago
|
||
(In reply to comment #11)
> To be specific, the first call to CanSavePresentation (from InternalLoad)
> returns true, but the second call (from CreateContentViewer) returns false,
> ostensibly because of a pending request for console.properties!
Well, that request is expected, because that was the link I clicked on, duh.
But I don't see why the old document is seeing it in its load group.
Comment 13•17 years ago
|
||
> ostensibly because of a pending request for console.properties!
This is view-source, so the loadgroup will have at least two requests in it: the view-source channel and the underlying (http, file, whatever) channel. So as things stand, this will never get bfcached.
Comment 14•17 years ago
|
||
Oh, and the loadgroup is per-docshell, not per-document, which is why we need the whole "check whether the loadgroup happens to only have the one request for the new document we're loading" hack.
Comment 15•17 years ago
|
||
Comment on attachment 404199 [details] [diff] [review]
patch v3
OK, so I think we need a big comment in case someone makes view source documents cacheable.
Attachment #404199 -
Flags: review?(neil) → review+
Comment 16•17 years ago
|
||
Is there a reason to not use pageshow/pagehide instead?
| Assignee | ||
Comment 17•17 years ago
|
||
landed with pageshow/pagehide:
http://hg.mozilla.org/mozilla-central/rev/0a7dd88dbe67
Status: ASSIGNED → RESOLVED
Closed: 17 years ago
Resolution: --- → FIXED
Summary: use smart getters in View Source → use smart getters in View Source window
Target Milestone: --- → mozilla1.9.3a1
Comment 18•17 years ago
|
||
Might have been worth renaming the methods too, but nm.
You need to log in
before you can comment on or make changes to this bug.
Description
•