зеркало из https://github.com/mozilla/gecko-dev.git
Bug 605618 Part 1: Tag layers with scrollable information r=cjones sr=roc a=blocking-fennec
This commit is contained in:
Родитель
fd43082ac3
Коммит
5950a36396
|
@ -48,6 +48,11 @@
|
||||||
|
|
||||||
using namespace mozilla::layers;
|
using namespace mozilla::layers;
|
||||||
|
|
||||||
|
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;
|
||||||
|
|
||||||
#ifdef MOZ_LAYERS_HAVE_LOG
|
#ifdef MOZ_LAYERS_HAVE_LOG
|
||||||
FILE*
|
FILE*
|
||||||
FILEOrDefault(FILE* aFile)
|
FILEOrDefault(FILE* aFile)
|
||||||
|
@ -79,6 +84,15 @@ AppendToString(nsACString& s, const gfxPattern::GraphicsFilter& f,
|
||||||
return s += sfx;
|
return s += sfx;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
nsACString&
|
||||||
|
AppendToString(nsACString& s, ViewID n,
|
||||||
|
const char* pfx="", const char* sfx="")
|
||||||
|
{
|
||||||
|
s += pfx;
|
||||||
|
s.AppendInt(n);
|
||||||
|
return s += sfx;
|
||||||
|
}
|
||||||
|
|
||||||
nsACString&
|
nsACString&
|
||||||
AppendToString(nsACString& s, const gfxRGBA& c,
|
AppendToString(nsACString& s, const gfxRGBA& c,
|
||||||
const char* pfx="", const char* sfx="")
|
const char* pfx="", const char* sfx="")
|
||||||
|
@ -164,9 +178,10 @@ AppendToString(nsACString& s, const FrameMetrics& m,
|
||||||
const char* pfx="", const char* sfx="")
|
const char* pfx="", const char* sfx="")
|
||||||
{
|
{
|
||||||
s += pfx;
|
s += pfx;
|
||||||
AppendToString(s, m.mViewportSize, "{ viewport=");
|
AppendToString(s, m.mViewport, "{ viewport=");
|
||||||
AppendToString(s, m.mViewportScrollOffset, " viewportScroll=");
|
AppendToString(s, m.mViewportScrollOffset, " viewportScroll=");
|
||||||
AppendToString(s, m.mDisplayPort, " displayport=", " }");
|
AppendToString(s, m.mDisplayPort, " displayport=");
|
||||||
|
AppendToString(s, m.mScrollId, " scrollId=", " }");
|
||||||
return s += sfx;
|
return s += sfx;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -87,18 +87,28 @@ class SpecificLayerAttributes;
|
||||||
* atomically with new pixels.
|
* atomically with new pixels.
|
||||||
*/
|
*/
|
||||||
struct FrameMetrics {
|
struct FrameMetrics {
|
||||||
|
public:
|
||||||
|
// We use IDs to identify frames across processes.
|
||||||
|
typedef PRUint64 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.
|
||||||
|
|
||||||
FrameMetrics()
|
FrameMetrics()
|
||||||
: mViewportSize(0, 0)
|
: mViewport(0, 0, 0, 0)
|
||||||
, mViewportScrollOffset(0, 0)
|
, mViewportScrollOffset(0, 0)
|
||||||
|
, mScrollId(NULL_SCROLL_ID)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
// Default copy ctor and operator= are fine
|
// Default copy ctor and operator= are fine
|
||||||
|
|
||||||
PRBool operator==(const FrameMetrics& aOther) const
|
PRBool operator==(const FrameMetrics& aOther) const
|
||||||
{
|
{
|
||||||
return (mViewportSize == aOther.mViewportSize &&
|
return (mViewport == aOther.mViewport &&
|
||||||
mViewportScrollOffset == aOther.mViewportScrollOffset &&
|
mViewportScrollOffset == aOther.mViewportScrollOffset &&
|
||||||
mDisplayPort == aOther.mDisplayPort);
|
mDisplayPort == aOther.mDisplayPort &&
|
||||||
|
mScrollId == aOther.mScrollId);
|
||||||
}
|
}
|
||||||
|
|
||||||
PRBool IsDefault() const
|
PRBool IsDefault() const
|
||||||
|
@ -106,9 +116,20 @@ struct FrameMetrics {
|
||||||
return (FrameMetrics() == *this);
|
return (FrameMetrics() == *this);
|
||||||
}
|
}
|
||||||
|
|
||||||
nsIntSize mViewportSize;
|
PRBool IsRootScrollable() const
|
||||||
|
{
|
||||||
|
return mScrollId == ROOT_SCROLL_ID;
|
||||||
|
}
|
||||||
|
|
||||||
|
PRBool IsScrollable() const
|
||||||
|
{
|
||||||
|
return mScrollId != NULL_SCROLL_ID;
|
||||||
|
}
|
||||||
|
|
||||||
|
nsIntRect mViewport;
|
||||||
nsIntPoint mViewportScrollOffset;
|
nsIntPoint mViewportScrollOffset;
|
||||||
nsIntRect mDisplayPort;
|
nsIntRect mDisplayPort;
|
||||||
|
ViewID mScrollId;
|
||||||
};
|
};
|
||||||
|
|
||||||
#define MOZ_LAYER_DECL_NAME(n, e) \
|
#define MOZ_LAYER_DECL_NAME(n, e) \
|
||||||
|
|
|
@ -63,16 +63,18 @@ struct ParamTraits<mozilla::layers::FrameMetrics>
|
||||||
|
|
||||||
static void Write(Message* aMsg, const paramType& aParam)
|
static void Write(Message* aMsg, const paramType& aParam)
|
||||||
{
|
{
|
||||||
WriteParam(aMsg, aParam.mViewportSize);
|
WriteParam(aMsg, aParam.mViewport);
|
||||||
WriteParam(aMsg, aParam.mViewportScrollOffset);
|
WriteParam(aMsg, aParam.mViewportScrollOffset);
|
||||||
WriteParam(aMsg, aParam.mDisplayPort);
|
WriteParam(aMsg, aParam.mDisplayPort);
|
||||||
|
WriteParam(aMsg, aParam.mScrollId);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool Read(const Message* aMsg, void** aIter, paramType* aResult)
|
static bool Read(const Message* aMsg, void** aIter, paramType* aResult)
|
||||||
{
|
{
|
||||||
return (ReadParam(aMsg, aIter, &aResult->mViewportSize) &&
|
return (ReadParam(aMsg, aIter, &aResult->mViewport) &&
|
||||||
ReadParam(aMsg, aIter, &aResult->mViewportScrollOffset) &&
|
ReadParam(aMsg, aIter, &aResult->mViewportScrollOffset) &&
|
||||||
ReadParam(aMsg, aIter, &aResult->mDisplayPort));
|
ReadParam(aMsg, aIter, &aResult->mDisplayPort) &&
|
||||||
|
ReadParam(aMsg, aIter, &aResult->mScrollId));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -67,6 +67,7 @@
|
||||||
|
|
||||||
using namespace mozilla;
|
using namespace mozilla;
|
||||||
using namespace mozilla::layers;
|
using namespace mozilla::layers;
|
||||||
|
typedef FrameMetrics::ViewID ViewID;
|
||||||
|
|
||||||
nsDisplayListBuilder::nsDisplayListBuilder(nsIFrame* aReferenceFrame,
|
nsDisplayListBuilder::nsDisplayListBuilder(nsIFrame* aReferenceFrame,
|
||||||
Mode aMode, PRBool aBuildCaret)
|
Mode aMode, PRBool aBuildCaret)
|
||||||
|
@ -147,6 +148,38 @@ static void UnmarkFrameForDisplay(nsIFrame* aFrame) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void RecordFrameMetrics(nsIFrame* aForFrame,
|
||||||
|
ContainerLayer* aRoot,
|
||||||
|
nsRect aVisibleRect,
|
||||||
|
nsRect aViewport,
|
||||||
|
ViewID aScrollId) {
|
||||||
|
nsPresContext* presContext = aForFrame->PresContext();
|
||||||
|
nsIPresShell* presShell = presContext->GetPresShell();
|
||||||
|
|
||||||
|
nsIntRect visible = aVisibleRect.ToNearestPixels(presContext->AppUnitsPerDevPixel());
|
||||||
|
aRoot->SetVisibleRegion(nsIntRegion(visible));
|
||||||
|
|
||||||
|
FrameMetrics metrics;
|
||||||
|
|
||||||
|
PRInt32 auPerDevPixel = presContext->AppUnitsPerDevPixel();
|
||||||
|
metrics.mViewport = aViewport.ToNearestPixels(auPerDevPixel);
|
||||||
|
if (presShell->UsingDisplayPort()) {
|
||||||
|
metrics.mDisplayPort =
|
||||||
|
presShell->GetDisplayPort().ToNearestPixels(auPerDevPixel);
|
||||||
|
}
|
||||||
|
|
||||||
|
nsIScrollableFrame* rootScrollableFrame =
|
||||||
|
presShell->GetRootScrollFrameAsScrollable();
|
||||||
|
if (rootScrollableFrame) {
|
||||||
|
metrics.mViewportScrollOffset =
|
||||||
|
rootScrollableFrame->GetScrollPosition().ToNearestPixels(auPerDevPixel);
|
||||||
|
|
||||||
|
metrics.mScrollId = aScrollId;
|
||||||
|
}
|
||||||
|
|
||||||
|
aRoot->SetFrameMetrics(metrics);
|
||||||
|
}
|
||||||
|
|
||||||
nsDisplayListBuilder::~nsDisplayListBuilder() {
|
nsDisplayListBuilder::~nsDisplayListBuilder() {
|
||||||
NS_ASSERTION(mFramesMarkedForDisplay.Length() == 0,
|
NS_ASSERTION(mFramesMarkedForDisplay.Length() == 0,
|
||||||
"All frames should have been unmarked");
|
"All frames should have been unmarked");
|
||||||
|
@ -467,28 +500,10 @@ void nsDisplayList::PaintForFrame(nsDisplayListBuilder* aBuilder,
|
||||||
nsPresContext* presContext = aForFrame->PresContext();
|
nsPresContext* presContext = aForFrame->PresContext();
|
||||||
nsIPresShell* presShell = presContext->GetPresShell();
|
nsIPresShell* presShell = presContext->GetPresShell();
|
||||||
|
|
||||||
nsIntRect visible = mVisibleRect.ToNearestPixels(presContext->AppUnitsPerDevPixel());
|
ViewID id = presContext->IsRootContentDocument() ? FrameMetrics::ROOT_SCROLL_ID
|
||||||
root->SetVisibleRegion(nsIntRegion(visible));
|
: FrameMetrics::NULL_SCROLL_ID;
|
||||||
|
|
||||||
// Collect frame metrics with which to stamp the root layer.
|
RecordFrameMetrics(aForFrame, root, mVisibleRect, mVisibleRect, id);
|
||||||
FrameMetrics metrics;
|
|
||||||
|
|
||||||
PRInt32 auPerCSSPixel = nsPresContext::AppUnitsPerCSSPixel();
|
|
||||||
metrics.mViewportSize =
|
|
||||||
presContext->GetVisibleArea().ToNearestPixels(auPerCSSPixel).Size();
|
|
||||||
if (presShell->UsingDisplayPort()) {
|
|
||||||
metrics.mDisplayPort =
|
|
||||||
presShell->GetDisplayPort().ToNearestPixels(auPerCSSPixel);
|
|
||||||
}
|
|
||||||
|
|
||||||
nsIScrollableFrame* rootScrollableFrame =
|
|
||||||
presShell->GetRootScrollFrameAsScrollable();
|
|
||||||
if (rootScrollableFrame) {
|
|
||||||
metrics.mViewportScrollOffset =
|
|
||||||
rootScrollableFrame->GetScrollPosition().ToNearestPixels(auPerCSSPixel);
|
|
||||||
}
|
|
||||||
|
|
||||||
root->SetFrameMetrics(metrics);
|
|
||||||
|
|
||||||
// If the layer manager supports resolution scaling, set that up
|
// If the layer manager supports resolution scaling, set that up
|
||||||
if (LayerManager::LAYERS_BASIC == layerManager->GetBackendType()) {
|
if (LayerManager::LAYERS_BASIC == layerManager->GetBackendType()) {
|
||||||
|
|
Загрузка…
Ссылка в новой задаче