Closed
Bug 343515
Opened 18 years ago
Closed 14 years ago
need API for tabbrowsers to tell docshells they're visible/hidden
Categories
(Core :: DOM: Navigation, defect)
Core
DOM: Navigation
Tracking
()
RESOLVED
FIXED
mozilla2.0b4
Tracking | Status | |
---|---|---|
blocking2.0 | --- | beta5+ |
People
(Reporter: csthomas, Assigned: bholley)
References
(Blocks 1 open bug)
Details
(Keywords: dev-doc-complete)
Attachments
(5 files, 7 obsolete files)
(deleted),
patch
|
bzbarsky
:
superreview+
|
Details | Diff | Splinter Review |
(deleted),
patch
|
bzbarsky
:
superreview+
|
Details | Diff | Splinter Review |
(deleted),
patch
|
Dolske
:
review+
|
Details | Diff | Splinter Review |
(deleted),
patch
|
Gavin
:
review+
|
Details | Diff | Splinter Review |
(deleted),
patch
|
Details | Diff | Splinter Review |
<dbaron> CTho, right now tabbrowser doesn't really communicate to Gecko which tab is active and which isn't
<dbaron> CTho, it probably should, formally
<CTho> dbaron: oh. is there an API for that already?
<dbaron> CTho, no, there isn't an API
Comment 1•18 years ago
|
||
So if you look at GetVisibility (on nsIBaseWindow), that seems to be pretty much what we want. We could try to teach the tree owner to be smarter or teach tabbrowser to communicate more with the tree owner. Or something...
Note that in an actual embedding situation, with an embeddor-implemented tree owner, this is all a non-issue -- just teach your tree owner about your tab implementation. This bug is about the xul treeowner implementation in particular, right?
Comment 2•18 years ago
|
||
I've thought GetVisibility would be better if there were a SetVisibility rather than trying to poke around and figure it out.
Comment 3•15 years ago
|
||
Making an observation with MS's VBA API vs FF.
VBA doesn't provide enough information for this type of coding to check active/visible/locked/enabled tabs. For reference: a VBA tab control which might be what IE's tab browser feature is based on (and all of IE's options windows), you only get the current tab's index number (0->?) as a reference for the active tab which is set = to main control's value.
Only problem is that there no simple code to check 'if IsActive(mytabName or mytabIndexNumber) Then yyy' to check active status. It stores the active tab # after a tab change.
You cannot just check to see if something is visible by a function, but you have to do some unnecessary logic like 'if tab.index(tab.index).Name = xxx then tab.index(tab.index).Visible = False' and you have to check all index and logic possibilities.
And, If you need logic based on that specific tab vs another, then you have to know the logic about which tab is active by checking something like the title of the tab before you can decide what action to take.
I imagine both the Tools>Options and Tools>Add-on's panels, and now the CTRL-TABs Panel as well as tabbrowser are coded differently, but they are all basically similar UI constructs to the user. [and the common API is probably the reason MS was so quick to add Tab-Browsing because everything in IE uses the same API for all UI interfaces]
I would think having a more powerful target goal API for this could be more useful down the road for future generations of FF, since so many pieces of FF are tab/panel/window type contructs, [ie. coded different multiple times, but similar logic ;-)].
Assignee | ||
Comment 4•15 years ago
|
||
As a note, somewhere we probably want to handle nsIDocShell::isOffscreenBrowser
http://mxr.mozilla.org/mozilla-central/source/docshell/base/nsIDocShell.idl#485
Since it seems to be a flag saying "offscreen, but treat it as onscreen"
Assignee | ||
Updated•15 years ago
|
Assignee: nobody → bobbyholley
Status: UNCONFIRMED → ASSIGNED
Ever confirmed: true
Assignee | ||
Comment 5•15 years ago
|
||
WIP patch.
This seems to work. However, one problem is that, when opening a link in a background tab, the presshell gets instantiated before the docshell is set to be inactive. This is a problem, because it means that we'll request decode on everything in bug 512260. I'm hoping bz can tell me a way for presshells to start out inactive if they're opened in a background tab.
Assignee | ||
Comment 6•15 years ago
|
||
Er, CCing bz, since I just asked him a question in the previous comment.
Comment 7•15 years ago
|
||
I'm confused. The presshell is instantiated but there is no DOM or anything, right? So there's nothing to request decode on.... Then you set it inactive. Or am I missing something?
Comment 8•15 years ago
|
||
Oh, and this still needs some way for non-current-firefox embeddings (e.g. e10s) to set things up correctly via nsIWebBrowser-and-friends.
Assignee | ||
Comment 9•15 years ago
|
||
(In reply to comment #7)
> I'm confused. The presshell is instantiated but there is no DOM or anything,
> right? So there's nothing to request decode on.... Then you set it inactive.
> Or am I missing something?
Shrug - as long as you think there's not much possibility for race-y behavior, then it's fine by me.
Comment 10•15 years ago
|
||
I doubt there really is.
Assignee | ||
Comment 11•14 years ago
|
||
working on this again. Unbitrotted the patch. Seems to work as before.
Attachment #401797 -
Attachment is obsolete: true
Assignee | ||
Comment 12•14 years ago
|
||
Added a patch that handles embedding. Flagging gavin for review, bz for sr.
Pushed to try as c97faaddb0b0.
Attachment #457316 -
Attachment is obsolete: true
Attachment #459483 -
Flags: superreview?(bzbarsky)
Attachment #459483 -
Flags: review?(gavin.sharp)
Comment 13•14 years ago
|
||
Comment on attachment 459483 [details] [diff] [review]
patch v3
Why do you need to qualify the GetPresShell call? You shouldn't need that.
Please add the new attribute at the end of the interface.
You need to rev the docshell iid.
For the presshell's mIsActive, just put it on nsIPresShell, please. That will avoid the virtual function calls, and we'll need a getter for it anyway. Or will SetIsActive on the presshell need access to PresShell members (as opposed to nsIPresShell ones)?
Attachment #459483 -
Flags: superreview?(bzbarsky) → superreview-
Assignee | ||
Comment 14•14 years ago
|
||
Updated patch addressing bz's review comments. Reflagging.
Attachment #459483 -
Attachment is obsolete: true
Attachment #459528 -
Flags: superreview?(bzbarsky)
Attachment #459528 -
Flags: review?(gavin.sharp)
Attachment #459483 -
Flags: review?(gavin.sharp)
Assignee | ||
Comment 15•14 years ago
|
||
pushed to try as c97faaddb0b0, since the old try push apparently got cancelled anyway.
Updated•14 years ago
|
Attachment #459528 -
Attachment is patch: true
Attachment #459528 -
Attachment mime type: application/octet-stream → text/plain
Comment 16•14 years ago
|
||
Comment on attachment 459528 [details] [diff] [review]
patch v4
>+++ b/layout/base/nsIPresShell.h
>+ virtual nsresult SetIsActive(PRBool aIsActive)
>+ {
>+ mIsActive = aIsActive;
>+ return NS_OK;
>+ }
>+
>+ virtual nsresult GetIsActive(PRBool *rv)
>+ {
>+ *rv = mIsActive;
>+ return NS_OK;
>+ }
>+
I was thinking more like:
void SetIsActive(PRBool aIsActive)
{
mIsActive = aIsActive;
}
PRBool IsActive()
{
return mIsActive;
}
with none of that COM-alike jazz. ;)
Though the setter might need to be virtual and be implemented as nsIPresShell::SetIsActive in nsPresShell.cpp for the stuff we want to do with refresh drivers. But we can worry about that when we're hooking those up. Inline for now.
>+++ b/layout/base/nsPresShell.cpp
>+ // Get our activeness from the docShell.
That chunk of code should probably move into a helper function and run both in Init and in Thaw. Otherwise if the active state of a docshell changes while the presshell is in bfcache and then you hit the back button the presshell's state will be wrong. We could use tests for that if possible...
Attachment #459528 -
Flags: superreview?(bzbarsky) → superreview-
Assignee | ||
Comment 17•14 years ago
|
||
addressed bz's new comments. Flagging.
Attachment #459528 -
Attachment is obsolete: true
Attachment #460086 -
Flags: superreview?(bzbarsky)
Attachment #460086 -
Flags: review?(gavin.sharp)
Attachment #459528 -
Flags: review?(gavin.sharp)
Comment 18•14 years ago
|
||
Comment on attachment 460086 [details] [diff] [review]
patch v5
sr=bzbarsky
Attachment #460086 -
Flags: superreview?(bzbarsky) → superreview+
Comment 19•14 years ago
|
||
Comment on attachment 460086 [details] [diff] [review]
patch v5
>--- a/browser/base/content/tabbrowser.xml
>+++ b/browser/base/content/tabbrowser.xml
>@@ -722,28 +722,31 @@
>
> <method name="updateCurrentBrowser">
> <parameter name="aForceUpdate"/>
> <body>
> <![CDATA[
> var newBrowser = this.getBrowserAtIndex(this.tabContainer.selectedIndex);
> if (this.mCurrentBrowser == newBrowser && !aForceUpdate)
> return;
>+ newBrowser.docShell.isActive = true;
Can you do this right below or above newBrowser.setAttribute("type", "content-primary");?
Comment 20•14 years ago
|
||
I just realized something. For subframes, shouldn't we be inheriting activeness from the parent?
Assignee | ||
Comment 21•14 years ago
|
||
Added a patch addressing bz and dao's latest comments.
Attachment #460277 -
Flags: review?(gavin.sharp)
Assignee | ||
Updated•14 years ago
|
Attachment #460086 -
Flags: review?(gavin.sharp)
Assignee | ||
Comment 22•14 years ago
|
||
This blocks bug 512260, which blocks a blocker (bug 563088). Nominating.
blocking2.0: --- → ?
Updated•14 years ago
|
blocking2.0: ? → betaN+
Comment 23•14 years ago
|
||
The way comment 20 was addressed is wrong in several ways:
1) You probably don't want to cross type boundaries when setting active on the
kids.
2) It doesn't handle the bfcache restoration case correctly, as far as I can see.
3) It doesn't handle navigation from one page with subframes to another
correctly...
Assignee | ||
Comment 24•14 years ago
|
||
(In reply to comment #23)
> The way comment 20 was addressed is wrong in several ways:
>
> 1) You probably don't want to cross type boundaries when setting active on the
> kids.
What type boundaries are being crossed? It's an nsIDocShell method calling other nsIDocShell methods, no?
> 2) It doesn't handle the bfcache restoration case correctly, as far as I can
> see.
> 3) It doesn't handle navigation from one page with subframes to another
> correctly...
I confess to not understand these comments. This code is more or less the same as before, all we're doing now is passing along the call to any descendants we might have rather than leaving them in the dark. What is it about having descendants that made this work before but not now? Maybe you can explain it to me on IRC if bmo is too cumbersome for that.
Assignee | ||
Updated•14 years ago
|
Attachment #460277 -
Flags: review?(gavin.sharp)
Comment 25•14 years ago
|
||
> It's an nsIDocShell method calling other nsIDocShell methods, no?
Yes. So if someone calls SetActive(PR_TRUE) on the root chrome docshell for a Firefox window, it will happily call SetActive(PR_TRUE) on every single tab in that window. That seems wrong to me... but maybe it's ok.
> I confess to not understand these comments.
Here's an example. Say I have a tab. It's not the currently active tab, so its docshell is marked inactive.
Now the page in that tab executes |window.location.href = "some url"|. The new url has a subframe. This creates a new docshell which is a child of our docshell. This docshell defaults to being active, and no one tells it otherwise. Its presshell likewise thinks its active.
> What is it about having descendants that made this work before but not now?
Nothing. Descendants didn't work at all correctly before....
I we're ok with crossing the chrome/content boundary, I think the right way to handle this is to propagate the active state to kids in SetDocLoaderParent and RestoreFromHistory (see where we make the SetAllowJavascript calls).
Assignee | ||
Comment 26•14 years ago
|
||
Updated patch, handling bz's comments the right way.
Attachment #460277 -
Attachment is obsolete: true
Assignee | ||
Comment 27•14 years ago
|
||
Tests, which triple-check that we're doing this properly. ;-)
Assignee | ||
Comment 28•14 years ago
|
||
So this bug should be in good shape now. I spent part of yesterday and all of today sorting through some issues in order to test this stuff properly, but now it's handled and we have tests that pass.
I pushed this to try as 6be97fbeeca9, after which point I'll reflag for reviews and then hopefully land all this stuff.
Assignee | ||
Comment 29•14 years ago
|
||
Comment on attachment 461077 [details] [diff] [review]
patch v7
Looks green on try with the tests included. Flagging for review.
Hopefully this is the last time. ;-)
Attachment #461077 -
Flags: superreview?(bzbarsky)
Attachment #461077 -
Flags: review?(gavin.sharp)
Assignee | ||
Updated•14 years ago
|
Attachment #461079 -
Flags: review?(dolske)
Comment 30•14 years ago
|
||
So for docshell, in RestoreFromHistory I think the code is wrong. What it should do instead is walk the list of kids and explicitly call SetIsActive(mIsActive) on them all. Otherwise subframes of bfcached pages will end up with the active state from before they went into bfcache.
Comment 31•14 years ago
|
||
Oh, and the rest of the patch looks great.
Comment 32•14 years ago
|
||
Comment on attachment 461077 [details] [diff] [review]
patch v7
So with that change, sr=me
Attachment #461077 -
Flags: superreview?(bzbarsky) → superreview+
Assignee | ||
Comment 33•14 years ago
|
||
Comment on attachment 461079 [details] [diff] [review]
tests v1
I modified the test to test the path bz brought up, and it still passes when it should fail. I'm investigating this now, but for the mean time I'm canceling review.
Attachment #461079 -
Flags: review?(dolske)
Assignee | ||
Comment 34•14 years ago
|
||
I just stepped through the part of the test I added that should fail but doesn't. What seems to be happening is that we call GoForward(), get to nsDocShell::RestorePresentation(), and then bail because we don't have a saved presentation:
http://mxr.mozilla.org/mozilla-central/source/docshell/base/nsDocShell.cpp#6555
I'll investigate this more tomorrow, but if anyone has any insight on what might cause this to be not saved, that would be very helpful. The page has two iframes, one of which has its own iframe (so 3 levels deep), if that makes a difference.
Comment 35•14 years ago
|
||
That part shouldn't matter.
You want to step into the CanSavePresentation called under the location set that navigates to pg3 to see what's going on there...
Comment 36•14 years ago
|
||
Also, a chrome test might have been more appropriate for the docshell bits than a browser test. Probably ok either way, though.
Assignee | ||
Comment 37•14 years ago
|
||
Uploaded new tests. These correctly detect the error in the previous patch (and thus fail).
These took me a long time to get right. First of all, mIsDocumentLoaded gets set in the post-fire load handler, so "load" event handlers get called when it's still false. This was a problem, because it meant that we were trying to navigate to a new page before the old one was completely done, meaning that we threw away the presentation instead of stashing it in the bfcache. So now we call executeSoon() on all the callbacks we use to progress through the test.
Furthermore, I was getting screwed up by "load" not firing on back/forward. Thanks to gavin for pointing me towards "pageshow" and "pagehide". Reflagging dolske for review on these.
Attachment #461079 -
Attachment is obsolete: true
Attachment #461367 -
Flags: review?(dolske)
Assignee | ||
Comment 38•14 years ago
|
||
Added a patch that fixes the bug bz pointed out, however it doesn't quite follow his instructions.
> What it should do instead is walk the list of kids and explicitly call
> SetIsActive(mIsActive) on them all.
I'm pretty sure this isn't necessary. Right before the code in question, we call AddChild():
http://mxr.mozilla.org/mozilla-central/source/docshell/base/nsDocShell.cpp#6908
This calls AddChildLoader():
http://mxr.mozilla.org/mozilla-central/source/docshell/base/nsDocShell.cpp#2997
Which calls SetDocLoaderParent():
http://mxr.mozilla.org/mozilla-central/source/uriloader/base/nsDocLoader.cpp#721
This is code that the patch already modifies to set activeness correctly.
bz - can you confirm this? Is there any reason to walk the children explicitly?
Comment 39•14 years ago
|
||
> Which calls SetDocLoaderParent():
Ah, which calls SetIsActive on self, and hence will call it on descendants too. OK, good. I don't know what I was thinking when I made that comment. ;)
I do think it's worth adding a comment in RestorePresentation that explains that we're purposefully inheriting parent's active state. Other than that, this looks great.
Assignee | ||
Comment 40•14 years ago
|
||
Added the comment that bz wanted. This patch should be 100% ready to go now, pending gavin's review. Flagging.
Attachment #461369 -
Attachment is obsolete: true
Attachment #461585 -
Flags: review?(gavin.sharp)
Assignee | ||
Updated•14 years ago
|
Attachment #461077 -
Flags: review?(gavin.sharp)
Comment 41•14 years ago
|
||
Comment on attachment 461367 [details] [diff] [review]
tests v2
>diff --git a/docshell/test/navigation/Makefile.in b/docshell/test/navigation/Makefile.in
>+_BROWSER_TEST_FILES = \
These will fail in Fennec until we implement isActive setting there, right? Need a
ifneq (mobile,$(MOZ_BUILD_APP))
here and a followup filed on getting this into Fennec as well, if so.
Comment 42•14 years ago
|
||
Comment on attachment 461585 [details] [diff] [review]
patch v9
r=me on the browser/ part.
Attachment #461585 -
Flags: review?(gavin.sharp) → review+
Assignee | ||
Comment 44•14 years ago
|
||
Pushed the code bits to mc:
http://hg.mozilla.org/mozilla-central/rev/b7836c3a63db
I'll land the tests later when I get review.
Updated•14 years ago
|
Status: ASSIGNED → RESOLVED
Closed: 14 years ago
Flags: in-testsuite?
OS: Windows XP → All
Hardware: x86 → All
Resolution: --- → FIXED
Target Milestone: --- → mozilla2.0b4
Comment 45•14 years ago
|
||
Comment on attachment 461367 [details] [diff] [review]
tests v2
I'm just rs+ing this on grounds that I don't see anything obviously terrible. If there was something you specifically wanted sanity checked, flag me^H^Hjoe for review again.
Side note: probably better to either preemptively check in with tests or wait for full reviews... code without tests in the tree is just asking for trouble. :)
Attachment #461367 -
Flags: review?(dolske) → review+
Assignee | ||
Comment 46•14 years ago
|
||
I filed bug 585771 and bug 585780 to get support for this into fennec and e10s.
Assignee | ||
Comment 47•14 years ago
|
||
Fixed the fennec build problems gavin pointed out. This is green on try.
Assignee | ||
Comment 48•14 years ago
|
||
Pushed the tests to mozilla-central:
http://hg.mozilla.org/mozilla-central/rev/f1e252898bca
Flags: in-testsuite? → in-testsuite+
Updated•14 years ago
|
Keywords: dev-doc-needed
Comment 49•14 years ago
|
||
Documentation updated:
https://developer.mozilla.org/en/XPCOM_Interface_Reference/nsIWebBrowser
https://developer.mozilla.org/en/XPCOM_Interface_Reference/nsIDocShell
And mentioned on Firefox 4 for developers page.
Keywords: dev-doc-needed → dev-doc-complete
You need to log in
before you can comment on or make changes to this bug.
Description
•