Backed out 6 changesets (bug 982141) for Windows and OSX bustage. CLOSED TREE

Backed out changeset 16540ab2d2cb (bug 982141)
Backed out changeset 2ad9ce9d904e (bug 982141)
Backed out changeset af219bb49c06 (bug 982141)
Backed out changeset ffe51d96e86e (bug 982141)
Backed out changeset 6642718ad3bb (bug 982141)
Backed out changeset 95b341d26f7b (bug 982141)
This commit is contained in:
Ryan VanderMeulen 2014-04-10 15:27:42 -04:00
parent 4f4c92a20d
commit 2bf6dfd88c
9 changed files with 182 additions and 401 deletions

View File

@ -434,6 +434,12 @@ nsDOMWindowUtils::SetDisplayPortMarginsForElement(float aLeftMargin,
return NS_ERROR_INVALID_ARG;
}
DisplayPortMarginsPropertyData* currentData =
static_cast<DisplayPortMarginsPropertyData*>(content->GetProperty(nsGkAtoms::DisplayPortMargins));
if (currentData && currentData->mPriority > aPriority) {
return NS_OK;
}
// Note order change of arguments between our function signature and
// LayerMargin constructor.
LayerMargin displayportMargins(aTopMargin,
@ -441,8 +447,21 @@ nsDOMWindowUtils::SetDisplayPortMarginsForElement(float aLeftMargin,
aBottomMargin,
aLeftMargin);
nsLayoutUtils::SetDisplayPortMargins(content, presShell, displayportMargins,
aAlignmentX, aAlignmentY, aPriority);
content->SetProperty(nsGkAtoms::DisplayPortMargins,
new DisplayPortMarginsPropertyData(displayportMargins, aAlignmentX, aAlignmentY, aPriority),
nsINode::DeleteProperty<DisplayPortMarginsPropertyData>);
nsIFrame* rootScrollFrame = presShell->GetRootScrollFrame();
if (rootScrollFrame && content == rootScrollFrame->GetContent()) {
// We are setting a root displayport for a document.
// The pres shell needs a special flag set.
presShell->SetIgnoreViewportScrolling(true);
}
nsIFrame* rootFrame = presShell->FrameManager()->GetRootFrame();
if (rootFrame) {
rootFrame->SchedulePaint();
}
return NS_OK;
}
@ -478,7 +497,8 @@ nsDOMWindowUtils::SetDisplayPortBaseForElement(int32_t aX,
return NS_ERROR_INVALID_ARG;
}
nsLayoutUtils::SetDisplayPortBase(content, nsRect(aX, aY, aWidth, aHeight));
content->SetProperty(nsGkAtoms::DisplayPortBase, new nsRect(aX, aY, aWidth, aHeight),
nsINode::DeleteProperty<nsRect>);
return NS_OK;
}

View File

@ -522,8 +522,7 @@ nsDisplayListBuilder::nsDisplayListBuilder(nsIFrame* aReferenceFrame,
mIsCompositingCheap(false),
mContainsPluginItem(false),
mContainsBlendMode(false),
mAncestorHasTouchEventHandler(false),
mHaveScrollableDisplayPort(false)
mAncestorHasTouchEventHandler(false)
{
MOZ_COUNT_CTOR(nsDisplayListBuilder);
PL_InitArenaPool(&mPool, "displayListArena", 1024,
@ -623,6 +622,83 @@ static bool GetApzcTreePrintPref() {
return gPrintApzcTree;
}
static CSSSize
CalculateRootCompositionSize(FrameMetrics& aMetrics,
bool aIsRootContentDocRootScrollFrame,
nsPresContext* aPresContext,
nsIFrame* aForFrame, nsIFrame* aScrollFrame)
{
if (aIsRootContentDocRootScrollFrame) {
return ViewAs<LayerPixel>(ParentLayerSize(aMetrics.mCompositionBounds.Size()),
PixelCastJustification::ParentLayerToLayerForRootComposition)
/ aMetrics.LayersPixelsPerCSSPixel();
}
LayerSize rootCompositionSize;
nsPresContext* rootPresContext =
aPresContext->GetToplevelContentDocumentPresContext();
if (!rootPresContext) {
rootPresContext = aPresContext->GetRootPresContext();
}
nsIPresShell* rootPresShell = nullptr;
if (rootPresContext) {
// See the comments in the code that calculates the root
// composition bounds in RecordFrameMetrics.
// TODO: Reuse that code here.
nsIPresShell* rootPresShell = rootPresContext->PresShell();
if (nsIFrame* rootFrame = rootPresShell->GetRootFrame()) {
if (nsView* view = rootFrame->GetView()) {
LayoutDeviceToParentLayerScale parentResolution(
rootPresShell->GetCumulativeResolution().width
/ rootPresShell->GetResolution().width);
int32_t rootAUPerDevPixel = rootPresContext->AppUnitsPerDevPixel();
nsRect viewBounds = view->GetBounds();
LayerSize viewSize = ViewAs<LayerPixel>(
(LayoutDeviceRect::FromAppUnits(viewBounds, rootAUPerDevPixel)
* parentResolution).Size(), PixelCastJustification::ParentLayerToLayerForRootComposition);
nsIWidget* widget =
#ifdef MOZ_WIDGET_ANDROID
rootFrame->GetNearestWidget();
#else
view->GetWidget();
#endif
if (widget) {
nsIntRect widgetBounds;
widget->GetBounds(widgetBounds);
rootCompositionSize = LayerSize(ViewAs<LayerPixel>(widgetBounds.Size()));
#ifdef MOZ_WIDGET_ANDROID
if (viewSize.height < rootCompositionSize.height) {
rootCompositionSize.height = viewSize.height;
}
#endif
} else {
rootCompositionSize = viewSize;
}
}
}
} else {
nsIWidget* widget = (aScrollFrame ? aScrollFrame : aForFrame)->GetNearestWidget();
nsIntRect bounds;
widget->GetBounds(bounds);
rootCompositionSize = LayerSize(ViewAs<LayerPixel>(bounds.Size()));
}
// Adjust composition size for the size of scroll bars.
nsIFrame* rootRootScrollFrame = rootPresShell ? rootPresShell->GetRootScrollFrame() : nullptr;
nsIScrollableFrame* rootScrollableFrame = nullptr;
if (rootRootScrollFrame) {
rootScrollableFrame = aScrollFrame->GetScrollTargetFrame();
}
if (rootScrollableFrame && !LookAndFeel::GetInt(LookAndFeel::eIntID_UseOverlayScrollbars)) {
CSSMargin margins = CSSMargin::FromAppUnits(rootScrollableFrame->GetActualScrollbarSizes());
// Scrollbars are not subject to scaling, so CSS pixels = layer pixels for them.
rootCompositionSize.width -= margins.LeftRight();
rootCompositionSize.height -= margins.TopBottom();
}
return rootCompositionSize / aMetrics.LayersPixelsPerCSSPixel();
}
static void RecordFrameMetrics(nsIFrame* aForFrame,
nsIFrame* aScrollFrame,
const nsIFrame* aReferenceFrame,
@ -782,8 +858,8 @@ static void RecordFrameMetrics(nsIFrame* aForFrame,
}
metrics.SetRootCompositionSize(
nsLayoutUtils::CalculateRootCompositionSize(aScrollFrame ? aScrollFrame : aForFrame,
isRootContentDocRootScrollFrame, metrics));
CalculateRootCompositionSize(metrics, isRootContentDocRootScrollFrame,
presContext, aForFrame, aScrollFrame));
if (GetApzcTreePrintPref()) {
if (nsIContent* content = frameForCompositionBoundsCalculation->GetContent()) {

View File

@ -317,9 +317,6 @@ public:
mAncestorHasTouchEventHandler = aValue;
}
bool HaveScrollableDisplayPort() const { return mHaveScrollableDisplayPort; }
void SetHaveScrollableDisplayPort() { mHaveScrollableDisplayPort = true; }
bool SetIsCompositingCheap(bool aCompositingCheap) {
bool temp = mIsCompositingCheap;
mIsCompositingCheap = aCompositingCheap;
@ -726,10 +723,6 @@ private:
bool mContainsPluginItem;
bool mContainsBlendMode;
bool mAncestorHasTouchEventHandler;
// True when the first async-scrollable scroll frame for which we build a
// display list has a display port. An async-scrollable scroll frame is one
// which WantsAsyncScroll().
bool mHaveScrollableDisplayPort;
};
class nsDisplayItem;

View File

@ -41,7 +41,6 @@
#include "nsIWidget.h"
#include "gfxMatrix.h"
#include "gfxPoint3D.h"
#include "gfxPrefs.h"
#include "gfxTypes.h"
#include "nsTArray.h"
#include "mozilla/dom/HTMLCanvasElement.h"
@ -75,8 +74,6 @@
#include "mozilla/gfx/2D.h"
#include "gfx2DGlue.h"
#include "mozilla/LookAndFeel.h"
#include "UnitTransforms.h"
#include "TiledLayerBuffer.h" // For TILEDLAYERBUFFER_TILE_SIZE
#include "mozilla/Preferences.h"
@ -89,11 +86,6 @@
#include "nsTransitionManager.h"
#include "RestyleManager.h"
// Additional includes used on B2G by code in GetOrMaybeCreateDisplayPort().
#ifdef MOZ_WIDGET_GONK
#include "mozilla/layers/AsyncPanZoomController.h"
#endif
using namespace mozilla;
using namespace mozilla::css;
using namespace mozilla::dom;
@ -778,41 +770,6 @@ nsLayoutUtils::GetDisplayPort(nsIContent* aContent, nsRect *aResult)
return true;
}
void
nsLayoutUtils::SetDisplayPortMargins(nsIContent* aContent,
nsIPresShell* aPresShell,
const LayerMargin& aMargins,
uint32_t aAlignmentX,
uint32_t aAlignmentY,
uint32_t aPriority,
RepaintMode aRepaintMode)
{
DisplayPortMarginsPropertyData* currentData =
static_cast<DisplayPortMarginsPropertyData*>(aContent->GetProperty(nsGkAtoms::DisplayPortMargins));
if (currentData && currentData->mPriority > aPriority) {
return;
}
aContent->SetProperty(nsGkAtoms::DisplayPortMargins,
new DisplayPortMarginsPropertyData(
aMargins, aAlignmentX, aAlignmentY, aPriority),
nsINode::DeleteProperty<DisplayPortMarginsPropertyData>);
nsIFrame* rootScrollFrame = aPresShell->GetRootScrollFrame();
if (rootScrollFrame && aContent == rootScrollFrame->GetContent()) {
// We are setting a root displayport for a document.
// The pres shell needs a special flag set.
aPresShell->SetIgnoreViewportScrolling(true);
}
if (aRepaintMode == RepaintMode::Repaint) {
nsIFrame* rootFrame = aPresShell->FrameManager()->GetRootFrame();
if (rootFrame) {
rootFrame->SchedulePaint();
}
}
}
void
nsLayoutUtils::SetDisplayPortBase(nsIContent* aContent, const nsRect& aBase)
{
@ -2450,101 +2407,6 @@ nsLayoutUtils::GetFramesForArea(nsIFrame* aFrame, const nsRect& aRect,
return NS_OK;
}
// aScrollFrame and aScrollFrameAsScrollable must be non-nullptr
static FrameMetrics
CalculateFrameMetricsForDisplayPort(nsIFrame* aScrollFrame,
nsIScrollableFrame* aScrollFrameAsScrollable) {
// Calculate the metrics necessary for calculating the displayport.
// This code has a lot in common with the code in RecordFrameMetrics();
// we may want to refactor this at some point.
FrameMetrics metrics;
nsPresContext* presContext = aScrollFrame->PresContext();
nsIPresShell* presShell = presContext->PresShell();
CSSToLayoutDeviceScale deviceScale(float(nsPresContext::AppUnitsPerCSSPixel())
/ presContext->AppUnitsPerDevPixel());
ParentLayerToLayerScale resolution(presShell->GetResolution().width);
LayoutDeviceToLayerScale cumulativeResolution(presShell->GetCumulativeResolution().width);
metrics.mDevPixelsPerCSSPixel = deviceScale;
metrics.mResolution = resolution;
metrics.mCumulativeResolution = cumulativeResolution;
metrics.SetZoom(deviceScale * cumulativeResolution * LayerToScreenScale(1));
// Only the size of the composition bounds is relevant to the
// displayport calculation, not its origin.
nsSize compositionSize = nsLayoutUtils::CalculateCompositionSizeForFrame(aScrollFrame);
metrics.mCompositionBounds
= RoundedToInt(LayoutDeviceRect::FromAppUnits(nsRect(nsPoint(0, 0), compositionSize),
presContext->AppUnitsPerDevPixel())
* (cumulativeResolution / resolution));
// This function is used for setting a display port for subframes, so
// aScrollFrame will not be the root content document's root scroll frame.
metrics.SetRootCompositionSize(
nsLayoutUtils::CalculateRootCompositionSize(aScrollFrame, false, metrics));
metrics.SetScrollOffset(CSSPoint::FromAppUnits(
aScrollFrameAsScrollable->GetScrollPosition()));
metrics.mScrollableRect = CSSRect::FromAppUnits(
nsLayoutUtils::CalculateScrollableRectForFrame(aScrollFrameAsScrollable, nullptr));
return metrics;
}
bool
nsLayoutUtils::GetOrMaybeCreateDisplayPort(nsDisplayListBuilder& aBuilder,
nsIFrame* aScrollFrame,
nsRect aDisplayPortBase,
nsRect* aOutDisplayport) {
nsIContent* content = aScrollFrame->GetContent();
nsIScrollableFrame* scrollableFrame = do_QueryFrame(aScrollFrame);
if (!content || !scrollableFrame) {
return false;
}
// Set the base rect. Note that this will not influence 'haveDisplayPort',
// which is based on either the whole rect or margins being set, but it
// will affect what is returned in 'aOutDisplayPort' if margins are set.
SetDisplayPortBase(content, aDisplayPortBase);
bool haveDisplayPort = GetDisplayPort(content, aOutDisplayport);
#ifdef MOZ_WIDGET_GONK
// On B2G, we perform an optimization where we ensure that at least one
// async-scrollable frame (i.e. one that WantsAsyncScroll()) has a displayport.
// If that's not the case yet, and we are async-scrollable, we will get a
// displayport.
// Note: we only do this in processes where we do subframe scrolling to
// begin with (i.e., not in the parent process on B2G).
if (WantSubAPZC() &&
!aBuilder.HaveScrollableDisplayPort() &&
scrollableFrame->WantAsyncScroll()) {
// If we don't already have a displayport, calculate and set one.
if (!haveDisplayPort) {
FrameMetrics metrics = CalculateFrameMetricsForDisplayPort(aScrollFrame, scrollableFrame);
LayerMargin displayportMargins = AsyncPanZoomController::CalculatePendingDisplayPort(
metrics, ScreenPoint(0.0f, 0.0f), 0.0);
nsIPresShell* presShell = aScrollFrame->PresContext()->GetPresShell();
gfx::IntSize alignment = gfxPrefs::LayersTilesEnabled()
? gfx::IntSize(gfxPrefs::LayersTileWidth(), gfxPrefs::LayersTileHeight()) :
gfx::IntSize(1, 1);
nsLayoutUtils::SetDisplayPortMargins(
content, presShell, displayportMargins, alignment.width,
alignment.height, 0, nsLayoutUtils::RepaintMode::DoNotRepaint);
haveDisplayPort = GetDisplayPort(content, aOutDisplayport);
NS_ASSERTION(haveDisplayPort, "should have a displayport after having just set it");
}
// Record that the we now have a scrollable display port.
aBuilder.SetHaveScrollableDisplayPort();
}
#endif
return haveDisplayPort;
}
nsresult
nsLayoutUtils::PaintFrame(nsRenderingContext* aRenderingContext, nsIFrame* aFrame,
const nsRegion& aDirtyRegion, nscolor aBackstop,
@ -2566,18 +2428,19 @@ nsLayoutUtils::PaintFrame(nsRenderingContext* aRenderingContext, nsIFrame* aFram
return NS_OK;
}
nsDisplayListBuilder builder(aFrame, nsDisplayListBuilder::PAINTING,
!(aFlags & PAINT_HIDE_CARET));
nsIFrame* rootScrollFrame = presShell->GetRootScrollFrame();
bool usingDisplayPort = false;
nsRect displayport;
if (rootScrollFrame && !aFrame->GetParent()) {
nsRect displayportBase(
nsPoint(0,0),
nsLayoutUtils::CalculateCompositionSizeForFrame(rootScrollFrame));
usingDisplayPort = nsLayoutUtils::GetOrMaybeCreateDisplayPort(
builder, rootScrollFrame, displayportBase, &displayport);
nsIContent* content = rootScrollFrame->GetContent();
if (content) {
usingDisplayPort = nsLayoutUtils::GetDisplayPort(content);
if (usingDisplayPort) {
nsLayoutUtils::SetDisplayPortBase(content,
nsRect(nsPoint(0,0), nsLayoutUtils::CalculateCompositionSizeForFrame(rootScrollFrame)));
nsLayoutUtils::GetDisplayPort(content, &displayport);
}
}
}
nsRegion visibleRegion;
@ -2602,6 +2465,9 @@ nsLayoutUtils::PaintFrame(nsRenderingContext* aRenderingContext, nsIFrame* aFram
// *and after* we draw.
bool willFlushRetainedLayers = (aFlags & PAINT_HIDE_CARET) != 0;
nsDisplayListBuilder builder(aFrame, nsDisplayListBuilder::PAINTING,
!(aFlags & PAINT_HIDE_CARET));
nsDisplayList list;
if (aFlags & PAINT_IN_TRANSFORM) {
builder.SetInTransform(true);
@ -6350,82 +6216,6 @@ nsLayoutUtils::CalculateCompositionSizeForFrame(nsIFrame* aFrame)
return size;
}
/* static */ CSSSize
nsLayoutUtils::CalculateRootCompositionSize(nsIFrame* aFrame,
bool aIsRootContentDocRootScrollFrame,
const FrameMetrics& aMetrics)
{
if (aIsRootContentDocRootScrollFrame) {
return ViewAs<LayerPixel>(ParentLayerSize(aMetrics.mCompositionBounds.Size()),
PixelCastJustification::ParentLayerToLayerForRootComposition)
/ aMetrics.LayersPixelsPerCSSPixel();
}
nsPresContext* presContext = aFrame->PresContext();
LayerSize rootCompositionSize;
nsPresContext* rootPresContext =
presContext->GetToplevelContentDocumentPresContext();
if (!rootPresContext) {
rootPresContext = presContext->GetRootPresContext();
}
nsIPresShell* rootPresShell = nullptr;
if (rootPresContext) {
// See the comments in the code that calculates the root
// composition bounds in RecordFrameMetrics.
// TODO: Reuse that code here.
nsIPresShell* rootPresShell = rootPresContext->PresShell();
if (nsIFrame* rootFrame = rootPresShell->GetRootFrame()) {
if (nsView* view = rootFrame->GetView()) {
LayoutDeviceToParentLayerScale parentResolution(
rootPresShell->GetCumulativeResolution().width
/ rootPresShell->GetResolution().width);
int32_t rootAUPerDevPixel = rootPresContext->AppUnitsPerDevPixel();
nsRect viewBounds = view->GetBounds();
LayerSize viewSize = ViewAs<LayerPixel>(
(LayoutDeviceRect::FromAppUnits(viewBounds, rootAUPerDevPixel)
* parentResolution).Size(), PixelCastJustification::ParentLayerToLayerForRootComposition);
nsIWidget* widget =
#ifdef MOZ_WIDGET_ANDROID
rootFrame->GetNearestWidget();
#else
view->GetWidget();
#endif
if (widget) {
nsIntRect widgetBounds;
widget->GetBounds(widgetBounds);
rootCompositionSize = LayerSize(ViewAs<LayerPixel>(widgetBounds.Size()));
#ifdef MOZ_WIDGET_ANDROID
if (viewSize.height < rootCompositionSize.height) {
rootCompositionSize.height = viewSize.height;
}
#endif
} else {
rootCompositionSize = viewSize;
}
}
}
} else {
nsIWidget* widget = aFrame->GetNearestWidget();
nsIntRect widgetBounds;
widget->GetBounds(widgetBounds);
rootCompositionSize = LayerSize(ViewAs<LayerPixel>(widgetBounds.Size()));
}
// Adjust composition size for the size of scroll bars.
nsIFrame* rootRootScrollFrame = rootPresShell ? rootPresShell->GetRootScrollFrame() : nullptr;
nsIScrollableFrame* rootScrollableFrame = nullptr;
if (rootRootScrollFrame) {
rootScrollableFrame = rootRootScrollFrame->GetScrollTargetFrame();
}
if (rootScrollableFrame && !LookAndFeel::GetInt(LookAndFeel::eIntID_UseOverlayScrollbars)) {
CSSMargin margins = CSSMargin::FromAppUnits(rootScrollableFrame->GetActualScrollbarSizes());
// Scrollbars are not subject to scaling, so CSS pixels = layer pixels for them.
rootCompositionSize.width -= margins.LeftRight();
rootCompositionSize.height -= margins.TopBottom();
}
return rootCompositionSize / aMetrics.LayersPixelsPerCSSPixel();
}
/* static */ nsRect
nsLayoutUtils::CalculateScrollableRectForFrame(nsIScrollableFrame* aScrollableFrame, nsIFrame* aRootFrame)
@ -6489,19 +6279,6 @@ nsLayoutUtils::CalculateExpandedScrollableRect(nsIFrame* aFrame)
return scrollableRect;
}
/* static */ bool
nsLayoutUtils::WantSubAPZC()
{
// TODO Turn this on for inprocess OMTC on all platforms
bool wantSubAPZC = gfxPrefs::APZSubframeEnabled();
#ifdef MOZ_WIDGET_GONK
if (XRE_GetProcessType() != GeckoProcessType_Content) {
wantSubAPZC = false;
}
#endif
return wantSubAPZC;
}
nsLayoutUtils::SurfaceFromElementResult::SurfaceFromElementResult()
// Use safe default values here
: mIsWriteOnly(true), mIsStillLoading(false), mCORSUsed(false)

View File

@ -126,8 +126,6 @@ public:
typedef mozilla::layers::FrameMetrics FrameMetrics;
typedef FrameMetrics::ViewID ViewID;
typedef mozilla::CSSPoint CSSPoint;
typedef mozilla::CSSSize CSSSize;
typedef mozilla::LayerMargin LayerMargin;
/**
* Finds previously assigned ViewID for the given content element, if any.
@ -156,38 +154,11 @@ public:
*/
static bool GetDisplayPort(nsIContent* aContent, nsRect *aResult = nullptr);
MOZ_BEGIN_ENUM_CLASS(RepaintMode, uint8_t)
Repaint,
DoNotRepaint
MOZ_END_ENUM_CLASS(RepaintMode)
/**
* Set the display port margins for a content element to be used with a
* display port base (see SetDisplayPortBase()).
* See also nsIDOMWindowUtils.setDisplayPortMargins.
* @param aContent the content element for which to set the margins
* @param aPresShell the pres shell for the document containing the element
* @param aMargins the margins to set
* @param aAlignmentX, alignmentY the amount of pixels to which to align the
* displayport built by combining the base
* rect with the margins, in either direction
* @param aPriority a priority value to determine which margins take effect
* when multiple callers specify margins
* @param aRepaintMode whether to schedule a paint after setting the margins
*/
static void SetDisplayPortMargins(nsIContent* aContent,
nsIPresShell* aPresShell,
const LayerMargin& aMargins,
uint32_t aAlignmentX,
uint32_t aAlignmentY,
uint32_t aPriority = 0,
RepaintMode aRepaintMode = RepaintMode::Repaint);
/**
* Set the display port base rect for given element to be used with display
* port margins.
*/
static void SetDisplayPortBase(nsIContent* aContent, const nsRect& aBase);
/**
* Set the display port base rect for given element to be used with display
* port margins.
*/
static void SetDisplayPortBase(nsIContent* aContent, const nsRect& aBase);
/**
* Get the critical display port for the given element.
@ -2129,22 +2100,6 @@ public:
static nsSize
CalculateCompositionSizeForFrame(nsIFrame* aFrame);
/**
* Calculate the composition size for the root scroll frame of the root
* content document.
* @param aFrame A frame in the root content document (or a descendant of it).
* @param aIsRootContentDocRootScrollFrame Whether aFrame is already the root
* scroll frame of the root content document. In this case we just
* use aFrame's own composition size.
* @param aMetrics A partially populated FrameMetrics for aFrame. Must have at
* least mCompositionBounds, mCumulativeResolution, and
* mDevPixelsPerCSSPixel set.
*/
static CSSSize
CalculateRootCompositionSize(nsIFrame* aFrame,
bool aIsRootContentDocRootScrollFrame,
const FrameMetrics& aMetrics);
/**
* Calculate the scrollable rect for a frame. See FrameMetrics.h for
* defintion of scrollable rect. aScrollableFrame is the scroll frame to calculate
@ -2161,32 +2116,6 @@ public:
static nsRect
CalculateExpandedScrollableRect(nsIFrame* aFrame);
/**
* Return whether we want to use APZ for subframes in this process.
* Currently we don't support APZ for the parent process on B2G.
*/
static bool WantSubAPZC();
/**
* Get the display port for |aScrollFrame|'s content. If |aScrollFrame|
* WantsAsyncScroll() and we don't have a scrollable displayport yet (as
* tracked by |aBuilder|), calculate and set a display port. Returns true if
* there is (now) a displayport, and if so the displayport is returned in
* |aOutDisplayport|.
*
* Note that a displayport can either be stored as a rect, or as a base
* rect + margins. If it is stored as a base rect + margins, the base rect
* is updated to |aDisplayPortBase|, and the rect assembled from the
* base rect and margins is returned. If this function creates a displayport,
* it computes margins and stores |aDisplayPortBase| as the base rect.
*
* This is intended to be called during display list building.
*/
static bool GetOrMaybeCreateDisplayPort(nsDisplayListBuilder& aBuilder,
nsIFrame* aScrollFrame,
nsRect aDisplayPortBase,
nsRect* aOutDisplayport);
private:
static uint32_t sFontSizeInflationEmPerLine;
static uint32_t sFontSizeInflationMinTwips;

View File

@ -1029,37 +1029,6 @@ ScrollFrameHelper::HandleScrollbarStyleSwitching()
}
}
static bool IsFocused(nsIContent* aContent)
{
// Some content elements, like the GetContent() of a scroll frame
// for a text input field, are inside anonymous subtrees, but the focus
// manager always reports a non-anonymous element as the focused one, so
// walk up the tree until we reach a non-anonymous element.
while (aContent && aContent->IsInAnonymousSubtree()) {
aContent = aContent->GetParent();
}
return aContent ? nsContentUtils::IsFocusedContent(aContent) : false;
}
bool
ScrollFrameHelper::WantAsyncScroll() const
{
nsRect scrollRange = GetScrollRange();
ScrollbarStyles styles = GetScrollbarStylesFromFrame();
bool isFocused = IsFocused(mOuter->GetContent());
bool isVScrollable = (scrollRange.height > 0)
&& (styles.mVertical != NS_STYLE_OVERFLOW_HIDDEN);
bool isHScrollable = (scrollRange.width > 0)
&& (styles.mHorizontal != NS_STYLE_OVERFLOW_HIDDEN);
// The check for scroll bars was added in bug 825692 to prevent layerization
// of text inputs for performance reasons. However, if a text input is
// focused we want to layerize it so we can async scroll it (bug 946408).
bool isVAsyncScrollable = isVScrollable && (mVScrollbarBox || isFocused);
bool isHAsyncScrollable = isHScrollable && (mHScrollbarBox || isFocused);
return isVAsyncScrollable || isHAsyncScrollable;
}
nsresult
nsXULScrollFrame::CreateAnonymousContent(nsTArray<ContentInfo>& aElements)
{
@ -2337,6 +2306,19 @@ ScrollFrameHelper::ExpandRect(const nsRect& aRect) const
return rect;
}
static bool IsFocused(nsIContent* aContent)
{
// Some content elements, like the GetContent() of a scroll frame
// for a text input field, are inside anonymous subtrees, but the focus
// manager always reports a non-anonymous element as the focused one, so
// walk up the tree until we reach a non-anonymous element.
while (aContent && aContent->IsInAnonymousSubtree()) {
aContent = aContent->GetParent();
}
return aContent ? nsContentUtils::IsFocusedContent(aContent) : false;
}
static bool
ShouldBeClippedByFrame(nsIFrame* aClipFrame, nsIFrame* aClippedFrame)
{
@ -2488,31 +2470,27 @@ ScrollFrameHelper::BuildDisplayList(nsDisplayListBuilder* aBuilder,
// dirty rect here.
nsRect dirtyRect = aDirtyRect.Intersect(mScrollPort);
// Override the dirty rectangle if the displayport has been set.
bool usingDisplayport =
nsLayoutUtils::GetDisplayPort(mOuter->GetContent()) &&
!aBuilder->IsForEventDelivery();
// don't set the display port base rect for root scroll frames,
// nsLayoutUtils::PaintFrame or nsSubDocumentFrame::BuildDisplayList
// does that for root scroll frames before it expands the dirty rect
// to the display port.
if (usingDisplayport && !mIsRoot) {
nsLayoutUtils::SetDisplayPortBase(mOuter->GetContent(), dirtyRect);
}
// now that we have an updated base rect we can get the display port
nsRect displayPort;
bool usingDisplayport = false;
if (!aBuilder->IsForEventDelivery()) {
if (!mIsRoot) {
// For a non-root scroll frame, override the value of the display port
// base rect, and possibly create a display port if there isn't one
// already. For root scroll frame, nsLayoutUtils::PaintFrame or
// nsSubDocumentFrame::BuildDisplayList takes care of this.
nsRect displayportBase = dirtyRect;
usingDisplayport = nsLayoutUtils::GetOrMaybeCreateDisplayPort(
*aBuilder, mOuter, displayportBase, &displayPort);
} else {
// For a root frmae, just get the value of the existing of the display
// port, if any.
usingDisplayport = nsLayoutUtils::GetDisplayPort(mOuter->GetContent(), &displayPort);
}
if (usingDisplayport && DisplayportExceedsMaxTextureSize(mOuter->PresContext(), displayPort)) {
usingDisplayport = false;
}
// Override the dirty rectangle if the displayport has been set.
if (usingDisplayport) {
dirtyRect = displayPort;
}
nsLayoutUtils::GetDisplayPort(mOuter->GetContent(), &displayPort);
if (usingDisplayport && DisplayportExceedsMaxTextureSize(mOuter->PresContext(), displayPort)) {
usingDisplayport = false;
}
if (usingDisplayport) {
dirtyRect = displayPort;
}
if (aBuilder->IsForImageVisibility()) {
@ -2599,9 +2577,28 @@ ScrollFrameHelper::BuildDisplayList(nsDisplayListBuilder* aBuilder,
if (mShouldBuildScrollableLayer) {
shouldBuildLayer = true;
} else {
nsRect scrollRange = GetScrollRange();
ScrollbarStyles styles = GetScrollbarStylesFromFrame();
bool isFocused = IsFocused(mOuter->GetContent());
bool isVScrollable = (scrollRange.height > 0)
&& (styles.mVertical != NS_STYLE_OVERFLOW_HIDDEN);
bool isHScrollable = (scrollRange.width > 0)
&& (styles.mHorizontal != NS_STYLE_OVERFLOW_HIDDEN);
// The check for scroll bars was added in bug 825692 to prevent layerization
// of text inputs for performance reasons. However, if a text input is
// focused we want to layerize it so we can async scroll it (bug 946408).
bool wantLayerV = isVScrollable && (mVScrollbarBox || isFocused);
bool wantLayerH = isHScrollable && (mHScrollbarBox || isFocused);
// TODO Turn this on for inprocess OMTC on all platforms
bool wantSubAPZC = gfxPrefs::APZSubframeEnabled();
#ifdef MOZ_WIDGET_GONK
if (XRE_GetProcessType() != GeckoProcessType_Content) {
wantSubAPZC = false;
}
#endif
shouldBuildLayer =
nsLayoutUtils::WantSubAPZC() &&
WantAsyncScroll() &&
wantSubAPZC &&
(wantLayerV || wantLayerH) &&
// If we are the root scroll frame for the display root then we don't need a scroll
// info layer to make a RecordFrameMetrics call for us as
// nsDisplayList::PaintForFrame already calls RecordFrameMetrics for us.

View File

@ -308,7 +308,6 @@ public:
mOriginOfLastScroll = nullptr;
}
}
bool WantAsyncScroll() const;
// owning references to the nsIAnonymousContentCreator-built content
nsCOMPtr<nsIContent> mHScrollbarContent;
@ -662,9 +661,6 @@ public:
virtual void ResetOriginIfScrollAtGeneration(uint32_t aGeneration) MOZ_OVERRIDE {
mHelper.ResetOriginIfScrollAtGeneration(aGeneration);
}
virtual bool WantAsyncScroll() const MOZ_OVERRIDE {
return mHelper.WantAsyncScroll();
}
// nsIStatefulFrame
NS_IMETHOD SaveState(nsPresState** aState) MOZ_OVERRIDE {
@ -969,9 +965,6 @@ public:
virtual void ResetOriginIfScrollAtGeneration(uint32_t aGeneration) MOZ_OVERRIDE {
mHelper.ResetOriginIfScrollAtGeneration(aGeneration);
}
virtual bool WantAsyncScroll() const MOZ_OVERRIDE {
return mHelper.WantAsyncScroll();
}
// nsIStatefulFrame
NS_IMETHOD SaveState(nsPresState** aState) MOZ_OVERRIDE {

View File

@ -291,11 +291,6 @@ public:
* counter.
*/
virtual void ResetOriginIfScrollAtGeneration(uint32_t aGeneration) = 0;
/**
* Determine whether it is desirable to be able to asynchronously scroll this
* scroll frame.
*/
virtual bool WantAsyncScroll() const = 0;
};
#endif

View File

@ -382,14 +382,15 @@ nsSubDocumentFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
dirty = dirty.ConvertAppUnitsRoundOut(parentAPD, subdocAPD);
nsIFrame* rootScrollFrame = presShell->GetRootScrollFrame();
// for root content documents we want the base to be the composition bounds
nsRect displayportBase = presContext->IsRootContentDocument() ?
nsRect(nsPoint(0,0), nsLayoutUtils::CalculateCompositionSizeForFrame(rootScrollFrame)) :
dirty;
nsRect displayPort;
if (nsLayoutUtils::GetOrMaybeCreateDisplayPort(
*aBuilder, rootScrollFrame, displayportBase, &displayPort)) {
if (nsLayoutUtils::ViewportHasDisplayPort(presContext)) {
haveDisplayPort = true;
// for root content documents we want the base to be the composition bounds
nsLayoutUtils::SetDisplayPortBase(rootScrollFrame->GetContent(),
presContext->IsRootContentDocument() ?
nsRect(nsPoint(0,0), nsLayoutUtils::CalculateCompositionSizeForFrame(rootScrollFrame)) :
dirty);
nsRect displayPort;
nsLayoutUtils::ViewportHasDisplayPort(presContext, &displayPort);
dirty = displayPort;
}