Bug 1398581: Ensure a first-letter doesn't incorrectly inherit from a first-line. r=heycam

This approach kinda sucks, because we woefully throw away the style context
computed in the case it inherited from a first-line, but it's the easiest thing
I could think of without either making it more inefficient, or threading a
parent style ignoring first-line through ResolvePseudoElementStyle and related
functions.

MozReview-Commit-ID: 3uGuU7dHEnE
This commit is contained in:
Emilio Cobos Álvarez
2017-09-11 09:51:30 +02:00
parent 278648e798
commit 1863a745a8

View File

@@ -11861,10 +11861,11 @@ nsCSSFrameConstructor::CreateLetterFrame(nsContainerFrame* aBlockFrame,
// Get style context for the first-letter-frame. Keep this in sync with
// nsBlockFrame::UpdatePseudoElementStyles.
nsStyleContext* parentStyleContext =
nsIFrame* parentFrame =
nsFrame::CorrectStyleParentFrame(aParentFrame,
nsCSSPseudoElements::firstLetter)->
StyleContext();
nsCSSPseudoElements::firstLetter);
nsStyleContext* parentStyleContext = parentFrame->StyleContext();
// Use content from containing block so that we can actually
// find a matching style rule.
@@ -11873,7 +11874,20 @@ nsCSSFrameConstructor::CreateLetterFrame(nsContainerFrame* aBlockFrame,
// Create first-letter style rule
RefPtr<nsStyleContext> sc =
GetFirstLetterStyle(blockContent, parentStyleContext);
if (sc) {
if (sc->IsServo() && parentFrame->IsLineFrame()) {
ServoStyleContext* parentStyleIgnoringFirstLine =
aBlockFrame->StyleContext()->AsServo();
sc =
mPresShell->StyleSet()->AsServo()->ReparentStyleContext(
sc->AsServo(),
parentStyleContext->AsServo(),
parentStyleIgnoringFirstLine,
parentStyleIgnoringFirstLine,
blockContent->AsElement());
}
RefPtr<nsStyleContext> textSC = mPresShell->StyleSet()->
ResolveStyleForText(aTextContent, sc);