tor-browser

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

nsFrameSetFrame.h (6701B)


      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 HTML <frameset> elements */
      8 
      9 #ifndef nsHTMLFrameset_h___
     10 #define nsHTMLFrameset_h___
     11 
     12 #include "nsColor.h"
     13 #include "nsContainerFrame.h"
     14 #include "nsTArray.h"
     15 
     16 class nsIContent;
     17 class nsPresContext;
     18 struct nsRect;
     19 struct nsSize;
     20 class nsAtom;
     21 class nsHTMLFramesetBorderFrame;
     22 class nsHTMLFramesetFrame;
     23 
     24 #define NO_COLOR 0xFFFFFFFA
     25 
     26 // defined at HTMLFrameSetElement.h
     27 struct nsFramesetSpec;
     28 
     29 struct nsBorderColor {
     30  nscolor mLeft;
     31  nscolor mRight;
     32  nscolor mTop;
     33  nscolor mBottom;
     34 
     35  nsBorderColor() { Set(NO_COLOR); }
     36  ~nsBorderColor() = default;
     37  void Set(nscolor aColor) { mLeft = mRight = mTop = mBottom = aColor; }
     38 };
     39 
     40 enum nsFrameborder {
     41  eFrameborder_Yes = 0,
     42  eFrameborder_No,
     43  eFrameborder_Notset
     44 };
     45 
     46 struct nsFramesetDrag {
     47  nsHTMLFramesetFrame* mSource;  // frameset whose border was dragged to cause
     48                                 // the resize
     49  int32_t mIndex;   // index of left col or top row of effected area
     50  int32_t mChange;  // pos for left to right or top to bottom, neg otherwise
     51  bool mVertical;   // vertical if true, otherwise horizontal
     52 
     53  nsFramesetDrag();
     54  void Reset(bool aVertical, int32_t aIndex, int32_t aChange,
     55             nsHTMLFramesetFrame* aSource);
     56  void UnSet();
     57 };
     58 
     59 /*******************************************************************************
     60 * nsHTMLFramesetFrame
     61 ******************************************************************************/
     62 class nsHTMLFramesetFrame final : public nsContainerFrame {
     63 public:
     64  NS_DECL_QUERYFRAME
     65  NS_DECL_FRAMEARENA_HELPERS(nsHTMLFramesetFrame)
     66 
     67  explicit nsHTMLFramesetFrame(ComputedStyle* aStyle,
     68                               nsPresContext* aPresContext);
     69 
     70  virtual ~nsHTMLFramesetFrame();
     71 
     72  virtual void Init(nsIContent* aContent, nsContainerFrame* aParent,
     73                    nsIFrame* aPrevInFlow) override;
     74 
     75  void SetInitialChildList(ChildListID aListID,
     76                           nsFrameList&& aChildList) override;
     77 
     78  static bool gDragInProgress;
     79 
     80  void GetSizeOfChild(nsIFrame* aChild, mozilla::WritingMode aWM,
     81                      mozilla::LogicalSize& aSize);
     82 
     83  void GetSizeOfChildAt(int32_t aIndexInParent, mozilla::WritingMode aWM,
     84                        mozilla::LogicalSize& aSize, nsIntPoint& aCellIndex);
     85 
     86  virtual nsresult HandleEvent(nsPresContext* aPresContext,
     87                               mozilla::WidgetGUIEvent* aEvent,
     88                               nsEventStatus* aEventStatus) override;
     89 
     90  Cursor GetCursor(const nsPoint&) override;
     91 
     92  virtual void BuildDisplayList(nsDisplayListBuilder* aBuilder,
     93                                const nsDisplayListSet& aLists) override;
     94 
     95  virtual void Reflow(nsPresContext* aPresContext, ReflowOutput& aDesiredSize,
     96                      const ReflowInput& aReflowInput,
     97                      nsReflowStatus& aStatus) override;
     98 
     99 #ifdef DEBUG_FRAME_DUMP
    100  virtual nsresult GetFrameName(nsAString& aResult) const override;
    101 #endif
    102 
    103  void StartMouseDrag(nsPresContext* aPresContext,
    104                      nsHTMLFramesetBorderFrame* aBorder,
    105                      mozilla::WidgetGUIEvent* aEvent);
    106 
    107  void MouseDrag(nsPresContext* aPresContext, mozilla::WidgetGUIEvent* aEvent);
    108 
    109  void EndMouseDrag(nsPresContext* aPresContext);
    110 
    111  nsFrameborder GetParentFrameborder() { return mParentFrameborder; }
    112 
    113  void SetParentFrameborder(nsFrameborder aValue) {
    114    mParentFrameborder = aValue;
    115  }
    116 
    117  nsFramesetDrag& GetDrag() { return mDrag; }
    118 
    119  void RecalculateBorderResize();
    120 
    121 protected:
    122  void Scale(nscoord aDesired, int32_t aNumIndicies,
    123             const nsTArray<int32_t>& aIndicies, nsTArray<int32_t>& aItems);
    124 
    125  void CalculateRowCol(nsPresContext* aPresContext, nscoord aSize,
    126                       const mozilla::Span<const nsFramesetSpec>& aSpecs,
    127                       nsTArray<nscoord>& aValues);
    128 
    129  void GenerateRowCol(nsPresContext* aPresContext, nscoord aSize,
    130                      const mozilla::Span<const nsFramesetSpec>& aSpecs,
    131                      const nsTArray<nscoord>& aValues, nsString& aNewAttr);
    132 
    133  virtual void GetDesiredSize(nsPresContext* aPresContext,
    134                              const ReflowInput& aReflowInput,
    135                              ReflowOutput& aDesiredSize);
    136 
    137  int32_t GetBorderWidth(nsPresContext* aPresContext,
    138                         bool aTakeForcingIntoAccount);
    139 
    140  int32_t GetParentBorderWidth() { return mParentBorderWidth; }
    141 
    142  void SetParentBorderWidth(int32_t aWidth) { mParentBorderWidth = aWidth; }
    143 
    144  nscolor GetParentBorderColor() { return mParentBorderColor; }
    145 
    146  void SetParentBorderColor(nscolor aColor) { mParentBorderColor = aColor; }
    147 
    148  nsFrameborder GetFrameBorder();
    149 
    150  nsFrameborder GetFrameBorder(nsIContent* aContent);
    151 
    152  nscolor GetBorderColor();
    153 
    154  nscolor GetBorderColor(nsIContent* aFrameContent);
    155 
    156  bool GetNoResize(nsIFrame* aChildFrame);
    157 
    158  void ReflowPlaceChild(nsIFrame* aChild, nsPresContext* aPresContext,
    159                        const ReflowInput& aReflowInput, nsPoint& aOffset,
    160                        nsSize& aSize, nsIntPoint* aCellIndex = 0);
    161 
    162  bool CanResize(bool aVertical, bool aLeft);
    163 
    164  bool CanChildResize(bool aVertical, bool aLeft, int32_t aChildX);
    165 
    166  void SetBorderResize(nsHTMLFramesetBorderFrame* aBorderFrame);
    167 
    168  int32_t NumRows() const;
    169  int32_t NumCols() const;
    170 
    171  nsFramesetDrag mDrag;
    172  nsBorderColor mEdgeColors;
    173  nsHTMLFramesetBorderFrame* mDragger;
    174  nsHTMLFramesetFrame* mTopLevelFrameset;
    175  nsTArray<nsHTMLFramesetBorderFrame*> mVerBorders;  // vertical borders
    176  nsTArray<nsHTMLFramesetBorderFrame*> mHorBorders;  // horizontal borders
    177  nsTArray<nsFrameborder>
    178      mChildFrameborder;  // the frameborder attr of children
    179  nsTArray<nsBorderColor> mChildBorderColors;
    180  nsTArray<nscoord> mRowSizes;  // currently computed row sizes
    181  nsTArray<nscoord> mColSizes;  // currently computed col sizes
    182  mozilla::LayoutDeviceIntPoint mFirstDragPoint;
    183  int32_t mNonBorderChildCount;
    184  int32_t mNonBlankChildCount;
    185  int32_t mEdgeVisibility;
    186  nsFrameborder mParentFrameborder;
    187  // If this is true, then we've been Init()'d, but haven't been reflowed, so
    188  // there's some extra work to do in the first reflow.
    189  bool mNeedFirstReflowWork = false;
    190  nscolor mParentBorderColor;
    191  int32_t mParentBorderWidth;
    192  int32_t mPrevNeighborOrigSize;  // used during resize
    193  int32_t mNextNeighborOrigSize;
    194  int32_t mMinDrag;
    195  int32_t mChildCount;
    196 };
    197 
    198 #endif