Bug 1019737 - Only layerize the scrollbar thumb if the target scroll frame has active scrolling. r=roc

This commit is contained in:
Markus Stange 2014-06-04 14:44:26 +02:00
parent 0a84c7f233
commit 77db589b6c
4 changed files with 30 additions and 6 deletions

View File

@ -1604,6 +1604,21 @@ nsLayoutUtils::IsFixedPosFrameInDisplayPort(const nsIFrame* aFrame, nsRect* aDis
return ViewportHasDisplayPort(aFrame->PresContext(), aDisplayPort);
}
NS_DECLARE_FRAME_PROPERTY(ScrollbarThumbLayerized, nullptr)
/* static */ void
nsLayoutUtils::SetScrollbarThumbLayerization(nsIFrame* aThumbFrame, bool aLayerize)
{
aThumbFrame->Properties().Set(ScrollbarThumbLayerized(),
reinterpret_cast<void*>(intptr_t(aLayerize)));
}
static bool
IsScrollbarThumbLayerized(nsIFrame* aThumbFrame)
{
return reinterpret_cast<intptr_t>(aThumbFrame->Properties().Get(ScrollbarThumbLayerized()));
}
static nsIFrame*
GetAnimatedGeometryRootForFrame(nsIFrame* aFrame,
const nsIFrame* aStopAtAncestor)
@ -1625,10 +1640,11 @@ GetAnimatedGeometryRootForFrame(nsIFrame* aFrame,
if (!parent)
break;
nsIAtom* parentType = parent->GetType();
// Treat the slider thumb as being as an active scrolled root
// so that it can move without repainting.
if (parentType == nsGkAtoms::sliderFrame)
// Treat the slider thumb as being as an active scrolled root when it wants
// its own layer so that it can move without repainting.
if (parentType == nsGkAtoms::sliderFrame && IsScrollbarThumbLayerized(f)) {
break;
}
// Sticky frames are active if their nearest scrollable frame
// is also active, just keep a record of sticky frames that we
// encounter for now.

View File

@ -480,6 +480,12 @@ public:
static bool IsFixedPosFrameInDisplayPort(const nsIFrame* aFrame,
nsRect* aDisplayPort = nullptr);
/**
* Store whether aThumbFrame wants its own layer. This sets a property on
* the frame.
*/
static void SetScrollbarThumbLayerization(nsIFrame* aThumbFrame, bool aLayerize);
/**
* Finds the nearest ancestor frame to aItem that is considered to have (or
* will have) "animated geometry". For example the scrolled frames of

View File

@ -2179,8 +2179,9 @@ ScrollFrameHelper::AppendScrollPartsTo(nsDisplayListBuilder* aBuilder,
scrollParts.AppendElement(kid);
}
mozilla::layers::FrameMetrics::ViewID scrollTargetId =
nsLayoutUtils::FindOrCreateIDFor(mScrolledFrame->GetContent());
mozilla::layers::FrameMetrics::ViewID scrollTargetId = IsScrollingActive()
? nsLayoutUtils::FindOrCreateIDFor(mScrolledFrame->GetContent())
: mozilla::layers::FrameMetrics::NULL_SCROLL_ID;
scrollParts.Sort(HoveredStateComparator());

View File

@ -1311,8 +1311,9 @@ nsBoxFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
} else {
nsIFrame* parent = GetParentBox(this);
if (parent && parent->GetType() == nsGkAtoms::sliderFrame) {
forceLayer = true;
aBuilder->GetScrollbarInfo(&scrollTargetId, &flags);
forceLayer = (scrollTargetId != layers::FrameMetrics::NULL_SCROLL_ID);
nsLayoutUtils::SetScrollbarThumbLayerization(this, forceLayer);
}
}
// Check for frames that are marked as a part of the region used