Bug 1355351: Clean up pseudo-element props. r=heycam

MozReview-Commit-ID: JZAhEN3chPs

--HG--
extra : rebase_source : f5756182a9ad35b6ac73a6f4d022c1f93ccbf333
This commit is contained in:
Emilio Cobos Álvarez 2017-04-19 10:27:33 +02:00
Родитель ea71d98f7b
Коммит 135c333511
3 изменённых файлов: 25 добавлений и 84 удалений

Просмотреть файл

@ -6145,6 +6145,9 @@ AddGenConPseudoToFrame(nsIFrame* aOwnerFrame, nsIContent* aContent)
NS_ASSERTION(nsLayoutUtils::IsFirstContinuationOrIBSplitSibling(aOwnerFrame),
"property should only be set on first continuation/ib-sibling");
// FIXME(emilio): Remove this property, and use the frame of the generated
// content itself to tear the content down? It should be quite simpler.
FrameProperties props = aOwnerFrame->Properties();
nsIFrame::ContentArray* value = props.Get(nsIFrame::GenConProperty());
if (!value) {
@ -6406,7 +6409,7 @@ AdjustAppendParentForAfterContent(nsFrameManager* aFrameManager,
// frames to find the first one that is either a ::after frame for an
// ancestor of aChild or a frame that is for a node later in the
// document than aChild and return that in aAfterFrame.
if (aParentFrame->GetGenConPseudos() ||
if (aParentFrame->Properties().Get(nsIFrame::GenConProperty()) ||
nsLayoutUtils::HasPseudoStyle(aContainer, aParentFrame->StyleContext(),
CSSPseudoElementType::after,
aParentFrame->PresContext()) ||
@ -8539,25 +8542,23 @@ nsCSSFrameConstructor::ContentRemoved(nsIContent* aContainer,
MOZ_ASSERT(!childFrame || !GetDisplayContentsStyleFor(aChild),
"display:contents nodes shouldn't have a frame");
if (!childFrame && GetDisplayContentsStyleFor(aChild)) {
nsIFrame* ancestorFrame = nullptr;
nsIContent* ancestor = aContainer;
for (; ancestor; ancestor = ancestor->GetParent()) {
ancestorFrame = ancestor->GetPrimaryFrame();
if (ancestorFrame) {
break;
}
while (!ancestor->GetPrimaryFrame()) {
// FIXME(emilio): Should this use the flattened tree parent instead?
ancestor = ancestor->GetParent();
MOZ_ASSERT(ancestor, "we can't have a display: contents subtree root!");
}
if (ancestorFrame) {
nsTArray<nsIContent*>* generated = ancestorFrame->GetGenConPseudos();
if (generated) {
*aDidReconstruct = true;
LAYOUT_PHASE_TEMP_EXIT();
// XXXmats Can we recreate frames only for the ::after/::before content?
// XXX Perhaps even only those that belong to the aChild sub-tree?
RecreateFramesForContent(ancestor, false, aFlags, aDestroyedFramesFor);
LAYOUT_PHASE_TEMP_REENTER();
return;
}
nsIFrame* ancestorFrame = ancestor->GetPrimaryFrame();
if (ancestorFrame->Properties().Get(nsIFrame::GenConProperty())) {
*aDidReconstruct = true;
LAYOUT_PHASE_TEMP_EXIT();
// XXXmats Can we recreate frames only for the ::after/::before content?
// XXX Perhaps even only those that belong to the aChild sub-tree?
RecreateFramesForContent(ancestor, false, aFlags, aDestroyedFramesFor);
LAYOUT_PHASE_TEMP_REENTER();
return;
}
FlattenedChildIterator iter(aChild);

Просмотреть файл

@ -1589,33 +1589,9 @@ nsLayoutUtils::GetChildListNameFor(nsIFrame* aChildFrame)
nsLayoutUtils::GetBeforeFrameForContent(nsIFrame* aFrame,
const nsIContent* aContent)
{
// We need to call GetGenConPseudos() on the first continuation/ib-split.
// Find it, for symmetry with GetAfterFrameForContent.
nsContainerFrame* genConParentFrame =
FirstContinuationOrIBSplitSibling(aFrame)->GetContentInsertionFrame();
if (!genConParentFrame) {
return nullptr;
}
nsTArray<nsIContent*>* prop = genConParentFrame->GetGenConPseudos();
if (prop) {
const nsTArray<nsIContent*>& pseudos(*prop);
for (uint32_t i = 0; i < pseudos.Length(); ++i) {
if (pseudos[i]->GetParent() == aContent &&
pseudos[i]->NodeInfo()->NameAtom() == nsGkAtoms::mozgeneratedcontentbefore) {
return pseudos[i]->GetPrimaryFrame();
}
}
}
// If the first child frame is a pseudo-frame, then try that.
// Note that the frame we create for the generated content is also a
// pseudo-frame and so don't drill down in that case.
nsIFrame* childFrame = genConParentFrame->PrincipalChildList().FirstChild();
if (childFrame &&
childFrame->IsPseudoFrame(aContent) &&
!childFrame->IsGeneratedContentFrame()) {
return GetBeforeFrameForContent(childFrame, aContent);
}
return nullptr;
auto* pseudo =
static_cast<Element*>(aContent->GetProperty(nsGkAtoms::beforePseudoProperty));
return pseudo ? pseudo->GetPrimaryFrame() : nullptr;
}
/*static*/ nsIFrame*
@ -1628,41 +1604,9 @@ nsLayoutUtils::GetBeforeFrame(nsIFrame* aFrame)
nsLayoutUtils::GetAfterFrameForContent(nsIFrame* aFrame,
const nsIContent* aContent)
{
// We need to call GetGenConPseudos() on the first continuation,
// but callers are likely to pass the last.
nsContainerFrame* genConParentFrame =
FirstContinuationOrIBSplitSibling(aFrame)->GetContentInsertionFrame();
if (!genConParentFrame) {
return nullptr;
}
nsTArray<nsIContent*>* prop = genConParentFrame->GetGenConPseudos();
if (prop) {
const nsTArray<nsIContent*>& pseudos(*prop);
for (uint32_t i = 0; i < pseudos.Length(); ++i) {
if (pseudos[i]->GetParent() == aContent &&
pseudos[i]->NodeInfo()->NameAtom() == nsGkAtoms::mozgeneratedcontentafter) {
return pseudos[i]->GetPrimaryFrame();
}
}
}
// If the last child frame is a pseudo-frame, then try that.
// Note that the frame we create for the generated content is also a
// pseudo-frame and so don't drill down in that case.
genConParentFrame = aFrame->GetContentInsertionFrame();
if (!genConParentFrame) {
return nullptr;
}
nsIFrame* lastParentContinuation =
LastContinuationWithChild(static_cast<nsContainerFrame*>(
LastContinuationOrIBSplitSibling(genConParentFrame)));
nsIFrame* childFrame =
lastParentContinuation->GetChildList(nsIFrame::kPrincipalList).LastChild();
if (childFrame &&
childFrame->IsPseudoFrame(aContent) &&
!childFrame->IsGeneratedContentFrame()) {
return GetAfterFrameForContent(childFrame->FirstContinuation(), aContent);
}
return nullptr;
auto* pseudo =
static_cast<Element*>(aContent->GetProperty(nsGkAtoms::afterPseudoProperty));
return pseudo ? pseudo->GetPrimaryFrame() : nullptr;
}
/*static*/ nsIFrame*

Просмотреть файл

@ -1180,10 +1180,6 @@ public:
return GetBidiData().embeddingLevel;
}
nsTArray<nsIContent*>* GetGenConPseudos() {
return Properties().Get(GenConProperty());
}
/**
* Return the distance between the border edge of the frame and the
* margin edge of the frame. Like GetRect(), returns the dimensions