1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/layout/style/nsStyleStructInlines.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,170 @@ 1.4 +/* vim: set shiftwidth=2 tabstop=8 autoindent cindent expandtab: */ 1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.8 + 1.9 +/* 1.10 + * Inline methods that belong in nsStyleStruct.h, except that they 1.11 + * require more headers. 1.12 + */ 1.13 + 1.14 +#ifndef nsStyleStructInlines_h_ 1.15 +#define nsStyleStructInlines_h_ 1.16 + 1.17 +#include "nsIFrame.h" 1.18 +#include "nsStyleStruct.h" 1.19 +#include "imgIRequest.h" 1.20 +#include "imgIContainer.h" 1.21 +#include "nsIContent.h" 1.22 + 1.23 +inline void 1.24 +nsStyleImage::SetSubImage(uint8_t aIndex, imgIContainer* aSubImage) const 1.25 +{ 1.26 + const_cast<nsStyleImage*>(this)->mSubImages.ReplaceObjectAt(aSubImage, aIndex); 1.27 +} 1.28 + 1.29 +inline imgIContainer* 1.30 +nsStyleImage::GetSubImage(uint8_t aIndex) const 1.31 +{ 1.32 + imgIContainer* subImage = nullptr; 1.33 + if (aIndex < mSubImages.Count()) 1.34 + subImage = mSubImages[aIndex]; 1.35 + return subImage; 1.36 +} 1.37 + 1.38 +bool 1.39 +nsStyleText::HasTextShadow() const 1.40 +{ 1.41 + return mTextShadow; 1.42 +} 1.43 + 1.44 +nsCSSShadowArray* 1.45 +nsStyleText::GetTextShadow() const 1.46 +{ 1.47 + return mTextShadow; 1.48 +} 1.49 + 1.50 +bool 1.51 +nsStyleText::WhiteSpaceCanWrap(const nsIFrame* aContextFrame) const 1.52 +{ 1.53 + NS_ASSERTION(aContextFrame->StyleText() == this, "unexpected aContextFrame"); 1.54 + return WhiteSpaceCanWrapStyle() && !aContextFrame->IsSVGText(); 1.55 +} 1.56 + 1.57 +bool 1.58 +nsStyleText::WordCanWrap(const nsIFrame* aContextFrame) const 1.59 +{ 1.60 + NS_ASSERTION(aContextFrame->StyleText() == this, "unexpected aContextFrame"); 1.61 + return WordCanWrapStyle() && !aContextFrame->IsSVGText(); 1.62 +} 1.63 + 1.64 +bool 1.65 +nsStyleDisplay::IsBlockInside(const nsIFrame* aContextFrame) const 1.66 +{ 1.67 + NS_ASSERTION(aContextFrame->StyleDisplay() == this, "unexpected aContextFrame"); 1.68 + if (aContextFrame->IsSVGText()) { 1.69 + return aContextFrame->GetType() == nsGkAtoms::blockFrame; 1.70 + } 1.71 + return IsBlockInsideStyle(); 1.72 +} 1.73 + 1.74 +bool 1.75 +nsStyleDisplay::IsBlockOutside(const nsIFrame* aContextFrame) const 1.76 +{ 1.77 + NS_ASSERTION(aContextFrame->StyleDisplay() == this, "unexpected aContextFrame"); 1.78 + if (aContextFrame->IsSVGText()) { 1.79 + return aContextFrame->GetType() == nsGkAtoms::blockFrame; 1.80 + } 1.81 + return IsBlockOutsideStyle(); 1.82 +} 1.83 + 1.84 +bool 1.85 +nsStyleDisplay::IsInlineOutside(const nsIFrame* aContextFrame) const 1.86 +{ 1.87 + NS_ASSERTION(aContextFrame->StyleDisplay() == this, "unexpected aContextFrame"); 1.88 + if (aContextFrame->IsSVGText()) { 1.89 + return aContextFrame->GetType() != nsGkAtoms::blockFrame; 1.90 + } 1.91 + return IsInlineOutsideStyle(); 1.92 +} 1.93 + 1.94 +bool 1.95 +nsStyleDisplay::IsOriginalDisplayInlineOutside(const nsIFrame* aContextFrame) const 1.96 +{ 1.97 + NS_ASSERTION(aContextFrame->StyleDisplay() == this, "unexpected aContextFrame"); 1.98 + if (aContextFrame->IsSVGText()) { 1.99 + return aContextFrame->GetType() != nsGkAtoms::blockFrame; 1.100 + } 1.101 + return IsOriginalDisplayInlineOutsideStyle(); 1.102 +} 1.103 + 1.104 +uint8_t 1.105 +nsStyleDisplay::GetDisplay(const nsIFrame* aContextFrame) const 1.106 +{ 1.107 + NS_ASSERTION(aContextFrame->StyleDisplay() == this, "unexpected aContextFrame"); 1.108 + if (aContextFrame->IsSVGText() && 1.109 + mDisplay != NS_STYLE_DISPLAY_NONE) { 1.110 + return aContextFrame->GetType() == nsGkAtoms::blockFrame ? 1.111 + NS_STYLE_DISPLAY_BLOCK : 1.112 + NS_STYLE_DISPLAY_INLINE; 1.113 + } 1.114 + return mDisplay; 1.115 +} 1.116 + 1.117 +bool 1.118 +nsStyleDisplay::IsFloating(const nsIFrame* aContextFrame) const 1.119 +{ 1.120 + NS_ASSERTION(aContextFrame->StyleDisplay() == this, "unexpected aContextFrame"); 1.121 + return IsFloatingStyle() && !aContextFrame->IsSVGText(); 1.122 +} 1.123 + 1.124 +bool 1.125 +nsStyleDisplay::HasTransform(const nsIFrame* aContextFrame) const 1.126 +{ 1.127 + NS_ASSERTION(aContextFrame->StyleDisplay() == this, "unexpected aContextFrame"); 1.128 + return HasTransformStyle() && aContextFrame->IsFrameOfType(nsIFrame::eSupportsCSSTransforms); 1.129 +} 1.130 + 1.131 +bool 1.132 +nsStyleDisplay::IsPositioned(const nsIFrame* aContextFrame) const 1.133 +{ 1.134 + NS_ASSERTION(aContextFrame->StyleDisplay() == this, 1.135 + "unexpected aContextFrame"); 1.136 + return (IsAbsolutelyPositionedStyle() || 1.137 + IsRelativelyPositionedStyle() || 1.138 + HasTransform(aContextFrame) || 1.139 + HasPerspectiveStyle()) && 1.140 + !aContextFrame->IsSVGText(); 1.141 +} 1.142 + 1.143 +bool 1.144 +nsStyleDisplay::IsRelativelyPositioned(const nsIFrame* aContextFrame) const 1.145 +{ 1.146 + NS_ASSERTION(aContextFrame->StyleDisplay() == this, "unexpected aContextFrame"); 1.147 + return IsRelativelyPositionedStyle() && !aContextFrame->IsSVGText(); 1.148 +} 1.149 + 1.150 +bool 1.151 +nsStyleDisplay::IsAbsolutelyPositioned(const nsIFrame* aContextFrame) const 1.152 +{ 1.153 + NS_ASSERTION(aContextFrame->StyleDisplay() == this, "unexpected aContextFrame"); 1.154 + return IsAbsolutelyPositionedStyle() && !aContextFrame->IsSVGText(); 1.155 +} 1.156 + 1.157 +uint8_t 1.158 +nsStyleVisibility::GetEffectivePointerEvents(nsIFrame* aFrame) const 1.159 +{ 1.160 + if (aFrame->GetContent() && !aFrame->GetContent()->GetParent()) { 1.161 + // The root element has a cluster of frames associated with it 1.162 + // (root scroll frame, canvas frame, the actual primary frame). Make 1.163 + // those take their pointer-events value from the root element's primary 1.164 + // frame. 1.165 + nsIFrame* f = aFrame->GetContent()->GetPrimaryFrame(); 1.166 + if (f) { 1.167 + return f->StyleVisibility()->mPointerEvents; 1.168 + } 1.169 + } 1.170 + return mPointerEvents; 1.171 +} 1.172 + 1.173 +#endif /* !defined(nsStyleStructInlines_h_) */