Closed Bug 1119233 Opened 9 years ago Closed 9 years ago

Move inline event handlers and styles from search.xul into other files

Categories

(Firefox :: Settings UI, defect)

defect
Not set
normal
Points:
3

Tracking

()

RESOLVED FIXED
Firefox 38
Iteration:
38.1 - 26 Jan

People

(Reporter: Gijs, Assigned: aryx)

References

Details

Attachments

(2 files, 5 obsolete files)

As per summary. These were (mostly?) added in bug 1088660 - the event handlers should be in JS instead, and the styles should be in CSS.
Flags: qe-verify-
Flags: in-testsuite?
Flags: firefox-backlog+
Assignee: nobody → archaeopteryx
Status: NEW → ASSIGNED
Attached patch js (apply first), v1 (obsolete) — Splinter Review
Attachment #8546494 - Flags: review?(gijskruitbosch+bugs)
Comment on attachment 8546494 [details] [diff] [review]
js (apply first), v1

Review of attachment 8546494 [details] [diff] [review]:
-----------------------------------------------------------------

Instead of adding the listeners as functions, please consider adding gSearchPane, and implementing a handleEvent method instead, with a switch() over the event type and then checks on the target IDs. This will avoid having to use anonymous functions to keep |this| in line (as |this| will be gSearchPane anyway in those cases).

::: browser/components/preferences/in-content/search.js
@@ +15,5 @@
>    {
> +    function setEventListener(aId, aEventType, aCallback)
> +    {
> +      document.getElementById(aId)
> +              .addEventListener(aEventType, aCallback.bind(gSearchPane));

Nit:

let node = document.getElementById(aId);
node.addEventListener...

::: browser/components/preferences/in-content/search.xul
@@ +54,5 @@
>        <hbox>
>          <button id="restoreDefaultSearchEngines"
>                  label="&restoreDefaultSearchEngines.label;"
>                  accesskey="&restoreDefaultSearchEngines.accesskey;"
> +        />

Nit: line up with "accesskey", please. :-)

@@ +60,5 @@
>          <button id="removeEngineButton"
>                  label="&removeEngine.label;"
>                  accesskey="&removeEngine.accesskey;"
>                  disabled="true"
> +        />

Nit: same.
Attachment #8546494 - Flags: review?(gijskruitbosch+bugs) → feedback+
Comment on attachment 8546495 [details] [diff] [review]
css, v1

Review of attachment 8546495 [details] [diff] [review]:
-----------------------------------------------------------------

::: browser/components/preferences/in-content/search.xul
@@ -24,5 @@
>        <label class="header-name">&paneSearch.title;</label>
>      </hbox>
>  
>      <!-- Default Search Engine -->
> -    <groupbox id="defaultEngineGroup" align="start" data-category="paneSearch">

I'm not sure if it's necessary to remove align="start", but it's certainly a good idea in principle. However...

@@ +65,5 @@
>        </hbox>
>  
>        <separator class="thin"/>
>  
> +      <hbox id="addEnginesBox" pack="start">

... but then you can also remove pack="start" (the equivalent is -moz-box-pack: start).

The same goes for flex (-moz-box-flex).

I think with those attributes (XUL flexbox model) we should be consistent and either move all of them to CSS or keep all of them in XUL. Considering precedent and requirements for this bug, I guess right now we should keep them in XUL, but we should open a discussion on firefox-dev. Personally, I suspect moving away from the attributes and towards using CSS for these is a good idea, but we should get feedback about it and then implement it more widely. :-)

::: browser/themes/shared/incontentprefs/search.css
@@ +2,5 @@
>   * License, v. 2.0. If a copy of the MPL was not distributed with this
>   * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
>  
> +#defaultEngineGroup {
> +  text-align: start;

the equivalent of align="start" in XUL is -moz-box-align: start, not text-align: start.
Attached patch js (apply first), v2 (obsolete) — Splinter Review
Attachment #8546494 - Attachment is obsolete: true
Attachment #8546671 - Flags: review?(gijskruitbosch+bugs)
Attached patch css, v2 (obsolete) — Splinter Review
Attachment #8546495 - Attachment is obsolete: true
Attachment #8546672 - Flags: review?(gijskruitbosch+bugs)
Attachment #8546672 - Flags: review?(gijskruitbosch+bugs) → review+
Comment on attachment 8546671 [details] [diff] [review]
js (apply first), v2

Review of attachment 8546671 [details] [diff] [review]:
-----------------------------------------------------------------

You're not actually adding gSearchPane as an event listener anywhere... did you not test this? Or did you forget to qref?

::: browser/components/preferences/in-content/search.js
@@ +63,5 @@
>      });
>    },
>  
> +  handleEvent: function(aEvent) {
> +    switch (aEvent.type) {

Nit: please indent all the case statements 2 spaces, too.

@@ +65,5 @@
>  
> +  handleEvent: function(aEvent) {
> +    switch (aEvent.type) {
> +    case "click":
> +      if (aEvent.target.id == "addEngines" && event.button == 0)

Nit: braces around the bits inside the if, please. :-)
Attachment #8546671 - Flags: review?(gijskruitbosch+bugs) → review-
Attached patch js (apply first), v3 (obsolete) — Splinter Review
> You're not actually adding gSearchPane as an event listener anywhere... did
> you not test this? Or did you forget to qref?
Forgot -purgecaches.
Attachment #8546671 - Attachment is obsolete: true
Attachment #8546785 - Flags: review?(gijskruitbosch+bugs)
Comment on attachment 8546785 [details] [diff] [review]
js (apply first), v3

Review of attachment 8546785 [details] [diff] [review]:
-----------------------------------------------------------------

LGTM!
Attachment #8546785 - Flags: review?(gijskruitbosch+bugs) → review+
https://hg.mozilla.org/mozilla-central/rev/18d17da8d569
https://hg.mozilla.org/mozilla-central/rev/5a902d6fc538
Status: ASSIGNED → RESOLVED
Closed: 9 years ago
Resolution: --- → FIXED
Whiteboard: [fixed-in-fx-team]
Target Milestone: --- → Firefox 38
Iteration: --- → 38.1 - 26 Jan
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: