Bug 1605473 - Implement 'content: none' for ::marker. r=emilio

Differential Revision: https://phabricator.services.mozilla.com/D111707
This commit is contained in:
Mats Palmgren 2021-06-23 02:52:42 +00:00
parent 815b68c3c8
commit c019c6f680
8 changed files with 31 additions and 35 deletions

View File

@ -1692,7 +1692,9 @@ void nsCSSFrameConstructor::CreateGeneratedContentItem(
ServoStyleSet* styleSet = mPresShell->StyleSet();
// Probe for the existence of the pseudo-element
// Probe for the existence of the pseudo-element.
// |ProbePseudoElementStyle| checks the relevant properties for the pseudo.
// It only returns a non-null value if the pseudo should exist.
RefPtr<ComputedStyle> pseudoStyle = styleSet->ProbePseudoElementStyle(
aOriginatingElement, aPseudoElement, &aStyle);
if (!pseudoStyle) {
@ -1720,10 +1722,6 @@ void nsCSSFrameConstructor::CreateGeneratedContentItem(
MOZ_ASSERT_UNREACHABLE("unexpected aPseudoElement");
}
// |ProbePseudoElementStyle| checked the 'display' property and the
// |ContentCount()| of the 'content' property for us, and for ::marker
// also that we have either a 'list-style-type' or 'list-style-image'
// non-initial value in case we have no 'content'.
RefPtr<NodeInfo> nodeInfo = mDocument->NodeInfoManager()->GetNodeInfo(
elemName, nullptr, kNameSpaceID_None, nsINode::ELEMENT_NODE);
RefPtr<Element> container;

View File

@ -7419,8 +7419,9 @@ bool nsBlockFrame::MarkerIsEmpty() const {
"should only care when we have an outside ::marker");
nsIFrame* marker = GetMarker();
const nsStyleList* list = marker->StyleList();
return list->mCounterStyle.IsNone() && list->mListStyleImage.IsNone() &&
marker->StyleContent()->ContentCount() == 0;
return marker->StyleContent()->mContent.IsNone() ||
(list->mCounterStyle.IsNone() && list->mListStyleImage.IsNone() &&
marker->StyleContent()->ContentCount() == 0);
}
void nsBlockFrame::ReflowOutsideMarker(nsIFrame* aMarkerFrame,

View File

@ -677,27 +677,35 @@ bool ServoStyleSet::GeneratedContentPseudoExists(
if (!aParentStyle.StyleDisplay()->IsListItem()) {
return false;
}
const auto& content = aPseudoStyle.StyleContent()->mContent;
// ::marker does not exist if 'content' is 'none' (this trumps
// any 'list-style-type' or 'list-style-image' values).
if (content.IsNone()) {
return false;
}
// ::marker only exist if we have 'content' or at least one of
// 'list-style-type' or 'list-style-image'.
if (aPseudoStyle.StyleList()->mCounterStyle.IsNone() &&
aPseudoStyle.StyleList()->mListStyleImage.IsNone() &&
aPseudoStyle.StyleContent()->ContentCount() == 0) {
content.IsNormal()) {
return false;
}
// display:none is equivalent to not having the pseudo-element at all.
// display:none is equivalent to not having a pseudo at all.
if (aPseudoStyle.StyleDisplay()->mDisplay == StyleDisplay::None) {
return false;
}
}
// For :before and :after pseudo-elements, having display: none or no
// 'content' property is equivalent to not having the pseudo-element
// at all.
// For ::before and ::after pseudo-elements, no 'content' items is
// equivalent to not having the pseudo-element at all.
if (type == PseudoStyleType::before || type == PseudoStyleType::after) {
if (aPseudoStyle.StyleDisplay()->mDisplay == StyleDisplay::None) {
if (!aPseudoStyle.StyleContent()->mContent.IsItems()) {
return false;
}
if (!aPseudoStyle.StyleContent()->ContentCount()) {
MOZ_ASSERT(aPseudoStyle.StyleContent()->ContentCount() > 0,
"IsItems() implies we have at least one item");
// display:none is equivalent to not having a pseudo at all.
if (aPseudoStyle.StyleDisplay()->mDisplay == StyleDisplay::None) {
return false;
}
}

View File

@ -831,10 +831,11 @@ impl<'a, 'b: 'a> StyleAdjuster<'a, 'b> {
fn adjust_for_marker_pseudo(&mut self) {
use crate::values::computed::font::{FontFamily, FontSynthesis};
use crate::values::computed::text::{LetterSpacing, WordSpacing};
use crate::values::computed::counters::{Content};
let is_legacy_marker = self.style.pseudo.map_or(false, |p| p.is_marker()) &&
self.style.get_counters().ineffective_content_property() &&
self.style.get_list().clone_list_style_type().is_bullet();
self.style.get_list().clone_list_style_type().is_bullet() &&
self.style.get_counters().clone_content() == Content::Normal;
if !is_legacy_marker {
return;
}

View File

@ -27,15 +27,16 @@ impl ToResolvedValue for computed::Content {
.style
.pseudo()
.map_or(false, |p| p.is_before_or_after());
let is_marker = context
.style
.pseudo()
.map_or(false, |p| p.is_marker());
match self {
Self::Normal if is_before_or_after => Self::None,
// For now, make `content: none` compute to `normal` on other
// elements, as we don't respect it.
//
// FIXME(emilio, bug 1605473): for marker this should be preserved
// and respected, probably.
Self::None if !is_before_or_after => Self::Normal,
// For now, make `content: none` compute to `normal` for elements
// other than ::before, ::after and ::marker, as we don't respect it.
Self::None if !is_before_or_after && !is_marker => Self::Normal,
other => other,
}
}

View File

@ -1,7 +0,0 @@
[marker-computed-content.html]
[Computed 'content' for non-list-item ::marker, variant none]
expected: FAIL
[Computed 'content' for list-item ::marker, variant none]
expected: FAIL

View File

@ -1,4 +0,0 @@
[marker-computed-size.html]
[::marker with no box due to 'content']
expected: FAIL

View File

@ -1,2 +0,0 @@
[marker-content-019.html]
expected: FAIL