Skip to content

Commit

Permalink
Bug 1139283 - Move some properties from nsStyleDisplay to nsStylePosi…
Browse files Browse the repository at this point in the history
…tion. r=dbaron

The moved properties are:
* clip
* transform-style
* transform-origin
* backface-visibility
* perspective
* perspective-origin
* will-change

--HG--
extra : source : 42bbf0328b450d1094250159fe9f7f0d07622290
  • Loading branch information
upsuper committed Mar 8, 2015
1 parent 751b0c9 commit d4289c7
Show file tree
Hide file tree
Showing 18 changed files with 606 additions and 573 deletions.
5 changes: 3 additions & 2 deletions layout/base/ActiveLayerTracker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -265,12 +265,13 @@ ActiveLayerTracker::IsStyleAnimated(nsDisplayListBuilder* aBuilder,
nsIFrame* aFrame, nsCSSProperty aProperty)
{
// TODO: Add some abuse restrictions
if ((aFrame->StyleDisplay()->mWillChangeBitField & NS_STYLE_WILL_CHANGE_TRANSFORM) &&
auto willChangeBitField = aFrame->StylePosition()->mWillChangeBitField;
if ((willChangeBitField & NS_STYLE_WILL_CHANGE_TRANSFORM) &&
aProperty == eCSSProperty_transform &&
(!aBuilder || aBuilder->IsInWillChangeBudget(aFrame))) {
return true;
}
if ((aFrame->StyleDisplay()->mWillChangeBitField & NS_STYLE_WILL_CHANGE_OPACITY) &&
if ((willChangeBitField & NS_STYLE_WILL_CHANGE_OPACITY) &&
aProperty == eCSSProperty_opacity &&
(!aBuilder || aBuilder->IsInWillChangeBudget(aFrame))) {
return true;
Expand Down
6 changes: 3 additions & 3 deletions layout/base/RestyleManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -332,12 +332,12 @@ ApplyRenderingChangeToTree(nsPresContext* aPresContext,
nsIFrame* aFrame,
nsChangeHint aChange)
{
// We check StyleDisplay()->HasTransformStyle() in addition to checking
// We check StylePosition()->HasTransformStyle() in addition to checking
// IsTransformed() since we can get here for some frames that don't support
// CSS transforms.
NS_ASSERTION(!(aChange & nsChangeHint_UpdateTransformLayer) ||
aFrame->IsTransformed() ||
aFrame->StyleDisplay()->HasTransformStyle(),
aFrame->StylePosition()->HasTransformStyle(),
"Unexpected UpdateTransformLayer hint");

nsIPresShell *shell = aPresContext->PresShell();
Expand Down Expand Up @@ -2605,7 +2605,7 @@ ElementRestyler::AddLayerChangesForAnimation()
// nsChangeHint_UpdateTransformLayer, ApplyRenderingChangeToTree would
// complain that we're updating a transform layer without a transform).
if (layerInfo[i].mLayerType == nsDisplayItem::TYPE_TRANSFORM &&
!mFrame->StyleDisplay()->HasTransformStyle()) {
!mFrame->StylePosition()->HasTransformStyle()) {
continue;
}
NS_UpdateHint(hint, layerInfo[i].mChangeHint);
Expand Down
15 changes: 9 additions & 6 deletions layout/base/nsCSSFrameConstructor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1059,8 +1059,8 @@ nsFrameConstructorState::PushAbsoluteContainingBlock(nsContainerFrame* aNewAbsol
* we're a transformed element.
*/
mFixedPosIsAbsPos = aPositionedFrame &&
(aPositionedFrame->StyleDisplay()->HasTransform(aPositionedFrame) ||
aPositionedFrame->StyleDisplay()->HasPerspectiveStyle());
(aPositionedFrame->StylePosition()->HasTransform(aPositionedFrame) ||
aPositionedFrame->StylePosition()->HasPerspectiveStyle());

if (aNewAbsoluteContainingBlock) {
aNewAbsoluteContainingBlock->MarkAsAbsoluteContainingBlock();
Expand Down Expand Up @@ -3788,7 +3788,9 @@ nsCSSFrameConstructor::ConstructFrameFromItemInternal(FrameConstructionItem& aIt

// If we need to create a block formatting context to wrap our
// kids, do it now.
const nsStylePosition* position = styleContext->StylePosition();
const nsStyleDisplay* maybeAbsoluteContainingBlockDisplay = display;
const nsStylePosition* maybeAbsoluteContainingBlockPosition = position;
nsIFrame* maybeAbsoluteContainingBlock = newFrame;
nsIFrame* possiblyLeafFrame = newFrame;
if (bits & FCDATA_CREATE_BLOCK_WRAPPER_FOR_ALL_KIDS) {
Expand All @@ -3814,6 +3816,7 @@ nsCSSFrameConstructor::ConstructFrameFromItemInternal(FrameConstructionItem& aIt
const nsStyleDisplay* blockDisplay = blockContext->StyleDisplay();
if (blockDisplay->IsPositioned(blockFrame)) {
maybeAbsoluteContainingBlockDisplay = blockDisplay;
maybeAbsoluteContainingBlockPosition = blockContext->StylePosition();
maybeAbsoluteContainingBlock = blockFrame;
}

Expand Down Expand Up @@ -3854,9 +3857,9 @@ nsCSSFrameConstructor::ConstructFrameFromItemInternal(FrameConstructionItem& aIt
// make the inner the containing block.
if ((maybeAbsoluteContainingBlockDisplay->IsAbsolutelyPositionedStyle() ||
maybeAbsoluteContainingBlockDisplay->IsRelativelyPositionedStyle() ||
(maybeAbsoluteContainingBlockDisplay->HasTransformStyle() &&
(maybeAbsoluteContainingBlockPosition->HasTransformStyle() &&
cb->IsFrameOfType(nsIFrame::eSupportsCSSTransforms)) ||
maybeAbsoluteContainingBlockDisplay->HasPerspectiveStyle()) &&
maybeAbsoluteContainingBlockPosition->HasPerspectiveStyle()) &&
!cb->IsSVGText()) {
nsContainerFrame* cf = static_cast<nsContainerFrame*>(cb);
aState.PushAbsoluteContainingBlock(cf, cf, absoluteSaveState);
Expand Down Expand Up @@ -5983,8 +5986,8 @@ nsCSSFrameConstructor::GetAbsoluteContainingBlock(nsIFrame* aFrame,
// not transformed, skip it.
if (!frame->IsPositioned() ||
(aType == FIXED_POS &&
!frame->StyleDisplay()->HasTransform(frame) &&
!frame->StyleDisplay()->HasPerspectiveStyle())) {
!frame->StylePosition()->HasTransform(frame) &&
!frame->StylePosition()->HasPerspectiveStyle())) {
continue;
}
nsIFrame* absPosCBCandidate = frame;
Expand Down
50 changes: 27 additions & 23 deletions layout/base/nsDisplayList.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -522,9 +522,9 @@ nsDisplayListBuilder::AddAnimationsAndTransitionsToLayer(Layer* aLayer,
nscoord perspective = 0.0;
nsStyleContext* parentStyleContext = aFrame->StyleContext()->GetParent();
if (parentStyleContext) {
const nsStyleDisplay* disp = parentStyleContext->StyleDisplay();
if (disp && disp->mChildPerspective.GetUnit() == eStyleUnit_Coord) {
perspective = disp->mChildPerspective.GetCoordValue();
const nsStylePosition* pos = parentStyleContext->StylePosition();
if (pos && pos->mChildPerspective.GetUnit() == eStyleUnit_Coord) {
perspective = pos->mChildPerspective.GetCoordValue();
}
}
nsPoint origin;
Expand Down Expand Up @@ -5027,8 +5027,8 @@ nsDisplayTransform::Init(nsDisplayListBuilder* aBuilder)
mStoredList.SetVisibleRect(mChildrenVisibleRect);
mMaybePrerender = ShouldPrerenderTransformedContent(aBuilder, mFrame);

const nsStyleDisplay* disp = mFrame->StyleDisplay();
if ((disp->mWillChangeBitField & NS_STYLE_WILL_CHANGE_TRANSFORM)) {
const nsStylePosition* pos = mFrame->StylePosition();
if ((pos->mWillChangeBitField & NS_STYLE_WILL_CHANGE_TRANSFORM)) {
// We will only pre-render if this will-change is on budget.
mMaybePrerender = true;
}
Expand Down Expand Up @@ -5082,7 +5082,8 @@ nsDisplayTransform::GetDeltaToTransformOrigin(const nsIFrame* aFrame,
const nsRect* aBoundsOverride)
{
NS_PRECONDITION(aFrame, "Can't get delta for a null frame!");
NS_PRECONDITION(aFrame->IsTransformed() || aFrame->StyleDisplay()->BackfaceIsHidden(),
NS_PRECONDITION(aFrame->IsTransformed() ||
aFrame->StylePosition()->BackfaceIsHidden(),
"Shouldn't get a delta for an untransformed frame!");

if (!aFrame->IsTransformed()) {
Expand All @@ -5093,7 +5094,7 @@ nsDisplayTransform::GetDeltaToTransformOrigin(const nsIFrame* aFrame,
* percentage, it's relative to the size of the frame. Otherwise, if it's
* a distance, it's already computed for us!
*/
const nsStyleDisplay* display = aFrame->StyleDisplay();
const nsStylePosition* pos = aFrame->StylePosition();
nsRect boundingRect = (aBoundsOverride ? *aBoundsOverride :
nsDisplayTransform::GetFrameBoundsForTransform(aFrame));

Expand All @@ -5106,7 +5107,7 @@ nsDisplayTransform::GetDeltaToTransformOrigin(const nsIFrame* aFrame,
/* If the -moz-transform-origin specifies a percentage, take the percentage
* of the size of the box.
*/
const nsStyleCoord &coord = display->mTransformOrigin[index];
const nsStyleCoord &coord = pos->mTransformOrigin[index];
if (coord.GetUnit() == eStyleUnit_Calc) {
const nsStyleCoord::Calc *calc = coord.GetCalcValue();
coords[index] =
Expand All @@ -5132,7 +5133,7 @@ nsDisplayTransform::GetDeltaToTransformOrigin(const nsIFrame* aFrame,
}
}

coords[2] = NSAppUnitsToFloatPixels(display->mTransformOrigin[2].GetCoordValue(),
coords[2] = NSAppUnitsToFloatPixels(pos->mTransformOrigin[2].GetCoordValue(),
aAppUnitsPerPixel);
/* Adjust based on the origin of the rectangle. */
coords[0] += NSAppUnitsToFloatPixels(boundingRect.x, aAppUnitsPerPixel);
Expand All @@ -5151,7 +5152,8 @@ nsDisplayTransform::GetDeltaToPerspectiveOrigin(const nsIFrame* aFrame,
float aAppUnitsPerPixel)
{
NS_PRECONDITION(aFrame, "Can't get delta for a null frame!");
NS_PRECONDITION(aFrame->IsTransformed() || aFrame->StyleDisplay()->BackfaceIsHidden(),
NS_PRECONDITION(aFrame->IsTransformed() ||
aFrame->StylePosition()->BackfaceIsHidden(),
"Shouldn't get a delta for an untransformed frame!");

if (!aFrame->IsTransformed()) {
Expand All @@ -5176,7 +5178,7 @@ nsDisplayTransform::GetDeltaToPerspectiveOrigin(const nsIFrame* aFrame,
return Point3D();
}
}
const nsStyleDisplay* display = psc->StyleDisplay();
const nsStylePosition* pos = psc->StylePosition();
nsRect boundingRect = nsDisplayTransform::GetFrameBoundsForTransform(parent);

/* Allows us to access named variables by index. */
Expand All @@ -5190,7 +5192,7 @@ nsDisplayTransform::GetDeltaToPerspectiveOrigin(const nsIFrame* aFrame,
/* If the -moz-transform-origin specifies a percentage, take the percentage
* of the size of the box.
*/
const nsStyleCoord &coord = display->mPerspectiveOrigin[index];
const nsStyleCoord &coord = pos->mPerspectiveOrigin[index];
if (coord.GetUnit() == eStyleUnit_Calc) {
const nsStyleCoord::Calc *calc = coord.GetCalcValue();
*coords[index] =
Expand Down Expand Up @@ -5221,18 +5223,18 @@ nsDisplayTransform::FrameTransformProperties::FrameTransformProperties(const nsI
float aAppUnitsPerPixel,
const nsRect* aBoundsOverride)
: mFrame(aFrame)
, mTransformList(aFrame->StyleDisplay()->mSpecifiedTransform)
, mTransformList(aFrame->StylePosition()->mSpecifiedTransform)
, mToTransformOrigin(GetDeltaToTransformOrigin(aFrame, aAppUnitsPerPixel, aBoundsOverride))
, mToPerspectiveOrigin(GetDeltaToPerspectiveOrigin(aFrame, aAppUnitsPerPixel))
, mChildPerspective(0)
{
const nsStyleDisplay* parentDisp = nullptr;
const nsStylePosition* parentPos = nullptr;
nsStyleContext* parentStyleContext = aFrame->StyleContext()->GetParent();
if (parentStyleContext) {
parentDisp = parentStyleContext->StyleDisplay();
parentPos = parentStyleContext->StylePosition();
}
if (parentDisp && parentDisp->mChildPerspective.GetUnit() == eStyleUnit_Coord) {
mChildPerspective = parentDisp->mChildPerspective.GetCoordValue();
if (parentPos && parentPos->mChildPerspective.GetUnit() == eStyleUnit_Coord) {
mChildPerspective = parentPos->mChildPerspective.GetCoordValue();
}
}

Expand Down Expand Up @@ -5412,8 +5414,8 @@ nsDisplayTransform::ShouldPrerender(nsDisplayListBuilder* aBuilder) {
return true;
}

const nsStyleDisplay* disp = mFrame->StyleDisplay();
if ((disp->mWillChangeBitField & NS_STYLE_WILL_CHANGE_TRANSFORM) &&
const nsStylePosition* pos = mFrame->StylePosition();
if ((pos->mWillChangeBitField & NS_STYLE_WILL_CHANGE_TRANSFORM) &&
aBuilder->IsInWillChangeBudget(mFrame)) {
return true;
}
Expand Down Expand Up @@ -5502,7 +5504,8 @@ static bool IsFrameVisible(nsIFrame* aFrame, const Matrix4x4& aMatrix)
if (aMatrix.IsSingular()) {
return false;
}
if (aFrame->StyleDisplay()->mBackfaceVisibility == NS_STYLE_BACKFACE_VISIBILITY_HIDDEN &&
const nsStylePosition* pos = aFrame->StylePosition();
if (pos->mBackfaceVisibility == NS_STYLE_BACKFACE_VISIBILITY_HIDDEN &&
aMatrix.IsBackfaceVisible()) {
return false;
}
Expand Down Expand Up @@ -5550,7 +5553,8 @@ already_AddRefed<Layer> nsDisplayTransform::BuildLayer(nsDisplayListBuilder *aBu
{
const Matrix4x4& newTransformMatrix = GetTransform();

if (mFrame->StyleDisplay()->mBackfaceVisibility == NS_STYLE_BACKFACE_VISIBILITY_HIDDEN &&
const nsStylePosition* pos = mFrame->StylePosition();
if (pos->mBackfaceVisibility == NS_STYLE_BACKFACE_VISIBILITY_HIDDEN &&
newTransformMatrix.IsBackfaceVisible()) {
return nullptr;
}
Expand Down Expand Up @@ -5609,8 +5613,8 @@ nsDisplayTransform::GetLayerState(nsDisplayListBuilder* aBuilder,
}
}

const nsStyleDisplay* disp = mFrame->StyleDisplay();
if ((disp->mWillChangeBitField & NS_STYLE_WILL_CHANGE_TRANSFORM)) {
const nsStylePosition* pos = mFrame->StylePosition();
if ((pos->mWillChangeBitField & NS_STYLE_WILL_CHANGE_TRANSFORM)) {
return LAYER_ACTIVE;
}

Expand Down
7 changes: 4 additions & 3 deletions layout/base/nsLayoutDebugger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -184,13 +184,14 @@ PrintDisplayItemTo(nsDisplayListBuilder* aBuilder, nsDisplayItem* aItem,
aStream << " fixed";
}

if (aItem->Frame()->StyleDisplay()->mWillChange.Length() > 0) {
const nsStylePosition* pos = aItem->Frame()->StylePosition();
if (pos->mWillChange.Length() > 0) {
aStream << " (will-change=";
for (size_t i = 0; i < aItem->Frame()->StyleDisplay()->mWillChange.Length(); i++) {
for (size_t i = 0; i < pos->mWillChange.Length(); i++) {
if (i > 0) {
aStream << ",";
}
aStream << NS_LossyConvertUTF16toASCII(aItem->Frame()->StyleDisplay()->mWillChange[i]).get();
aStream << NS_LossyConvertUTF16toASCII(pos->mWillChange[i]).get();
}
aStream << ")";
}
Expand Down
Loading

0 comments on commit d4289c7

Please sign in to comment.