Bug 1491864 - Ignore anon boxes for preserve-3d. r=mattwoodrow

In the button case we have a ::-moz-button-content pseudo-element, but this is
also an issue for tables and such.

These are supposed to be implementation details, so avoid looking at them for
preserve-3d.

I don't know how I didn't think of this on the regressing bug.

Differential Revision: https://phabricator.services.mozilla.com/D6131

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Emilio Cobos Álvarez 2018-09-19 21:21:18 +00:00
parent 79ea3c1025
commit 4aab8cafdd
7 changed files with 269 additions and 701 deletions

View File

@ -1604,7 +1604,7 @@ bool
nsIFrame::Combines3DTransformWithAncestors(const nsStyleDisplay* aStyleDisplay) const
{
MOZ_ASSERT(aStyleDisplay == StyleDisplay());
nsIFrame* parent = GetInFlowParent();
nsIFrame* parent = GetInFlowParentIgnoringAnonBoxes();
if (!parent || !parent->Extend3DContext()) {
return false;
}
@ -2625,9 +2625,9 @@ FrameParticipatesIn3DContext(nsIFrame* aAncestor, nsIFrame* aDescendant) {
MOZ_ASSERT(aAncestor != aDescendant);
MOZ_ASSERT(aAncestor->Extend3DContext());
nsIFrame* frame;
for (frame = aDescendant->GetInFlowParent();
for (frame = aDescendant->GetInFlowParentIgnoringAnonBoxes();
frame && aAncestor != frame;
frame = frame->GetInFlowParent()) {
frame = frame->GetInFlowParentIgnoringAnonBoxes()) {
if (!frame->Extend3DContext()) {
return false;
}

View File

@ -867,12 +867,18 @@ public:
/**
* Gets the parent of a frame, using the parent of the placeholder for
* out-of-flow frames.
*/
inline nsContainerFrame* GetInFlowParent() const;
/**
* Gets the in-flow parent, skipping any anonymous box that we may find along
* the way.
*
* This is effectively the primary frame (or one of the continuations) of the
* closest flattened tree ancestor that has a frame (flattened tree ancestors
* may not have frames in presence of display: contents).
*/
inline nsContainerFrame* GetInFlowParent() const;
inline nsContainerFrame* GetInFlowParentIgnoringAnonBoxes() const;
/**
* Return the placeholder for this frame (which must be out-of-flow).

View File

@ -180,4 +180,14 @@ nsIFrame::GetInFlowParent() const
return GetParent();
}
nsContainerFrame*
nsIFrame::GetInFlowParentIgnoringAnonBoxes() const
{
nsContainerFrame* parent = GetInFlowParent();
while (parent && parent->Style()->IsAnonBox()) {
parent = parent->GetInFlowParent();
}
return parent;
}
#endif

View File

@ -8385,7 +8385,7 @@ nsDisplayTransform::GetResultingTransformMatrixInternal(
if ((aFlags & INCLUDE_PRESERVE3D_ANCESTORS) && frame &&
frame->Combines3DTransformWithAncestors()) {
// Include the transform set on our parent
nsIFrame* parentFrame = frame->GetInFlowParent();
nsIFrame* parentFrame = frame->GetInFlowParentIgnoringAnonBoxes();
NS_ASSERTION(parentFrame && parentFrame->IsTransformed() &&
parentFrame->Extend3DContext(),
"Preserve3D mismatch!");
@ -8664,7 +8664,7 @@ nsDisplayTransform::GetAccumulatedPreserved3DTransform(
const nsIFrame* establisher; // Establisher of the 3D rendering context.
for (establisher = mFrame;
establisher && establisher->Combines3DTransformWithAncestors();
establisher = establisher->GetInFlowParent()) {
establisher = establisher->GetInFlowParentIgnoringAnonBoxes()) {
}
const nsIFrame* establisherReference = aBuilder->FindReferenceFrameFor(
nsLayoutUtils::GetCrossDocParentFrame(establisher));

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,42 @@
<!doctype html>
<title>CSS Test Reference</title>
<link rel="author" title="Emilio Cobos Álvarez" href="mailto:emilio@crisal.io">
<link rel="author" title="Mozilla" href="https://mozilla.org">
<style>
.scene {
width: 200px;
height: 200px;
perspective: 5000px;
}
.card {
width: 100%;
height: 100%;
transform-style: preserve-3d;
position: relative;
background: none;
border: 0;
padding: 0;
transform: rotateY(180deg);
}
.face {
position: absolute;
top: 0;
width: 100%;
height: 100%;
backface-visibility: hidden;
background: red;
}
.backface {
background: green;
transform: rotateY(180deg);
}
</style>
<div class="scene">
<div class="card">
<div class="face"></div>
<div class="face backface"></div>
</div>
</div>

View File

@ -0,0 +1,44 @@
<!doctype html>
<title>CSS Test: preserve-3d on buttons</title>
<link rel="author" title="Emilio Cobos Álvarez" href="mailto:emilio@crisal.io">
<link rel="author" title="Mozilla" href="https://mozilla.org">
<link rel="match" href="preserve3d-button-ref.html">
<link rel="help" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1491864">
<style>
.scene {
width: 200px;
height: 200px;
perspective: 5000px;
}
.card {
width: 100%;
height: 100%;
transform-style: preserve-3d;
position: relative;
background: none;
border: 0;
padding: 0;
transform: rotateY(180deg);
}
.face {
position: absolute;
top: 0;
width: 100%;
height: 100%;
backface-visibility: hidden;
background: red;
}
.backface {
background: green;
transform: rotateY(180deg);
}
</style>
<div class="scene">
<button class="card">
<div class="face"></div>
<div class="face backface"></div>
</button>
</div>