LCOV - code coverage report
Current view: directory - layout/generic - nsInlineFrame.h (source / functions) Found Hit Coverage
Test: app.info Lines: 21 0 0.0 %
Date: 2012-06-02 Functions: 10 0 0.0 %

       1                 : /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
       2                 : /* ***** BEGIN LICENSE BLOCK *****
       3                 :  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
       4                 :  *
       5                 :  * The contents of this file are subject to the Mozilla Public License Version
       6                 :  * 1.1 (the "License"); you may not use this file except in compliance with
       7                 :  * the License. You may obtain a copy of the License at
       8                 :  * http://www.mozilla.org/MPL/
       9                 :  *
      10                 :  * Software distributed under the License is distributed on an "AS IS" basis,
      11                 :  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
      12                 :  * for the specific language governing rights and limitations under the
      13                 :  * License.
      14                 :  *
      15                 :  * The Original Code is Mozilla Communicator client code.
      16                 :  *
      17                 :  * The Initial Developer of the Original Code is
      18                 :  * Netscape Communications Corporation.
      19                 :  * Portions created by the Initial Developer are Copyright (C) 1998
      20                 :  * the Initial Developer. All Rights Reserved.
      21                 :  *
      22                 :  * Contributor(s):
      23                 :  *
      24                 :  * Alternatively, the contents of this file may be used under the terms of
      25                 :  * either of the GNU General Public License Version 2 or later (the "GPL"),
      26                 :  * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
      27                 :  * in which case the provisions of the GPL or the LGPL are applicable instead
      28                 :  * of those above. If you wish to allow use of your version of this file only
      29                 :  * under the terms of either the GPL or the LGPL, and not to allow others to
      30                 :  * use your version of this file under the terms of the MPL, indicate your
      31                 :  * decision by deleting the provisions above and replace them with the notice
      32                 :  * and other provisions required by the GPL or the LGPL. If you do not delete
      33                 :  * the provisions above, a recipient may use your version of this file under
      34                 :  * the terms of any one of the MPL, the GPL or the LGPL.
      35                 :  *
      36                 :  * ***** END LICENSE BLOCK ***** */
      37                 : 
      38                 : /* rendering object for CSS display:inline objects */
      39                 : 
      40                 : #ifndef nsInlineFrame_h___
      41                 : #define nsInlineFrame_h___
      42                 : 
      43                 : #include "nsContainerFrame.h"
      44                 : #include "nsLineLayout.h"
      45                 : 
      46                 : /**  In Bidi left (or right) margin/padding/border should be applied to left
      47                 :  *  (or right) most frame (or a continuation frame).
      48                 :  *  This state value shows if this frame is left (or right) most continuation
      49                 :  *  or not.
      50                 :  */
      51                 : #define NS_INLINE_FRAME_BIDI_VISUAL_STATE_IS_SET     NS_FRAME_STATE_BIT(21)
      52                 : 
      53                 : #define NS_INLINE_FRAME_BIDI_VISUAL_IS_LEFT_MOST     NS_FRAME_STATE_BIT(22)
      54                 : 
      55                 : #define NS_INLINE_FRAME_BIDI_VISUAL_IS_RIGHT_MOST    NS_FRAME_STATE_BIT(23)
      56                 : 
      57                 : /**
      58                 :  * Inline frame class.
      59                 :  *
      60                 :  * This class manages a list of child frames that are inline frames. Working with
      61                 :  * nsLineLayout, the class will reflow and place inline frames on a line.
      62                 :  */
      63                 : class nsInlineFrame : public nsContainerFrame
      64               0 : {
      65                 : public:
      66                 :   NS_DECL_QUERYFRAME_TARGET(nsInlineFrame)
      67                 :   NS_DECL_QUERYFRAME
      68                 :   NS_DECL_FRAMEARENA_HELPERS
      69                 : 
      70                 :   friend nsIFrame* NS_NewInlineFrame(nsIPresShell* aPresShell, nsStyleContext* aContext);
      71                 : 
      72                 :   /** sets defaults for inline-specific style.
      73                 :     * @see nsIFrame::Init
      74                 :     */
      75                 :   NS_IMETHOD Init(nsIContent*      aContent,
      76                 :                   nsIFrame*        aParent,
      77                 :                   nsIFrame*        aPrevInFlow);
      78                 : 
      79                 :   // nsIFrame overrides
      80                 :   NS_IMETHOD BuildDisplayList(nsDisplayListBuilder*   aBuilder,
      81                 :                               const nsRect&           aDirtyRect,
      82                 :                               const nsDisplayListSet& aLists);
      83                 : 
      84                 : #ifdef ACCESSIBILITY
      85                 :   virtual already_AddRefed<nsAccessible> CreateAccessible();
      86                 : #endif
      87                 : 
      88                 : #ifdef DEBUG
      89                 :   NS_IMETHOD GetFrameName(nsAString& aResult) const;
      90                 : #endif
      91                 :   virtual nsIAtom* GetType() const;
      92                 : 
      93               0 :   virtual bool IsFrameOfType(PRUint32 aFlags) const
      94                 :   {
      95                 :     return nsContainerFrame::IsFrameOfType(aFlags &
      96               0 :       ~(nsIFrame::eBidiInlineContainer | nsIFrame::eLineParticipant));
      97                 :   }
      98                 : 
      99                 :   virtual bool IsEmpty();
     100                 :   virtual bool IsSelfEmpty();
     101                 : 
     102                 :   virtual void DestroyFrom(nsIFrame* aDestructRoot);
     103                 : 
     104                 :   virtual bool PeekOffsetCharacter(bool aForward, PRInt32* aOffset,
     105                 :                                      bool aRespectClusters = true);
     106                 :   
     107                 :   // nsIHTMLReflow overrides
     108                 :   virtual void AddInlineMinWidth(nsRenderingContext *aRenderingContext,
     109                 :                                  InlineMinWidthData *aData);
     110                 :   virtual void AddInlinePrefWidth(nsRenderingContext *aRenderingContext,
     111                 :                                   InlinePrefWidthData *aData);
     112                 :   virtual nsSize ComputeSize(nsRenderingContext *aRenderingContext,
     113                 :                              nsSize aCBSize, nscoord aAvailableWidth,
     114                 :                              nsSize aMargin, nsSize aBorder, nsSize aPadding,
     115                 :                              bool aShrinkWrap);
     116                 :   virtual nsRect ComputeTightBounds(gfxContext* aContext) const;
     117                 :   NS_IMETHOD Reflow(nsPresContext* aPresContext,
     118                 :                     nsHTMLReflowMetrics& aDesiredSize,
     119                 :                     const nsHTMLReflowState& aReflowState,
     120                 :                     nsReflowStatus& aStatus);
     121                 : 
     122                 :   virtual bool CanContinueTextRun() const;
     123                 : 
     124                 :   virtual void PullOverflowsFromPrevInFlow();
     125                 :   virtual nscoord GetBaseline() const;
     126                 : 
     127                 :   /**
     128                 :    * Return true if the frame is leftmost frame or continuation.
     129                 :    */
     130               0 :   bool IsLeftMost() const {
     131                 :     // If the frame's bidi visual state is set, return is-leftmost state
     132                 :     // else return true if it's the first continuation.
     133               0 :     return (GetStateBits() & NS_INLINE_FRAME_BIDI_VISUAL_STATE_IS_SET)
     134               0 :              ? !!(GetStateBits() & NS_INLINE_FRAME_BIDI_VISUAL_IS_LEFT_MOST)
     135               0 :              : (!GetPrevInFlow());
     136                 :   }
     137                 : 
     138                 :   /**
     139                 :    * Return true if the frame is rightmost frame or continuation.
     140                 :    */
     141               0 :   bool IsRightMost() const {
     142                 :     // If the frame's bidi visual state is set, return is-rightmost state
     143                 :     // else return true if it's the last continuation.
     144               0 :     return (GetStateBits() & NS_INLINE_FRAME_BIDI_VISUAL_STATE_IS_SET)
     145               0 :              ? !!(GetStateBits() & NS_INLINE_FRAME_BIDI_VISUAL_IS_RIGHT_MOST)
     146               0 :              : (!GetNextInFlow());
     147                 :   }
     148                 : 
     149                 : protected:
     150                 :   // Additional reflow state used during our reflow methods
     151                 :   struct InlineReflowState {
     152                 :     nsIFrame* mPrevFrame;
     153                 :     nsInlineFrame* mNextInFlow;
     154                 :     nsIFrame*      mLineContainer;
     155                 :     nsLineLayout*  mLineLayout;
     156                 :     bool mSetParentPointer;  // when reflowing child frame first set its
     157                 :                                      // parent frame pointer
     158                 : 
     159               0 :     InlineReflowState()  {
     160               0 :       mPrevFrame = nsnull;
     161               0 :       mNextInFlow = nsnull;
     162               0 :       mLineContainer = nsnull;
     163               0 :       mLineLayout = nsnull;
     164               0 :       mSetParentPointer = false;
     165               0 :     }
     166                 :   };
     167                 : 
     168               0 :   nsInlineFrame(nsStyleContext* aContext) : nsContainerFrame(aContext) {}
     169                 : 
     170                 :   virtual PRIntn GetSkipSides() const;
     171                 : 
     172                 :   nsresult ReflowFrames(nsPresContext* aPresContext,
     173                 :                         const nsHTMLReflowState& aReflowState,
     174                 :                         InlineReflowState& rs,
     175                 :                         nsHTMLReflowMetrics& aMetrics,
     176                 :                         nsReflowStatus& aStatus);
     177                 : 
     178                 :   nsresult ReflowInlineFrame(nsPresContext* aPresContext,
     179                 :                              const nsHTMLReflowState& aReflowState,
     180                 :                              InlineReflowState& rs,
     181                 :                              nsIFrame* aFrame,
     182                 :                              nsReflowStatus& aStatus);
     183                 : 
     184                 :   /**
     185                 :    * Reparent floats whose placeholders are inline descendants of aFrame from
     186                 :    * whatever block they're currently parented by to aOurBlock.
     187                 :    * @param aReparentSiblings if this is true, we follow aFrame's
     188                 :    * GetNextSibling chain reparenting them all
     189                 :    */
     190                 :   void ReparentFloatsForInlineChild(nsIFrame* aOurBlock, nsIFrame* aFrame,
     191                 :                                     bool aReparentSiblings);
     192                 : 
     193                 :   virtual nsIFrame* PullOneFrame(nsPresContext* aPresContext,
     194                 :                                  InlineReflowState& rs,
     195                 :                                  bool* aIsComplete);
     196                 : 
     197                 :   virtual void PushFrames(nsPresContext* aPresContext,
     198                 :                           nsIFrame* aFromChild,
     199                 :                           nsIFrame* aPrevSibling,
     200                 :                           InlineReflowState& aState);
     201                 : 
     202                 :   nscoord mBaseline;
     203                 : };
     204                 : 
     205                 : //----------------------------------------------------------------------
     206                 : 
     207                 : /**
     208                 :  * Variation on inline-frame used to manage lines for line layout in
     209                 :  * special situations (:first-line style in particular).
     210                 :  */
     211               0 : class nsFirstLineFrame : public nsInlineFrame {
     212                 : public:
     213                 :   NS_DECL_FRAMEARENA_HELPERS
     214                 : 
     215                 :   friend nsIFrame* NS_NewFirstLineFrame(nsIPresShell* aPresShell, nsStyleContext* aContext);
     216                 : 
     217                 : #ifdef DEBUG
     218                 :   NS_IMETHOD GetFrameName(nsAString& aResult) const;
     219                 : #endif
     220                 :   virtual nsIAtom* GetType() const;
     221                 :   NS_IMETHOD Reflow(nsPresContext* aPresContext,
     222                 :                     nsHTMLReflowMetrics& aDesiredSize,
     223                 :                     const nsHTMLReflowState& aReflowState,
     224                 :                     nsReflowStatus& aStatus);
     225                 : 
     226                 :   virtual void PullOverflowsFromPrevInFlow();
     227                 : 
     228                 : protected:
     229               0 :   nsFirstLineFrame(nsStyleContext* aContext) : nsInlineFrame(aContext) {}
     230                 : 
     231                 :   virtual nsIFrame* PullOneFrame(nsPresContext* aPresContext,
     232                 :                                  InlineReflowState& rs,
     233                 :                                  bool* aIsComplete);
     234                 : };
     235                 : 
     236                 : #endif /* nsInlineFrame_h___ */

Generated by: LCOV version 1.7