Bug 980493 - Transition FrameMetrics::mScrollId to use a getter/setter. r=botond

--HG--
extra : histedit_source : 1c84496d4b61f019e6e6cc24591ee3a10434e4cc
This commit is contained in:
Chadd Williams 2014-03-21 17:48:08 -04:00
parent d20d064223
commit 29c628c5eb
17 changed files with 53 additions and 43 deletions

View File

@ -628,7 +628,7 @@ TabChild::HandlePossibleViewportChange()
defaultZoom <= viewportInfo.GetMaxZoom());
metrics.SetZoom(defaultZoom);
metrics.mScrollId = viewId;
metrics.SetScrollId(viewId);
}
metrics.mCumulativeResolution = metrics.GetZoom() / metrics.mDevPixelsPerCSSPixel * ScreenToLayerScale(1);
@ -1472,7 +1472,7 @@ TabChild::DispatchMessageManagerMessage(const nsAString& aMessageName,
bool
TabChild::RecvUpdateFrame(const FrameMetrics& aFrameMetrics)
{
MOZ_ASSERT(aFrameMetrics.mScrollId != FrameMetrics::NULL_SCROLL_ID);
MOZ_ASSERT(aFrameMetrics.GetScrollId() != FrameMetrics::NULL_SCROLL_ID);
if (aFrameMetrics.mIsRoot) {
nsCOMPtr<nsIDOMWindowUtils> utils(GetDOMWindowUtils());
@ -1485,7 +1485,7 @@ TabChild::RecvUpdateFrame(const FrameMetrics& aFrameMetrics)
// aFrameMetrics.mIsRoot is false, so we are trying to update a subframe.
// This requires special handling.
nsCOMPtr<nsIContent> content = nsLayoutUtils::FindContentFor(
aFrameMetrics.mScrollId);
aFrameMetrics.GetScrollId());
if (content) {
FrameMetrics newSubFrameMetrics(aFrameMetrics);
APZCCallbackHelper::UpdateSubFrame(content, newSubFrameMetrics);

View File

@ -71,7 +71,6 @@ public:
, mDisplayPort(0, 0, 0, 0)
, mCriticalDisplayPort(0, 0, 0, 0)
, mViewport(0, 0, 0, 0)
, mScrollId(NULL_SCROLL_ID)
, mScrollableRect(0, 0, 0, 0)
, mResolution(1)
, mCumulativeResolution(1)
@ -81,6 +80,7 @@ public:
, mMayHaveTouchListeners(false)
, mIsRoot(false)
, mHasScrollgrab(false)
, mScrollId(NULL_SCROLL_ID)
, mScrollOffset(0, 0)
, mZoom(1)
, mUpdateScrollOffset(false)
@ -97,7 +97,6 @@ public:
mDisplayPort.IsEqualEdges(aOther.mDisplayPort) &&
mCriticalDisplayPort.IsEqualEdges(aOther.mCriticalDisplayPort) &&
mViewport.IsEqualEdges(aOther.mViewport) &&
mScrollId == aOther.mScrollId &&
mScrollableRect.IsEqualEdges(aOther.mScrollableRect) &&
mResolution == aOther.mResolution &&
mCumulativeResolution == aOther.mCumulativeResolution &&
@ -105,6 +104,7 @@ public:
mMayHaveTouchListeners == aOther.mMayHaveTouchListeners &&
mPresShellId == aOther.mPresShellId &&
mIsRoot == aOther.mIsRoot &&
mScrollId == aOther.mScrollId &&
mScrollOffset == aOther.mScrollOffset &&
mHasScrollgrab == aOther.mHasScrollgrab &&
mUpdateScrollOffset == aOther.mUpdateScrollOffset;
@ -265,9 +265,6 @@ public:
// meaningless and invalid.
CSSRect mViewport;
// A unique ID assigned to each scrollable frame.
ViewID mScrollId;
// The scrollable bounds of a frame. This is determined by reflow.
// Ordinarily the x and y will be 0 and the width and height will be the
// size of the element being scrolled. However for RTL pages or elements
@ -370,10 +367,23 @@ public:
mContentDescription = aContentDescription;
}
ViewID GetScrollId() const
{
return mScrollId;
}
void SetScrollId(ViewID scrollId)
{
mScrollId = scrollId;
}
private:
// New fields from now on should be made private and old fields should
// be refactored to be private.
// A unique ID assigned to each scrollable frame.
ViewID mScrollId;
// The position of the top-left of the CSS viewport, relative to the document
// (or the document relative to the viewport, if that helps understand it).
//
@ -441,7 +451,7 @@ struct ScrollableLayerGuid {
ScrollableLayerGuid(uint64_t aLayersId, const FrameMetrics& aMetrics)
: mLayersId(aLayersId)
, mPresShellId(aMetrics.mPresShellId)
, mScrollId(aMetrics.mScrollId)
, mScrollId(aMetrics.GetScrollId())
{
MOZ_COUNT_CTOR(ScrollableLayerGuid);
}

View File

@ -121,7 +121,7 @@ AppendToString(nsACString& s, const FrameMetrics& m,
AppendToString(s, m.GetScrollOffset(), " viewportScroll=");
AppendToString(s, m.mDisplayPort, " displayport=");
AppendToString(s, m.mScrollableRect, " scrollableRect=");
AppendToString(s, m.mScrollId, " scrollId=", " }");
AppendToString(s, m.GetScrollId(), " scrollId=", " }");
return s += sfx;
}

View File

@ -72,7 +72,7 @@ ClientTiledThebesLayer::BeginPaint()
ContainerLayer* scrollParent = nullptr;
for (ContainerLayer* parent = GetParent(); parent; parent = parent->GetParent()) {
const FrameMetrics& metrics = parent->GetFrameMetrics();
if (metrics.mScrollId != FrameMetrics::NULL_SCROLL_ID) {
if (metrics.GetScrollId() != FrameMetrics::NULL_SCROLL_ID) {
scrollParent = parent;
break;
}

View File

@ -284,7 +284,7 @@ SimpleClientTiledThebesLayer::BeginPaint()
ContainerLayer* scrollParent = nullptr;
for (ContainerLayer* parent = GetParent(); parent; parent = parent->GetParent()) {
const FrameMetrics& metrics = parent->GetFrameMetrics();
if (metrics.mScrollId != FrameMetrics::NULL_SCROLL_ID) {
if (metrics.GetScrollId() != FrameMetrics::NULL_SCROLL_ID) {
scrollParent = parent;
break;
}

View File

@ -156,7 +156,7 @@ SharedFrameMetricsHelper::UpdateFromCompositorFrameMetrics(
const FrameMetrics& contentMetrics = aLayer->GetFrameMetrics();
FrameMetrics compositorMetrics;
if (!compositor->LookupCompositorFrameMetrics(contentMetrics.mScrollId,
if (!compositor->LookupCompositorFrameMetrics(contentMetrics.GetScrollId(),
compositorMetrics)) {
FindFallbackContentFrameMetrics(aLayer, aCompositionBounds, aZoom);
return false;

View File

@ -211,7 +211,7 @@ APZCTreeManager::UpdatePanZoomControllerTree(CompositorParent* aCompositor,
apzc->SetPrevSibling(nullptr);
apzc->SetLastChild(nullptr);
}
APZC_LOG("Using APZC %p for layer %p with identifiers %lld %lld\n", apzc, aLayer, aLayersId, container->GetFrameMetrics().mScrollId);
APZC_LOG("Using APZC %p for layer %p with identifiers %lld %lld\n", apzc, aLayer, aLayersId, container->GetFrameMetrics().GetScrollId());
apzc->NotifyLayersUpdated(metrics,
aIsFirstPaint && (aLayersId == aFirstPaintLayersId));

View File

@ -244,7 +244,7 @@ AsyncCompositionManager::AlignFixedAndStickyLayers(Layer* aLayer,
bool isStickyForSubtree = aLayer->GetIsStickyPosition() &&
aTransformedSubtreeRoot->AsContainerLayer() &&
aLayer->GetStickyScrollContainerId() ==
aTransformedSubtreeRoot->AsContainerLayer()->GetFrameMetrics().mScrollId;
aTransformedSubtreeRoot->AsContainerLayer()->GetFrameMetrics().GetScrollId();
if (aLayer != aTransformedSubtreeRoot && (isRootFixed || isStickyForSubtree)) {
// Insert a translation so that the position of the anchor point is the same
// before and after the change to the transform of aTransformedSubtreeRoot.
@ -606,7 +606,7 @@ AsyncCompositionManager::ApplyAsyncTransformToScrollbar(ContainerLayer* aLayer)
continue;
}
const FrameMetrics& metrics = scrollTarget->AsContainerLayer()->GetFrameMetrics();
if (metrics.mScrollId != aLayer->GetScrollbarTargetContainerId()) {
if (metrics.GetScrollId() != aLayer->GetScrollbarTargetContainerId()) {
continue;
}
if (!LayerHasNonContainerDescendants(scrollTarget->AsContainerLayer())) {

View File

@ -182,7 +182,7 @@ ThebesLayerComposite::GetEffectiveResolution()
{
for (ContainerLayer* parent = GetParent(); parent; parent = parent->GetParent()) {
const FrameMetrics& metrics = parent->GetFrameMetrics();
if (metrics.mScrollId != FrameMetrics::NULL_SCROLL_ID) {
if (metrics.GetScrollId() != FrameMetrics::NULL_SCROLL_ID) {
return metrics.GetZoom();
}
}

View File

@ -69,7 +69,7 @@
" i=(%ld %lld) cb=(%d %d %d %d) dp=(%.3f %.3f %.3f %.3f) v=(%.3f %.3f %.3f %.3f) " \
"s=(%.3f %.3f) sr=(%.3f %.3f %.3f %.3f) z=(%.3f %.3f %.3f %.3f) u=(%d %llu)\n", \
__VA_ARGS__, \
fm.mPresShellId, fm.mScrollId, \
fm.mPresShellId, fm.GetScrollId(), \
fm.mCompositionBounds.x, fm.mCompositionBounds.y, fm.mCompositionBounds.width, fm.mCompositionBounds.height, \
fm.mDisplayPort.x, fm.mDisplayPort.y, fm.mDisplayPort.width, fm.mDisplayPort.height, \
fm.mViewport.x, fm.mViewport.y, fm.mViewport.width, fm.mViewport.height, \
@ -325,7 +325,7 @@ static inline void LogRendertraceRect(const ScrollableLayerGuid& aGuid, const ch
static const TimeStamp sRenderStart = TimeStamp::Now();
TimeDuration delta = TimeStamp::Now() - sRenderStart;
printf_stderr("(%llu,%lu,%llu)%s RENDERTRACE %f rect %s %f %f %f %f\n",
aGuid.mLayersId, aGuid.mPresShellId, aGuid.mScrollId,
aGuid.mLayersId, aGuid.mPresShellId, aGuid.GetScrollId(),
aDesc, delta.ToMilliseconds(), aColor,
aRect.x, aRect.y, aRect.width, aRect.height);
#endif
@ -480,7 +480,7 @@ AsyncPanZoomController::~AsyncPanZoomController() {
// Only send the release message if the SharedFrameMetrics has been created.
if (compositor && mSharedFrameMetricsBuffer) {
unused << compositor->SendReleaseSharedCompositorFrameMetrics(mFrameMetrics.mScrollId, mAPZCId);
unused << compositor->SendReleaseSharedCompositorFrameMetrics(mFrameMetrics.GetScrollId(), mAPZCId);
}
delete mSharedFrameMetricsBuffer;
@ -1778,7 +1778,7 @@ void AsyncPanZoomController::NotifyLayersUpdated(const FrameMetrics& aLayerMetri
// more "legitimate" sources like content scripts.
nsRefPtr<GeckoContentController> controller = GetGeckoContentController();
if (controller) {
controller->AcknowledgeScrollUpdate(aLayerMetrics.mScrollId,
controller->AcknowledgeScrollUpdate(aLayerMetrics.GetScrollId(),
aLayerMetrics.GetScrollGeneration());
}
}
@ -1989,10 +1989,10 @@ void AsyncPanZoomController::SetState(PanZoomState aNewState) {
if (mGeckoContentController) {
if (!IsTransformingState(oldState) && IsTransformingState(aNewState)) {
mGeckoContentController->NotifyTransformBegin(
ScrollableLayerGuid(mLayersId, mFrameMetrics.mPresShellId, mFrameMetrics.mScrollId));
ScrollableLayerGuid(mLayersId, mFrameMetrics.mPresShellId, mFrameMetrics.GetScrollId()));
} else if (IsTransformingState(oldState) && !IsTransformingState(aNewState)) {
mGeckoContentController->NotifyTransformEnd(
ScrollableLayerGuid(mLayersId, mFrameMetrics.mPresShellId, mFrameMetrics.mScrollId));
ScrollableLayerGuid(mLayersId, mFrameMetrics.mPresShellId, mFrameMetrics.GetScrollId()));
}
}
}

View File

@ -211,7 +211,7 @@ CompositorChild::SharedFrameMetricsData::GetViewID()
MOZ_ASSERT(frame);
// Not locking to read of mScrollId since it should not change after being
// initially set.
return frame->mScrollId;
return frame->GetScrollId();
}
uint32_t

View File

@ -511,10 +511,10 @@ TEST(AsyncPanZoomController, ComplexTransform) {
metrics.mResolution = ParentLayerToLayerScale(2);
metrics.SetZoom(CSSToScreenScale(6));
metrics.mDevPixelsPerCSSPixel = CSSToLayoutDeviceScale(3);
metrics.mScrollId = FrameMetrics::START_SCROLL_ID;
metrics.SetScrollId(FrameMetrics::START_SCROLL_ID);
FrameMetrics childMetrics = metrics;
childMetrics.mScrollId = FrameMetrics::START_SCROLL_ID + 1;
childMetrics.SetScrollId(FrameMetrics::START_SCROLL_ID + 1);
layers[0]->AsContainerLayer()->SetFrameMetrics(metrics);
layers[1]->AsContainerLayer()->SetFrameMetrics(childMetrics);
@ -927,7 +927,7 @@ SetScrollableFrameMetrics(Layer* aLayer, FrameMetrics::ViewID aScrollId,
{
ContainerLayer* container = aLayer->AsContainerLayer();
FrameMetrics metrics;
metrics.mScrollId = aScrollId;
metrics.SetScrollId(aScrollId);
nsIntRect layerBound = aLayer->GetVisibleRegion().GetBounds();
metrics.mCompositionBounds = ParentLayerIntRect(layerBound.x, layerBound.y,
layerBound.width, layerBound.height);

View File

@ -698,7 +698,7 @@ static void RecordFrameMetrics(nsIFrame* aForFrame,
metrics.mScrollableRect = CSSRect::FromAppUnits(contentBounds);
}
metrics.mScrollId = aScrollId;
metrics.SetScrollId(aScrollId);
metrics.mIsRoot = aIsRoot;
// Only the root scrollable frame for a given presShell should pick up

View File

@ -212,7 +212,7 @@ BuildListForLayer(Layer* aLayer,
gfx3DMatrix transform;
if (metrics && metrics->IsScrollable()) {
const ViewID scrollId = metrics->mScrollId;
const ViewID scrollId = metrics->GetScrollId();
// We need to figure out the bounds of the scrollable region using the
// shadow layer tree from the remote process. The metrics viewport is
@ -280,7 +280,7 @@ TransformShadowTree(nsDisplayListBuilder* aBuilder, nsFrameLoader* aFrameLoader,
ViewTransform layerTransform = aTransform;
if (metrics && metrics->IsScrollable()) {
const ViewID scrollId = metrics->mScrollId;
const ViewID scrollId = metrics->GetScrollId();
const nsContentView* view =
aFrameLoader->GetCurrentRemoteFrame()->GetContentView(scrollId);
NS_ABORT_IF_FALSE(view, "Array of views should be consistent with layer tree");
@ -382,7 +382,7 @@ BuildViewMap(ViewMap& oldContentViews, ViewMap& newContentViews,
if (!container)
return;
const FrameMetrics metrics = container->GetFrameMetrics();
const ViewID scrollId = metrics.mScrollId;
const ViewID scrollId = metrics.GetScrollId();
gfx3DMatrix transform;
To3DMatrix(aLayer->GetTransform(), transform);
aXScale *= GetXScale(transform);
@ -744,7 +744,7 @@ RenderFrameParent::Init(nsFrameLoader* aFrameLoader,
}
if (lm && lm->GetRoot() && lm->GetRoot()->AsContainerLayer()) {
ViewID rootScrollId = lm->GetRoot()->AsContainerLayer()->GetFrameMetrics().mScrollId;
ViewID rootScrollId = lm->GetRoot()->AsContainerLayer()->GetFrameMetrics().GetScrollId();
if (rootScrollId != FrameMetrics::NULL_SCROLL_ID) {
mContentViews[rootScrollId] = new nsContentView(aFrameLoader, rootScrollId, true);
}

View File

@ -24,7 +24,7 @@ public:
NS_IMETHOD Run() {
MOZ_ASSERT(NS_IsMainThread());
nsCOMPtr<nsIContent> content = nsLayoutUtils::FindContentFor(mFrameMetrics.mScrollId);
nsCOMPtr<nsIContent> content = nsLayoutUtils::FindContentFor(mFrameMetrics.GetScrollId());
if (content) {
APZCCallbackHelper::UpdateSubFrame(content, mFrameMetrics);
}
@ -38,7 +38,7 @@ protected:
void
ParentProcessController::RequestContentRepaint(const FrameMetrics& aFrameMetrics)
{
if (aFrameMetrics.mScrollId == FrameMetrics::NULL_SCROLL_ID) {
if (aFrameMetrics.GetScrollId() == FrameMetrics::NULL_SCROLL_ID) {
return;
}

View File

@ -103,7 +103,7 @@ public:
nsCOMPtr<nsIDocument> subDocument;
nsCOMPtr<nsIContent> targetContent;
if (!GetDOMTargets(mFrameMetrics.mScrollId,
if (!GetDOMTargets(mFrameMetrics.GetScrollId(),
subDocument, targetContent)) {
return NS_OK;
}
@ -132,7 +132,7 @@ public:
#ifdef DEBUG_CONTROLLER
WinUtils::Log("APZController: %I64d mDisplayPort: %0.2f %0.2f %0.2f %0.2f",
mFrameMetrics.mScrollId,
mFrameMetrics.GetScrollId(),
mFrameMetrics.mDisplayPort.x,
mFrameMetrics.mDisplayPort.y,
mFrameMetrics.mDisplayPort.width,
@ -205,7 +205,7 @@ APZController::RequestContentRepaint(const FrameMetrics& aFrameMetrics)
#ifdef DEBUG_CONTROLLER
WinUtils::Log("APZController::RequestContentRepaint scrollid=%I64d",
aFrameMetrics.mScrollId);
aFrameMetrics.GetScrollId());
#endif
nsCOMPtr<nsIRunnable> r1 = new RequestContentRepaintEvent(aFrameMetrics,
mWidgetListener);

View File

@ -145,7 +145,7 @@ APZCCallbackHelper::UpdateRootFrame(nsIDOMWindowUtils* aUtils,
{
// Precondition checks
MOZ_ASSERT(aUtils);
if (aMetrics.mScrollId == FrameMetrics::NULL_SCROLL_ID) {
if (aMetrics.GetScrollId() == FrameMetrics::NULL_SCROLL_ID) {
return;
}
@ -160,7 +160,7 @@ APZCCallbackHelper::UpdateRootFrame(nsIDOMWindowUtils* aUtils,
aUtils->SetScrollPositionClampingScrollPortSize(scrollPort.width, scrollPort.height);
// Scroll the window to the desired spot
nsIScrollableFrame* sf = nsLayoutUtils::FindScrollableFrameFor(aMetrics.mScrollId);
nsIScrollableFrame* sf = nsLayoutUtils::FindScrollableFrameFor(aMetrics.GetScrollId());
bool scrollUpdated = false;
CSSPoint actualScrollOffset = ScrollFrameTo(sf, aMetrics.GetScrollOffset(), scrollUpdated);
@ -197,7 +197,7 @@ APZCCallbackHelper::UpdateRootFrame(nsIDOMWindowUtils* aUtils,
aUtils->SetResolution(presShellResolution.scale, presShellResolution.scale);
// Finally, we set the displayport.
nsCOMPtr<nsIContent> content = nsLayoutUtils::FindContentFor(aMetrics.mScrollId);
nsCOMPtr<nsIContent> content = nsLayoutUtils::FindContentFor(aMetrics.GetScrollId());
if (!content) {
return;
}
@ -218,7 +218,7 @@ APZCCallbackHelper::UpdateSubFrame(nsIContent* aContent,
{
// Precondition checks
MOZ_ASSERT(aContent);
if (aMetrics.mScrollId == FrameMetrics::NULL_SCROLL_ID) {
if (aMetrics.GetScrollId() == FrameMetrics::NULL_SCROLL_ID) {
return;
}
@ -230,7 +230,7 @@ APZCCallbackHelper::UpdateSubFrame(nsIContent* aContent,
// We currently do not support zooming arbitrary subframes. They can only
// be scrolled, so here we only have to set the scroll position and displayport.
nsIScrollableFrame* sf = nsLayoutUtils::FindScrollableFrameFor(aMetrics.mScrollId);
nsIScrollableFrame* sf = nsLayoutUtils::FindScrollableFrameFor(aMetrics.GetScrollId());
bool scrollUpdated = false;
CSSPoint actualScrollOffset = ScrollFrameTo(sf, aMetrics.GetScrollOffset(), scrollUpdated);
@ -334,7 +334,7 @@ DestroyCSSPoint(void* aObject, nsIAtom* aPropertyName,
void
APZCCallbackHelper::UpdateCallbackTransform(const FrameMetrics& aApzcMetrics, const FrameMetrics& aActualMetrics)
{
nsCOMPtr<nsIContent> content = nsLayoutUtils::FindContentFor(aApzcMetrics.mScrollId);
nsCOMPtr<nsIContent> content = nsLayoutUtils::FindContentFor(aApzcMetrics.GetScrollId());
if (!content) {
return;
}