LCOV - app.info - layout/xul/base/src/nsDocElementBoxFrame.cpp

LCOV - code coverage report
| Current view: | directory - layout/xul/base/src - nsDocElementBoxFrame.cpp (source / functions) |  | Found | Hit | Coverage |
| Test: | app.info | Lines: | 45 | 0 | 0.0 %
| Date: | 2012-06-02 | Functions: | 12 | 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                 : #include "nsHTMLParts.h"
          38                 : #include "nsContainerFrame.h"
          39                 : #include "nsCSSRendering.h"
          40                 : #include "nsIDocument.h"
          41                 : #include "nsPageFrame.h"
          42                 : #include "nsGUIEvent.h"
          43                 : #include "nsIDOMEvent.h"
          44                 : #include "nsStyleConsts.h"
          45                 : #include "nsGkAtoms.h"
          46                 : #include "nsIPresShell.h"
          47                 : #include "nsBoxFrame.h"
          48                 : #include "nsStackLayout.h"
          49                 : #include "nsIAnonymousContentCreator.h"
          50                 : #include "nsINodeInfo.h"
          51                 : #include "nsIServiceManager.h"
          52                 : #include "nsNodeInfoManager.h"
          53                 : #include "nsContentCreatorFunctions.h"
          54                 : #include "nsContentUtils.h"
          55                 :
          56                 : //#define DEBUG_REFLOW
          57                 :
          58                 : class nsDocElementBoxFrame : public nsBoxFrame,
          59                 :                              public nsIAnonymousContentCreator
          60               0 : {
          61                 : public:
          62                 :   virtual void DestroyFrom(nsIFrame* aDestructRoot);
          63                 :
          64                 :   friend nsIFrame* NS_NewBoxFrame(nsIPresShell* aPresShell,
          65                 :                                   nsStyleContext* aContext);
          66                 :
          67               0 :   nsDocElementBoxFrame(nsIPresShell* aShell, nsStyleContext* aContext)
          68               0 :     :nsBoxFrame(aShell, aContext, true) {}
          69                 :
          70                 :   NS_DECL_QUERYFRAME
          71                 :   NS_DECL_FRAMEARENA_HELPERS
          72                 :
          73                 :   // nsIAnonymousContentCreator
          74                 :   virtual nsresult CreateAnonymousContent(nsTArray<ContentInfo>& aElements);
          75                 :   virtual void AppendAnonymousContentTo(nsBaseContentList& aElements,
          76                 :                                         PRUint32 aFilter);
          77                 :
          78               0 :   virtual bool IsFrameOfType(PRUint32 aFlags) const
          79                 :   {
          80                 :     // Override nsBoxFrame.
          81               0 :     if (aFlags & (nsIFrame::eReplacedContainsBlock | nsIFrame::eReplaced))
          82               0 :       return false;
          83               0 :     return nsBoxFrame::IsFrameOfType(aFlags);
          84                 :   }
          85                 :
          86                 : #ifdef DEBUG
          87                 :   NS_IMETHOD GetFrameName(nsAString& aResult) const;
          88                 : #endif
          89                 : private:
          90                 :   nsCOMPtr<nsIContent> mPopupgroupContent;
          91                 :   nsCOMPtr<nsIContent> mTooltipContent;
          92                 : };
          93                 :
          94                 : //----------------------------------------------------------------------
          95                 :
          96                 : nsIFrame*
          97               0 : NS_NewDocElementBoxFrame(nsIPresShell* aPresShell, nsStyleContext* aContext)
          98                 : {
          99               0 :   return new (aPresShell) nsDocElementBoxFrame (aPresShell, aContext);
         100                 : }
         101                 :
         102               0 : NS_IMPL_FRAMEARENA_HELPERS(nsDocElementBoxFrame)
         103                 :
         104                 : void
         105               0 : nsDocElementBoxFrame::DestroyFrom(nsIFrame* aDestructRoot)
         106                 : {
         107               0 :   nsContentUtils::DestroyAnonymousContent(&mPopupgroupContent);
         108               0 :   nsContentUtils::DestroyAnonymousContent(&mTooltipContent);
         109               0 :   nsBoxFrame::DestroyFrom(aDestructRoot);
         110               0 : }
         111                 :
         112                 : nsresult
         113               0 : nsDocElementBoxFrame::CreateAnonymousContent(nsTArray<ContentInfo>& aElements)
         114                 : {
         115               0 :   nsIDocument* doc = mContent->GetDocument();
         116               0 :   if (!doc) {
         117                 :     // The page is currently being torn down.  Why bother.
         118               0 :     return NS_ERROR_FAILURE;
         119                 :   }
         120               0 :   nsNodeInfoManager *nodeInfoManager = doc->NodeInfoManager();
         121                 :
         122                 :   // create the top-secret popupgroup node. shhhhh!
         123               0 :   nsCOMPtr<nsINodeInfo> nodeInfo;
         124                 :   nodeInfo = nodeInfoManager->GetNodeInfo(nsGkAtoms::popupgroup,
         125                 :                                           nsnull, kNameSpaceID_XUL,
         126               0 :                                           nsIDOMNode::ELEMENT_NODE);
         127               0 :   NS_ENSURE_TRUE(nodeInfo, NS_ERROR_OUT_OF_MEMORY);
         128                 :
         129               0 :   nsresult rv = NS_NewXULElement(getter_AddRefs(mPopupgroupContent),
         130               0 :                                  nodeInfo.forget());
         131               0 :   NS_ENSURE_SUCCESS(rv, rv);
         132                 :
         133               0 :   if (!aElements.AppendElement(mPopupgroupContent))
         134               0 :     return NS_ERROR_OUT_OF_MEMORY;
         135                 :
         136                 :   // create the top-secret default tooltip node. shhhhh!
         137                 :   nodeInfo = nodeInfoManager->GetNodeInfo(nsGkAtoms::tooltip, nsnull,
         138                 :                                           kNameSpaceID_XUL,
         139               0 :                                           nsIDOMNode::ELEMENT_NODE);
         140               0 :   NS_ENSURE_TRUE(nodeInfo, NS_ERROR_OUT_OF_MEMORY);
         141                 :
         142               0 :   rv = NS_NewXULElement(getter_AddRefs(mTooltipContent), nodeInfo.forget());
         143               0 :   NS_ENSURE_SUCCESS(rv, rv);
         144                 :
         145                 :   mTooltipContent->SetAttr(nsnull, nsGkAtoms::_default,
         146               0 :                            NS_LITERAL_STRING("true"), false);
         147                 :
         148               0 :   if (!aElements.AppendElement(mTooltipContent))
         149               0 :     return NS_ERROR_OUT_OF_MEMORY;
         150                 :
         151               0 :   return NS_OK;
         152                 : }
         153                 :
         154                 : void
         155               0 : nsDocElementBoxFrame::AppendAnonymousContentTo(nsBaseContentList& aElements,
         156                 :                                                PRUint32 aFilter)
         157                 : {
         158               0 :   aElements.MaybeAppendElement(mPopupgroupContent);
         159               0 :   aElements.MaybeAppendElement(mTooltipContent);
         160               0 : }
         161                 :
         162               0 : NS_QUERYFRAME_HEAD(nsDocElementBoxFrame)
         163               0 :   NS_QUERYFRAME_ENTRY(nsIAnonymousContentCreator)
         164               0 : NS_QUERYFRAME_TAIL_INHERITING(nsBoxFrame)
         165                 :
         166                 : #ifdef DEBUG
         167                 : NS_IMETHODIMP
         168               0 : nsDocElementBoxFrame::GetFrameName(nsAString& aResult) const
         169                 : {
         170               0 :   return MakeFrameName(NS_LITERAL_STRING("DocElementBox"), aResult);
         171                 : }
         172                 : #endif

Generated by: LCOV version 1.7