Bug 1567773 - [css-lists] Look for an inside ::marker frame too when searching for a suitable sibling. r=emilio

Differential Revision: https://phabricator.services.mozilla.com/D38902

--HG--
extra : rebase_source : a09bf54989c7cea4b263c845ffe6d10770b050dc
This commit is contained in:
Mats Palmgren 2019-07-22 15:43:16 +02:00
Родитель a530f658c5
Коммит f75547f074
3 изменённых файлов: 135 добавлений и 8 удалений

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

@ -6140,16 +6140,32 @@ nsIFrame* nsCSSFrameConstructor::FindSiblingInternal(
: aIter.GetPreviousChild();
};
auto getNearPseudo = [](const nsIContent* aContent) -> nsIFrame* {
return aDirection == SiblingDirection::Forward
? nsLayoutUtils::GetBeforeFrame(aContent)
: nsLayoutUtils::GetAfterFrame(aContent);
auto getInsideMarkerFrame = [](const nsIContent* aContent) -> nsIFrame* {
auto* marker = nsLayoutUtils::GetMarkerFrame(aContent);
const bool isInsideMarker = marker &&
marker->GetInFlowParent()->StyleList()->mListStylePosition ==
NS_STYLE_LIST_STYLE_POSITION_INSIDE;
return isInsideMarker ? marker : nullptr;
};
auto getFarPseudo = [](const nsIContent* aContent) -> nsIFrame* {
return aDirection == SiblingDirection::Forward
? nsLayoutUtils::GetAfterFrame(aContent)
: nsLayoutUtils::GetBeforeFrame(aContent);
auto getNearPseudo = [&](const nsIContent* aContent) -> nsIFrame* {
if (aDirection == SiblingDirection::Forward) {
if (auto* marker = getInsideMarkerFrame(aContent)) {
return marker;
}
return nsLayoutUtils::GetBeforeFrame(aContent);
}
return nsLayoutUtils::GetAfterFrame(aContent);
};
auto getFarPseudo = [&](const nsIContent* aContent) -> nsIFrame* {
if (aDirection == SiblingDirection::Forward) {
return nsLayoutUtils::GetAfterFrame(aContent);
}
if (auto* before = nsLayoutUtils::GetBeforeFrame(aContent)) {
return before;
}
return getInsideMarkerFrame(aContent);
};
while (nsIContent* sibling = nextDomSibling(aIter)) {

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

@ -0,0 +1,51 @@
<!DOCTYPE HTML>
<!--
Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/
-->
<html><head>
<meta charset="utf-8">
<title>Reference: Insert text node as first child in LI</title>
<link rel="author" title="Mats Palmgren" href="mailto:mats@mozilla.org">
<style>
ul.inside { list-style-position: inside; }
.before::before { content: "before"; }
.after::after { content: "after"; }
</style>
</head>
<body>
<ul class="inside">
<li>AB</li>
</ul>
<ul class="inside">
<li class="before">AB</li>
</ul>
<ul class="inside">
<li class="after">AB</li>
</ul>
<ul class="inside">
<li class="before after">AB</li>
</ul>
<ul>
<li>AB</li>
</ul>
<ul>
<li class="before">AB</li>
</ul>
<ul>
<li class="after">AB</li>
</ul>
<ul>
<li class="before after">AB</li>
</ul>
</body>
</html>

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

@ -0,0 +1,60 @@
<!DOCTYPE HTML>
<!--
Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/
-->
<html class="reftest-wait"><head>
<meta charset="utf-8">
<title>Test: Insert text node as first child in LI</title>
<link rel="author" title="Mats Palmgren" href="mailto:mats@mozilla.org">
<link rel="help" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1567773">
<link rel="match" href="li-insert-child-ref.html">
<style>
ul.inside { list-style-position: inside; }
.before::before { content: "before"; }
.after::after { content: "after"; }
</style>
</head>
<body>
<ul class="inside">
<li>B</li>
</ul>
<ul class="inside">
<li class="before">B</li>
</ul>
<ul class="inside">
<li class="after">B</li>
</ul>
<ul class="inside">
<li class="before after">B</li>
</ul>
<ul>
<li>B</li>
</ul>
<ul>
<li class="before">B</li>
</ul>
<ul>
<li class="after">B</li>
</ul>
<ul>
<li class="before after">B</li>
</ul>
<script>
document.body.offsetHeight;
let items = Array.prototype.slice.call(document.querySelectorAll('li'));
items.map(li => li.insertBefore(document.createTextNode('A'), li.firstChild));
document.documentElement.className = '';
</script>
</body>
</html>