Bumping manifests a=b2g-bump
[gecko.git] / layout / style / nsStyleStructInlines.h
blobc6410621dbad412894d80913cf83854b6cc918a9
1 /* vim: set shiftwidth=2 tabstop=8 autoindent cindent expandtab: */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 /*
7 * Inline methods that belong in nsStyleStruct.h, except that they
8 * require more headers.
9 */
11 #ifndef nsStyleStructInlines_h_
12 #define nsStyleStructInlines_h_
14 #include "nsIFrame.h"
15 #include "nsStyleStruct.h"
16 #include "nsIContent.h" // for GetParent()
18 inline void
19 nsStyleImage::SetSubImage(uint8_t aIndex, imgIContainer* aSubImage) const
21 const_cast<nsStyleImage*>(this)->mSubImages.ReplaceObjectAt(aSubImage, aIndex);
24 inline imgIContainer*
25 nsStyleImage::GetSubImage(uint8_t aIndex) const
27 imgIContainer* subImage = nullptr;
28 if (aIndex < mSubImages.Count())
29 subImage = mSubImages[aIndex];
30 return subImage;
33 bool
34 nsStyleText::HasTextShadow() const
36 return mTextShadow;
39 nsCSSShadowArray*
40 nsStyleText::GetTextShadow() const
42 return mTextShadow;
45 bool
46 nsStyleText::WhiteSpaceCanWrap(const nsIFrame* aContextFrame) const
48 NS_ASSERTION(aContextFrame->StyleText() == this, "unexpected aContextFrame");
49 return WhiteSpaceCanWrapStyle() && !aContextFrame->IsSVGText();
52 bool
53 nsStyleText::WordCanWrap(const nsIFrame* aContextFrame) const
55 NS_ASSERTION(aContextFrame->StyleText() == this, "unexpected aContextFrame");
56 return WordCanWrapStyle() && !aContextFrame->IsSVGText();
59 bool
60 nsStyleDisplay::IsBlockInside(const nsIFrame* aContextFrame) const
62 NS_ASSERTION(aContextFrame->StyleDisplay() == this, "unexpected aContextFrame");
63 if (aContextFrame->IsSVGText()) {
64 return aContextFrame->GetType() == nsGkAtoms::blockFrame;
66 return IsBlockInsideStyle();
69 bool
70 nsStyleDisplay::IsBlockOutside(const nsIFrame* aContextFrame) const
72 NS_ASSERTION(aContextFrame->StyleDisplay() == this, "unexpected aContextFrame");
73 if (aContextFrame->IsSVGText()) {
74 return aContextFrame->GetType() == nsGkAtoms::blockFrame;
76 return IsBlockOutsideStyle();
79 bool
80 nsStyleDisplay::IsInlineOutside(const nsIFrame* aContextFrame) const
82 NS_ASSERTION(aContextFrame->StyleDisplay() == this, "unexpected aContextFrame");
83 if (aContextFrame->IsSVGText()) {
84 return aContextFrame->GetType() != nsGkAtoms::blockFrame;
86 return IsInlineOutsideStyle();
89 bool
90 nsStyleDisplay::IsOriginalDisplayInlineOutside(const nsIFrame* aContextFrame) const
92 NS_ASSERTION(aContextFrame->StyleDisplay() == this, "unexpected aContextFrame");
93 if (aContextFrame->IsSVGText()) {
94 return aContextFrame->GetType() != nsGkAtoms::blockFrame;
96 return IsOriginalDisplayInlineOutsideStyle();
99 uint8_t
100 nsStyleDisplay::GetDisplay(const nsIFrame* aContextFrame) const
102 NS_ASSERTION(aContextFrame->StyleDisplay() == this, "unexpected aContextFrame");
103 if (aContextFrame->IsSVGText() &&
104 mDisplay != NS_STYLE_DISPLAY_NONE) {
105 return aContextFrame->GetType() == nsGkAtoms::blockFrame ?
106 NS_STYLE_DISPLAY_BLOCK :
107 NS_STYLE_DISPLAY_INLINE;
109 return mDisplay;
112 bool
113 nsStyleDisplay::IsFloating(const nsIFrame* aContextFrame) const
115 NS_ASSERTION(aContextFrame->StyleDisplay() == this, "unexpected aContextFrame");
116 return IsFloatingStyle() && !aContextFrame->IsSVGText();
119 bool
120 nsStyleDisplay::HasTransform(const nsIFrame* aContextFrame) const
122 NS_ASSERTION(aContextFrame->StyleDisplay() == this, "unexpected aContextFrame");
123 return HasTransformStyle() && aContextFrame->IsFrameOfType(nsIFrame::eSupportsCSSTransforms);
126 bool
127 nsStyleDisplay::IsPositioned(const nsIFrame* aContextFrame) const
129 NS_ASSERTION(aContextFrame->StyleDisplay() == this,
130 "unexpected aContextFrame");
131 return (IsAbsolutelyPositionedStyle() ||
132 IsRelativelyPositionedStyle() ||
133 HasTransform(aContextFrame) ||
134 HasPerspectiveStyle()) &&
135 !aContextFrame->IsSVGText();
138 bool
139 nsStyleDisplay::IsRelativelyPositioned(const nsIFrame* aContextFrame) const
141 NS_ASSERTION(aContextFrame->StyleDisplay() == this, "unexpected aContextFrame");
142 return IsRelativelyPositionedStyle() && !aContextFrame->IsSVGText();
145 bool
146 nsStyleDisplay::IsAbsolutelyPositioned(const nsIFrame* aContextFrame) const
148 NS_ASSERTION(aContextFrame->StyleDisplay() == this, "unexpected aContextFrame");
149 return IsAbsolutelyPositionedStyle() && !aContextFrame->IsSVGText();
152 uint8_t
153 nsStyleVisibility::GetEffectivePointerEvents(nsIFrame* aFrame) const
155 if (aFrame->GetContent() && !aFrame->GetContent()->GetParent()) {
156 // The root element has a cluster of frames associated with it
157 // (root scroll frame, canvas frame, the actual primary frame). Make
158 // those take their pointer-events value from the root element's primary
159 // frame.
160 nsIFrame* f = aFrame->GetContent()->GetPrimaryFrame();
161 if (f) {
162 return f->StyleVisibility()->mPointerEvents;
165 return mPointerEvents;
168 #endif /* !defined(nsStyleStructInlines_h_) */