2017-10-27 20:33:53 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
2012-05-21 15:12:37 +04:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
1999-03-25 09:35:59 +03:00
|
|
|
|
2006-03-30 09:56:38 +04:00
|
|
|
/*
|
|
|
|
* a list of the recomputation that needs to be done in response to a
|
|
|
|
* style change
|
|
|
|
*/
|
|
|
|
|
1999-03-25 09:35:59 +03:00
|
|
|
#include "nsStyleChangeList.h"
|
2018-03-06 12:25:52 +03:00
|
|
|
|
Bug 1303605: Remove the undisplayed maps. r=bz,mats
This is mostly code removal, changing GetDisplayContentsStyle(..) checks by an
FFI call to Servo.
The tricky parts are:
* MaybeCreateLazily, which I fixed to avoid setting bits under display: none
stuff. This was a pre-existing problem, which was wallpapered by the
sc->IsInDisplayNoneSubtree() check, which effectively made the whole
assertion useless (see bug 1381017 for the only crashtest that hit this
though).
* ContentRemoved, where we can no longer know for sure whether the element is
actually display: contents if we're removing it as a response to a style
change. See the comment there. That kinda sucks, but that case is relatively
weird, and it's better than adding tons of complexity to handle that.
* GetParentComputedStyle, which also has a comment there. Also, this function
has only one caller now, so we should maybe try to remove it.
The different assertions after DestroyFramesForAndRestyle are changed for a
single assertion in the function itself, and the node bit used as an
optimization to avoid hashtable lookups is taken back.
MozReview-Commit-ID: AZm822QnhF9
2018-03-29 04:49:26 +03:00
|
|
|
#include "mozilla/dom/ElementInlines.h"
|
|
|
|
|
2018-03-06 12:25:52 +03:00
|
|
|
#include "nsCSSFrameConstructor.h"
|
1999-09-21 11:49:55 +04:00
|
|
|
#include "nsIContent.h"
|
2014-11-20 21:24:10 +03:00
|
|
|
#include "nsIFrame.h"
|
1999-03-25 09:35:59 +03:00
|
|
|
|
2002-08-24 18:41:28 +04:00
|
|
|
void nsStyleChangeList::AppendChange(nsIFrame* aFrame, nsIContent* aContent,
|
|
|
|
nsChangeHint aHint) {
|
2016-08-17 03:15:29 +03:00
|
|
|
MOZ_ASSERT(aFrame || (aHint & nsChangeHint_ReconstructFrame),
|
|
|
|
"must have frame");
|
2017-01-14 12:39:33 +03:00
|
|
|
MOZ_ASSERT(aHint, "No hint to process?");
|
|
|
|
MOZ_ASSERT(!(aHint & nsChangeHint_NeutralChange),
|
|
|
|
"Neutral changes do not need extra processing, "
|
|
|
|
"and should be stripped out");
|
2016-08-17 03:15:29 +03:00
|
|
|
MOZ_ASSERT(aContent || !(aHint & nsChangeHint_ReconstructFrame),
|
|
|
|
"must have content");
|
2010-04-30 17:12:06 +04:00
|
|
|
// XXXbz we should make this take Element instead of nsIContent
|
2016-08-17 03:15:29 +03:00
|
|
|
MOZ_ASSERT(
|
|
|
|
!aContent || aContent->IsElement() ||
|
|
|
|
// display:contents elements posts the changes for their children:
|
Bug 1303605: Remove the undisplayed maps. r=bz,mats
This is mostly code removal, changing GetDisplayContentsStyle(..) checks by an
FFI call to Servo.
The tricky parts are:
* MaybeCreateLazily, which I fixed to avoid setting bits under display: none
stuff. This was a pre-existing problem, which was wallpapered by the
sc->IsInDisplayNoneSubtree() check, which effectively made the whole
assertion useless (see bug 1381017 for the only crashtest that hit this
though).
* ContentRemoved, where we can no longer know for sure whether the element is
actually display: contents if we're removing it as a response to a style
change. See the comment there. That kinda sucks, but that case is relatively
weird, and it's better than adding tons of complexity to handle that.
* GetParentComputedStyle, which also has a comment there. Also, this function
has only one caller now, so we should maybe try to remove it.
The different assertions after DestroyFramesForAndRestyle are changed for a
single assertion in the function itself, and the node bit used as an
optimization to avoid hashtable lookups is taken back.
MozReview-Commit-ID: AZm822QnhF9
2018-03-29 04:49:26 +03:00
|
|
|
(aFrame && aContent->GetFlattenedTreeParentElementForStyle() &&
|
|
|
|
Servo_Element_IsDisplayContents(
|
|
|
|
aContent->GetFlattenedTreeParentElementForStyle())) ||
|
2017-02-28 06:06:07 +03:00
|
|
|
(aContent->IsText() && aContent->HasFlag(NODE_NEEDS_FRAME) &&
|
|
|
|
aHint & nsChangeHint_ReconstructFrame),
|
2016-08-17 03:15:29 +03:00
|
|
|
"Shouldn't be trying to restyle non-elements directly, "
|
2017-02-28 06:06:07 +03:00
|
|
|
"except if it's a display:contents child or a text node "
|
|
|
|
"doing lazy frame construction");
|
2016-08-17 03:15:29 +03:00
|
|
|
MOZ_ASSERT(!(aHint & nsChangeHint_AllReflowHints) ||
|
|
|
|
(aHint & nsChangeHint_NeedReflow),
|
|
|
|
"Reflow hint bits set without actually asking for a reflow");
|
|
|
|
|
2018-02-21 11:52:02 +03:00
|
|
|
if (aHint & nsChangeHint_ReconstructFrame) {
|
2017-07-27 19:23:05 +03:00
|
|
|
// If Servo fires reconstruct at a node, it is the only change hint fired at
|
|
|
|
// that node.
|
2018-03-23 19:01:34 +03:00
|
|
|
|
|
|
|
// Note: Because we check whether |aHint| is a reconstruct above (which is
|
|
|
|
// necessary to avoid debug test timeouts on certain crashtests), this check
|
|
|
|
// will not find bugs where we add a non-reconstruct hint for an element
|
|
|
|
// after adding a reconstruct. This is ok though, since
|
|
|
|
// ProcessRestyledFrames will handle that case via mDestroyedFrames.
|
2018-02-21 11:52:02 +03:00
|
|
|
#ifdef DEBUG
|
2018-03-23 19:01:34 +03:00
|
|
|
for (size_t i = 0; i < Length(); ++i) {
|
|
|
|
MOZ_ASSERT(aContent != (*this)[i].mContent ||
|
|
|
|
!((*this)[i].mHint & nsChangeHint_ReconstructFrame),
|
|
|
|
"Should not append a non-ReconstructFrame hint after \
|
|
|
|
appending a ReconstructFrame hint for the same \
|
|
|
|
content.");
|
1999-09-21 11:49:55 +04:00
|
|
|
}
|
2018-03-23 19:01:34 +03:00
|
|
|
#endif
|
1999-09-21 11:49:55 +04:00
|
|
|
}
|
|
|
|
|
2016-08-17 03:15:29 +03:00
|
|
|
if (!IsEmpty() && aFrame && aFrame == LastElement().mFrame) {
|
|
|
|
LastElement().mHint |= aHint;
|
|
|
|
return;
|
1999-03-25 09:35:59 +03:00
|
|
|
}
|
|
|
|
|
2016-08-17 03:15:29 +03:00
|
|
|
AppendElement(nsStyleChangeData{aFrame, aContent, aHint});
|
1999-03-25 09:35:59 +03:00
|
|
|
}
|