LCOV - code coverage report
Current view: directory - layout/tools/layout-debug/src - nsLayoutDebugCLH.cpp (source / functions) Found Hit Coverage
Test: app.info Lines: 35 10 28.6 %
Date: 2012-06-02 Functions: 8 7 87.5 %

       1                 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 : // vim:cindent:tabstop=4:expandtab:shiftwidth=4:
       3                 : /* ***** BEGIN LICENSE BLOCK *****
       4                 :  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
       5                 :  *
       6                 :  * The contents of this file are subject to the Mozilla Public License Version
       7                 :  * 1.1 (the "License"); you may not use this file except in compliance with
       8                 :  * the License. You may obtain a copy of the License at
       9                 :  * http://www.mozilla.org/MPL/
      10                 :  *
      11                 :  * Software distributed under the License is distributed on an "AS IS" basis,
      12                 :  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
      13                 :  * for the specific language governing rights and limitations under the
      14                 :  * License.
      15                 :  *
      16                 :  * The Original Code is layout debugging code.
      17                 :  *
      18                 :  * The Initial Developer of the Original Code is 
      19                 :  * Netscape Communications Corporation.
      20                 :  * Portions created by the Initial Developer are Copyright (C) 2003
      21                 :  * the Initial Developer. All Rights Reserved.
      22                 :  *
      23                 :  * Contributor(s):
      24                 :  *   L. David Baron <dbaron@dbaron.org> (original author)
      25                 :  *
      26                 :  * Alternatively, the contents of this file may be used under the terms of
      27                 :  * either the GNU General Public License Version 2 or later (the "GPL"), or
      28                 :  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
      29                 :  * in which case the provisions of the GPL or the LGPL are applicable instead
      30                 :  * of those above. If you wish to allow use of your version of this file only
      31                 :  * under the terms of either the GPL or the LGPL, and not to allow others to
      32                 :  * use your version of this file under the terms of the MPL, indicate your
      33                 :  * decision by deleting the provisions above and replace them with the notice
      34                 :  * and other provisions required by the GPL or the LGPL. If you do not delete
      35                 :  * the provisions above, a recipient may use your version of this file under
      36                 :  * the terms of any one of the MPL, the GPL or the LGPL.
      37                 :  *
      38                 :  * ***** END LICENSE BLOCK ***** */
      39                 : 
      40                 : #include "nsLayoutDebugCLH.h"
      41                 : #include "nsString.h"
      42                 : #include "plstr.h"
      43                 : #include "nsCOMPtr.h"
      44                 : #include "nsIWindowWatcher.h"
      45                 : #include "nsIServiceManager.h"
      46                 : #include "nsIDOMWindow.h"
      47                 : #include "nsISupportsArray.h"
      48                 : #include "nsISupportsPrimitives.h"
      49                 : #include "nsICommandLine.h"
      50                 : 
      51               2 : nsLayoutDebugCLH::nsLayoutDebugCLH()
      52                 : {
      53               2 : }
      54                 : 
      55               4 : nsLayoutDebugCLH::~nsLayoutDebugCLH()
      56                 : {
      57               8 : }
      58                 : 
      59              42 : NS_IMPL_ISUPPORTS1(nsLayoutDebugCLH, ICOMMANDLINEHANDLER)
      60                 : 
      61                 : NS_IMETHODIMP
      62               2 : nsLayoutDebugCLH::Handle(nsICommandLine* aCmdLine)
      63                 : {
      64                 :     nsresult rv;
      65                 : 
      66                 :     PRInt32 idx;
      67               2 :     rv = aCmdLine->FindFlag(NS_LITERAL_STRING("layoutdebug"), false, &idx);
      68               2 :     NS_ENSURE_SUCCESS(rv, rv);
      69               2 :     if (idx < 0)
      70               2 :       return NS_OK;
      71                 : 
      72                 :     PRInt32 length;
      73               0 :     aCmdLine->GetLength(&length);
      74                 : 
      75               0 :     nsAutoString url;
      76               0 :     if (idx + 1 < length) {
      77               0 :         rv = aCmdLine->GetArgument(idx + 1, url);
      78               0 :         NS_ENSURE_SUCCESS(rv, rv);
      79               0 :         if (!url.IsEmpty() && url.CharAt(0) == '-')
      80               0 :             url.Truncate();
      81                 :     }
      82                 : 
      83               0 :     aCmdLine->RemoveArguments(idx, idx + !url.IsEmpty());
      84                 : 
      85                 :     nsCOMPtr<nsISupportsArray> argsArray =
      86               0 :         do_CreateInstance(NS_SUPPORTSARRAY_CONTRACTID, &rv);
      87               0 :     NS_ENSURE_SUCCESS(rv, rv);
      88                 : 
      89               0 :     if (!url.IsEmpty())
      90                 :     {
      91                 :         nsCOMPtr<nsISupportsString> scriptableURL =
      92               0 :             do_CreateInstance(NS_SUPPORTS_STRING_CONTRACTID);
      93               0 :         NS_ENSURE_TRUE(scriptableURL, NS_ERROR_FAILURE);
      94                 :   
      95               0 :         scriptableURL->SetData(url);
      96               0 :         argsArray->AppendElement(scriptableURL);
      97                 :     }
      98                 : 
      99                 :     nsCOMPtr<nsIWindowWatcher> wwatch =
     100               0 :         do_GetService(NS_WINDOWWATCHER_CONTRACTID);
     101               0 :     NS_ENSURE_TRUE(wwatch, NS_ERROR_FAILURE);
     102                 : 
     103               0 :     nsCOMPtr<nsIDOMWindow> opened;
     104               0 :     wwatch->OpenWindow(nsnull, "chrome://layoutdebug/content/",
     105                 :                        "_blank", "chrome,dialog=no,all", argsArray,
     106               0 :                        getter_AddRefs(opened));
     107               0 :     aCmdLine->SetPreventDefault(true);
     108               0 :     return NS_OK;
     109                 : }
     110                 : 
     111                 : NS_IMETHODIMP
     112               0 : nsLayoutDebugCLH::GetHelpInfo(nsACString& aResult)
     113                 : {
     114               0 :     aResult.Assign(NS_LITERAL_CSTRING("  -layoutdebug [<url>] Start with Layout Debugger\n"));
     115               0 :     return NS_OK;
     116                 : }
     117                 : 

Generated by: LCOV version 1.7