LCOV - app.info - content/base/src/nsXHTMLContentSerializer.h

LCOV - code coverage report
| Current view: | directory - content/base/src - nsXHTMLContentSerializer.h (source / functions) |  | Found | Hit | Coverage |
| Test: | app.info | Lines: | 8 | 0 | 0.0 %
| Date: | 2012-07-07 | Functions: | 3 | 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.org 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                 :  *   Laurent Jouanneau <laurent.jouanneau@disruptive-innovations.com>
          24                 :  *
          25                 :  * Alternatively, the contents of this file may be used under the terms of
          26                 :  * either of the GNU General Public License Version 2 or later (the "GPL"),
          27                 :  * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
          28                 :  * in which case the provisions of the GPL or the LGPL are applicable instead
          29                 :  * of those above. If you wish to allow use of your version of this file only
          30                 :  * under the terms of either the GPL or the LGPL, and not to allow others to
          31                 :  * use your version of this file under the terms of the MPL, indicate your
          32                 :  * decision by deleting the provisions above and replace them with the notice
          33                 :  * and other provisions required by the GPL or the LGPL. If you do not delete
          34                 :  * the provisions above, a recipient may use your version of this file under
          35                 :  * the terms of any one of the MPL, the GPL or the LGPL.
          36                 :  *
          37                 :  * ***** END LICENSE BLOCK ***** */
          38                 :
          39                 : /*
          40                 :  * nsIContentSerializer implementation that can be used with an
          41                 :  * nsIDocumentEncoder to convert an XHTML (not HTML!) DOM to an XHTML
          42                 :  * string that could be parsed into more or less the original DOM.
          43                 :  */
          44                 :
          45                 : #ifndef nsXHTMLContentSerializer_h__
          46                 : #define nsXHTMLContentSerializer_h__
          47                 :
          48                 : #include "nsXMLContentSerializer.h"
          49                 : #include "nsIEntityConverter.h"
          50                 : #include "nsString.h"
          51                 : #include "nsTArray.h"
          52                 :
          53                 : class nsIContent;
          54                 : class nsIAtom;
          55                 :
          56                 : class nsXHTMLContentSerializer : public nsXMLContentSerializer {
          57                 :  public:
          58                 :   nsXHTMLContentSerializer();
          59                 :   virtual ~nsXHTMLContentSerializer();
          60                 :
          61                 :   NS_IMETHOD Init(PRUint32 flags, PRUint32 aWrapColumn,
          62                 :                   const char* aCharSet, bool aIsCopying,
          63                 :                   bool aRewriteEncodingDeclaration);
          64                 :
          65                 :   NS_IMETHOD AppendText(nsIContent* aText,
          66                 :                         PRInt32 aStartOffset,
          67                 :                         PRInt32 aEndOffset,
          68                 :                         nsAString& aStr);
          69                 :
          70                 :   NS_IMETHOD AppendDocumentStart(nsIDocument *aDocument,
          71                 :                                  nsAString& aStr);
          72                 :
          73                 :  protected:
          74                 :
          75                 :
          76                 :   virtual bool CheckElementStart(nsIContent * aContent,
          77                 :                           bool & aForceFormat,
          78                 :                           nsAString& aStr);
          79                 :
          80                 :   virtual void AppendEndOfElementStart(nsIContent *aOriginalElement,
          81                 :                                nsIAtom * aName,
          82                 :                                PRInt32 aNamespaceID,
          83                 :                                nsAString& aStr);
          84                 :
          85                 :   virtual void AfterElementStart(nsIContent * aContent,
          86                 :                          nsIContent *aOriginalElement,
          87                 :                          nsAString& aStr);
          88                 :
          89                 :   virtual bool CheckElementEnd(nsIContent * aContent,
          90                 :                           bool & aForceFormat,
          91                 :                           nsAString& aStr);
          92                 :
          93                 :   virtual void AfterElementEnd(nsIContent * aContent,
          94                 :                                nsAString& aStr);
          95                 :
          96                 :   virtual bool LineBreakBeforeOpen(PRInt32 aNamespaceID, nsIAtom* aName);
          97                 :   virtual bool LineBreakAfterOpen(PRInt32 aNamespaceID, nsIAtom* aName);
          98                 :   virtual bool LineBreakBeforeClose(PRInt32 aNamespaceID, nsIAtom* aName);
          99                 :   virtual bool LineBreakAfterClose(PRInt32 aNamespaceID, nsIAtom* aName);
         100                 :
         101                 :   bool HasLongLines(const nsString& text, PRInt32& aLastNewlineOffset);
         102                 :
         103                 :   // functions to check if we enter in or leave from a preformated content
         104                 :   virtual void MaybeEnterInPreContent(nsIContent* aNode);
         105                 :   virtual void MaybeLeaveFromPreContent(nsIContent* aNode);
         106                 :
         107                 :   virtual void SerializeAttributes(nsIContent* aContent,
         108                 :                            nsIContent *aOriginalElement,
         109                 :                            nsAString& aTagPrefix,
         110                 :                            const nsAString& aTagNamespaceURI,
         111                 :                            nsIAtom* aTagName,
         112                 :                            nsAString& aStr,
         113                 :                            PRUint32 aSkipAttr,
         114                 :                            bool aAddNSAttr);
         115                 :
         116                 :   bool IsFirstChildOfOL(nsIContent* aElement);
         117                 :
         118                 :   void SerializeLIValueAttribute(nsIContent* aElement,
         119                 :                                  nsAString& aStr);
         120                 :   bool IsShorthandAttr(const nsIAtom* aAttrName,
         121                 :                          const nsIAtom* aElementName);
         122                 :   virtual void AppendAndTranslateEntities(const nsAString& aStr,
         123                 :                                           nsAString& aOutputStr);
         124                 :   nsresult EscapeURI(nsIContent* aContent,
         125                 :                      const nsAString& aURI,
         126                 :                      nsAString& aEscapedURI);
         127                 :
         128                 :   nsCOMPtr<nsIEntityConverter> mEntityConverter;
         129                 :
         130                 :   /*
         131                 :    * isHTMLParser should be set to true by the HTML parser which inherits from
         132                 :    * this class. It avoids to redefine methods just for few changes.
         133                 :    */
         134                 :   bool          mIsHTMLSerializer;
         135                 :
         136                 :   bool          mDoHeader;
         137                 :   bool          mIsCopying; // Set to true only while copying
         138                 :
         139                 :   /*
         140                 :    * mDisableEntityEncoding is higher than 0 while the serializer is serializing
         141                 :    * the content of a element whose content is considerd CDATA by the
         142                 :    * serializer (such elements are 'script', 'style', 'noscript' and
         143                 :    * possibly others in XHTML) This doesn't have anything to do with if the
         144                 :    * element is defined as CDATA in the DTD, it simply means we'll
         145                 :    * output the content of the element without doing any entity encoding
         146                 :    * what so ever.
         147                 :    */
         148                 :   PRInt32 mDisableEntityEncoding;
         149                 :
         150                 :   // This is to ensure that we only do meta tag fixups when dealing with
         151                 :   // whole documents.
         152                 :   bool          mRewriteEncodingDeclaration;
         153                 :
         154                 :   // To keep track of First LI child of OL in selected range
         155                 :   bool          mIsFirstChildOfOL;
         156                 :
         157                 :   // To keep track of startvalue of OL and first list item for nested lists
         158               0 :   struct olState {
         159               0 :     olState(PRInt32 aStart, bool aIsFirst)
         160                 :       : startVal(aStart),
         161               0 :         isFirstListItem(aIsFirst)
         162                 :     {
         163               0 :     }
         164                 :
         165               0 :     olState(const olState & aOlState)
         166                 :     {
         167               0 :       startVal = aOlState.startVal;
         168               0 :       isFirstListItem = aOlState.isFirstListItem;
         169               0 :     }
         170                 :
         171                 :     // the value of the start attribute in the OL
         172                 :     PRInt32 startVal;
         173                 :
         174                 :     // is true only before the serialization of the first li of an ol
         175                 :     // should be false for other li in the list
         176                 :     bool isFirstListItem;
         177                 :   };
         178                 :
         179                 :   // Stack to store one olState struct per <OL>.
         180                 :   nsAutoTArray<olState, 8> mOLStateStack;
         181                 :
         182                 :   bool HasNoChildren(nsIContent* aContent);
         183                 : };
         184                 :
         185                 : nsresult
         186                 : NS_NewXHTMLContentSerializer(nsIContentSerializer** aSerializer);
         187                 :
         188                 : #endif

Generated by: LCOV version 1.7