Bug 1375315. Make sure to update block pseudo-element styles on various anonymous blocks. r=emilio

MozReview-Commit-ID: HBabvfWYgdP

--HG--
extra : rebase_source : 6fb94a3494873d63bc49fd44e9951a9c7c5a8d8b
This commit is contained in:
Boris Zbarsky 2017-06-22 11:24:11 -04:00
parent 0100675f7f
commit 6fd06e372d
29 changed files with 257 additions and 26 deletions

View File

@ -250,22 +250,6 @@ private:
nsChangeHint mComputedHint;
};
static void
UpdateBlockFramePseudoElements(nsBlockFrame* aFrame,
ServoRestyleState& aRestyleState)
{
if (nsBulletFrame* bullet = aFrame->GetBullet()) {
RefPtr<nsStyleContext> newContext =
aRestyleState.StyleSet().ResolvePseudoElementStyle(
aFrame->GetContent()->AsElement(),
bullet->StyleContext()->GetPseudoType(),
aFrame->StyleContext(),
/* aPseudoElement = */ nullptr);
aFrame->UpdateStyleOfOwnedChildFrame(bullet, newContext, aRestyleState);
}
}
static void
UpdateBackdropIfNeeded(nsIFrame* aFrame, ServoRestyleState& aRestyleState)
{
@ -307,8 +291,7 @@ UpdateFramePseudoElementStyles(nsIFrame* aFrame,
ServoRestyleState& aRestyleState)
{
if (aFrame->IsFrameOfType(nsIFrame::eBlockFrame)) {
UpdateBlockFramePseudoElements(static_cast<nsBlockFrame*>(aFrame),
aRestyleState);
static_cast<nsBlockFrame*>(aFrame)->UpdatePseudoElementStyles(aRestyleState);
}
UpdateBackdropIfNeeded(aFrame, aRestyleState);

View File

@ -55,6 +55,8 @@
#include "nsISelection.h"
#include "mozilla/dom/HTMLDetailsElement.h"
#include "mozilla/dom/HTMLSummaryElement.h"
#include "mozilla/ServoRestyleManager.h"
#include "mozilla/ServoStyleSet.h"
#include "mozilla/StyleSetHandle.h"
#include "mozilla/StyleSetHandleInlines.h"
#include "mozilla/Telemetry.h"
@ -7079,14 +7081,8 @@ nsBlockFrame::CreateBulletFrameForListItem(bool aCreateBulletList,
CSSPseudoElementType::mozListBullet :
CSSPseudoElementType::mozListNumber;
nsStyleContext* parentStyle =
CorrectStyleParentFrame(this,
nsCSSPseudoElements::GetPseudoAtom(pseudoType))->
StyleContext();
RefPtr<nsStyleContext> kidSC = shell->StyleSet()->
ResolvePseudoElementStyle(mContent->AsElement(), pseudoType,
parentStyle, nullptr);
RefPtr<nsStyleContext> kidSC = ResolveBulletStyle(pseudoType,
shell->StyleSet());
// Create bullet frame
nsBulletFrame* bullet = new (shell) nsBulletFrame(kidSC);
@ -7519,6 +7515,30 @@ nsBlockFrame::ResolveBidi()
return nsBidiPresUtils::Resolve(this);
}
void
nsBlockFrame::UpdatePseudoElementStyles(ServoRestyleState& aRestyleState)
{
if (nsBulletFrame* bullet = GetBullet()) {
CSSPseudoElementType type = bullet->StyleContext()->GetPseudoType();
RefPtr<nsStyleContext> newBulletStyle =
ResolveBulletStyle(type, &aRestyleState.StyleSet());
UpdateStyleOfOwnedChildFrame(bullet, newBulletStyle, aRestyleState);
}
}
already_AddRefed<nsStyleContext>
nsBlockFrame::ResolveBulletStyle(CSSPseudoElementType aType,
StyleSetHandle aStyleSet)
{
nsStyleContext* parentStyle =
CorrectStyleParentFrame(this,
nsCSSPseudoElements::GetPseudoAtom(aType))->
StyleContext();
return aStyleSet->ResolvePseudoElementStyle(mContent->AsElement(), aType,
parentStyle, nullptr);
}
#ifdef DEBUG
void
nsBlockFrame::VerifyLines(bool aFinalCheckOK)

View File

@ -44,6 +44,8 @@ class nsBlockInFlowLineIterator;
class nsBulletFrame;
namespace mozilla {
class BlockReflowInput;
class ServoRestyleState;
class StyleSetHandle;
} // namespace mozilla
/**
@ -395,6 +397,12 @@ public:
nsFrameList mFrames;
};
/**
* Update the styles of our various pseudo-elements (bullets, first-letter,
* first-line, etc).
*/
void UpdatePseudoElementStyles(mozilla::ServoRestyleState& aRestyleState);
protected:
explicit nsBlockFrame(nsStyleContext* aContext, ClassID aID = kClassID)
: nsContainerFrame(aContext, aID)
@ -903,6 +911,13 @@ protected:
// Remove and return the pushed floats list.
nsFrameList* RemovePushedFloats();
// Resolve a style context for our bullet frame. aType should be
// mozListBullet or mozListNumber. Passing in the style set is an
// optimization, because all callsites have it.
already_AddRefed<nsStyleContext> ResolveBulletStyle(
mozilla::CSSPseudoElementType aType,
mozilla::StyleSetHandle aStyleSet);
#ifdef DEBUG
void VerifyLines(bool aFinalCheckOK);
void VerifyOverflowSituation();

View File

@ -10231,6 +10231,17 @@ nsIFrame::UpdateStyleOfChildAnonBox(nsIFrame* aChildFrame,
// has anon boxes to deal with.
ServoRestyleState childrenState(aRestyleState, childHint);
aChildFrame->UpdateStyleOfOwnedAnonBoxes(childrenState);
// Assuming anon boxes don't have ::backdrop associated with them... if that
// ever changes, we'd need to handle that here, like we do in
// ServoRestyleManager::ProcessPostTraversal
// We do need to handle block pseudo-elements here, though. Especially list
// bullets.
if (aChildFrame->IsFrameOfType(nsIFrame::eBlockFrame)) {
auto block = static_cast<nsBlockFrame*>(aChildFrame);
block->UpdatePseudoElementStyles(childrenState);
}
}
nsChangeHint

View File

@ -0,0 +1,6 @@
<!DOCTYPE html>
<ul>
<li style="overflow: hidden; list-style-position: inside; color: green">
Bullet should be green.
</li>
</ul>

View File

@ -0,0 +1,12 @@
<!DOCTYPE html>
<script>
onload = function() {
var height = document.body.offsetHeight; // Flush layout
document.querySelector("li").style.color = "green";
}
</script>
<ul>
<li style="overflow: hidden; list-style-position: inside; color: red">
Bullet should be green.
</li>
</ul>

View File

@ -0,0 +1,4 @@
<!DOCTYPE html>
<button style="display: list-item; color: green">
Bullet should be green.
</button>

View File

@ -0,0 +1,10 @@
<!DOCTYPE html>
<script>
onload = function() {
var height = document.body.offsetHeight; // Flush layout
document.querySelector("button").style.color = "green";
}
</script>
<button style="display: list-item; color: red">
Bullet should be green.
</button>

View File

@ -0,0 +1,4 @@
<!DOCTYPE html>
<select style="display: list-item; list-style-position: inside; color: green">
<option>Bullets should be green</option>
</select>

View File

@ -0,0 +1,10 @@
<!DOCTYPE html>
<script>
onload = function() {
var height = document.body.offsetHeight; // Flush layout
document.querySelector("select").style.color = "green";
}
</script>
<select style="display: list-item; list-style-position: inside; color: red">
<option>Bullets should be green</option>
</select>

View File

@ -0,0 +1,5 @@
<!DOCTYPE html>
<select multiple
style="display: list-item; list-style-position: inside; color: green">
<option>Bullet should be green</option>
</select>

View File

@ -0,0 +1,11 @@
<!DOCTYPE html>
<script>
onload = function() {
var height = document.body.offsetHeight; // Flush layout
document.querySelector("select").style.color = "green";
}
</script>
<select multiple
style="display: list-item; list-style-position: inside; color: red">
<option>Bullet should be green</option>
</select>

View File

@ -0,0 +1,6 @@
<!DOCTYPE html>
<ul>
<li style="column-count: 2; width: 50px; list-style-position: inside; color: green">
Bullet should be green.
</li>
</ul>

View File

@ -0,0 +1,12 @@
<!DOCTYPE html>
<script>
onload = function() {
var height = document.body.offsetHeight; // Flush layout
document.querySelector("li").style.color = "green";
}
</script>
<ul>
<li style="column-count: 2; width: 50px; list-style-position: inside; color: red">
Bullet should be green.
</li>
</ul>

View File

@ -0,0 +1,6 @@
<!DOCTYPE html>
<ul>
<li style="column-count: 2; width: 50px; color: green">
Bullet should be green.
</li>
</ul>

View File

@ -0,0 +1,12 @@
<!DOCTYPE html>
<script>
onload = function() {
var height = document.body.offsetHeight; // Flush layout
document.querySelector("li").style.color = "green";
}
</script>
<ul>
<li style="column-count: 2; width: 50px; color: red">
Bullet should be green.
</li>
</ul>

View File

@ -0,0 +1,6 @@
<!DOCTYPE html>
<ul>
<li style="column-count: 2; width: 50px; color: green">
Bullet should be green.
</li>
</ul>

View File

@ -0,0 +1,12 @@
<!DOCTYPE html>
<script>
onload = function() {
var height = document.body.offsetHeight; // Flush layout
document.querySelector("li").style.color = "green";
}
</script>
<ul>
<li style="column-count: 2; width: 50px; color: red">
Bullet should be green.
</li>
</ul>

View File

@ -0,0 +1,5 @@
<!DOCTYPE html>
<details open
style="display: list-item; padding: 40px; margin: 40px; color: green">
Bullet should be green.
</details>

View File

@ -0,0 +1,11 @@
<!DOCTYPE html>
<script>
onload = function() {
var height = document.body.offsetHeight; // Flush layout
document.querySelector("details").style.color = "green";
}
</script>
<details open
style="display: list-item; padding: 40px; margin: 40px; color: red">
Bullet should be green.
</details>

View File

@ -0,0 +1,5 @@
<!DOCTYPE html>
<details open
style="display: list-item; list-style-position: inside; color: green">
Bullet should be green.
</details>

View File

@ -0,0 +1,11 @@
<!DOCTYPE html>
<script>
onload = function() {
var height = document.body.offsetHeight; // Flush layout
document.querySelector("details").style.color = "green";
}
</script>
<details open
style="display: list-item; list-style-position: inside; color: red">
Bullet should be green.
</details>

View File

@ -0,0 +1,4 @@
<!DOCTYPE html>
<fieldset>
<legend style="display: list-item; color: green">Bullet should be green</legend>
</fieldset>

View File

@ -0,0 +1,10 @@
<!DOCTYPE html>
<script>
onload = function() {
var height = document.body.offsetHeight; // Flush layout
document.querySelector("legend").style.color = "green";
}
</script>
<fieldset>
<legend style="display: list-item; color: red">Bullet should be green</legend>
</fieldset>

View File

@ -0,0 +1,4 @@
<!DOCTYPE html>
<fieldset style="display: list-item; margin: 40px; color: green">
Bullet should be green
</fieldset>

View File

@ -0,0 +1,10 @@
<!DOCTYPE html>
<script>
onload = function() {
var height = document.body.offsetHeight; // Flush layout
document.querySelector("fieldset").style.color = "green";
}
</script>
<fieldset style="display: list-item; margin: 40px; color: red">
Bullet should be green
</fieldset>

View File

@ -0,0 +1,4 @@
<!DOCTYPE html>
<fieldset style="display: list-item; column-count: 2; width: 100px; color: green">
Bullet should be green
</fieldset>

View File

@ -0,0 +1,10 @@
<!DOCTYPE html>
<script>
onload = function() {
var height = document.body.offsetHeight; // Flush layout
document.querySelector("fieldset").style.color = "green";
}
</script>
<fieldset style="display: list-item; column-count: 2; width: 100px; color: red">
Bullet should be green
</fieldset>

View File

@ -2015,4 +2015,16 @@ fails-if(!stylo||styloVsGecko) == 1365162-1.html 1365162-1-ref.html
== 1369954-1.xhtml 1369954-1-ref.xhtml
== 1369985-1.html 1369985-1-ref.html
== 1371130.xhtml 1371130-ref.xhtml
== 1375315-1.html 1375315-1-ref.html
== 1375315-2.html 1375315-2-ref.html
== 1375315-3.html 1375315-3-ref.html
== 1375315-4.html 1375315-4-ref.html
== 1375315-5.html 1375315-5-ref.html
== 1375315-6.html 1375315-6-ref.html
== 1375315-7.html 1375315-7-ref.html
== 1375315-8.html 1375315-8-ref.html
== 1375315-9.html 1375315-9-ref.html
== 1375315-10.html 1375315-10-ref.html
== 1375315-11.html 1375315-11-ref.html
== 1375315-12.html 1375315-12-ref.html
== 1374062.html 1374062-ref.html