tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

nsStyleStructInlines.h (5456B)


      1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
      2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
      3 /* This Source Code Form is subject to the terms of the Mozilla Public
      4 * License, v. 2.0. If a copy of the MPL was not distributed with this
      5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
      6 
      7 /*
      8 * Inline methods that belong in nsStyleStruct.h, except that they
      9 * require more headers.
     10 */
     11 
     12 #ifndef nsStyleStructInlines_h_
     13 #define nsStyleStructInlines_h_
     14 
     15 #include "nsIContent.h"  // for GetParent()
     16 #include "nsIFrame.h"
     17 #include "nsStyleStruct.h"
     18 #include "nsTextFrame.h"  // for nsTextFrame::ShouldSuppressLineBreak
     19 
     20 bool nsStyleText::NewlineIsSignificant(const nsTextFrame* aContextFrame) const {
     21  NS_ASSERTION(aContextFrame->StyleText() == this, "unexpected aContextFrame");
     22  return NewlineIsSignificantStyle() &&
     23         !aContextFrame->ShouldSuppressLineBreak() &&
     24         !aContextFrame->Style()->IsTextCombined();
     25 }
     26 
     27 bool nsStyleText::WhiteSpaceCanWrap(const nsIFrame* aContextFrame) const {
     28  NS_ASSERTION(aContextFrame->StyleText() == this, "unexpected aContextFrame");
     29  return WhiteSpaceCanWrapStyle() && !aContextFrame->IsInSVGTextSubtree() &&
     30         !aContextFrame->Style()->IsTextCombined();
     31 }
     32 
     33 bool nsStyleText::WordCanWrap(const nsIFrame* aContextFrame) const {
     34  NS_ASSERTION(aContextFrame->StyleText() == this, "unexpected aContextFrame");
     35  return WordCanWrapStyle() && !aContextFrame->IsInSVGTextSubtree();
     36 }
     37 
     38 bool nsStyleDisplay::IsBlockOutside(const nsIFrame* aContextFrame) const {
     39  NS_ASSERTION(aContextFrame->StyleDisplay() == this,
     40               "unexpected aContextFrame");
     41  if (aContextFrame->IsInSVGTextSubtree()) {
     42    return aContextFrame->IsBlockFrame();
     43  }
     44  return IsBlockOutsideStyle();
     45 }
     46 
     47 bool nsStyleDisplay::IsInlineOutside(const nsIFrame* aContextFrame) const {
     48  NS_ASSERTION(aContextFrame->StyleDisplay() == this,
     49               "unexpected aContextFrame");
     50  if (aContextFrame->IsInSVGTextSubtree()) {
     51    return !aContextFrame->IsBlockFrame();
     52  }
     53  return IsInlineOutsideStyle();
     54 }
     55 
     56 mozilla::StyleDisplay nsStyleDisplay::GetDisplay(
     57    const nsIFrame* aContextFrame) const {
     58  NS_ASSERTION(aContextFrame->StyleDisplay() == this,
     59               "unexpected aContextFrame");
     60  if (aContextFrame->IsInSVGTextSubtree() &&
     61      mDisplay != mozilla::StyleDisplay::None) {
     62    return aContextFrame->IsBlockFrame() ? mozilla::StyleDisplay::Block
     63                                         : mozilla::StyleDisplay::Inline;
     64  }
     65  return mDisplay;
     66 }
     67 
     68 bool nsStyleDisplay::IsFloating(const nsIFrame* aContextFrame) const {
     69  NS_ASSERTION(aContextFrame->StyleDisplay() == this,
     70               "unexpected aContextFrame");
     71  return IsFloatingStyle() && !aContextFrame->IsInSVGTextSubtree();
     72 }
     73 
     74 // If you change this function, also change the corresponding block in
     75 // nsCSSFrameConstructor::ConstructFrameFromItemInternal that references
     76 // this function in comments.
     77 bool nsStyleDisplay::HasTransform(const nsIFrame* aContextFrame) const {
     78  NS_ASSERTION(aContextFrame->StyleDisplay() == this,
     79               "unexpected aContextFrame");
     80  return HasTransformStyle() && aContextFrame->SupportsCSSTransforms();
     81 }
     82 
     83 bool nsStyleDisplay::HasPerspective(const nsIFrame* aContextFrame) const {
     84  MOZ_ASSERT(aContextFrame->StyleDisplay() == this, "unexpected aContextFrame");
     85  return HasPerspectiveStyle() && aContextFrame->SupportsCSSTransforms();
     86 }
     87 
     88 bool nsStyleDisplay::
     89    IsFixedPosContainingBlockForContainLayoutAndPaintSupportingFrames() const {
     90  return IsContainPaint() || IsContainLayout() ||
     91         mWillChange.bits & mozilla::StyleWillChangeBits::CONTAIN;
     92 }
     93 
     94 bool nsStyleDisplay::IsFixedPosContainingBlockForTransformSupportingFrames()
     95    const {
     96  // NOTE: Any CSS properties that influence the output of this function
     97  // should also look at mWillChange as necessary.
     98  return HasTransformStyle() || HasPerspectiveStyle() ||
     99         mWillChange.bits & mozilla::StyleWillChangeBits::PERSPECTIVE;
    100 }
    101 
    102 bool nsStyleDisplay::IsRelativelyOrStickyPositioned(
    103    const nsIFrame* aContextFrame) const {
    104  NS_ASSERTION(aContextFrame->StyleDisplay() == this,
    105               "unexpected aContextFrame");
    106  return IsRelativelyOrStickyPositionedStyle() &&
    107         !aContextFrame->IsInSVGTextSubtree();
    108 }
    109 
    110 bool nsStyleDisplay::IsRelativelyPositioned(
    111    const nsIFrame* aContextFrame) const {
    112  NS_ASSERTION(aContextFrame->StyleDisplay() == this,
    113               "unexpected aContextFrame");
    114  return IsRelativelyPositionedStyle() && !aContextFrame->IsInSVGTextSubtree();
    115 }
    116 
    117 bool nsStyleDisplay::IsStickyPositioned(const nsIFrame* aContextFrame) const {
    118  NS_ASSERTION(aContextFrame->StyleDisplay() == this,
    119               "unexpected aContextFrame");
    120  return IsStickyPositionedStyle() && !aContextFrame->IsInSVGTextSubtree();
    121 }
    122 
    123 bool nsStyleDisplay::IsAbsolutelyPositioned(
    124    const nsIFrame* aContextFrame) const {
    125  NS_ASSERTION(aContextFrame->StyleDisplay() == this,
    126               "unexpected aContextFrame");
    127  return IsAbsolutelyPositionedStyle() && !aContextFrame->IsInSVGTextSubtree();
    128 }
    129 
    130 bool nsStyleBackground::HasLocalBackground() const {
    131  NS_FOR_VISIBLE_IMAGE_LAYERS_BACK_TO_FRONT(i, mImage) {
    132    const nsStyleImageLayers::Layer& layer = mImage.mLayers[i];
    133    if (!layer.mImage.IsNone() &&
    134        layer.mAttachment == mozilla::StyleImageLayerAttachment::Local) {
    135      return true;
    136    }
    137  }
    138  return false;
    139 }
    140 
    141 #endif /* !defined(nsStyleStructInlines_h_) */