michael@0: /* vim: set shiftwidth=2 tabstop=8 autoindent cindent expandtab: */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: /* michael@0: * Inline methods that belong in nsStyleStruct.h, except that they michael@0: * require more headers. michael@0: */ michael@0: michael@0: #ifndef nsStyleStructInlines_h_ michael@0: #define nsStyleStructInlines_h_ michael@0: michael@0: #include "nsIFrame.h" michael@0: #include "nsStyleStruct.h" michael@0: #include "imgIRequest.h" michael@0: #include "imgIContainer.h" michael@0: #include "nsIContent.h" michael@0: michael@0: inline void michael@0: nsStyleImage::SetSubImage(uint8_t aIndex, imgIContainer* aSubImage) const michael@0: { michael@0: const_cast(this)->mSubImages.ReplaceObjectAt(aSubImage, aIndex); michael@0: } michael@0: michael@0: inline imgIContainer* michael@0: nsStyleImage::GetSubImage(uint8_t aIndex) const michael@0: { michael@0: imgIContainer* subImage = nullptr; michael@0: if (aIndex < mSubImages.Count()) michael@0: subImage = mSubImages[aIndex]; michael@0: return subImage; michael@0: } michael@0: michael@0: bool michael@0: nsStyleText::HasTextShadow() const michael@0: { michael@0: return mTextShadow; michael@0: } michael@0: michael@0: nsCSSShadowArray* michael@0: nsStyleText::GetTextShadow() const michael@0: { michael@0: return mTextShadow; michael@0: } michael@0: michael@0: bool michael@0: nsStyleText::WhiteSpaceCanWrap(const nsIFrame* aContextFrame) const michael@0: { michael@0: NS_ASSERTION(aContextFrame->StyleText() == this, "unexpected aContextFrame"); michael@0: return WhiteSpaceCanWrapStyle() && !aContextFrame->IsSVGText(); michael@0: } michael@0: michael@0: bool michael@0: nsStyleText::WordCanWrap(const nsIFrame* aContextFrame) const michael@0: { michael@0: NS_ASSERTION(aContextFrame->StyleText() == this, "unexpected aContextFrame"); michael@0: return WordCanWrapStyle() && !aContextFrame->IsSVGText(); michael@0: } michael@0: michael@0: bool michael@0: nsStyleDisplay::IsBlockInside(const nsIFrame* aContextFrame) const michael@0: { michael@0: NS_ASSERTION(aContextFrame->StyleDisplay() == this, "unexpected aContextFrame"); michael@0: if (aContextFrame->IsSVGText()) { michael@0: return aContextFrame->GetType() == nsGkAtoms::blockFrame; michael@0: } michael@0: return IsBlockInsideStyle(); michael@0: } michael@0: michael@0: bool michael@0: nsStyleDisplay::IsBlockOutside(const nsIFrame* aContextFrame) const michael@0: { michael@0: NS_ASSERTION(aContextFrame->StyleDisplay() == this, "unexpected aContextFrame"); michael@0: if (aContextFrame->IsSVGText()) { michael@0: return aContextFrame->GetType() == nsGkAtoms::blockFrame; michael@0: } michael@0: return IsBlockOutsideStyle(); michael@0: } michael@0: michael@0: bool michael@0: nsStyleDisplay::IsInlineOutside(const nsIFrame* aContextFrame) const michael@0: { michael@0: NS_ASSERTION(aContextFrame->StyleDisplay() == this, "unexpected aContextFrame"); michael@0: if (aContextFrame->IsSVGText()) { michael@0: return aContextFrame->GetType() != nsGkAtoms::blockFrame; michael@0: } michael@0: return IsInlineOutsideStyle(); michael@0: } michael@0: michael@0: bool michael@0: nsStyleDisplay::IsOriginalDisplayInlineOutside(const nsIFrame* aContextFrame) const michael@0: { michael@0: NS_ASSERTION(aContextFrame->StyleDisplay() == this, "unexpected aContextFrame"); michael@0: if (aContextFrame->IsSVGText()) { michael@0: return aContextFrame->GetType() != nsGkAtoms::blockFrame; michael@0: } michael@0: return IsOriginalDisplayInlineOutsideStyle(); michael@0: } michael@0: michael@0: uint8_t michael@0: nsStyleDisplay::GetDisplay(const nsIFrame* aContextFrame) const michael@0: { michael@0: NS_ASSERTION(aContextFrame->StyleDisplay() == this, "unexpected aContextFrame"); michael@0: if (aContextFrame->IsSVGText() && michael@0: mDisplay != NS_STYLE_DISPLAY_NONE) { michael@0: return aContextFrame->GetType() == nsGkAtoms::blockFrame ? michael@0: NS_STYLE_DISPLAY_BLOCK : michael@0: NS_STYLE_DISPLAY_INLINE; michael@0: } michael@0: return mDisplay; michael@0: } michael@0: michael@0: bool michael@0: nsStyleDisplay::IsFloating(const nsIFrame* aContextFrame) const michael@0: { michael@0: NS_ASSERTION(aContextFrame->StyleDisplay() == this, "unexpected aContextFrame"); michael@0: return IsFloatingStyle() && !aContextFrame->IsSVGText(); michael@0: } michael@0: michael@0: bool michael@0: nsStyleDisplay::HasTransform(const nsIFrame* aContextFrame) const michael@0: { michael@0: NS_ASSERTION(aContextFrame->StyleDisplay() == this, "unexpected aContextFrame"); michael@0: return HasTransformStyle() && aContextFrame->IsFrameOfType(nsIFrame::eSupportsCSSTransforms); michael@0: } michael@0: michael@0: bool michael@0: nsStyleDisplay::IsPositioned(const nsIFrame* aContextFrame) const michael@0: { michael@0: NS_ASSERTION(aContextFrame->StyleDisplay() == this, michael@0: "unexpected aContextFrame"); michael@0: return (IsAbsolutelyPositionedStyle() || michael@0: IsRelativelyPositionedStyle() || michael@0: HasTransform(aContextFrame) || michael@0: HasPerspectiveStyle()) && michael@0: !aContextFrame->IsSVGText(); michael@0: } michael@0: michael@0: bool michael@0: nsStyleDisplay::IsRelativelyPositioned(const nsIFrame* aContextFrame) const michael@0: { michael@0: NS_ASSERTION(aContextFrame->StyleDisplay() == this, "unexpected aContextFrame"); michael@0: return IsRelativelyPositionedStyle() && !aContextFrame->IsSVGText(); michael@0: } michael@0: michael@0: bool michael@0: nsStyleDisplay::IsAbsolutelyPositioned(const nsIFrame* aContextFrame) const michael@0: { michael@0: NS_ASSERTION(aContextFrame->StyleDisplay() == this, "unexpected aContextFrame"); michael@0: return IsAbsolutelyPositionedStyle() && !aContextFrame->IsSVGText(); michael@0: } michael@0: michael@0: uint8_t michael@0: nsStyleVisibility::GetEffectivePointerEvents(nsIFrame* aFrame) const michael@0: { michael@0: if (aFrame->GetContent() && !aFrame->GetContent()->GetParent()) { michael@0: // The root element has a cluster of frames associated with it michael@0: // (root scroll frame, canvas frame, the actual primary frame). Make michael@0: // those take their pointer-events value from the root element's primary michael@0: // frame. michael@0: nsIFrame* f = aFrame->GetContent()->GetPrimaryFrame(); michael@0: if (f) { michael@0: return f->StyleVisibility()->mPointerEvents; michael@0: } michael@0: } michael@0: return mPointerEvents; michael@0: } michael@0: michael@0: #endif /* !defined(nsStyleStructInlines_h_) */