Bug 1840065 [wpt PR 40721] - Switch from using AV1 to VP9 for the test trying to...
[gecko.git] / layout / base / nsStyleChangeList.cpp
blobd41ee991954c05a46c6bbc30abc8ad2835b9d5ce
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 /*
8 * a list of the recomputation that needs to be done in response to a
9 * style change
12 #include "nsStyleChangeList.h"
14 #include "mozilla/dom/ElementInlines.h"
16 #include "nsCSSFrameConstructor.h"
17 #include "nsIContent.h"
18 #include "nsIFrame.h"
20 void nsStyleChangeList::AppendChange(nsIFrame* aFrame, nsIContent* aContent,
21 nsChangeHint aHint) {
22 MOZ_ASSERT(aFrame || (aHint & nsChangeHint_ReconstructFrame),
23 "must have frame");
24 MOZ_ASSERT(aHint, "No hint to process?");
25 MOZ_ASSERT(!(aHint & nsChangeHint_NeutralChange),
26 "Neutral changes do not need extra processing, "
27 "and should be stripped out");
28 MOZ_ASSERT(aContent || !(aHint & nsChangeHint_ReconstructFrame),
29 "must have content");
30 // XXXbz we should make this take Element instead of nsIContent
31 MOZ_ASSERT(
32 !aContent || aContent->IsElement() ||
33 // display:contents elements posts the changes for their children:
34 (aFrame && aContent->GetFlattenedTreeParentElementForStyle() &&
35 Servo_Element_IsDisplayContents(
36 aContent->GetFlattenedTreeParentElementForStyle())) ||
37 (aContent->IsText() && aContent->HasFlag(NODE_NEEDS_FRAME) &&
38 aHint & nsChangeHint_ReconstructFrame),
39 "Shouldn't be trying to restyle non-elements directly, "
40 "except if it's a display:contents child or a text node "
41 "doing lazy frame construction");
42 MOZ_ASSERT(!(aHint & nsChangeHint_AllReflowHints) ||
43 (aHint & nsChangeHint_NeedReflow),
44 "Reflow hint bits set without actually asking for a reflow");
46 if (aHint & nsChangeHint_ReconstructFrame) {
47 // If Servo fires reconstruct at a node, it is the only change hint fired at
48 // that node.
50 // Note: Because we check whether |aHint| is a reconstruct above (which is
51 // necessary to avoid debug test timeouts on certain crashtests), this check
52 // will not find bugs where we add a non-reconstruct hint for an element
53 // after adding a reconstruct. This is ok though, since
54 // ProcessRestyledFrames will handle that case via mDestroyedFrames.
55 #ifdef DEBUG
56 for (size_t i = 0; i < Length(); ++i) {
57 MOZ_ASSERT(aContent != (*this)[i].mContent ||
58 !((*this)[i].mHint & nsChangeHint_ReconstructFrame),
59 "Should not append a non-ReconstructFrame hint after \
60 appending a ReconstructFrame hint for the same \
61 content.");
63 #endif
66 if (!IsEmpty() && aFrame && aFrame == LastElement().mFrame) {
67 LastElement().mHint |= aHint;
68 return;
71 AppendElement(nsStyleChangeData{aFrame, aContent, aHint});