Replace "GetContentRect() - GetPosition()" with GetContentRectRelativeToSelf()

RESOLVED FIXED in mozilla35

Status

()

Core
Layout
RESOLVED FIXED
3 years ago
3 years ago

People

(Reporter: dholbert, Assigned: dholbert)

Tracking

Trunk
mozilla35
Points:
---
Bug Flags:
in-testsuite -

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(1 attachment)

(Assignee)

Description

3 years ago
We have several places in layout where we do arithmetic with:
 GetContentRect() - GetPosition()

GetContentRect() gives us nsRect(x,y,width,height); GetPosition() gives us (x,y); so this expression produces nsRect(0,0,width,height).

This is silly, though, because GetContentRect() itself is implemented as follows:
> 1155 nsRect
> 1156 nsIFrame::GetContentRect() const
> 1157 {
> 1158   return GetContentRectRelativeToSelf() + GetPosition();
> 1159 }

So, anyone calling "GetContentRect() - GetPosition()" should really just be calling GetContentRectRelativeToSelf().
(Assignee)

Comment 1

3 years ago
(actually, the "0,0" in "0,0,width,height" isn't quite right in my hand-wavy overview at the start of comment 0, because borderpadding impacts things a bit, as shown by the GetContentRectRelativeToSelf() implementation. That's tangential to the main point here, though, which is that GetContentRect() - GetPosition() is silly & wasteful.)
(Assignee)

Comment 2

3 years ago
Created attachment 8487508 [details] [diff] [review]
fix v1

(As noted in the patch, this makes nsImageFrame's helper-method "GetInnerArea()" a bit silly, albeit a bit conciser than GetContentRectRelativeToSelf(). Similar for nsHTMLCanvasFrame::GetInnerArea, which is documented as having been copied from nsImageFrame at some point in the past.)
Attachment #8487508 - Flags: review?(tnikkel)
(Assignee)

Comment 3

3 years ago
Try run: https://tbpl.mozilla.org/?tree=Try&rev=b2fcec18384b
Attachment #8487508 - Flags: review?(tnikkel) → review+
(Assignee)

Comment 4

3 years ago
https://hg.mozilla.org/integration/mozilla-inbound/rev/3a582ed49923
Flags: in-testsuite-
https://hg.mozilla.org/mozilla-central/rev/3a582ed49923
Status: ASSIGNED → RESOLVED
Last Resolved: 3 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla35
You need to log in before you can comment on or make changes to this bug.