Some engine manager cleanup found by SeaMonkey reviews

RESOLVED FIXED in Firefox 13

Status

()

Firefox
Search
RESOLVED FIXED
6 years ago
6 years ago

People

(Reporter: Robert Kaiser, Assigned: Robert Kaiser)

Tracking

unspecified
Firefox 13
Points:
---
Dependency tree / graph

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(6 attachments, 1 obsolete attachment)

(Assignee)

Description

6 years ago
Splitting off the engine manager parts from bug 643172.
(Assignee)

Updated

6 years ago
Assignee: nobody → kairo
(Assignee)

Comment 1

6 years ago
Created attachment 580760 [details] [diff] [review]
services, v1

Here's the first and probably largest part - Switching engine manager to using Services.jsm, and as it's closely connected, it also removes redundancy in removing the observer, putting it in a common destroy/onunload function, obsoleting the onCancel one.
Attachment #580760 - Flags: review?(gavin.sharp)
(Assignee)

Comment 2

6 years ago
Created attachment 580762 [details] [diff] [review]
engine.name, v1

This patch fixes the use of engine.name outside the loop where it's declared with a let. This is a generic bug in current engine manager, as there it currently must end up being undefined, the way I'm reading the code (and Neil agreed with that POV in the SeaMonkey reviews).
Attachment #580762 - Flags: review?(gavin.sharp)
(Assignee)

Comment 3

6 years ago
Created attachment 580764 [details] [diff] [review]
observer, v1

Here's a patch for the observer - only "engine-changed" needs to .invalidate() as .rowCountChanged() does the invalidate/update to the tree display anyhow (in an optimized way to only do it for the affected rows), calling .invalidate() there will just be more work with the same effect. This ends up being a slight perf fix.
(Also, the "Not relevant" cases also can now exit the function normally, no need to early return there).
Attachment #580764 - Flags: review?(gavin.sharp)
(Assignee)

Comment 4

6 years ago
Created attachment 580765 [details] [diff] [review]
_cloneEngine, v1

This patch makes _cloneEngine easier to read and debug (and also makes the object init to be an object and not an array).
When I read this function the first time, I had difficulty wrapping my head around what this intermediate variable was, in the patched version it's clear that it's a cloned object. Also, the function name now correlates with the method name it has in EngineStore.
Attachment #580765 - Flags: review?(gavin.sharp)
(Assignee)

Comment 5

6 years ago
Created attachment 580766 [details] [diff] [review]
onSelect, v1

This patch makes onSelect better readable, also avoiding another intermittent variable and using the nice fact that if we only have one engine left, it's both the first and last one in the list.
Attachment #580766 - Flags: review?(gavin.sharp)
(Assignee)

Comment 6

6 years ago
Created attachment 580767 [details] [diff] [review]
onSelect, v1

Actually, this is the correct patch for this (the original comment is correct).
Attachment #580766 - Attachment is obsolete: true
Attachment #580766 - Flags: review?(gavin.sharp)
Attachment #580767 - Flags: review?(gavin.sharp)
(Assignee)

Comment 7

6 years ago
Created attachment 580769 [details] [diff] [review]
nits, v1

OK, here's the last patch in this series, consisting of a number of nits - whitespace fixes, superfluous brackets, missing semicolons, superfluous "!important" markers, unneeded spacers, a better understandable button ID - and using the fact that we can use .currentIndex instead of re-calculating the position of the just-selected item another time.
Attachment #580769 - Flags: review?(gavin.sharp)
Attachment #580765 - Flags: review?(gavin.sharp) → review+
Attachment #580767 - Flags: review?(gavin.sharp) → review+
Attachment #580760 - Flags: review?(gavin.sharp) → review+
Attachment #580764 - Flags: review?(gavin.sharp) → review+
Comment on attachment 580762 [details] [diff] [review]
engine.name, v1

This fixes the engine duplicate case, but doesn't properly handle the bookmark duplication case (dupName will be ""), so it's necessary but not sufficient. I guess maybe we need to have two different error messages ("used by 'Someengine'" vs. "used by a bookmark.").
Attachment #580762 - Flags: review?(gavin.sharp) → review-
Attachment #580769 - Flags: review?(gavin.sharp) → review+
Before landing, please make sure that all of these changes together don't break the engine manager with manual testing, if you haven't already.

Thanks for doing this!
(Assignee)

Comment 10

6 years ago
(In reply to Gavin Sharp (use gavin@gavinsharp.com for email) from comment #9)
> Before landing, please make sure that all of these changes together don't
> break the engine manager with manual testing, if you haven't already.

I had done this before and did it again (including adding/resorting/keywording/removing engines) before pushing. I also pushed to try to be extra sure (and found something it doesn't like in the bug 643172 patches, still need to investigate that, but the ones here are fine).

> Thanks for doing this!

I just hope it will still be helpful, given that work to move the engine management into add-on manager has been picked up again (which is good in its own respect). ;-)


http://hg.mozilla.org/integration/mozilla-inbound/rev/84becc09d904
http://hg.mozilla.org/integration/mozilla-inbound/rev/79cb693afd54
http://hg.mozilla.org/integration/mozilla-inbound/rev/3374fe9737a9
http://hg.mozilla.org/integration/mozilla-inbound/rev/c8ed809f6a9d
http://hg.mozilla.org/integration/mozilla-inbound/rev/622f1d1e7c52
https://hg.mozilla.org/mozilla-central/rev/84becc09d904
https://hg.mozilla.org/mozilla-central/rev/79cb693afd54
https://hg.mozilla.org/mozilla-central/rev/3374fe9737a9
https://hg.mozilla.org/mozilla-central/rev/c8ed809f6a9d
https://hg.mozilla.org/mozilla-central/rev/622f1d1e7c52
Status: NEW → RESOLVED
Last Resolved: 6 years ago
Resolution: --- → FIXED
Target Milestone: --- → Firefox 12
(Assignee)

Comment 12

6 years ago
Let's leave the bug open as one patch didn't get the reviews to land right now. I'll look into that one as soon as I have some time.
Status: RESOLVED → REOPENED
Resolution: FIXED → ---
Target Milestone: Firefox 12 → ---
Depends on: 719990
Blocks: 728508
Comment on attachment 580762 [details] [diff] [review]
engine.name, v1

Reuben pointed out in bug 728508 that I misunderstood this code - there already are two different strings, and the alert prompt uses the right one depending on whether eduplicate is true. So this patch is fine!
Attachment #580762 - Flags: review- → review+
(sorry about that)
(Assignee)

Comment 15

6 years ago
OK, pushed this one as well: https://hg.mozilla.org/integration/mozilla-inbound/rev/f21351397aa7
https://hg.mozilla.org/mozilla-central/rev/f21351397aa7

Robert, please close this if everything has landed.
Target Milestone: --- → Firefox 13
(Assignee)

Comment 17

6 years ago
Yes, this one is fixed now (bug 643172 isn't, though).
Status: REOPENED → RESOLVED
Last Resolved: 6 years ago6 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.