LCOV - code coverage report
Current view: directory - editor/libeditor/text - nsTextEditUtils.cpp (source / functions) Found Hit Coverage
Test: app.info Lines: 26 0 0.0 %
Date: 2012-06-02 Functions: 7 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                 :  *
      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                 : #include "nsTextEditUtils.h"
      39                 : 
      40                 : #include "mozilla/dom/Element.h"
      41                 : 
      42                 : #include "nsEditor.h"
      43                 : #include "nsPlaintextEditor.h"
      44                 : #include "nsEditProperty.h"
      45                 : 
      46                 : using namespace mozilla;
      47                 : 
      48                 : ///////////////////////////////////////////////////////////////////////////
      49                 : // IsBody: true if node an html body node
      50                 : //                  
      51                 : // Would use NodeIsType and the corresponding atom, but
      52                 : // the atom list isn't generationed in a plaintext-only
      53                 : // configured build.
      54                 : bool 
      55               0 : nsTextEditUtils::IsBody(nsIDOMNode *node)
      56                 : {
      57               0 :   return nsEditor::NodeIsTypeString(node, NS_LITERAL_STRING("body"));
      58                 : }
      59                 : 
      60                 : 
      61                 : ///////////////////////////////////////////////////////////////////////////
      62                 : // IsBreak: true if node an html break node
      63                 : //                  
      64                 : // See previous comment regarding NodeisType
      65                 : bool 
      66               0 : nsTextEditUtils::IsBreak(nsIDOMNode *node)
      67                 : {
      68               0 :   return nsEditor::NodeIsTypeString(node, NS_LITERAL_STRING("br"));
      69                 : }
      70                 : 
      71                 : 
      72                 : ///////////////////////////////////////////////////////////////////////////
      73                 : // IsMozBR: true if node an html br node with type = _moz
      74                 : //                  
      75                 : bool 
      76               0 : nsTextEditUtils::IsMozBR(nsIDOMNode *node)
      77                 : {
      78               0 :   NS_PRECONDITION(node, "null node passed to nsHTMLEditUtils::IsMozBR");
      79               0 :   return IsBreak(node) && HasMozAttr(node);
      80                 : }
      81                 : 
      82                 : 
      83                 : bool
      84               0 : nsTextEditUtils::IsMozBR(dom::Element* aNode)
      85                 : {
      86               0 :   MOZ_ASSERT(aNode);
      87               0 :   return aNode->IsHTML(nsGkAtoms::br) &&
      88                 :          aNode->AttrValueIs(kNameSpaceID_None, nsGkAtoms::type,
      89               0 :                             NS_LITERAL_STRING("_moz"), eIgnoreCase);
      90                 : }
      91                 : 
      92                 : ///////////////////////////////////////////////////////////////////////////
      93                 : // HasMozAttr: true if node has type attribute = _moz
      94                 : //             (used to indicate the div's and br's we use in
      95                 : //              mail compose rules)
      96                 : //                  
      97                 : bool 
      98               0 : nsTextEditUtils::HasMozAttr(nsIDOMNode *node)
      99                 : {
     100               0 :   NS_PRECONDITION(node, "null parent passed to nsHTMLEditUtils::HasMozAttr");
     101               0 :   nsCOMPtr<nsIDOMElement> elem = do_QueryInterface(node);
     102               0 :   if (elem)
     103                 :   {
     104               0 :     nsAutoString typeAttrVal;
     105               0 :     nsresult res = elem->GetAttribute(NS_LITERAL_STRING("type"), typeAttrVal);
     106               0 :     if (NS_SUCCEEDED(res) && (typeAttrVal.LowerCaseEqualsLiteral("_moz")))
     107               0 :       return true;
     108                 :   }
     109               0 :   return false;
     110                 : }
     111                 : 
     112                 : 
     113                 : ///////////////////////////////////////////////////////////////////////////
     114                 : // nsAutoEditInitRulesTrigger methods
     115                 : //
     116               0 : nsAutoEditInitRulesTrigger::nsAutoEditInitRulesTrigger( nsPlaintextEditor *aEd, nsresult &aRes) : mEd(aEd), mRes(aRes)
     117                 : {
     118               0 :     if (mEd) mEd->BeginEditorInit();
     119               0 : }
     120                 : 
     121               0 : nsAutoEditInitRulesTrigger::~nsAutoEditInitRulesTrigger()
     122                 : {
     123               0 :     if (mEd) mRes = mEd->EndEditorInit();
     124               0 : }
     125                 : 

Generated by: LCOV version 1.7