LCOV - code coverage report
Current view: directory - layout/base - nsLayoutDebugger.cpp (source / functions) Found Hit Coverage
Test: app.info Lines: 82 0 0.0 %
Date: 2012-06-02 Functions: 16 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                 : /*
      39                 :  * implementation of interface that allows layout-debug extension access
      40                 :  * to some internals of layout
      41                 :  */
      42                 : 
      43                 : #include "nsILayoutDebugger.h"
      44                 : #include "nsFrame.h"
      45                 : #include "nsDisplayList.h"
      46                 : #include "FrameLayerBuilder.h"
      47                 : 
      48                 : #include <stdio.h>
      49                 : 
      50                 : using namespace mozilla::layers;
      51                 : 
      52                 : #ifdef NS_DEBUG
      53                 : class nsLayoutDebugger : public nsILayoutDebugger {
      54                 : public:
      55                 :   nsLayoutDebugger();
      56                 :   virtual ~nsLayoutDebugger();
      57                 : 
      58                 :   NS_DECL_ISUPPORTS
      59                 : 
      60                 :   NS_IMETHOD SetShowFrameBorders(bool aEnable);
      61                 : 
      62                 :   NS_IMETHOD GetShowFrameBorders(bool* aResult);
      63                 : 
      64                 :   NS_IMETHOD SetShowEventTargetFrameBorder(bool aEnable);
      65                 : 
      66                 :   NS_IMETHOD GetShowEventTargetFrameBorder(bool* aResult);
      67                 : 
      68                 :   NS_IMETHOD GetContentSize(nsIDocument* aDocument,
      69                 :                             PRInt32* aSizeInBytesResult);
      70                 : 
      71                 :   NS_IMETHOD GetFrameSize(nsIPresShell* aPresentation,
      72                 :                           PRInt32* aSizeInBytesResult);
      73                 : 
      74                 :   NS_IMETHOD GetStyleSize(nsIPresShell* aPresentation,
      75                 :                           PRInt32* aSizeInBytesResult);
      76                 : 
      77                 : };
      78                 : 
      79                 : nsresult
      80               0 : NS_NewLayoutDebugger(nsILayoutDebugger** aResult)
      81                 : {
      82               0 :   NS_PRECONDITION(aResult, "null OUT ptr");
      83               0 :   if (!aResult) {
      84               0 :     return NS_ERROR_NULL_POINTER;
      85                 :   }
      86               0 :   nsLayoutDebugger* it = new nsLayoutDebugger();
      87               0 :   return it->QueryInterface(NS_GET_IID(nsILayoutDebugger), (void**)aResult);
      88                 : }
      89                 : 
      90               0 : nsLayoutDebugger::nsLayoutDebugger()
      91                 : {
      92               0 : }
      93                 : 
      94               0 : nsLayoutDebugger::~nsLayoutDebugger()
      95                 : {
      96               0 : }
      97                 : 
      98               0 : NS_IMPL_ISUPPORTS1(nsLayoutDebugger, nsILayoutDebugger)
      99                 : 
     100                 : NS_IMETHODIMP
     101               0 : nsLayoutDebugger::SetShowFrameBorders(bool aEnable)
     102                 : {
     103               0 :   nsFrame::ShowFrameBorders(aEnable);
     104               0 :   return NS_OK;
     105                 : }
     106                 : 
     107                 : NS_IMETHODIMP
     108               0 : nsLayoutDebugger::GetShowFrameBorders(bool* aResult)
     109                 : {
     110               0 :   *aResult = nsFrame::GetShowFrameBorders();
     111               0 :   return NS_OK;
     112                 : }
     113                 : 
     114                 : NS_IMETHODIMP
     115               0 : nsLayoutDebugger::SetShowEventTargetFrameBorder(bool aEnable)
     116                 : {
     117               0 :   nsFrame::ShowEventTargetFrameBorder(aEnable);
     118               0 :   return NS_OK;
     119                 : }
     120                 : 
     121                 : NS_IMETHODIMP
     122               0 : nsLayoutDebugger::GetShowEventTargetFrameBorder(bool* aResult)
     123                 : {
     124               0 :   *aResult = nsFrame::GetShowEventTargetFrameBorder();
     125               0 :   return NS_OK;
     126                 : }
     127                 : 
     128                 : NS_IMETHODIMP
     129               0 : nsLayoutDebugger::GetContentSize(nsIDocument* aDocument,
     130                 :                                  PRInt32* aSizeInBytesResult)
     131                 : {
     132               0 :   *aSizeInBytesResult = 0;
     133               0 :   return NS_ERROR_FAILURE;
     134                 : }
     135                 : 
     136                 : NS_IMETHODIMP
     137               0 : nsLayoutDebugger::GetFrameSize(nsIPresShell* aPresentation,
     138                 :                                PRInt32* aSizeInBytesResult)
     139                 : {
     140               0 :   *aSizeInBytesResult = 0;
     141               0 :   return NS_ERROR_FAILURE;
     142                 : }
     143                 : 
     144                 : NS_IMETHODIMP
     145               0 : nsLayoutDebugger::GetStyleSize(nsIPresShell* aPresentation,
     146                 :                                PRInt32* aSizeInBytesResult)
     147                 : {
     148               0 :   *aSizeInBytesResult = 0;
     149               0 :   return NS_ERROR_FAILURE;
     150                 : }
     151                 : #endif
     152                 : 
     153                 : #ifdef MOZ_DUMP_PAINTING
     154                 : static void
     155               0 : PrintDisplayListTo(nsDisplayListBuilder* aBuilder, const nsDisplayList& aList,
     156                 :                    FILE* aOutput)
     157                 : {
     158               0 :   fprintf(aOutput, "<ul>");
     159                 : 
     160               0 :   for (nsDisplayItem* i = aList.GetBottom(); i != nsnull; i = i->GetAbove()) {
     161                 : #ifdef DEBUG
     162               0 :     if (aList.DidComputeVisibility() && i->GetVisibleRect().IsEmpty())
     163               0 :       continue;
     164                 : #endif
     165               0 :     fprintf(aOutput, "<li>");
     166               0 :     nsIFrame* f = i->GetUnderlyingFrame();
     167               0 :     nsAutoString fName;
     168                 : #ifdef DEBUG
     169               0 :     if (f) {
     170               0 :       f->GetFrameName(fName);
     171                 :     }
     172                 : #endif
     173               0 :     nsRect rect = i->GetBounds(aBuilder);
     174               0 :     switch (i->GetType()) {
     175                 :       case nsDisplayItem::TYPE_CLIP:
     176                 :       case nsDisplayItem::TYPE_CLIP_ROUNDED_RECT: {
     177               0 :         nsDisplayClip* c = static_cast<nsDisplayClip*>(i);
     178               0 :         rect = c->GetClipRect();
     179               0 :         break;
     180                 :       }
     181                 :       default:
     182               0 :         break;
     183                 :     }
     184                 :     nscolor color;
     185               0 :     nsRect vis = i->GetVisibleRect();
     186               0 :     nsDisplayList* list = i->GetList();
     187               0 :     nsRegion opaque;
     188               0 :     if (i->GetType() == nsDisplayItem::TYPE_TRANSFORM) {
     189               0 :         nsDisplayTransform* t = static_cast<nsDisplayTransform*>(i);
     190               0 :         list = t->GetStoredList()->GetList();
     191                 :     }
     192                 : #ifdef DEBUG
     193               0 :     if (!list || list->DidComputeVisibility()) {
     194               0 :       opaque = i->GetOpaqueRegion(aBuilder);
     195                 :     }
     196                 : #endif
     197               0 :     if (i->Painted()) {
     198               0 :       nsCString string(i->Name());
     199               0 :       string.Append("-");
     200               0 :       string.AppendInt((PRUint64)i);
     201               0 :       fprintf(aOutput, "<a href=\"javascript:ViewImage('%s')\">", string.BeginReading());
     202                 :     }
     203                 :     fprintf(aOutput, "%s %p(%s) (%d,%d,%d,%d)(%d,%d,%d,%d)%s%s",
     204               0 :             i->Name(), (void*)f, NS_ConvertUTF16toUTF8(fName).get(),
     205                 :             rect.x, rect.y, rect.width, rect.height,
     206                 :             vis.x, vis.y, vis.width, vis.height,
     207               0 :             opaque.IsEmpty() ? "" : " opaque",
     208               0 :             i->IsUniform(aBuilder, &color) ? " uniform" : "");
     209               0 :     if (i->Painted()) {
     210               0 :       fprintf(aOutput, "</a>");
     211                 :     }
     212               0 :     if (f) {
     213               0 :       PRUint32 key = i->GetPerFrameKey();
     214               0 :       Layer* layer = aBuilder->LayerBuilder()->GetOldLayerFor(f, key);
     215               0 :       if (layer) {
     216               0 :         fprintf(aOutput, " <a href=\"#%p\">layer=%p</a>", layer, layer);
     217                 :       }
     218                 :     }
     219               0 :     if (i->GetType() == nsDisplayItem::TYPE_SVG_EFFECTS) {
     220               0 :       (static_cast<nsDisplaySVGEffects*>(i))->PrintEffects(aOutput);
     221                 :     }
     222               0 :     fputc('\n', aOutput);
     223               0 :     if (list) {
     224               0 :       PrintDisplayListTo(aBuilder, *list, aOutput);
     225                 :     }
     226               0 :     fprintf(aOutput, "</li>");
     227                 :   }
     228                 :   
     229               0 :   fprintf(aOutput, "</ul>");
     230               0 : }
     231                 : 
     232                 : void
     233               0 : nsFrame::PrintDisplayList(nsDisplayListBuilder* aBuilder,
     234                 :                           const nsDisplayList& aList,
     235                 :                           FILE* aFile)
     236                 : {
     237               0 :   PrintDisplayListTo(aBuilder, aList, aFile);
     238               0 : }
     239                 : 
     240                 : #endif

Generated by: LCOV version 1.7