Bug 1429962: Don't add frames / reframe text that is going to get reframed anyway. r?bz
MozReview-Commit-ID: GuWjYYP0dBR
new file mode 100644
--- /dev/null
+++ b/layout/base/crashtests/1429962.html
@@ -0,0 +1,12 @@
+<script>
+function go(){
+ let o=document.getElementById('a');
+ let n=document.createElement('li');
+ o.parentNode.replaceChild(n,o);
+}
+document.addEventListener("DOMContentLoaded", go);
+</script>
+<fieldset>
+<canvas id='a'></canvas>
+<footer>
+
--- a/layout/base/crashtests/crashtests.list
+++ b/layout/base/crashtests/crashtests.list
@@ -518,8 +518,9 @@ load 1411138.html
load 1419762.html
load 1420533.html
load 1425959.html
load 1425893.html
load 1428353.html
pref(dom.webcomponents.shadowdom.enabled,true) load 1429088.html
load 1429961.html
load 1435015.html
+load 1429962.html
--- a/layout/base/nsCSSFrameConstructor.cpp
+++ b/layout/base/nsCSSFrameConstructor.cpp
@@ -7168,41 +7168,43 @@ MaybeGetListBoxBodyFrame(nsIContent* aCo
void
nsCSSFrameConstructor::AddTextItemIfNeeded(nsFrameConstructorState& aState,
const InsertionPoint& aInsertion,
nsIContent* aPossibleTextContent,
FrameConstructionItemList& aItems)
{
NS_PRECONDITION(aPossibleTextContent, "Must have node");
if (!aPossibleTextContent->IsNodeOfType(nsINode::eTEXT) ||
- !aPossibleTextContent->HasFlag(NS_CREATE_FRAME_IF_NON_WHITESPACE)) {
- // Not text, or not suppressed due to being all-whitespace (if it
- // were being suppressed, it would have the
- // NS_CREATE_FRAME_IF_NON_WHITESPACE flag)
+ !aPossibleTextContent->HasFlag(NS_CREATE_FRAME_IF_NON_WHITESPACE) ||
+ aPossibleTextContent->HasFlag(NODE_NEEDS_FRAME)) {
+ // Not text, or not suppressed due to being all-whitespace (if it were being
+ // suppressed, it would have the NS_CREATE_FRAME_IF_NON_WHITESPACE flag), or
+ // going to be reframed anyway.
return;
}
- NS_ASSERTION(!aPossibleTextContent->GetPrimaryFrame(),
- "Text node has a frame and NS_CREATE_FRAME_IF_NON_WHITESPACE");
+ MOZ_ASSERT(!aPossibleTextContent->GetPrimaryFrame(),
+ "Text node has a frame and NS_CREATE_FRAME_IF_NON_WHITESPACE");
AddFrameConstructionItems(aState, aPossibleTextContent, false,
aInsertion, aItems);
}
void
nsCSSFrameConstructor::ReframeTextIfNeeded(nsIContent* aParentContent,
nsIContent* aContent)
{
if (!aContent->IsNodeOfType(nsINode::eTEXT) ||
- !aContent->HasFlag(NS_CREATE_FRAME_IF_NON_WHITESPACE)) {
- // Not text, or not suppressed due to being all-whitespace (if it
- // were being suppressed, it would have the
- // NS_CREATE_FRAME_IF_NON_WHITESPACE flag)
+ !aContent->HasFlag(NS_CREATE_FRAME_IF_NON_WHITESPACE) ||
+ aContent->HasFlag(NODE_NEEDS_FRAME)) {
+ // Not text, or not suppressed due to being all-whitespace (if it were being
+ // suppressed, it would have the NS_CREATE_FRAME_IF_NON_WHITESPACE flag), or
+ // going to be reframed anyway.
return;
}
- NS_ASSERTION(!aContent->GetPrimaryFrame(),
- "Text node has a frame and NS_CREATE_FRAME_IF_NON_WHITESPACE");
+ MOZ_ASSERT(!aContent->GetPrimaryFrame(),
+ "Text node has a frame and NS_CREATE_FRAME_IF_NON_WHITESPACE");
ContentInserted(aParentContent, aContent, nullptr, InsertionKind::Async);
}
#ifdef DEBUG
void
nsCSSFrameConstructor::CheckBitsForLazyFrameConstruction(nsIContent* aParent)
{
// If we hit a node with no primary frame, or the NODE_NEEDS_FRAME bit set