tor-browser

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

nsRubyFrame.h (2746B)


      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 /* rendering object for CSS "display: ruby" */
      8 
      9 #ifndef nsRubyFrame_h___
     10 #define nsRubyFrame_h___
     11 
     12 #include "RubyUtils.h"
     13 #include "nsInlineFrame.h"
     14 
     15 namespace mozilla {
     16 class PresShell;
     17 }  // namespace mozilla
     18 
     19 /**
     20 * Factory function.
     21 * @return a newly allocated nsRubyFrame (infallible)
     22 */
     23 nsContainerFrame* NS_NewRubyFrame(mozilla::PresShell* aPresShell,
     24                                  mozilla::ComputedStyle* aStyle);
     25 
     26 class nsRubyFrame final : public nsInlineFrame {
     27 public:
     28  NS_DECL_FRAMEARENA_HELPERS(nsRubyFrame)
     29  NS_DECL_QUERYFRAME
     30 
     31  void AddInlineMinISize(const mozilla::IntrinsicSizeInput& aInput,
     32                         InlineMinISizeData* aData) override;
     33  void AddInlinePrefISize(const mozilla::IntrinsicSizeInput& aInput,
     34                          InlinePrefISizeData* aData) override;
     35  void Reflow(nsPresContext* aPresContext, ReflowOutput& aDesiredSize,
     36              const ReflowInput& aReflowInput,
     37              nsReflowStatus& aStatus) override;
     38 
     39 #ifdef DEBUG_FRAME_DUMP
     40  nsresult GetFrameName(nsAString& aResult) const override;
     41 #endif
     42 
     43  mozilla::RubyBlockLeadings GetBlockLeadings() const { return mLeadings; }
     44 
     45  mozilla::RubyMetrics RubyMetrics(float aRubyMetricsFactor) const override {
     46    // aRubyMetricsFactor is ignored here; it was already accounted for in
     47    // accumulating mRubyMetrics.
     48    return mRubyMetrics;
     49  }
     50 
     51 protected:
     52  friend nsContainerFrame* NS_NewRubyFrame(mozilla::PresShell* aPresShell,
     53                                           ComputedStyle* aStyle);
     54  explicit nsRubyFrame(ComputedStyle* aStyle, nsPresContext* aPresContext)
     55      : nsInlineFrame(aStyle, aPresContext, kClassID) {}
     56 
     57  void ReflowSegment(nsPresContext* aPresContext,
     58                     const ReflowInput& aReflowInput, nscoord aBlockStartAscent,
     59                     nscoord aBlockSize,
     60                     nsRubyBaseContainerFrame* aBaseContainer,
     61                     nsReflowStatus& aStatus);
     62 
     63  nsRubyBaseContainerFrame* PullOneSegment(const nsLineLayout* aLineLayout,
     64                                           ContinuationTraversingState& aState);
     65 
     66  // The leadings required to put the annotations. They are dummy-
     67  // initialized to 0, and get meaningful values at first reflow.
     68  mozilla::RubyBlockLeadings mLeadings;
     69 
     70  // Accumulated normalized-ascent/descent metrics used for ruby positioning.
     71  mozilla::RubyMetrics mRubyMetrics;
     72 };
     73 
     74 #endif /* nsRubyFrame_h___ */