Bug 1194851. Change GetDisplayPortForVisibilityTesting into GetDisplayPortRelativeToScrollFrameForVisibilityTesting since it has only one user. r=botond

Also update the other image visibility GetDisplayPort. It will get changed to GetDisplayPortRelativeToScrollFrameForVisibilityTesting in another bug.
This commit is contained in:
Timothy Nikkel 2016-01-07 18:27:49 -06:00
parent 859f318413
commit a83245ddd4
3 changed files with 31 additions and 14 deletions

View File

@ -1086,15 +1086,23 @@ nsLayoutUtils::GetDisplayPort(nsIContent* aContent, nsRect *aResult)
return GetDisplayPortImpl(aContent, aResult, 1.0f);
}
void
TranslateFromScrollPortToScrollFrame(nsIContent* aContent, nsRect* aRect)
{
nsIFrame* frame = GetScrollFrameFromContent(aContent);
nsIScrollableFrame* scrollableFrame = frame ? frame->GetScrollTargetFrame() : nullptr;
if (scrollableFrame) {
*aRect += scrollableFrame->GetScrollPortRect().TopLeft();
}
}
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();
if (usingDisplayPort) {
TranslateFromScrollPortToScrollFrame(aContent, aResult);
}
return usingDisplayPort;
}
@ -1105,10 +1113,16 @@ nsLayoutUtils::HasDisplayPort(nsIContent* aContent) {
}
/* static */ bool
nsLayoutUtils::GetDisplayPortForVisibilityTesting(nsIContent* aContent,
nsRect* aResult)
nsLayoutUtils::GetDisplayPortRelativeToScrollFrameForVisibilityTesting(
nsIContent* aContent,
nsRect* aResult)
{
return GetDisplayPortImpl(aContent, aResult, 1.0f);
MOZ_ASSERT(aResult);
bool usingDisplayPort = GetDisplayPortImpl(aContent, aResult, 1.0f);
if (usingDisplayPort) {
TranslateFromScrollPortToScrollFrame(aContent, aResult);
}
return usingDisplayPort;
}
bool

View File

@ -185,11 +185,13 @@ public:
* @return the display port for the given element which should be used for
* visibility testing purposes.
*
* If low-precision buffers are enabled, this is the critical display port;
* otherwise, it's the same display port returned by GetDisplayPort().
* If low-precision buffers are enabled, this is the critical display port
* relative to the scroll frame; otherwise, it's the same display port
* returned by GetDisplayPortRelativeToScrollFrame().
*/
static bool GetDisplayPortForVisibilityTesting(nsIContent* aContent,
nsRect* aResult = nullptr);
static bool GetDisplayPortRelativeToScrollFrameForVisibilityTesting(
nsIContent* aContent,
nsRect* aResult);
enum class RepaintMode : uint8_t {
Repaint,

View File

@ -34,6 +34,7 @@
#include "mozilla/TextEvents.h"
#include "mozilla/TouchEvents.h"
#include "mozilla/UniquePtr.h"
#include "mozilla/unused.h"
#include <algorithm>
#ifdef XP_WIN
@ -5574,8 +5575,8 @@ PresShell::MarkImagesInSubtreeVisible(nsIFrame* aFrame, const nsRect& aRect)
if (scrollFrame) {
nsRect displayPort;
bool usingDisplayport =
nsLayoutUtils::GetDisplayPortForVisibilityTesting(aFrame->GetContent(),
&displayPort);
nsLayoutUtils::GetDisplayPortRelativeToScrollFrameForVisibilityTesting(
aFrame->GetContent(), &displayPort);
if (usingDisplayport) {
rect = displayPort;
} else {
@ -5678,7 +5679,7 @@ PresShell::UpdateImageVisibility()
if (rootScroll) {
nsIContent* content = rootScroll->GetContent();
if (content) {
nsLayoutUtils::GetDisplayPort(content, &updateRect);
Unused << nsLayoutUtils::GetDisplayPortRelativeToScrollFrame(content, &updateRect);
}
if (IgnoringViewportScrolling()) {