Bug 890279 - Create ScrollInfoLayers for frames we want APZC support. r=kats

This commit is contained in:
Benoit Girard 2013-07-02 11:16:05 -04:00
parent 73dba62c25
commit f152264ea8
5 changed files with 34 additions and 12 deletions

View File

@ -109,7 +109,8 @@ ContainerRender(ContainerT* aContainer,
for (uint32_t i = 0; i < children.Length(); i++) {
LayerComposite* layerToRender = static_cast<LayerComposite*>(children.ElementAt(i)->ImplData());
if (layerToRender->GetLayer()->GetEffectiveVisibleRegion().IsEmpty()) {
if (layerToRender->GetLayer()->GetEffectiveVisibleRegion().IsEmpty() &&
!layerToRender->GetLayer()->AsContainerLayer()) {
continue;
}
@ -154,7 +155,9 @@ ContainerRender(ContainerT* aContainer,
gfx::Matrix4x4 transform;
ToMatrix4x4(aContainer->GetEffectiveTransform(), transform);
gfx::Rect rect(visibleRect.x, visibleRect.y, visibleRect.width, visibleRect.height);
const FrameMetrics& frame = aContainer->GetFrameMetrics();
LayerRect layerViewport = frame.mViewport * frame.LayersPixelsPerCSSPixel();
gfx::Rect rect(layerViewport.x, layerViewport.y, layerViewport.width, layerViewport.height);
gfx::Rect clipRect(aClipRect.x, aClipRect.y, aClipRect.width, aClipRect.height);
aManager->GetCompositor()->DrawDiagnostics(gfx::Color(1.0, 0.0, 0.0, 1.0),
rect, clipRect,

View File

@ -1480,10 +1480,12 @@ static void GetAPZCAtPointOnSubtree(const ContainerLayer& aLayerIn,
currLayer = currLayer->GetPrevSibling();
}
bool intersect = aLayer.GetVisibleRegion().Contains(nsIntRect(layerPoint.x, layerPoint.y, 1, 1));
if (aLayer.GetFrameMetrics().IsScrollable()) {
const FrameMetrics& frame = aLayer.GetFrameMetrics();
LayerRect layerViewport = frame.mViewport * frame.LayersPixelsPerCSSPixel();
bool intersect = layerViewport.Contains(layerPoint.x, layerPoint.y);
if (intersect) {
if (aLayer.GetFrameMetrics().IsScrollable()) {
if (intersect) {
*aApzcOut = aLayer.GetAsyncPanZoomController();
*aRelativePointOut = LayerIntPoint(NS_lround(layerPoint.x), NS_lround(layerPoint.y));
}

View File

@ -337,6 +337,7 @@ TEST(AsyncPanZoomController, GetAPZCAtPoint) {
nsRefPtr<AsyncPanZoomController> apzcSub7 = new AsyncPanZoomController(mcc);
apzcMain->NotifyLayersUpdated(TestFrameMetrics(), true);
nsIntRect layerBound;
ScreenIntPoint touchPoint(20, 20);
AsyncPanZoomController* apzcOut;
LayerIntPoint relativePointOut;
@ -352,6 +353,9 @@ TEST(AsyncPanZoomController, GetAPZCAtPoint) {
// Now we have a root APZC that will match the page
scrollable.mScrollId = FrameMetrics::ROOT_SCROLL_ID;
layerBound = root->GetVisibleRegion().GetBounds();
scrollable.mViewport = CSSRect(layerBound.x, layerBound.y,
layerBound.width, layerBound.height);
root->AsContainerLayer()->SetFrameMetrics(scrollable);
root->AsContainerLayer()->SetAsyncPanZoomController(apzcMain);
AsyncPanZoomController::GetAPZCAtPoint(*root->AsContainerLayer(), touchPoint,
@ -361,6 +365,9 @@ TEST(AsyncPanZoomController, GetAPZCAtPoint) {
// Now we have a sub APZC with a better fit
scrollable.mScrollId = FrameMetrics::START_SCROLL_ID;
layerBound = layers[3]->GetVisibleRegion().GetBounds();
scrollable.mViewport = CSSRect(layerBound.x, layerBound.y,
layerBound.width, layerBound.height);
layers[3]->AsContainerLayer()->SetFrameMetrics(scrollable);
layers[3]->AsContainerLayer()->SetAsyncPanZoomController(apzcSub3);
AsyncPanZoomController::GetAPZCAtPoint(*root->AsContainerLayer(), touchPoint,
@ -374,6 +381,9 @@ TEST(AsyncPanZoomController, GetAPZCAtPoint) {
&apzcOut, &relativePointOut);
EXPECT_EQ(apzcOut, apzcSub3.get()); // We haven't bound apzcSub4 yet
scrollable.mScrollId++;
layerBound = layers[4]->GetVisibleRegion().GetBounds();
scrollable.mViewport = CSSRect(layerBound.x, layerBound.y,
layerBound.width, layerBound.height);
layers[4]->AsContainerLayer()->SetFrameMetrics(scrollable);
layers[4]->AsContainerLayer()->SetAsyncPanZoomController(apzcSub4);
AsyncPanZoomController::GetAPZCAtPoint(*root->AsContainerLayer(), touchPoint,
@ -425,6 +435,9 @@ TEST(AsyncPanZoomController, GetAPZCAtPoint) {
// Transformation chain to layer 7
scrollable.mScrollId++;
layerBound = layers[7]->GetVisibleRegion().GetBounds();
scrollable.mViewport = CSSRect(layerBound.x, layerBound.y,
layerBound.width, layerBound.height);
layers[7]->AsContainerLayer()->SetFrameMetrics(scrollable);
layers[7]->AsContainerLayer()->SetAsyncPanZoomController(apzcSub7);

View File

@ -635,7 +635,7 @@ static void RecordFrameMetrics(nsIFrame* aForFrame,
nsIntRect visible = aVisibleRect.ScaleToNearestPixels(
resolution.scale, resolution.scale, auPerDevPixel);
aRoot->SetVisibleRegion(nsIntRegion(visible));
aRoot->SetVisibleRegion(visible);
FrameMetrics metrics;
metrics.mViewport = CSSRect::FromAppUnits(aViewport);
@ -3278,7 +3278,7 @@ nsDisplayScrollInfoLayer::nsDisplayScrollInfoLayer(
nsDisplayListBuilder* aBuilder,
nsIFrame* aScrolledFrame,
nsIFrame* aScrollFrame)
: nsDisplayScrollLayer(aBuilder, aScrolledFrame, aScrolledFrame, aScrollFrame)
: nsDisplayScrollLayer(aBuilder, aScrollFrame, aScrolledFrame, aScrollFrame)
{
#ifdef NS_BUILD_REFCNT_LOGGING
MOZ_COUNT_CTOR(nsDisplayScrollInfoLayer);

View File

@ -2238,12 +2238,16 @@ nsGfxScrollFrameInner::BuildDisplayList(nsDisplayListBuilder* aBuilder,
} else {
nsRect scrollRange = GetScrollRange();
ScrollbarStyles styles = GetScrollbarStylesFromFrame();
bool hasScrollableOverflow =
(scrollRange.width > 0 || scrollRange.height > 0) &&
((styles.mHorizontal != NS_STYLE_OVERFLOW_HIDDEN && mHScrollbarBox) ||
(styles.mVertical != NS_STYLE_OVERFLOW_HIDDEN && mVScrollbarBox));
// TODO Turn this on for inprocess OMTC
bool wantSubAPZC = (XRE_GetProcessType() == GeckoProcessType_Content);
mShouldBuildLayer =
((styles.mHorizontal != NS_STYLE_OVERFLOW_HIDDEN && mHScrollbarBox) ||
(styles.mVertical != NS_STYLE_OVERFLOW_HIDDEN && mVScrollbarBox)) &&
(XRE_GetProcessType() == GeckoProcessType_Content &&
(scrollRange.width > 0 || scrollRange.height > 0) &&
(!mIsRoot || !mOuter->PresContext()->IsRootContentDocument()));
wantSubAPZC &&
hasScrollableOverflow &&
(!mIsRoot || !mOuter->PresContext()->IsRootContentDocument());
}
if (ShouldBuildLayer()) {