2008-07-16 23:30:25 -07:00
|
|
|
/* vim: set shiftwidth=2 tabstop=8 autoindent cindent expandtab: */
|
2012-05-21 04:12:37 -07:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2008-07-16 23:30:25 -07:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Inline methods that belong in nsStyleStruct.h, except that they
|
|
|
|
* require more headers.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef nsStyleStructInlines_h_
|
|
|
|
#define nsStyleStructInlines_h_
|
|
|
|
|
2012-08-02 04:38:49 -07:00
|
|
|
#include "nsIFrame.h"
|
2008-07-16 23:30:25 -07:00
|
|
|
#include "nsStyleStruct.h"
|
2014-08-18 07:44:50 -07:00
|
|
|
#include "nsIContent.h" // for GetParent()
|
2015-05-03 14:52:53 -07:00
|
|
|
#include "nsTextFrame.h" // for nsTextFrame::ShouldSuppressLineBreak
|
2008-07-16 23:30:25 -07:00
|
|
|
|
|
|
|
inline void
|
2014-01-30 19:36:41 -08:00
|
|
|
nsStyleImage::SetSubImage(uint8_t aIndex, imgIContainer* aSubImage) const
|
2008-07-16 23:30:25 -07:00
|
|
|
{
|
2014-01-30 19:36:41 -08:00
|
|
|
const_cast<nsStyleImage*>(this)->mSubImages.ReplaceObjectAt(aSubImage, aIndex);
|
2009-11-13 20:23:00 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
inline imgIContainer*
|
2014-01-30 19:36:41 -08:00
|
|
|
nsStyleImage::GetSubImage(uint8_t aIndex) const
|
2009-11-13 20:23:00 -08:00
|
|
|
{
|
2012-07-30 07:20:58 -07:00
|
|
|
imgIContainer* subImage = nullptr;
|
2010-01-08 21:03:38 -08:00
|
|
|
if (aIndex < mSubImages.Count())
|
2009-11-13 20:23:00 -08:00
|
|
|
subImage = mSubImages[aIndex];
|
|
|
|
return subImage;
|
|
|
|
}
|
|
|
|
|
2012-08-08 04:37:13 -07:00
|
|
|
bool
|
2014-01-13 04:21:42 -08:00
|
|
|
nsStyleText::HasTextShadow() const
|
2012-08-08 04:37:13 -07:00
|
|
|
{
|
2014-01-13 04:21:42 -08:00
|
|
|
return mTextShadow;
|
2012-08-08 04:37:13 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
nsCSSShadowArray*
|
2014-01-13 04:21:42 -08:00
|
|
|
nsStyleText::GetTextShadow() const
|
2012-08-08 04:37:13 -07:00
|
|
|
{
|
|
|
|
return mTextShadow;
|
|
|
|
}
|
|
|
|
|
2015-03-17 01:10:15 -07:00
|
|
|
bool
|
2015-05-03 14:52:53 -07:00
|
|
|
nsStyleText::NewlineIsSignificant(const nsTextFrame* aContextFrame) const
|
2015-03-17 01:10:15 -07:00
|
|
|
{
|
|
|
|
NS_ASSERTION(aContextFrame->StyleText() == this, "unexpected aContextFrame");
|
|
|
|
return NewlineIsSignificantStyle() &&
|
2015-05-03 14:52:53 -07:00
|
|
|
!aContextFrame->ShouldSuppressLineBreak();
|
2015-03-17 01:10:15 -07:00
|
|
|
}
|
|
|
|
|
2013-03-24 20:50:59 -07:00
|
|
|
bool
|
2013-04-06 16:40:07 -07:00
|
|
|
nsStyleText::WhiteSpaceCanWrap(const nsIFrame* aContextFrame) const
|
2013-03-24 20:50:59 -07:00
|
|
|
{
|
2013-04-06 16:40:07 -07:00
|
|
|
NS_ASSERTION(aContextFrame->StyleText() == this, "unexpected aContextFrame");
|
|
|
|
return WhiteSpaceCanWrapStyle() && !aContextFrame->IsSVGText();
|
2013-03-24 20:50:59 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2013-04-06 16:40:07 -07:00
|
|
|
nsStyleText::WordCanWrap(const nsIFrame* aContextFrame) const
|
2013-03-24 20:50:59 -07:00
|
|
|
{
|
2013-04-06 16:40:07 -07:00
|
|
|
NS_ASSERTION(aContextFrame->StyleText() == this, "unexpected aContextFrame");
|
|
|
|
return WordCanWrapStyle() && !aContextFrame->IsSVGText();
|
2013-03-24 20:50:59 -07:00
|
|
|
}
|
|
|
|
|
2012-08-02 04:38:51 -07:00
|
|
|
bool
|
2013-04-06 16:40:07 -07:00
|
|
|
nsStyleDisplay::IsBlockInside(const nsIFrame* aContextFrame) const
|
2012-08-02 04:38:51 -07:00
|
|
|
{
|
2013-04-06 16:40:07 -07:00
|
|
|
NS_ASSERTION(aContextFrame->StyleDisplay() == this, "unexpected aContextFrame");
|
|
|
|
if (aContextFrame->IsSVGText()) {
|
|
|
|
return aContextFrame->GetType() == nsGkAtoms::blockFrame;
|
2012-08-02 04:38:51 -07:00
|
|
|
}
|
|
|
|
return IsBlockInsideStyle();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2013-04-06 16:40:07 -07:00
|
|
|
nsStyleDisplay::IsBlockOutside(const nsIFrame* aContextFrame) const
|
2012-08-02 04:38:51 -07:00
|
|
|
{
|
2013-04-06 16:40:07 -07:00
|
|
|
NS_ASSERTION(aContextFrame->StyleDisplay() == this, "unexpected aContextFrame");
|
|
|
|
if (aContextFrame->IsSVGText()) {
|
|
|
|
return aContextFrame->GetType() == nsGkAtoms::blockFrame;
|
2012-08-02 04:38:51 -07:00
|
|
|
}
|
|
|
|
return IsBlockOutsideStyle();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2013-04-06 16:40:07 -07:00
|
|
|
nsStyleDisplay::IsInlineOutside(const nsIFrame* aContextFrame) const
|
2012-08-02 04:38:51 -07:00
|
|
|
{
|
2013-04-06 16:40:07 -07:00
|
|
|
NS_ASSERTION(aContextFrame->StyleDisplay() == this, "unexpected aContextFrame");
|
|
|
|
if (aContextFrame->IsSVGText()) {
|
|
|
|
return aContextFrame->GetType() != nsGkAtoms::blockFrame;
|
2012-08-02 04:38:51 -07:00
|
|
|
}
|
|
|
|
return IsInlineOutsideStyle();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2013-04-06 16:40:07 -07:00
|
|
|
nsStyleDisplay::IsOriginalDisplayInlineOutside(const nsIFrame* aContextFrame) const
|
2012-08-02 04:38:51 -07:00
|
|
|
{
|
2013-04-06 16:40:07 -07:00
|
|
|
NS_ASSERTION(aContextFrame->StyleDisplay() == this, "unexpected aContextFrame");
|
|
|
|
if (aContextFrame->IsSVGText()) {
|
|
|
|
return aContextFrame->GetType() != nsGkAtoms::blockFrame;
|
2012-08-02 04:38:51 -07:00
|
|
|
}
|
|
|
|
return IsOriginalDisplayInlineOutsideStyle();
|
|
|
|
}
|
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
uint8_t
|
2013-04-06 16:40:07 -07:00
|
|
|
nsStyleDisplay::GetDisplay(const nsIFrame* aContextFrame) const
|
2012-08-02 04:38:51 -07:00
|
|
|
{
|
2013-04-06 16:40:07 -07:00
|
|
|
NS_ASSERTION(aContextFrame->StyleDisplay() == this, "unexpected aContextFrame");
|
|
|
|
if (aContextFrame->IsSVGText() &&
|
2012-08-02 04:38:51 -07:00
|
|
|
mDisplay != NS_STYLE_DISPLAY_NONE) {
|
2013-04-06 16:40:07 -07:00
|
|
|
return aContextFrame->GetType() == nsGkAtoms::blockFrame ?
|
2012-08-02 04:38:51 -07:00
|
|
|
NS_STYLE_DISPLAY_BLOCK :
|
|
|
|
NS_STYLE_DISPLAY_INLINE;
|
|
|
|
}
|
|
|
|
return mDisplay;
|
|
|
|
}
|
|
|
|
|
2012-08-02 04:38:49 -07:00
|
|
|
bool
|
2013-04-06 16:40:07 -07:00
|
|
|
nsStyleDisplay::IsFloating(const nsIFrame* aContextFrame) const
|
2012-08-02 04:38:49 -07:00
|
|
|
{
|
2013-04-06 16:40:07 -07:00
|
|
|
NS_ASSERTION(aContextFrame->StyleDisplay() == this, "unexpected aContextFrame");
|
|
|
|
return IsFloatingStyle() && !aContextFrame->IsSVGText();
|
2012-08-02 04:38:49 -07:00
|
|
|
}
|
|
|
|
|
2015-03-11 20:21:01 -07:00
|
|
|
// If you change this function, also change the corresponding block in
|
|
|
|
// nsCSSFrameConstructor::ConstructFrameFromItemInternal that references
|
|
|
|
// this function in comments.
|
2015-03-19 21:12:17 -07:00
|
|
|
bool
|
|
|
|
nsStyleDisplay::HasTransform(const nsIFrame* aContextFrame) const
|
|
|
|
{
|
|
|
|
NS_ASSERTION(aContextFrame->StyleDisplay() == this, "unexpected aContextFrame");
|
|
|
|
return HasTransformStyle() && aContextFrame->IsFrameOfType(nsIFrame::eSupportsCSSTransforms);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
nsStyleDisplay::IsFixedPosContainingBlock(const nsIFrame* aContextFrame) const
|
|
|
|
{
|
|
|
|
return (HasTransform(aContextFrame) || HasPerspectiveStyle() ||
|
|
|
|
!aContextFrame->StyleSVGReset()->mFilters.IsEmpty()) &&
|
|
|
|
!aContextFrame->IsSVGText();
|
|
|
|
}
|
|
|
|
|
2012-08-02 04:38:50 -07:00
|
|
|
bool
|
2015-03-11 20:21:01 -07:00
|
|
|
nsStyleDisplay::IsAbsPosContainingBlock(const nsIFrame* aContextFrame) const
|
2012-08-02 04:38:50 -07:00
|
|
|
{
|
2013-04-06 16:40:07 -07:00
|
|
|
NS_ASSERTION(aContextFrame->StyleDisplay() == this,
|
|
|
|
"unexpected aContextFrame");
|
2015-03-11 20:21:01 -07:00
|
|
|
return ((IsAbsolutelyPositionedStyle() || IsRelativelyPositionedStyle()) &&
|
2015-03-19 21:12:17 -07:00
|
|
|
!aContextFrame->IsSVGText()) || IsFixedPosContainingBlock(aContextFrame);
|
2012-08-02 04:38:50 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2013-04-06 16:40:07 -07:00
|
|
|
nsStyleDisplay::IsRelativelyPositioned(const nsIFrame* aContextFrame) const
|
2012-08-02 04:38:50 -07:00
|
|
|
{
|
2013-04-06 16:40:07 -07:00
|
|
|
NS_ASSERTION(aContextFrame->StyleDisplay() == this, "unexpected aContextFrame");
|
|
|
|
return IsRelativelyPositionedStyle() && !aContextFrame->IsSVGText();
|
2012-08-02 04:38:50 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2013-04-06 16:40:07 -07:00
|
|
|
nsStyleDisplay::IsAbsolutelyPositioned(const nsIFrame* aContextFrame) const
|
2012-08-02 04:38:50 -07:00
|
|
|
{
|
2013-04-06 16:40:07 -07:00
|
|
|
NS_ASSERTION(aContextFrame->StyleDisplay() == this, "unexpected aContextFrame");
|
|
|
|
return IsAbsolutelyPositionedStyle() && !aContextFrame->IsSVGText();
|
2012-08-02 04:38:50 -07:00
|
|
|
}
|
|
|
|
|
2012-11-02 03:42:59 -07:00
|
|
|
uint8_t
|
|
|
|
nsStyleVisibility::GetEffectivePointerEvents(nsIFrame* aFrame) const
|
|
|
|
{
|
|
|
|
if (aFrame->GetContent() && !aFrame->GetContent()->GetParent()) {
|
|
|
|
// The root element has a cluster of frames associated with it
|
|
|
|
// (root scroll frame, canvas frame, the actual primary frame). Make
|
|
|
|
// those take their pointer-events value from the root element's primary
|
|
|
|
// frame.
|
|
|
|
nsIFrame* f = aFrame->GetContent()->GetPrimaryFrame();
|
|
|
|
if (f) {
|
2013-02-16 13:51:02 -08:00
|
|
|
return f->StyleVisibility()->mPointerEvents;
|
2012-11-02 03:42:59 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return mPointerEvents;
|
|
|
|
}
|
|
|
|
|
2008-07-16 23:30:25 -07:00
|
|
|
#endif /* !defined(nsStyleStructInlines_h_) */
|