зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1194851. Introduce GetDisplayPortRelativeToScrollFrame. r=botond
This commit is contained in:
Родитель
f06c43de07
Коммит
859f318413
|
@ -851,6 +851,21 @@ GetDisplayPortFromRectData(nsIContent* aContent,
|
|||
return ApplyRectMultiplier(aRectData->mRect, aMultiplier);
|
||||
}
|
||||
|
||||
nsIFrame*
|
||||
GetScrollFrameFromContent(nsIContent* aContent)
|
||||
{
|
||||
nsIFrame* frame = aContent->GetPrimaryFrame();
|
||||
if (frame && aContent->OwnerDoc()->GetRootElement() == aContent) {
|
||||
// We want the scroll frame, the root scroll frame differs from all
|
||||
// others in that the primary frame is not the scroll frame.
|
||||
if (nsIFrame* rootScrollFrame =
|
||||
frame->PresContext()->PresShell()->GetRootScrollFrame()) {
|
||||
frame = rootScrollFrame;
|
||||
}
|
||||
}
|
||||
return frame;
|
||||
}
|
||||
|
||||
static nsRect
|
||||
GetDisplayPortFromMarginsData(nsIContent* aContent,
|
||||
DisplayPortMarginsPropertyData* aMarginsData,
|
||||
|
@ -869,7 +884,7 @@ GetDisplayPortFromMarginsData(nsIContent* aContent,
|
|||
// Fall through for graceful handling.
|
||||
}
|
||||
|
||||
nsIFrame* frame = aContent->GetPrimaryFrame();
|
||||
nsIFrame* frame = GetScrollFrameFromContent(aContent);
|
||||
if (!frame) {
|
||||
// Turns out we can't really compute it. Oops. We still should return
|
||||
// something sane. Note that since we can't clamp the rect without a
|
||||
|
@ -881,13 +896,6 @@ GetDisplayPortFromMarginsData(nsIContent* aContent,
|
|||
|
||||
bool isRoot = false;
|
||||
if (aContent->OwnerDoc()->GetRootElement() == aContent) {
|
||||
// We want the scroll frame, the root scroll frame differs from all
|
||||
// others in that the primary frame is not the scroll frame.
|
||||
if (nsIFrame* rootScrollFrame =
|
||||
frame->PresContext()->PresShell()->GetRootScrollFrame()) {
|
||||
frame = rootScrollFrame;
|
||||
}
|
||||
|
||||
isRoot = true;
|
||||
}
|
||||
|
||||
|
@ -1078,6 +1086,19 @@ nsLayoutUtils::GetDisplayPort(nsIContent* aContent, nsRect *aResult)
|
|||
return GetDisplayPortImpl(aContent, aResult, 1.0f);
|
||||
}
|
||||
|
||||
bool
|
||||
nsLayoutUtils::GetDisplayPortRelativeToScrollFrame(nsIContent* aContent, nsRect *aResult)
|
||||
{
|
||||
MOZ_ASSERT(aResult);
|
||||
bool usingDisplayPort = GetDisplayPort(aContent, aResult);
|
||||
nsIFrame* frame = GetScrollFrameFromContent(aContent);
|
||||
nsIScrollableFrame* scrollableFrame = frame ? frame->GetScrollTargetFrame() : nullptr;
|
||||
if (usingDisplayPort && scrollableFrame) {
|
||||
*aResult += scrollableFrame->GetScrollPortRect().TopLeft();
|
||||
}
|
||||
return usingDisplayPort;
|
||||
}
|
||||
|
||||
bool
|
||||
nsLayoutUtils::HasDisplayPort(nsIContent* aContent) {
|
||||
return GetDisplayPort(aContent, nullptr);
|
||||
|
|
|
@ -166,10 +166,16 @@ public:
|
|||
static nsIScrollableFrame* FindScrollableFrameFor(ViewID aId);
|
||||
|
||||
/**
|
||||
* Get display port for the given element.
|
||||
* Get display port for the given element. The displayport is relative to the
|
||||
* scrollport.
|
||||
*/
|
||||
static bool GetDisplayPort(nsIContent* aContent, nsRect *aResult);
|
||||
|
||||
/**
|
||||
* Get display port for the given element relative to the scroll frame.
|
||||
*/
|
||||
static bool GetDisplayPortRelativeToScrollFrame(nsIContent* aContent, nsRect *aResult);
|
||||
|
||||
/**
|
||||
* Check whether the given element has a displayport.
|
||||
*/
|
||||
|
|
Загрузка…
Ссылка в новой задаче