/src/mozilla-central/layout/base/nsStyleChangeList.cpp
Line | Count | Source (jump to first uncovered line) |
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/. */ |
6 | | |
7 | | /* |
8 | | * a list of the recomputation that needs to be done in response to a |
9 | | * style change |
10 | | */ |
11 | | |
12 | | #include "nsStyleChangeList.h" |
13 | | |
14 | | #include "mozilla/dom/ElementInlines.h" |
15 | | |
16 | | #include "nsCSSFrameConstructor.h" |
17 | | #include "nsIContent.h" |
18 | | #include "nsIFrame.h" |
19 | | |
20 | | void |
21 | | nsStyleChangeList::AppendChange(nsIFrame* aFrame, nsIContent* aContent, nsChangeHint aHint) |
22 | 0 | { |
23 | 0 | MOZ_ASSERT(aFrame || (aHint & nsChangeHint_ReconstructFrame), |
24 | 0 | "must have frame"); |
25 | 0 | MOZ_ASSERT(aHint, "No hint to process?"); |
26 | 0 | MOZ_ASSERT(!(aHint & nsChangeHint_NeutralChange), |
27 | 0 | "Neutral changes do not need extra processing, " |
28 | 0 | "and should be stripped out"); |
29 | 0 | MOZ_ASSERT(aContent || !(aHint & nsChangeHint_ReconstructFrame), |
30 | 0 | "must have content"); |
31 | 0 | // XXXbz we should make this take Element instead of nsIContent |
32 | 0 | MOZ_ASSERT(!aContent || aContent->IsElement() || |
33 | 0 | // display:contents elements posts the changes for their children: |
34 | 0 | (aFrame && aContent->GetFlattenedTreeParentElementForStyle() && |
35 | 0 | Servo_Element_IsDisplayContents( |
36 | 0 | aContent->GetFlattenedTreeParentElementForStyle())) || |
37 | 0 | (aContent->IsText() && |
38 | 0 | aContent->HasFlag(NODE_NEEDS_FRAME) && |
39 | 0 | aHint & nsChangeHint_ReconstructFrame), |
40 | 0 | "Shouldn't be trying to restyle non-elements directly, " |
41 | 0 | "except if it's a display:contents child or a text node " |
42 | 0 | "doing lazy frame construction"); |
43 | 0 | MOZ_ASSERT(!(aHint & nsChangeHint_AllReflowHints) || |
44 | 0 | (aHint & nsChangeHint_NeedReflow), |
45 | 0 | "Reflow hint bits set without actually asking for a reflow"); |
46 | 0 |
|
47 | 0 | if (aHint & nsChangeHint_ReconstructFrame) { |
48 | 0 | // If Servo fires reconstruct at a node, it is the only change hint fired at |
49 | 0 | // that node. |
50 | 0 |
|
51 | 0 | // Note: Because we check whether |aHint| is a reconstruct above (which is |
52 | 0 | // necessary to avoid debug test timeouts on certain crashtests), this check |
53 | 0 | // will not find bugs where we add a non-reconstruct hint for an element after |
54 | 0 | // adding a reconstruct. This is ok though, since ProcessRestyledFrames will |
55 | 0 | // handle that case via mDestroyedFrames. |
56 | | #ifdef DEBUG |
57 | | for (size_t i = 0; i < Length(); ++i) { |
58 | | MOZ_ASSERT(aContent != (*this)[i].mContent || |
59 | | !((*this)[i].mHint & nsChangeHint_ReconstructFrame), |
60 | | "Should not append a non-ReconstructFrame hint after \ |
61 | | appending a ReconstructFrame hint for the same \ |
62 | | content."); |
63 | | } |
64 | | #endif |
65 | | } |
66 | 0 |
|
67 | 0 | if (!IsEmpty() && aFrame && aFrame == LastElement().mFrame) { |
68 | 0 | LastElement().mHint |= aHint; |
69 | 0 | return; |
70 | 0 | } |
71 | 0 | |
72 | 0 | AppendElement(nsStyleChangeData { aFrame, aContent, aHint }); |
73 | 0 | } |