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/. */
7 * Inline methods that belong in nsStyleStruct.h, except that they
8 * require more headers.
11 #ifndef nsStyleStructInlines_h_
12 #define nsStyleStructInlines_h_
15 #include "nsStyleStruct.h"
16 #include "nsIContent.h" // for GetParent()
19 nsStyleImage::SetSubImage(uint8_t aIndex
, imgIContainer
* aSubImage
) const
21 const_cast<nsStyleImage
*>(this)->mSubImages
.ReplaceObjectAt(aSubImage
, aIndex
);
25 nsStyleImage::GetSubImage(uint8_t aIndex
) const
27 imgIContainer
* subImage
= nullptr;
28 if (aIndex
< mSubImages
.Count())
29 subImage
= mSubImages
[aIndex
];
34 nsStyleText::HasTextShadow() const
40 nsStyleText::GetTextShadow() const
46 nsStyleText::WhiteSpaceCanWrap(const nsIFrame
* aContextFrame
) const
48 NS_ASSERTION(aContextFrame
->StyleText() == this, "unexpected aContextFrame");
49 return WhiteSpaceCanWrapStyle() && !aContextFrame
->IsSVGText();
53 nsStyleText::WordCanWrap(const nsIFrame
* aContextFrame
) const
55 NS_ASSERTION(aContextFrame
->StyleText() == this, "unexpected aContextFrame");
56 return WordCanWrapStyle() && !aContextFrame
->IsSVGText();
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();
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();
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();
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();
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
;
113 nsStyleDisplay::IsFloating(const nsIFrame
* aContextFrame
) const
115 NS_ASSERTION(aContextFrame
->StyleDisplay() == this, "unexpected aContextFrame");
116 return IsFloatingStyle() && !aContextFrame
->IsSVGText();
120 nsStyleDisplay::HasTransform(const nsIFrame
* aContextFrame
) const
122 NS_ASSERTION(aContextFrame
->StyleDisplay() == this, "unexpected aContextFrame");
123 return HasTransformStyle() && aContextFrame
->IsFrameOfType(nsIFrame::eSupportsCSSTransforms
);
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();
139 nsStyleDisplay::IsRelativelyPositioned(const nsIFrame
* aContextFrame
) const
141 NS_ASSERTION(aContextFrame
->StyleDisplay() == this, "unexpected aContextFrame");
142 return IsRelativelyPositionedStyle() && !aContextFrame
->IsSVGText();
146 nsStyleDisplay::IsAbsolutelyPositioned(const nsIFrame
* aContextFrame
) const
148 NS_ASSERTION(aContextFrame
->StyleDisplay() == this, "unexpected aContextFrame");
149 return IsAbsolutelyPositionedStyle() && !aContextFrame
->IsSVGText();
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
160 nsIFrame
* f
= aFrame
->GetContent()->GetPrimaryFrame();
162 return f
->StyleVisibility()->mPointerEvents
;
165 return mPointerEvents
;
168 #endif /* !defined(nsStyleStructInlines_h_) */