mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 900092 - Remove FrameMetrics::ROOT_SCROLL_ID. r=kats,tn
This commit is contained in:
parent
86cbe2498d
commit
20adb2fb8e
@ -123,12 +123,6 @@ public:
|
||||
|
||||
NS_IMPL_ISUPPORTS1(nsContentView, nsIContentView)
|
||||
|
||||
bool
|
||||
nsContentView::IsRoot() const
|
||||
{
|
||||
return mScrollId == FrameMetrics::ROOT_SCROLL_ID;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsContentView::Update(const ViewConfig& aConfig)
|
||||
{
|
||||
@ -2376,7 +2370,7 @@ nsFrameLoader::GetRootContentView(nsIContentView** aContentView)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsContentView* view = rfp->GetContentView();
|
||||
nsContentView* view = rfp->GetRootContentView();
|
||||
NS_ABORT_IF_FALSE(view, "Should always be able to create root scrollable!");
|
||||
nsRefPtr<nsIContentView>(view).forget(aContentView);
|
||||
|
||||
|
@ -103,7 +103,7 @@ public:
|
||||
float mYScale;
|
||||
};
|
||||
|
||||
nsContentView(nsFrameLoader* aFrameLoader, ViewID aScrollId,
|
||||
nsContentView(nsFrameLoader* aFrameLoader, ViewID aScrollId, bool aIsRoot,
|
||||
ViewConfig aConfig = ViewConfig())
|
||||
: mViewportSize(0, 0)
|
||||
, mContentSize(0, 0)
|
||||
@ -111,10 +111,14 @@ public:
|
||||
, mParentScaleY(1.0)
|
||||
, mFrameLoader(aFrameLoader)
|
||||
, mScrollId(aScrollId)
|
||||
, mIsRoot(aIsRoot)
|
||||
, mConfig(aConfig)
|
||||
{}
|
||||
|
||||
bool IsRoot() const;
|
||||
bool IsRoot() const
|
||||
{
|
||||
return mIsRoot;
|
||||
}
|
||||
|
||||
ViewID GetId() const
|
||||
{
|
||||
@ -137,6 +141,7 @@ private:
|
||||
nsresult Update(const ViewConfig& aConfig);
|
||||
|
||||
ViewID mScrollId;
|
||||
bool mIsRoot;
|
||||
ViewConfig mConfig;
|
||||
};
|
||||
|
||||
|
@ -1699,22 +1699,6 @@ nsDOMWindowUtils::FindElementWithViewId(nsViewID aID,
|
||||
return NS_ERROR_DOM_SECURITY_ERR;
|
||||
}
|
||||
|
||||
if (aID == FrameMetrics::ROOT_SCROLL_ID) {
|
||||
nsPresContext* presContext = GetPresContext();
|
||||
if (!presContext) {
|
||||
return NS_ERROR_NOT_AVAILABLE;
|
||||
}
|
||||
|
||||
nsIDocument* document = presContext->Document();
|
||||
Element* rootElement = document->GetRootElement();
|
||||
if (!rootElement) {
|
||||
return NS_ERROR_NOT_AVAILABLE;
|
||||
}
|
||||
|
||||
CallQueryInterface(rootElement, aResult);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsRefPtr<nsIContent> content = nsLayoutUtils::FindContentFor(aID);
|
||||
return content ? CallQueryInterface(content, aResult) : NS_OK;
|
||||
}
|
||||
|
@ -293,7 +293,7 @@ parent:
|
||||
* The zoom controller code lives on the parent side and so this allows it to
|
||||
* have up-to-date zoom constraints.
|
||||
*/
|
||||
UpdateZoomConstraints(uint32_t aPresShellId, ViewID aViewId,
|
||||
UpdateZoomConstraints(uint32_t aPresShellId, ViewID aViewId, bool aIsRoot,
|
||||
bool aAllowZoom, CSSToScreenScale aMinZoom, CSSToScreenScale aMaxZoom);
|
||||
|
||||
/**
|
||||
|
@ -303,7 +303,6 @@ TabChild::HandleEvent(nsIDOMEvent* aEvent)
|
||||
|
||||
ViewID viewId;
|
||||
uint32_t presShellId;
|
||||
nsIScrollableFrame* scrollFrame = nullptr;
|
||||
|
||||
nsCOMPtr<nsIContent> content;
|
||||
if (nsCOMPtr<nsIDocument> doc = do_QueryInterface(target))
|
||||
@ -317,27 +316,19 @@ TabChild::HandleEvent(nsIDOMEvent* aEvent)
|
||||
if (!nsLayoutUtils::FindIDFor(content, &viewId))
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
|
||||
// Note that we cannot use FindScrollableFrameFor(ROOT_SCROLL_ID) because
|
||||
// it might return the root element from a different page in the case where
|
||||
// that page is in the bfcache and this page is not run through layout
|
||||
// before being drawn to the screen. Hence the code blocks below treat
|
||||
// ROOT_SCROLL_ID separately from the non-ROOT_SCROLL_ID case.
|
||||
nsIScrollableFrame* scrollFrame = nsLayoutUtils::FindScrollableFrameFor(viewId);
|
||||
if (!scrollFrame)
|
||||
return NS_OK;
|
||||
|
||||
CSSIntPoint scrollOffset;
|
||||
if (viewId != FrameMetrics::ROOT_SCROLL_ID) {
|
||||
scrollFrame = nsLayoutUtils::FindScrollableFrameFor(viewId);
|
||||
if (!scrollFrame) {
|
||||
return NS_OK;
|
||||
}
|
||||
scrollOffset = scrollFrame->GetScrollPositionCSSPixels();
|
||||
} else {
|
||||
CSSIntPoint scrollOffset = scrollFrame->GetScrollPositionCSSPixels();
|
||||
|
||||
if (viewId == mLastMetrics.mScrollId) {
|
||||
// For the root frame, we store the last metrics, including the last
|
||||
// scroll offset, sent by APZC. (This is updated in ProcessUpdateFrame()).
|
||||
// We use this here to avoid sending APZC back a scroll event that
|
||||
// originally came from APZC (besides being unnecessary, the event might
|
||||
// be slightly out of date by the time it reaches APZC).
|
||||
// We should probably do this for subframes, too.
|
||||
utils->GetScrollXY(false, &scrollOffset.x, &scrollOffset.y);
|
||||
if (RoundedToInt(mLastMetrics.mScrollOffset) == scrollOffset) {
|
||||
return NS_OK;
|
||||
}
|
||||
@ -347,6 +338,7 @@ TabChild::HandleEvent(nsIDOMEvent* aEvent)
|
||||
// gets a chance to update it.
|
||||
mLastMetrics.mScrollOffset = scrollOffset;
|
||||
}
|
||||
|
||||
SendUpdateScrollOffset(presShellId, viewId, scrollOffset);
|
||||
}
|
||||
|
||||
@ -547,6 +539,7 @@ TabChild::HandlePossibleViewportChange()
|
||||
nsViewportInfo viewportInfo = nsContentUtils::GetViewportInfo(document, mInnerSize);
|
||||
SendUpdateZoomConstraints(presShellId,
|
||||
viewId,
|
||||
/* isRoot = */ true,
|
||||
viewportInfo.IsZoomAllowed(),
|
||||
viewportInfo.GetMinZoom(),
|
||||
viewportInfo.GetMaxZoom());
|
||||
@ -1537,14 +1530,14 @@ TabChild::RecvUpdateFrame(const FrameMetrics& aFrameMetrics)
|
||||
{
|
||||
MOZ_ASSERT(aFrameMetrics.mScrollId != FrameMetrics::NULL_SCROLL_ID);
|
||||
|
||||
if (aFrameMetrics.mScrollId == FrameMetrics::ROOT_SCROLL_ID) {
|
||||
if (aFrameMetrics.mIsRoot) {
|
||||
nsCOMPtr<nsIDOMWindowUtils> utils(GetDOMWindowUtils());
|
||||
if (APZCCallbackHelper::HasValidPresShellId(utils, aFrameMetrics)) {
|
||||
return ProcessUpdateFrame(aFrameMetrics);
|
||||
}
|
||||
} else {
|
||||
// aFrameMetrics.mScrollId is not FrameMetrics::ROOT_SCROLL_ID,
|
||||
// so we are trying to update a subframe. This requires special handling.
|
||||
// aFrameMetrics.mIsRoot is false, so we are trying to update a subframe.
|
||||
// This requires special handling.
|
||||
nsCOMPtr<nsIContent> content = nsLayoutUtils::FindContentFor(
|
||||
aFrameMetrics.mScrollId);
|
||||
if (content) {
|
||||
|
@ -1628,12 +1628,13 @@ TabParent::RecvZoomToRect(const uint32_t& aPresShellId,
|
||||
bool
|
||||
TabParent::RecvUpdateZoomConstraints(const uint32_t& aPresShellId,
|
||||
const ViewID& aViewId,
|
||||
const bool& aIsRoot,
|
||||
const bool& aAllowZoom,
|
||||
const CSSToScreenScale& aMinZoom,
|
||||
const CSSToScreenScale& aMaxZoom)
|
||||
{
|
||||
if (RenderFrameParent* rfp = GetRenderFrame()) {
|
||||
rfp->UpdateZoomConstraints(aPresShellId, aViewId, aAllowZoom, aMinZoom, aMaxZoom);
|
||||
rfp->UpdateZoomConstraints(aPresShellId, aViewId, aIsRoot, aAllowZoom, aMinZoom, aMaxZoom);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -167,6 +167,7 @@ public:
|
||||
const CSSRect& aRect);
|
||||
virtual bool RecvUpdateZoomConstraints(const uint32_t& aPresShellId,
|
||||
const ViewID& aViewId,
|
||||
const bool& aIsRoot,
|
||||
const bool& aAllowZoom,
|
||||
const CSSToScreenScale& aMinZoom,
|
||||
const CSSToScreenScale& aMaxZoom);
|
||||
|
@ -584,6 +584,7 @@ struct ParamTraits<mozilla::layers::FrameMetrics>
|
||||
WriteParam(aMsg, aParam.mDevPixelsPerCSSPixel);
|
||||
WriteParam(aMsg, aParam.mMayHaveTouchListeners);
|
||||
WriteParam(aMsg, aParam.mPresShellId);
|
||||
WriteParam(aMsg, aParam.mIsRoot);
|
||||
}
|
||||
|
||||
static bool Read(const Message* aMsg, void** aIter, paramType* aResult)
|
||||
@ -600,7 +601,8 @@ struct ParamTraits<mozilla::layers::FrameMetrics>
|
||||
ReadParam(aMsg, aIter, &aResult->mZoom) &&
|
||||
ReadParam(aMsg, aIter, &aResult->mDevPixelsPerCSSPixel) &&
|
||||
ReadParam(aMsg, aIter, &aResult->mMayHaveTouchListeners) &&
|
||||
ReadParam(aMsg, aIter, &aResult->mPresShellId));
|
||||
ReadParam(aMsg, aIter, &aResult->mPresShellId) &&
|
||||
ReadParam(aMsg, aIter, &aResult->mIsRoot));
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -36,7 +36,6 @@ public:
|
||||
// We use IDs to identify frames across processes.
|
||||
typedef uint64_t ViewID;
|
||||
static const ViewID NULL_SCROLL_ID; // This container layer does not scroll.
|
||||
static const ViewID ROOT_SCROLL_ID; // This is the root scroll frame.
|
||||
static const ViewID START_SCROLL_ID; // This is the ID that scrolling subframes
|
||||
// will begin at.
|
||||
|
||||
@ -54,6 +53,7 @@ public:
|
||||
, mDevPixelsPerCSSPixel(1)
|
||||
, mMayHaveTouchListeners(false)
|
||||
, mPresShellId(-1)
|
||||
, mIsRoot(false)
|
||||
{}
|
||||
|
||||
// Default copy ctor and operator= are fine
|
||||
@ -71,7 +71,8 @@ public:
|
||||
mCumulativeResolution == aOther.mCumulativeResolution &&
|
||||
mDevPixelsPerCSSPixel == aOther.mDevPixelsPerCSSPixel &&
|
||||
mMayHaveTouchListeners == aOther.mMayHaveTouchListeners &&
|
||||
mPresShellId == aOther.mPresShellId;
|
||||
mPresShellId == aOther.mPresShellId &&
|
||||
mIsRoot == aOther.mIsRoot;
|
||||
}
|
||||
bool operator!=(const FrameMetrics& aOther) const
|
||||
{
|
||||
@ -88,7 +89,7 @@ public:
|
||||
|
||||
bool IsRootScrollable() const
|
||||
{
|
||||
return mScrollId == ROOT_SCROLL_ID;
|
||||
return mIsRoot;
|
||||
}
|
||||
|
||||
bool IsScrollable() const
|
||||
@ -206,8 +207,7 @@ public:
|
||||
// not any parents, regardless of parent transforms.
|
||||
CSSPoint mScrollOffset;
|
||||
|
||||
// A unique ID assigned to each scrollable frame (unless this is
|
||||
// ROOT_SCROLL_ID, in which case it is not unique).
|
||||
// A unique ID assigned to each scrollable frame.
|
||||
ViewID mScrollId;
|
||||
|
||||
// The scrollable bounds of a frame. This is determined by reflow.
|
||||
@ -253,6 +253,9 @@ public:
|
||||
bool mMayHaveTouchListeners;
|
||||
|
||||
uint32_t mPresShellId;
|
||||
|
||||
// Whether or not this is the root scroll frame for the root content document.
|
||||
bool mIsRoot;
|
||||
};
|
||||
|
||||
/**
|
||||
@ -293,16 +296,6 @@ struct ScrollableLayerGuid {
|
||||
MOZ_COUNT_CTOR(ScrollableLayerGuid);
|
||||
}
|
||||
|
||||
ScrollableLayerGuid(uint64_t aLayersId)
|
||||
: mLayersId(aLayersId)
|
||||
, mPresShellId(0)
|
||||
, mScrollId(FrameMetrics::ROOT_SCROLL_ID)
|
||||
{
|
||||
MOZ_COUNT_CTOR(ScrollableLayerGuid);
|
||||
// TODO: get rid of this constructor once all callers know their
|
||||
// presShellId and scrollId
|
||||
}
|
||||
|
||||
~ScrollableLayerGuid()
|
||||
{
|
||||
MOZ_COUNT_DTOR(ScrollableLayerGuid);
|
||||
|
@ -37,8 +37,7 @@ using namespace mozilla::gfx;
|
||||
|
||||
typedef FrameMetrics::ViewID ViewID;
|
||||
const ViewID FrameMetrics::NULL_SCROLL_ID = 0;
|
||||
const ViewID FrameMetrics::ROOT_SCROLL_ID = 1;
|
||||
const ViewID FrameMetrics::START_SCROLL_ID = 2;
|
||||
const ViewID FrameMetrics::START_SCROLL_ID = 1;
|
||||
|
||||
uint8_t gLayerManagerLayerBuilder;
|
||||
|
||||
|
@ -1527,19 +1527,19 @@ void AsyncPanZoomController::SendAsyncScrollEvent() {
|
||||
return;
|
||||
}
|
||||
|
||||
FrameMetrics::ViewID scrollId;
|
||||
bool isRoot;
|
||||
CSSRect contentRect;
|
||||
CSSSize scrollableSize;
|
||||
{
|
||||
ReentrantMonitorAutoEnter lock(mMonitor);
|
||||
|
||||
scrollId = mFrameMetrics.mScrollId;
|
||||
isRoot = mFrameMetrics.mIsRoot;
|
||||
scrollableSize = mFrameMetrics.mScrollableRect.Size();
|
||||
contentRect = mFrameMetrics.CalculateCompositedRectInCssPixels();
|
||||
contentRect.MoveTo(mCurrentAsyncScrollOffset);
|
||||
}
|
||||
|
||||
controller->SendAsyncScrollDOMEvent(scrollId, contentRect, scrollableSize);
|
||||
controller->SendAsyncScrollDOMEvent(isRoot, contentRect, scrollableSize);
|
||||
}
|
||||
|
||||
void AsyncPanZoomController::UpdateScrollOffset(const CSSPoint& aScrollOffset)
|
||||
|
@ -54,7 +54,7 @@ public:
|
||||
* |aContentRect| is in CSS pixels, relative to the current cssPage.
|
||||
* |aScrollableSize| is the current content width/height in CSS pixels.
|
||||
*/
|
||||
virtual void SendAsyncScrollDOMEvent(FrameMetrics::ViewID aScrollId,
|
||||
virtual void SendAsyncScrollDOMEvent(bool aIsRoot,
|
||||
const CSSRect &aContentRect,
|
||||
const CSSSize &aScrollableSize) = 0;
|
||||
|
||||
|
@ -28,7 +28,7 @@ public:
|
||||
MOCK_METHOD1(HandleDoubleTap, void(const CSSIntPoint&));
|
||||
MOCK_METHOD1(HandleSingleTap, void(const CSSIntPoint&));
|
||||
MOCK_METHOD1(HandleLongTap, void(const CSSIntPoint&));
|
||||
MOCK_METHOD3(SendAsyncScrollDOMEvent, void(FrameMetrics::ViewID aScrollId, const CSSRect &aContentRect, const CSSSize &aScrollableSize));
|
||||
MOCK_METHOD3(SendAsyncScrollDOMEvent, void(bool aIsRoot, const CSSRect &aContentRect, const CSSSize &aScrollableSize));
|
||||
MOCK_METHOD2(PostDelayedTask, void(Task* aTask, int aDelayMs));
|
||||
};
|
||||
|
||||
@ -273,10 +273,10 @@ TEST(AsyncPanZoomController, ComplexTransform) {
|
||||
metrics.mResolution = ParentLayerToLayerScale(2);
|
||||
metrics.mZoom = CSSToScreenScale(6);
|
||||
metrics.mDevPixelsPerCSSPixel = CSSToLayoutDeviceScale(3);
|
||||
metrics.mScrollId = FrameMetrics::ROOT_SCROLL_ID;
|
||||
metrics.mScrollId = FrameMetrics::START_SCROLL_ID;
|
||||
|
||||
FrameMetrics childMetrics = metrics;
|
||||
childMetrics.mScrollId = FrameMetrics::START_SCROLL_ID;
|
||||
childMetrics.mScrollId = FrameMetrics::START_SCROLL_ID + 1;
|
||||
|
||||
layers[0]->AsContainerLayer()->SetFrameMetrics(metrics);
|
||||
layers[1]->AsContainerLayer()->SetFrameMetrics(childMetrics);
|
||||
@ -521,7 +521,7 @@ TEST(APZCTreeManager, HitTesting1) {
|
||||
EXPECT_EQ(gfx3DMatrix(), transformToGecko);
|
||||
|
||||
// Now we have a root APZC that will match the page
|
||||
SetScrollableFrameMetrics(root, FrameMetrics::ROOT_SCROLL_ID);
|
||||
SetScrollableFrameMetrics(root, FrameMetrics::START_SCROLL_ID);
|
||||
manager->UpdatePanZoomControllerTree(nullptr, root, false, 0);
|
||||
hit = GetTargetAPZC(manager, ScreenPoint(15, 15), transformToApzc, transformToGecko);
|
||||
EXPECT_EQ(root->AsContainerLayer()->GetAsyncPanZoomController(), hit.get());
|
||||
@ -530,7 +530,7 @@ TEST(APZCTreeManager, HitTesting1) {
|
||||
EXPECT_EQ(gfxPoint(15, 15), transformToGecko.Transform(gfxPoint(15, 15)));
|
||||
|
||||
// Now we have a sub APZC with a better fit
|
||||
SetScrollableFrameMetrics(layers[3], FrameMetrics::START_SCROLL_ID);
|
||||
SetScrollableFrameMetrics(layers[3], FrameMetrics::START_SCROLL_ID + 1);
|
||||
manager->UpdatePanZoomControllerTree(nullptr, root, false, 0);
|
||||
EXPECT_NE(root->AsContainerLayer()->GetAsyncPanZoomController(), layers[3]->AsContainerLayer()->GetAsyncPanZoomController());
|
||||
hit = GetTargetAPZC(manager, ScreenPoint(15, 15), transformToApzc, transformToGecko);
|
||||
@ -542,7 +542,7 @@ TEST(APZCTreeManager, HitTesting1) {
|
||||
// Now test hit testing when we have two scrollable layers
|
||||
hit = GetTargetAPZC(manager, ScreenPoint(15, 15), transformToApzc, transformToGecko);
|
||||
EXPECT_EQ(layers[3]->AsContainerLayer()->GetAsyncPanZoomController(), hit.get());
|
||||
SetScrollableFrameMetrics(layers[4], FrameMetrics::START_SCROLL_ID + 1);
|
||||
SetScrollableFrameMetrics(layers[4], FrameMetrics::START_SCROLL_ID + 2);
|
||||
manager->UpdatePanZoomControllerTree(nullptr, root, false, 0);
|
||||
hit = GetTargetAPZC(manager, ScreenPoint(15, 15), transformToApzc, transformToGecko);
|
||||
EXPECT_EQ(layers[4]->AsContainerLayer()->GetAsyncPanZoomController(), hit.get());
|
||||
@ -592,9 +592,9 @@ TEST(APZCTreeManager, HitTesting2) {
|
||||
layers[2]->SetBaseTransform(transform);
|
||||
|
||||
// Make some other layers scrollable.
|
||||
SetScrollableFrameMetrics(root, FrameMetrics::ROOT_SCROLL_ID, CSSRect(0, 0, 200, 200));
|
||||
SetScrollableFrameMetrics(layers[1], FrameMetrics::START_SCROLL_ID, CSSRect(0, 0, 80, 80));
|
||||
SetScrollableFrameMetrics(layers[3], FrameMetrics::START_SCROLL_ID + 1, CSSRect(0, 0, 80, 80));
|
||||
SetScrollableFrameMetrics(root, FrameMetrics::START_SCROLL_ID, CSSRect(0, 0, 200, 200));
|
||||
SetScrollableFrameMetrics(layers[1], FrameMetrics::START_SCROLL_ID + 1, CSSRect(0, 0, 80, 80));
|
||||
SetScrollableFrameMetrics(layers[3], FrameMetrics::START_SCROLL_ID + 2, CSSRect(0, 0, 80, 80));
|
||||
|
||||
manager->UpdatePanZoomControllerTree(nullptr, root, false, 0);
|
||||
|
||||
|
@ -593,6 +593,7 @@ static void RecordFrameMetrics(nsIFrame* aForFrame,
|
||||
nsRect* aDisplayPort,
|
||||
nsRect* aCriticalDisplayPort,
|
||||
ViewID aScrollId,
|
||||
bool aIsRoot,
|
||||
const ContainerLayerParameters& aContainerParameters) {
|
||||
nsPresContext* presContext = aForFrame->PresContext();
|
||||
int32_t auPerDevPixel = presContext->AppUnitsPerDevPixel();
|
||||
@ -629,6 +630,7 @@ static void RecordFrameMetrics(nsIFrame* aForFrame,
|
||||
}
|
||||
|
||||
metrics.mScrollId = aScrollId;
|
||||
metrics.mIsRoot = aIsRoot;
|
||||
|
||||
// Only the root scrollable frame for a given presShell should pick up
|
||||
// the presShell's resolution. All the other frames are 1.0.
|
||||
@ -1150,8 +1152,8 @@ void nsDisplayList::PaintForFrame(nsDisplayListBuilder* aBuilder,
|
||||
root->SetPostScale(1.0f/containerParameters.mXScale,
|
||||
1.0f/containerParameters.mYScale);
|
||||
|
||||
ViewID id = presContext->IsRootContentDocument() ? FrameMetrics::ROOT_SCROLL_ID
|
||||
: FrameMetrics::NULL_SCROLL_ID;
|
||||
ViewID id = FrameMetrics::NULL_SCROLL_ID;
|
||||
bool isRoot = presContext->IsRootContentDocument();
|
||||
|
||||
nsIFrame* rootScrollFrame = presShell->GetRootScrollFrame();
|
||||
nsRect displayport, criticalDisplayport;
|
||||
@ -1164,11 +1166,9 @@ void nsDisplayList::PaintForFrame(nsDisplayListBuilder* aBuilder,
|
||||
usingCriticalDisplayport =
|
||||
nsLayoutUtils::GetCriticalDisplayPort(content, &criticalDisplayport);
|
||||
|
||||
if (id == FrameMetrics::ROOT_SCROLL_ID) {
|
||||
// Record the mapping between the root scroll frame's content and
|
||||
// ROOT_SCROLL_ID so that users of nsLayoutUtils::FindIDFor() and
|
||||
// nsLayoutUtils::FindContentFor() don't have to special-case the root.
|
||||
nsLayoutUtils::FindOrCreateIDFor(content, true);
|
||||
// If this is the root content document, we want it to have a scroll id.
|
||||
if (isRoot) {
|
||||
id = nsLayoutUtils::FindOrCreateIDFor(content);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1180,7 +1180,7 @@ void nsDisplayList::PaintForFrame(nsDisplayListBuilder* aBuilder,
|
||||
root, mVisibleRect, viewport,
|
||||
(usingDisplayport ? &displayport : nullptr),
|
||||
(usingCriticalDisplayport ? &criticalDisplayport : nullptr),
|
||||
id, containerParameters);
|
||||
id, isRoot, containerParameters);
|
||||
if (usingDisplayport &&
|
||||
!(root->GetContentFlags() & Layer::CONTENT_OPAQUE)) {
|
||||
// See bug 693938, attachment 567017
|
||||
@ -3450,7 +3450,7 @@ nsDisplayScrollLayer::BuildLayer(nsDisplayListBuilder* aBuilder,
|
||||
mVisibleRect, viewport,
|
||||
(usingDisplayport ? &displayport : nullptr),
|
||||
(usingCriticalDisplayport ? &criticalDisplayport : nullptr),
|
||||
scrollId, aContainerParameters);
|
||||
scrollId, false, aContainerParameters);
|
||||
|
||||
return layer.forget();
|
||||
}
|
||||
|
@ -528,22 +528,12 @@ nsLayoutUtils::FindIDFor(const nsIContent* aContent, ViewID* aOutViewId)
|
||||
}
|
||||
|
||||
ViewID
|
||||
nsLayoutUtils::FindOrCreateIDFor(nsIContent* aContent, bool aRoot)
|
||||
nsLayoutUtils::FindOrCreateIDFor(nsIContent* aContent)
|
||||
{
|
||||
ViewID scrollId;
|
||||
|
||||
if (!FindIDFor(aContent, &scrollId)) {
|
||||
scrollId = aRoot ? FrameMetrics::ROOT_SCROLL_ID : sScrollIdCounter++;
|
||||
if (aRoot) {
|
||||
// We are possibly replacing the old ROOT_SCROLL_ID content with a new one, so
|
||||
// we should clear the property on the old content if there is one. Otherwise when
|
||||
// that content is destroyed it will clear its property list and clobber ROOT_SCROLL_ID.
|
||||
nsIContent* oldRoot;
|
||||
bool oldExists = GetContentMap().Get(scrollId, &oldRoot);
|
||||
if (oldExists) {
|
||||
oldRoot->DeleteProperty(nsGkAtoms::RemoteId);
|
||||
}
|
||||
}
|
||||
scrollId = sScrollIdCounter++;
|
||||
aContent->SetProperty(nsGkAtoms::RemoteId, new ViewID(scrollId),
|
||||
DestroyViewID);
|
||||
GetContentMap().Put(scrollId, aContent);
|
||||
|
@ -95,10 +95,9 @@ public:
|
||||
|
||||
/**
|
||||
* Finds previously assigned or generates a unique ViewID for the given
|
||||
* content element. If aRoot is true, the special ID
|
||||
* FrameMetrics::ROOT_SCROLL_ID is used.
|
||||
* content element.
|
||||
*/
|
||||
static ViewID FindOrCreateIDFor(nsIContent* aContent, bool aRoot = false);
|
||||
static ViewID FindOrCreateIDFor(nsIContent* aContent);
|
||||
|
||||
/**
|
||||
* Find content for given ID.
|
||||
|
@ -109,7 +109,7 @@ AssertInTopLevelChromeDoc(ContainerLayer* aContainer,
|
||||
"Expected frame to be in top-level chrome document");
|
||||
}
|
||||
|
||||
// Return view for given ID in aArray, nullptr if not found.
|
||||
// Return view for given ID in aMap, nullptr if not found.
|
||||
static nsContentView*
|
||||
FindViewForId(const ViewMap& aMap, ViewID aId)
|
||||
{
|
||||
@ -117,6 +117,19 @@ FindViewForId(const ViewMap& aMap, ViewID aId)
|
||||
return iter != aMap.end() ? iter->second : nullptr;
|
||||
}
|
||||
|
||||
// Return the root content view in aMap, nullptr if not found.
|
||||
static nsContentView*
|
||||
FindRootView(const ViewMap& aMap)
|
||||
{
|
||||
for (ViewMap::const_iterator iter = aMap.begin(), end = aMap.end();
|
||||
iter != end;
|
||||
++iter) {
|
||||
if (iter->second->IsRoot())
|
||||
return iter->second;
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
static const FrameMetrics*
|
||||
GetFrameMetrics(Layer* aLayer)
|
||||
{
|
||||
@ -403,7 +416,7 @@ BuildViewMap(ViewMap& oldContentViews, ViewMap& newContentViews,
|
||||
config.mScrollOffset = nsPoint(
|
||||
NSIntPixelsToAppUnits(metrics.mScrollOffset.x, auPerCSSPixel) * aXScale,
|
||||
NSIntPixelsToAppUnits(metrics.mScrollOffset.y, auPerCSSPixel) * aYScale);
|
||||
view = new nsContentView(aFrameLoader, scrollId, config);
|
||||
view = new nsContentView(aFrameLoader, scrollId, metrics.mIsRoot, config);
|
||||
view->mParentScaleX = aAccConfigXScale;
|
||||
view->mParentScaleY = aAccConfigYScale;
|
||||
}
|
||||
@ -554,7 +567,7 @@ public:
|
||||
|
||||
void ClearRenderFrame() { mRenderFrame = nullptr; }
|
||||
|
||||
virtual void SendAsyncScrollDOMEvent(FrameMetrics::ViewID aScrollId,
|
||||
virtual void SendAsyncScrollDOMEvent(bool aIsRoot,
|
||||
const CSSRect& aContentRect,
|
||||
const CSSSize& aContentSize) MOZ_OVERRIDE
|
||||
{
|
||||
@ -563,10 +576,10 @@ public:
|
||||
FROM_HERE,
|
||||
NewRunnableMethod(this,
|
||||
&RemoteContentController::SendAsyncScrollDOMEvent,
|
||||
aScrollId, aContentRect, aContentSize));
|
||||
aIsRoot, aContentRect, aContentSize));
|
||||
return;
|
||||
}
|
||||
if (mRenderFrame && aScrollId == FrameMetrics::ROOT_SCROLL_ID) {
|
||||
if (mRenderFrame && aIsRoot) {
|
||||
TabParent* browser = static_cast<TabParent*>(mRenderFrame->Manager());
|
||||
BrowserElementParent::DispatchAsyncScrollEvent(browser, aContentRect,
|
||||
aContentSize);
|
||||
@ -627,9 +640,6 @@ RenderFrameParent::RenderFrameParent(nsFrameLoader* aFrameLoader,
|
||||
, mFrameLoaderDestroyed(false)
|
||||
, mBackgroundColor(gfxRGBA(1, 1, 1))
|
||||
{
|
||||
mContentViews[FrameMetrics::ROOT_SCROLL_ID] =
|
||||
new nsContentView(aFrameLoader, FrameMetrics::ROOT_SCROLL_ID);
|
||||
|
||||
*aId = 0;
|
||||
|
||||
nsRefPtr<LayerManager> lm = GetFrom(mFrameLoader);
|
||||
@ -640,6 +650,13 @@ RenderFrameParent::RenderFrameParent(nsFrameLoader* aFrameLoader,
|
||||
*aTextureFactoryIdentifier = TextureFactoryIdentifier();
|
||||
}
|
||||
|
||||
if (lm && lm->GetRoot() && lm->GetRoot()->AsContainerLayer()) {
|
||||
ViewID rootScrollId = lm->GetRoot()->AsContainerLayer()->GetFrameMetrics().mScrollId;
|
||||
if (rootScrollId != FrameMetrics::NULL_SCROLL_ID) {
|
||||
mContentViews[rootScrollId] = new nsContentView(aFrameLoader, rootScrollId, true);
|
||||
}
|
||||
}
|
||||
|
||||
if (CompositorParent::CompositorLoop()) {
|
||||
// Our remote frame will push layers updates to the compositor,
|
||||
// and we'll keep an indirect reference to that tree.
|
||||
@ -695,6 +712,12 @@ RenderFrameParent::GetContentView(ViewID aId)
|
||||
return FindViewForId(mContentViews, aId);
|
||||
}
|
||||
|
||||
nsContentView*
|
||||
RenderFrameParent::GetRootContentView()
|
||||
{
|
||||
return FindRootView(mContentViews);
|
||||
}
|
||||
|
||||
void
|
||||
RenderFrameParent::ContentViewScaleChanged(nsContentView* aView)
|
||||
{
|
||||
@ -805,7 +828,7 @@ RenderFrameParent::BuildLayer(nsDisplayListBuilder* aBuilder,
|
||||
mContainer->SetClipRect(nullptr);
|
||||
|
||||
if (mFrameLoader->AsyncScrollEnabled()) {
|
||||
const nsContentView* view = GetContentView(FrameMetrics::ROOT_SCROLL_ID);
|
||||
const nsContentView* view = GetRootContentView();
|
||||
BuildBackgroundPatternFor(mContainer,
|
||||
shadowRoot,
|
||||
view->GetViewConfig(),
|
||||
@ -927,8 +950,9 @@ RenderFrameParent::BuildViewMap()
|
||||
// the content view map should only contain the root view and content
|
||||
// views that are present in the layer tree.
|
||||
if (newContentViews.empty()) {
|
||||
newContentViews[FrameMetrics::ROOT_SCROLL_ID] =
|
||||
FindViewForId(mContentViews, FrameMetrics::ROOT_SCROLL_ID);
|
||||
nsContentView* rootView = FindRootView(mContentViews);
|
||||
if (rootView)
|
||||
newContentViews[rootView->GetId()] = rootView;
|
||||
}
|
||||
|
||||
mContentViews = newContentViews;
|
||||
@ -1023,11 +1047,12 @@ RenderFrameParent::ContentReceivedTouch(const ScrollableLayerGuid& aGuid,
|
||||
void
|
||||
RenderFrameParent::UpdateZoomConstraints(uint32_t aPresShellId,
|
||||
ViewID aViewId,
|
||||
bool aIsRoot,
|
||||
bool aAllowZoom,
|
||||
const CSSToScreenScale& aMinZoom,
|
||||
const CSSToScreenScale& aMaxZoom)
|
||||
{
|
||||
if (mContentController && aViewId == FrameMetrics::ROOT_SCROLL_ID) {
|
||||
if (mContentController && aIsRoot) {
|
||||
mContentController->SaveZoomConstraints(aAllowZoom, aMinZoom, aMaxZoom);
|
||||
}
|
||||
if (GetApzcTreeManager()) {
|
||||
|
@ -68,10 +68,11 @@ public:
|
||||
void Destroy();
|
||||
|
||||
/**
|
||||
* Helper function for getting a non-owning reference to a scrollable.
|
||||
* Helper functions for getting a non-owning reference to a scrollable.
|
||||
* @param aId The ID of the frame.
|
||||
*/
|
||||
nsContentView* GetContentView(ViewID aId = FrameMetrics::ROOT_SCROLL_ID);
|
||||
nsContentView* GetContentView(ViewID aId);
|
||||
nsContentView* GetRootContentView();
|
||||
|
||||
void ContentViewScaleChanged(nsContentView* aView);
|
||||
|
||||
@ -117,6 +118,7 @@ public:
|
||||
|
||||
void UpdateZoomConstraints(uint32_t aPresShellId,
|
||||
ViewID aViewId,
|
||||
bool aIsRoot,
|
||||
bool aAllowZoom,
|
||||
const CSSToScreenScale& aMinZoom,
|
||||
const CSSToScreenScale& aMaxZoom);
|
||||
|
@ -1939,7 +1939,7 @@ AndroidBridge::HandleLongTap(const CSSIntPoint& aPoint)
|
||||
}
|
||||
|
||||
void
|
||||
AndroidBridge::SendAsyncScrollDOMEvent(mozilla::layers::FrameMetrics::ViewID aScrollId,
|
||||
AndroidBridge::SendAsyncScrollDOMEvent(bool aIsRoot,
|
||||
const CSSRect& aContentRect,
|
||||
const CSSSize& aScrollableSize)
|
||||
{
|
||||
|
@ -419,7 +419,7 @@ public:
|
||||
void HandleDoubleTap(const CSSIntPoint& aPoint) MOZ_OVERRIDE;
|
||||
void HandleSingleTap(const CSSIntPoint& aPoint) MOZ_OVERRIDE;
|
||||
void HandleLongTap(const CSSIntPoint& aPoint) MOZ_OVERRIDE;
|
||||
void SendAsyncScrollDOMEvent(mozilla::layers::FrameMetrics::ViewID aScrollId,
|
||||
void SendAsyncScrollDOMEvent(bool aIsRoot,
|
||||
const CSSRect& aContentRect,
|
||||
const CSSSize& aScrollableSize) MOZ_OVERRIDE;
|
||||
void PostDelayedTask(Task* aTask, int aDelayMs) MOZ_OVERRIDE;
|
||||
|
@ -850,7 +850,8 @@ Java_org_mozilla_gecko_gfx_NativePanZoomController_abortAnimation(JNIEnv* env, j
|
||||
{
|
||||
APZCTreeManager *controller = nsWindow::GetAPZCTreeManager();
|
||||
if (controller) {
|
||||
controller->CancelAnimation(ScrollableLayerGuid(nsWindow::RootLayerTreeId()));
|
||||
// TODO: Pass in correct values for presShellId and viewId.
|
||||
controller->CancelAnimation(ScrollableLayerGuid(nsWindow::RootLayerTreeId(), 0, 0));
|
||||
}
|
||||
}
|
||||
|
||||
@ -918,7 +919,8 @@ Java_org_mozilla_gecko_gfx_NativePanZoomController_notifyDefaultActionPrevented(
|
||||
{
|
||||
APZCTreeManager *controller = nsWindow::GetAPZCTreeManager();
|
||||
if (controller) {
|
||||
controller->ContentReceivedTouch(ScrollableLayerGuid(nsWindow::RootLayerTreeId()), prevented);
|
||||
// TODO: Pass in correct values for presShellId and viewId.
|
||||
controller->ContentReceivedTouch(ScrollableLayerGuid(nsWindow::RootLayerTreeId(), 0, 0), prevented);
|
||||
}
|
||||
}
|
||||
|
||||
@ -947,7 +949,8 @@ Java_org_mozilla_gecko_gfx_NativePanZoomController_updateScrollOffset(JNIEnv* en
|
||||
{
|
||||
APZCTreeManager *controller = nsWindow::GetAPZCTreeManager();
|
||||
if (controller) {
|
||||
controller->UpdateScrollOffset(ScrollableLayerGuid(nsWindow::RootLayerTreeId()), CSSPoint(cssX, cssY));
|
||||
// TODO: Pass in correct values for presShellId and viewId.
|
||||
controller->UpdateScrollOffset(ScrollableLayerGuid(nsWindow::RootLayerTreeId(), 0, 0), CSSPoint(cssX, cssY));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -299,7 +299,7 @@ APZController::HandleLongTap(const CSSIntPoint& aPoint)
|
||||
|
||||
// requests that we send a mozbrowserasyncscroll domevent. not in use.
|
||||
void
|
||||
APZController::SendAsyncScrollDOMEvent(FrameMetrics::ViewID aScrollId,
|
||||
APZController::SendAsyncScrollDOMEvent(bool aIsRoot,
|
||||
const CSSRect &aContentRect,
|
||||
const CSSSize &aScrollableSize)
|
||||
{
|
||||
|
@ -35,7 +35,7 @@ public:
|
||||
virtual void HandleDoubleTap(const mozilla::CSSIntPoint& aPoint);
|
||||
virtual void HandleSingleTap(const mozilla::CSSIntPoint& aPoint);
|
||||
virtual void HandleLongTap(const mozilla::CSSIntPoint& aPoint);
|
||||
virtual void SendAsyncScrollDOMEvent(FrameMetrics::ViewID aScrollId, const mozilla::CSSRect &aContentRect, const mozilla::CSSSize &aScrollableSize);
|
||||
virtual void SendAsyncScrollDOMEvent(bool aIsRoot, const mozilla::CSSRect &aContentRect, const mozilla::CSSSize &aScrollableSize);
|
||||
virtual void PostDelayedTask(Task* aTask, int aDelayMs);
|
||||
virtual void HandlePanBegin();
|
||||
virtual void HandlePanEnd();
|
||||
|
Loading…
Reference in New Issue
Block a user