Closed Bug 582865 Opened 14 years ago Closed 14 years ago

Provide a shared "shape" module for Point, Rect, etc.

Categories

(Toolkit Graveyard :: XULRunner, defect)

defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED
mozilla2.0b4

People

(Reporter: Mardak, Assigned: mitcho)

References

Details

(Keywords: dev-doc-complete)

Attachments

(1 file, 4 obsolete files)

From bug 582023 comment 3:

Fennec has Rect/Point classes that are very similar to the ones in this file
already:

http://mxr.mozilla.org/mobile-browser/source/chrome/content/Util.js#310

Their code is in a separate repository, so sharing it directly isn't possible
at the moment, but perhaps it would be worth copying it over rather than having
a slightly different (new) implementation here? I think switching wouldn't
require many changes, and it would make it possible to move the code into a
shared location (toolkit) in the future.
Sounds OK to the Fennec team
I'm sorry for my ignorance, but how would we go about requesting to move this code into the toolkit?

Mark, it looks like Point and Rect are the only components of this Util.js that we would want to use. I assume moving just Point and Rect out into a shared location but leaving the rest alone would also be alright for you?
(In reply to comment #2)

> Mark, it looks like Point and Rect are the only components of this Util.js that
> we would want to use. I assume moving just Point and Rect out into a shared
> location but leaving the rest alone would also be alright for you?

Sounds fine to me.
(In reply to comment #2)
> how would we go about requesting to move this code into the toolkit?

Attach a patch that adds a Geometry.jsm to toolkit/content that exports Point/Rect symbols using the Fennec code, and ask review from Dave Townsend? Once it's landed we can file a followup on making Fennec use it instead of its own copy - same for tabcandy.
Thanks Gavin. Here's the patch.
Attachment #464064 - Flags: review?(dtownsend)
Also added the browser_rect.js test from Mobile as browser_Geometry.js

http://mxr.mozilla.org/mobile-browser/source/chrome/tests/browser_rect.js
Attachment #464064 - Attachment is obsolete: true
Attachment #464075 - Flags: review?(dtownsend)
Attachment #464064 - Flags: review?(dtownsend)
What am I reviewing here, all the code in the file or just code that is moving from somewhere else?
(In reply to comment #7)
> What am I reviewing here, all the code in the file or just code that is moving
> from somewhere else?

This is just code moving from Mobile to toolkit. Changes made are the license code and the JSM-ing.
Blocks: 585672
A diff against the source file might be useful for review.
(In reply to comment #9)
> A diff against the source file might be useful for review.

Thanks Gavin. Diffs for both files attached.
Attachment #464400 - Attachment is patch: true
Comment on attachment 464399 [details] [diff] [review]
diff mobile-browser/source/chrome/content/Util.js tabcandy-central/toolkit/content/Geometry.jsm

Unified diffs are generally preferred but ok. So this is a copy of code from, tabcandy-central. Who wrote that code and who did the code review on it?
(In reply to comment #13)
> So this is a copy of code from,
> tabcandy-central. Who wrote that code and who did the code review on it?

The idea of this ticket is to move code which could be reused from mobile to the toolkit, as was suggested by gavin. I've simply gone ahead and committed it against our branch of mozilla-central, tabcandy-central, but I'm requesting the patch be applied to mozilla-central.

The code itself—the geometry classes in Util.js (now Geometry.jsm) and tests/browser_rect.js (now tests/browser_Geometry.js—were mostly written by Benjamin Stover and reviwed by Gavin, as per the hg log:

http://hg.mozilla.org/mobile-browser/log/1693b30538a3/chrome/content/Util.js
http://hg.mozilla.org/mobile-browser/log/1693b30538a3/chrome/tests/browser_rect.js
Attachment #464075 - Flags: review?(dtownsend) → review+
Attachment #464075 - Flags: approval2.0?
Attachment #464075 - Flags: approval2.0? → approval2.0+
Comment on attachment 464075 [details] [diff] [review]
Move Geometry utility classes (+tests) to the toolkit

>diff --git a/toolkit/content/Geometry.jsm b/toolkit/content/Geometry.jsm

>+ * The Initial Developer of the Original Code is
>+ * Mozilla Corporation.

We should probably take this opportunity to change this to "the Mozilla Foundation".

>+ * Contributor(s):
>+ *   Roy Frostig <rfrostig@mozilla.com>
>+ *   Ben Combee <bcombee@mozilla.com>
>+ *   Matt Brubeck <mbrubeck@mozilla.com>
>+ *   Michael Yoshitaka Erlewine <mitcho@mitcho.com>

and it wouldn't hurt to add "Benjamin Stover <bstover@mozilla.com>" here.
Assignee: nobody → mitcho
OS: Mac OS X → All
Hardware: x86 → All
Also don't forget to get the Fennec bug about using this filed :)
Attached patch v2Splinter Review
I'll land it on m-c when the tree is green.
Attachment #464075 - Attachment is obsolete: true
Attachment #464399 - Attachment is obsolete: true
Attachment #464400 - Attachment is obsolete: true
Blocks: 586296
http://hg.mozilla.org/mozilla-central/rev/cdfff833edf9
Status: NEW → RESOLVED
Closed: 14 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla2.0b4
Question:

  expandToIntegers: function round() {
    this.left = Math.floor(this.left);
    this.top = Math.floor(this.top);
    this.right = Math.ceil(this.right);
    this.bottom = Math.ceil(this.bottom);
    return this;
  },


Shouldn't the "round()" here be "expandToIntegers()"?
Using this JSM doesn't work well in desktop right now due to conflicts with like-named classes. I'm calling this documentation complete for now; we'll revisit when it can be more easily fiddled with on Desktop.
Product: Toolkit → Toolkit Graveyard
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: