Closed Bug 268576 Opened 20 years ago Closed 20 years ago

[FIXr]Method to get screen coordinates on nsIFrame

Categories

(Core :: Layout, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla1.8alpha6

People

(Reporter: aaronlev, Assigned: bzbarsky)

References

Details

(Keywords: memory-footprint)

Attachments

(1 file, 1 obsolete file)

Spun off from bug 175568.

Here's the list of places that Boris mentioned all use some method of getting
the screen coordinates from a frame:
  nsMenuPopupFrame::GetScreenPosition
  nsSVGSVGElement::GetScreenPosition
  nsBoxObject::GetScreenRect
  nsAccessibleText::GetCharacterExtents (this has the COORD_TYPE_WINDOW
    weirdness, though).
  Some Inspector code that's unused and removed in my tree...
Note: bug 175568 will add another consumer of this sort of thing.
Target Milestone: --- → mozilla1.8alpha6
Attached patch Patch (obsolete) — Splinter Review
Attachment #166147 - Flags: superreview?(roc)
Attachment #166147 - Flags: review?(roc)
Note that for views I did position, not rect, because the bounds topleft may not
match the origins and callers seemed to want the origin.
Summary: Method to get screen coordinates on nsIFrame → [FIX]Method to get screen coordinates on nsIFrame
Doesn't look like we can use this for context menu stuff in
nsEventListenerManager after all, since that's not in screen coordinates. Too bad.
Comment on attachment 166147 [details] [diff] [review]
Patch

+      // XXXbz there needs to be a better way to do this scaling
+      nsIntRect ourPxRect(NSTwipsToIntPixels(ourRect.x, t2p),
+			   NSTwipsToIntPixels(ourRect.y, t2p),
+			   NSTwipsToIntPixels(ourRect.width, t2p),
+			   NSTwipsToIntPixels(ourRect.height, t2p));

There is: nsRect::ScaleRoundOut. With that, r+sr=roc
Attachment #166147 - Flags: superreview?(roc)
Attachment #166147 - Flags: superreview+
Attachment #166147 - Flags: review?(roc)
Attachment #166147 - Flags: review+
But that rounds out instead of rounding to the nearest int (which is what the
code in question does, I think).  Do we care?
Summary: [FIX]Method to get screen coordinates on nsIFrame → [FIXr]Method to get screen coordinates on nsIFrame
I don't think so. It really depends on the caller, but I bet that rounding out
is always no less correct than rounding to the nearest int.
Sounds good.
Note to self:

> +    frameScreenRect.x += NS_TwipsToIntPixels(beforeWidth. t2p);

Should have a comma, not a dot, after beforeWidth (this is in the accessibility
code).
Attachment #166147 - Attachment is obsolete: true
Fixed on trunk.
Status: NEW → RESOLVED
Closed: 20 years ago
Resolution: --- → FIXED
This caused bug 271702 (because that code mis-treated screenY) and bug 271891
(because this patch had an error in it).
Blocks: 186229
Could this have caused bug 273226?
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: