Bug 1384542: Remove the use of GetParentAllowServo in nsFirstLetterFrame. r?heycam
MozReview-Commit-ID: Gt9MX8t3vUh
--- a/layout/generic/nsFirstLetterFrame.cpp
+++ b/layout/generic/nsFirstLetterFrame.cpp
@@ -54,23 +54,23 @@ void
nsFirstLetterFrame::Init(nsIContent* aContent,
nsContainerFrame* aParent,
nsIFrame* aPrevInFlow)
{
RefPtr<nsStyleContext> newSC;
if (aPrevInFlow) {
// Get proper style context for ourselves. We're creating the frame
// that represents everything *except* the first letter, so just create
- // a style context like we would for a text node.
- nsStyleContext* parentStyleContext = mStyleContext->GetParentAllowServo();
- if (parentStyleContext) {
- newSC = PresContext()->StyleSet()->
- ResolveStyleForFirstLetterContinuation(parentStyleContext);
- SetStyleContextWithoutNotification(newSC);
- }
+ // a style context that inherits from our style parent, with no extra rules.
+ nsIFrame* styleParent =
+ CorrectStyleParentFrame(aParent, nsCSSPseudoElements::firstLetter);
+ nsStyleContext* parentStyleContext = styleParent->StyleContext();
+ newSC = PresContext()->StyleSet()->
+ ResolveStyleForFirstLetterContinuation(parentStyleContext);
+ SetStyleContextWithoutNotification(newSC);
}
nsContainerFrame::Init(aContent, aParent, aPrevInFlow);
}
void
nsFirstLetterFrame::SetInitialChildList(ChildListID aListID,
nsFrameList& aChildList)
@@ -373,24 +373,33 @@ nsFirstLetterFrame::DrainOverflowFrames(
mFrames.AppendFrames(nullptr, *overflowFrames);
}
// Now repair our first frames style context (since we only reflow
// one frame there is no point in doing any other ones until they
// are reflowed)
nsIFrame* kid = mFrames.FirstChild();
if (kid) {
- RefPtr<nsStyleContext> sc;
nsIContent* kidContent = kid->GetContent();
if (kidContent) {
NS_ASSERTION(kidContent->IsNodeOfType(nsINode::eTEXT),
"should contain only text nodes");
- nsStyleContext* parentSC = prevInFlow ? mStyleContext->GetParentAllowServo() :
- mStyleContext;
- sc = aPresContext->StyleSet()->ResolveStyleForText(kidContent, parentSC);
+ nsStyleContext* parentSC;
+ if (prevInFlow) {
+ // This is for the rest of the content not in the first-letter.
+ nsIFrame* styleParent =
+ CorrectStyleParentFrame(GetParent(),
+ nsCSSPseudoElements::firstLetter);
+ parentSC = styleParent->StyleContext();
+ } else {
+ // And this for the first-letter style.
+ parentSC = mStyleContext;
+ }
+ RefPtr<nsStyleContext> sc =
+ aPresContext->StyleSet()->ResolveStyleForText(kidContent, parentSC);
kid->SetStyleContext(sc);
nsLayoutUtils::MarkDescendantsDirty(kid);
}
}
}
nscoord
nsFirstLetterFrame::GetLogicalBaseline(WritingMode aWritingMode) const