tor-browser

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

nsMathMLmpaddedFrame.h (2834B)


      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 #ifndef nsMathMLmpaddedFrame_h___
      8 #define nsMathMLmpaddedFrame_h___
      9 
     10 #include "nsCSSValue.h"
     11 #include "nsMathMLContainerFrame.h"
     12 
     13 namespace mozilla {
     14 class PresShell;
     15 }  // namespace mozilla
     16 
     17 //
     18 // <mpadded> -- adjust space around content
     19 //
     20 
     21 class nsMathMLmpaddedFrame final : public nsMathMLContainerFrame {
     22 public:
     23  NS_DECL_FRAMEARENA_HELPERS(nsMathMLmpaddedFrame)
     24 
     25  friend nsIFrame* NS_NewMathMLmpaddedFrame(mozilla::PresShell* aPresShell,
     26                                            ComputedStyle* aStyle);
     27 
     28  NS_IMETHOD
     29  InheritAutomaticData(nsIFrame* aParent) override;
     30 
     31  NS_IMETHOD
     32  TransmitAutomaticData() override {
     33    return TransmitAutomaticDataForMrowLikeElement();
     34  }
     35 
     36  void Place(DrawTarget* aDrawTarget, const PlaceFlags& aFlags,
     37             ReflowOutput& aDesiredSize) override;
     38 
     39  bool IsMrowLike() override {
     40    return mFrames.FirstChild() != mFrames.LastChild() || !mFrames.FirstChild();
     41  }
     42 
     43 protected:
     44  explicit nsMathMLmpaddedFrame(ComputedStyle* aStyle,
     45                                nsPresContext* aPresContext)
     46      : nsMathMLContainerFrame(aStyle, aPresContext, kClassID) {}
     47 
     48  virtual ~nsMathMLmpaddedFrame();
     49 
     50 private:
     51  struct Attribute {
     52    enum class Sign : uint8_t {
     53      Unspecified,
     54      Minus,
     55      Plus,
     56    };
     57    enum class PseudoUnit : uint8_t {
     58      Unspecified,
     59      ItSelf,
     60      Width,
     61      Height,
     62      Depth,
     63      NamedSpace,
     64    };
     65    nsCSSValue mValue;
     66    Sign mSign = Sign::Unspecified;
     67    PseudoUnit mPseudoUnit = PseudoUnit::Unspecified;
     68    enum class ParsingState : uint8_t {
     69      Valid,
     70      Invalid,
     71      Dirty,
     72    };
     73    ParsingState mState = ParsingState::Dirty;
     74    void Reset() {
     75      mValue.Reset();
     76      mSign = Sign::Unspecified;
     77      mPseudoUnit = PseudoUnit::Unspecified;
     78      mState = ParsingState::Dirty;
     79    }
     80    bool IsValid() const { return mState == ParsingState::Valid; }
     81  };
     82 
     83  Attribute mWidth;
     84  Attribute mHeight;
     85  Attribute mDepth;
     86  Attribute mLeadingSpace;
     87  Attribute mVerticalOffset;
     88 
     89  nsresult AttributeChanged(int32_t aNameSpaceID, nsAtom* aAttribute,
     90                            AttrModType aModType) final;
     91  void ParseAttribute(nsAtom* aAtom, Attribute& aAttribute);
     92  bool ParseAttribute(nsString& aString, Attribute& aAttribute);
     93 
     94  void UpdateValue(const Attribute& aAttribute, Attribute::PseudoUnit aSelfUnit,
     95                   const ReflowOutput& aDesiredSize, nscoord& aValueToUpdate,
     96                   float aFontSizeInflation);
     97 };
     98 
     99 #endif /* nsMathMLmpaddedFrame_h___ */