mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1001438 - Rearrange the code in nsLayoutUtils::GetDisplayPort. r=tn
This commit is contained in:
parent
a99a3096b2
commit
cc2c523775
@ -682,7 +682,12 @@ nsLayoutUtils::GetDisplayPort(nsIContent* aContent, nsRect *aResult)
|
||||
return false;
|
||||
}
|
||||
|
||||
if (aResult) {
|
||||
if (!aResult) {
|
||||
// We have displayport data, but no need to compute it because the
|
||||
// caller doesn't want it
|
||||
return true;
|
||||
}
|
||||
|
||||
if (rectData && marginsData) {
|
||||
// choose margins if equal priority
|
||||
if (rectData->mPriority > marginsData->mPriority) {
|
||||
@ -693,8 +698,10 @@ nsLayoutUtils::GetDisplayPort(nsIContent* aContent, nsRect *aResult)
|
||||
}
|
||||
|
||||
if (rectData) {
|
||||
// We have it as a straight-up rect
|
||||
*aResult = rectData->mRect;
|
||||
} else {
|
||||
// We need to compute it from the margins + base rect
|
||||
nsRect* baseData =
|
||||
static_cast<nsRect*>(aContent->GetProperty(nsGkAtoms::DisplayPortBase));
|
||||
nsRect base;
|
||||
@ -703,7 +710,14 @@ nsLayoutUtils::GetDisplayPort(nsIContent* aContent, nsRect *aResult)
|
||||
}
|
||||
|
||||
nsIFrame* frame = aContent->GetPrimaryFrame();
|
||||
if (frame) {
|
||||
if (!frame) {
|
||||
// Turns out we can't really compute it. Oops. We still should
|
||||
// return true and set aResult to something sane.
|
||||
NS_WARNING("Attempting to get a displayport from a content with no primary frame!");
|
||||
*aResult = base;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool isRoot = false;
|
||||
if (aContent->OwnerDoc()->GetRootElement() == aContent) {
|
||||
// We want the scroll frame, the root scroll frame differs from all
|
||||
@ -727,16 +741,13 @@ nsLayoutUtils::GetDisplayPort(nsIContent* aContent, nsRect *aResult)
|
||||
LayerRect rect;
|
||||
rect.x = parentRes.width * NSAppUnitsToFloatPixels(base.x, auPerDevPixel);
|
||||
rect.y = parentRes.height * NSAppUnitsToFloatPixels(base.y, auPerDevPixel);
|
||||
rect.width =
|
||||
parentRes.width * NSAppUnitsToFloatPixels(base.width, auPerDevPixel);
|
||||
rect.height =
|
||||
parentRes.height * NSAppUnitsToFloatPixels(base.height, auPerDevPixel);
|
||||
rect.width = parentRes.width * NSAppUnitsToFloatPixels(base.width, auPerDevPixel);
|
||||
rect.height = parentRes.height * NSAppUnitsToFloatPixels(base.height, auPerDevPixel);
|
||||
|
||||
rect.Inflate(marginsData->mMargins);
|
||||
|
||||
nsIScrollableFrame* scrollableFrame = frame->GetScrollTargetFrame();
|
||||
nsPoint scrollPos(
|
||||
scrollableFrame ? scrollableFrame->GetScrollPosition() : nsPoint(0,0));
|
||||
nsPoint scrollPos(scrollableFrame ? scrollableFrame->GetScrollPosition() : nsPoint(0,0));
|
||||
if (marginsData->mAlignmentX > 0 || marginsData->mAlignmentY > 0) {
|
||||
// Avoid division by zero.
|
||||
if (marginsData->mAlignmentX == 0) {
|
||||
@ -757,14 +768,10 @@ nsLayoutUtils::GetDisplayPort(nsIContent* aContent, nsRect *aResult)
|
||||
// up to tile boundaries.
|
||||
rect.Inflate(1);
|
||||
|
||||
float left =
|
||||
marginsData->mAlignmentX * floor(rect.x / marginsData->mAlignmentX);
|
||||
float top =
|
||||
marginsData->mAlignmentY * floor(rect.y / marginsData->mAlignmentY);
|
||||
float right =
|
||||
marginsData->mAlignmentX * ceil(rect.XMost() / marginsData->mAlignmentX);
|
||||
float bottom =
|
||||
marginsData->mAlignmentY * ceil(rect.YMost() / marginsData->mAlignmentY);
|
||||
float left = marginsData->mAlignmentX * floor(rect.x / marginsData->mAlignmentX);
|
||||
float top = marginsData->mAlignmentY * floor(rect.y / marginsData->mAlignmentY);
|
||||
float right = marginsData->mAlignmentX * ceil(rect.XMost() / marginsData->mAlignmentX);
|
||||
float bottom = marginsData->mAlignmentY * ceil(rect.YMost() / marginsData->mAlignmentY);
|
||||
rect = LayerRect(left, top, right - left, bottom - top);
|
||||
rect -= scrollPosLayer;
|
||||
}
|
||||
@ -772,10 +779,8 @@ nsLayoutUtils::GetDisplayPort(nsIContent* aContent, nsRect *aResult)
|
||||
nsRect result;
|
||||
result.x = NSFloatPixelsToAppUnits(rect.x / res.width, auPerDevPixel);
|
||||
result.y = NSFloatPixelsToAppUnits(rect.y / res.height, auPerDevPixel);
|
||||
result.width =
|
||||
NSFloatPixelsToAppUnits(rect.width / res.width, auPerDevPixel);
|
||||
result.height =
|
||||
NSFloatPixelsToAppUnits(rect.height / res.height, auPerDevPixel);
|
||||
result.width = NSFloatPixelsToAppUnits(rect.width / res.width, auPerDevPixel);
|
||||
result.height = NSFloatPixelsToAppUnits(rect.height / res.height, auPerDevPixel);
|
||||
|
||||
// Finally, clamp the display port to the expanded scrollable rect.
|
||||
nsRect expandedScrollableRect = CalculateExpandedScrollableRect(frame);
|
||||
@ -783,9 +788,6 @@ nsLayoutUtils::GetDisplayPort(nsIContent* aContent, nsRect *aResult)
|
||||
|
||||
*aResult = result;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user