Closed
Bug 1488321
Opened 7 years ago
Closed 7 years ago
Remove nsISHTransaction
Categories
(Core :: DOM: Navigation, enhancement, P3)
Core
DOM: Navigation
Tracking
()
RESOLVED
FIXED
mozilla64
| Tracking | Status | |
|---|---|---|
| firefox64 | --- | fixed |
People
(Reporter: n.nethercote, Assigned: n.nethercote)
References
Details
Attachments
(8 files, 1 obsolete file)
|
1.73 KB,
patch
|
nika
:
review+
|
Details | Diff | Splinter Review |
|
7.69 KB,
patch
|
nika
:
review+
|
Details | Diff | Splinter Review |
|
6.21 KB,
patch
|
nika
:
review+
|
Details | Diff | Splinter Review |
|
7.52 KB,
patch
|
nika
:
review+
|
Details | Diff | Splinter Review |
|
9.73 KB,
patch
|
nika
:
review+
|
Details | Diff | Splinter Review |
|
22.53 KB,
patch
|
nika
:
review+
|
Details | Diff | Splinter Review |
|
45.71 KB,
patch
|
nika
:
review+
|
Details | Diff | Splinter Review |
|
8.18 KB,
patch
|
frg
:
review+
|
Details | Diff | Splinter Review |
It's just a thin wrapper around nsISHEntry.
| Assignee | ||
Comment 1•7 years ago
|
||
It was used to protect against changes in mIndex by history listeners, but the
new code structure doesn't need it, because we want to use mIndex afterwards.
Attachment #9006134 -
Flags: review?(nika)
| Assignee | ||
Updated•7 years ago
|
Assignee: nobody → n.nethercote
Status: NEW → ASSIGNED
| Assignee | ||
Comment 2•7 years ago
|
||
Attachment #9006135 -
Flags: review?(nika)
| Assignee | ||
Comment 3•7 years ago
|
||
In practice it's always non-null, and only half the places that deal with it
have null handling code. So this simplifies things.
Attachment #9006136 -
Flags: review?(nika)
| Assignee | ||
Comment 4•7 years ago
|
||
Specifically:
- Check the nsresult consistently, but don't check (unnecessarily) for null on
success.
- In AddEntry(), move GetTransactionAtIndex() before all state-changing
operations, so we don't end up with partial state updates upon failure.
- Use early returns to reduce indenting.
Attachment #9006137 -
Flags: review?(nika)
| Assignee | ||
Comment 5•7 years ago
|
||
This requires making nsISHEntry `builtinclass`.
Attachment #9006139 -
Flags: review?(nika)
| Assignee | ||
Comment 6•7 years ago
|
||
Because it's a wafer-thin wrapper around nsISHEntry that just complicates
things.
This patch leaves behind a combination of "entry" and "transaction"
terminology. I'll fix that in a subsequent patch.
Attachment #9006140 -
Flags: review?(nika)
| Assignee | ||
Comment 7•7 years ago
|
||
nsISHEntry.index is readonly, but if you pass `true` as getEntryAtIndex()'s
second argument, nsISHEntry.index will be modified. This is pretty gross.
This patch changes `index` so it's not readonly (because it's not!) and removes
getEntryAtIndex()'s second argument.
Attachment #9006141 -
Flags: review?(nika)
| Assignee | ||
Comment 8•7 years ago
|
||
This patch:
- removes GetTransactionAtIndex(), because getTransactionAtIndex() can be used
instead;
- renames a lot of things;
- updates some comments.
Attachment #9006142 -
Flags: review?(nika)
| Assignee | ||
Comment 9•7 years ago
|
||
Updated•7 years ago
|
Attachment #9006134 -
Flags: review?(nika) → review+
Comment 10•7 years ago
|
||
Comment on attachment 9006135 [details] [diff] [review]
Make nsISHTransaction builtin and its attributes infallible
Review of attachment 9006135 [details] [diff] [review]:
-----------------------------------------------------------------
::: docshell/shistory/nsISHTransaction.idl
@@ +12,5 @@
> {
> /**
> * The nsISHEntry for the current transaction.
> */
> + [infallible] attribute nsISHEntry sHEntry;
Huh, I completely forgot I had landed [infallible] on interface types!
::: docshell/shistory/nsSHistory.cpp
@@ +702,5 @@
> /* GetTransactionAtIndex ensures aResult is valid and validates aIndex */
> rv = GetTransactionAtIndex(aIndex, getter_AddRefs(txn));
> if (NS_SUCCEEDED(rv) && txn) {
> // Get the Entry from the transaction
> + txn->GetSHEntry(aResult);
This method technically still returns a nsresult. It might be nicer to do it with a
nsCOMPtr<nsISHEntry> entry = txn->GetSHEntry();
entry.forget(aResult);
to make it clear that we're infallible.
Attachment #9006135 -
Flags: review?(nika) → review+
Updated•7 years ago
|
Attachment #9006136 -
Flags: review?(nika) → review+
Comment 11•7 years ago
|
||
Comment on attachment 9006137 [details] [diff] [review]
Improve GetTransactionAtIndex() result checking
Review of attachment 9006137 [details] [diff] [review]:
-----------------------------------------------------------------
::: docshell/shistory/nsSHistory.cpp
@@ +612,5 @@
>
> + nsCOMPtr<nsISHTransaction> currentTxn;
> + if (mIndex >= 0) {
> + nsresult rv = GetTransactionAtIndex(mIndex, getter_AddRefs(currentTxn));
> + NS_ENSURE_SUCCESS(rv, rv);
Previously this method would've not failed if mIndex >= Length(), right?
Attachment #9006137 -
Flags: review?(nika) → review+
Comment 12•7 years ago
|
||
Comment on attachment 9006139 [details] [diff] [review]
Move the `persist` attribute from nsISHTransaction to nsISHEntry
Review of attachment 9006139 [details] [diff] [review]:
-----------------------------------------------------------------
::: docshell/shistory/nsISHEntry.idl
@@ +405,5 @@
> + * When an entry is serving as a transaction within nsISHistory, this
> + * property specifies if it should persist. If not it will be replaced by
> + * new additions to the list.
> + */
> + [infallible] attribute boolean persist;
Perhaps we should assert that this value is only set & read from toplevel SHEntries?
Attachment #9006139 -
Flags: review?(nika) → review+
Updated•7 years ago
|
Attachment #9006140 -
Flags: review?(nika) → review+
Comment 13•7 years ago
|
||
Comment on attachment 9006141 [details] [diff] [review]
Fix up nsISHEntry.{index,getEntryAtIndex()}
Review of attachment 9006141 [details] [diff] [review]:
-----------------------------------------------------------------
::: toolkit/modules/sessionstore/SessionHistory.jsm
@@ +313,5 @@
>
> // Select the right history entry.
> let index = tabData.index - 1;
> if (index < history.count && history.index != index) {
> + history.index = index;
A vast improvement across the board. Thanks!
Attachment #9006141 -
Flags: review?(nika) → review+
Comment 14•7 years ago
|
||
Comment on attachment 9006142 [details] [diff] [review]
Remove all traces of the "transaction" terminology in SHistory
Review of attachment 9006142 [details] [diff] [review]:
-----------------------------------------------------------------
::: docshell/base/nsDocShell.cpp
@@ +2288,5 @@
> // which session history entries are candidates for content viewer
> // eviction. We need to adjust by the number of entries that we
> // just purged from history, so that we look at the right session history
> // entries during eviction.
> + if (aIndex == mPreviousEntryIndex) { // njn: rename
nit: Can you add more detail to this todo?
Attachment #9006142 -
Flags: review?(nika) → review+
Updated•7 years ago
|
Priority: -- → P3
| Assignee | ||
Comment 15•7 years ago
|
||
> > + if (aIndex == mPreviousEntryIndex) { // njn: rename
>
> nit: Can you add more detail to this todo?
Whoops, that's not supposed to be there :) Thanks for spotting.
| Assignee | ||
Comment 16•7 years ago
|
||
> Huh, I completely forgot I had landed [infallible] on interface types!
That was you? Cool. I think I was the one who landed the initial support for builtin types :) I updated the XPIDL wiki page to say that it works with interface types.
| Assignee | ||
Comment 17•7 years ago
|
||
Jorg, as usual, this compiles but I make no other promises :)
Attachment #9006400 -
Flags: review?(jorgk)
| Assignee | ||
Updated•7 years ago
|
Attachment #9006141 -
Attachment is obsolete: true
Comment 18•7 years ago
|
||
Comment on attachment 9006400 [details] [diff] [review]
Update comm-central for nsISHEntry.{index,getEntryAtIndex()} changes
Thanks, but this is all suite/ code.
Attachment #9006400 -
Flags: review?(jorgk) → review?(frgrahl)
| Assignee | ||
Comment 19•7 years ago
|
||
> > + txn->GetSHEntry(aResult);
>
> This method technically still returns a nsresult. It might be nicer to do it with a
>
> nsCOMPtr<nsISHEntry> entry = txn->GetSHEntry();
> entry.forget(aResult);
>
> to make it clear that we're infallible.
It's a good suggestion, but GetSHEntry() is removed in a later patch so I won't bother changing it.
| Assignee | ||
Comment 20•7 years ago
|
||
> Previously this method would've not failed if mIndex >= Length(), right?
Correct. I think it's reasonable for it to fail in that case, given that `mIndex >= Length()` should only occur if there is a bug within this code.
| Assignee | ||
Comment 21•7 years ago
|
||
> Perhaps we should assert that this value is only set & read from toplevel SHEntries?
I tried doing this, by adding `!mParent` assertions in GetPersist() and SetPersist() but I'm getting tons of violations for GetPersist() calls that originate from JS code. Not sure why, perhaps I've misunderstood how parenting works. I will land the existing patches because I don't want that to block, but a follow-up is possible if you think it's important.
Comment 22•7 years ago
|
||
Pushed by nnethercote@mozilla.com:
https://hg.mozilla.org/integration/mozilla-inbound/rev/89a18b3527ec
Remove `currentIndex` in nsSHistory::AddEntry(). r=nika
https://hg.mozilla.org/integration/mozilla-inbound/rev/b737e972ee94
Make nsISHTransaction builtin and its attributes infallible. r=nika
https://hg.mozilla.org/integration/mozilla-inbound/rev/ebe467bd12d8
Enforce non-nullness for nsISHTransaction.sHEntry. r=nika
https://hg.mozilla.org/integration/mozilla-inbound/rev/e0a9359cbabc
Improve GetTransactionAtIndex() result checking. r=nika
https://hg.mozilla.org/integration/mozilla-inbound/rev/afb85694d4ff
Move the `persist` attribute from nsISHTransaction to nsISHEntry. r=nika
https://hg.mozilla.org/integration/mozilla-inbound/rev/107e7b610762
Remove nsISHTransaction. r=nika
https://hg.mozilla.org/integration/mozilla-inbound/rev/f451bd99a45e
Fix up nsISHEntry.{index,getEntryAtIndex()}. r=nika
https://hg.mozilla.org/integration/mozilla-inbound/rev/00d48361106a
Remove all traces of the "transaction" terminology in SHistory. r=nika.
Comment 23•7 years ago
|
||
| bugherder | ||
https://hg.mozilla.org/mozilla-central/rev/89a18b3527ec
https://hg.mozilla.org/mozilla-central/rev/b737e972ee94
https://hg.mozilla.org/mozilla-central/rev/ebe467bd12d8
https://hg.mozilla.org/mozilla-central/rev/e0a9359cbabc
https://hg.mozilla.org/mozilla-central/rev/afb85694d4ff
https://hg.mozilla.org/mozilla-central/rev/107e7b610762
https://hg.mozilla.org/mozilla-central/rev/f451bd99a45e
https://hg.mozilla.org/mozilla-central/rev/00d48361106a
Status: ASSIGNED → RESOLVED
Closed: 7 years ago
status-firefox64:
--- → fixed
Resolution: --- → FIXED
Target Milestone: --- → mozilla64
Comment 24•7 years ago
|
||
Comment on attachment 9006400 [details] [diff] [review]
Update comm-central for nsISHEntry.{index,getEntryAtIndex()} changes
Thanks. Can't test it now because of other breakages but looks A++.
Attachment #9006400 -
Flags: review?(frgrahl) → review+
Comment 25•7 years ago
|
||
Pushed by frgrahl@gmx.net:
https://hg.mozilla.org/comm-central/rev/4e7bcb952b29
Update comm-central for nsISHEntry.{index,getEntryAtIndex()} changes. r=frg
You need to log in
before you can comment on or make changes to this bug.
Description
•