LCOV - code coverage report
Current view: top level - layout/tools/layout-debug/src - nsLayoutDebugCLH.cpp (source / functions) Hit Total Coverage
Test: output.info Lines: 8 34 23.5 %
Date: 2017-07-14 16:53:18 Functions: 5 8 62.5 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : // vim:cindent:tabstop=4:expandtab:shiftwidth=4:
       3             : /* This Source Code Form is subject to the terms of the Mozilla Public
       4             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       5             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
       6             : 
       7             : #include "nsLayoutDebugCLH.h"
       8             : #include "nsArray.h"
       9             : #include "nsString.h"
      10             : #include "plstr.h"
      11             : #include "nsCOMPtr.h"
      12             : #include "nsIWindowWatcher.h"
      13             : #include "nsIServiceManager.h"
      14             : #include "nsIDOMWindow.h"
      15             : #include "nsISupportsPrimitives.h"
      16             : #include "nsICommandLine.h"
      17             : 
      18           1 : nsLayoutDebugCLH::nsLayoutDebugCLH()
      19             : {
      20           1 : }
      21             : 
      22           0 : nsLayoutDebugCLH::~nsLayoutDebugCLH()
      23             : {
      24           0 : }
      25             : 
      26          12 : NS_IMPL_ISUPPORTS(nsLayoutDebugCLH, ICOMMANDLINEHANDLER)
      27             : 
      28             : NS_IMETHODIMP
      29           1 : nsLayoutDebugCLH::Handle(nsICommandLine* aCmdLine)
      30             : {
      31             :     nsresult rv;
      32             : 
      33             :     int32_t idx;
      34           1 :     rv = aCmdLine->FindFlag(NS_LITERAL_STRING("layoutdebug"), false, &idx);
      35           1 :     NS_ENSURE_SUCCESS(rv, rv);
      36           1 :     if (idx < 0)
      37           1 :       return NS_OK;
      38             : 
      39             :     int32_t length;
      40           0 :     aCmdLine->GetLength(&length);
      41             : 
      42           0 :     nsAutoString url;
      43           0 :     if (idx + 1 < length) {
      44           0 :         rv = aCmdLine->GetArgument(idx + 1, url);
      45           0 :         NS_ENSURE_SUCCESS(rv, rv);
      46           0 :         if (!url.IsEmpty() && url.CharAt(0) == '-')
      47           0 :             url.Truncate();
      48             :     }
      49             : 
      50           0 :     aCmdLine->RemoveArguments(idx, idx + !url.IsEmpty());
      51             : 
      52           0 :     nsCOMPtr<nsIMutableArray> argsArray = nsArray::Create();
      53             : 
      54           0 :     if (!url.IsEmpty())
      55             :     {
      56             :         nsCOMPtr<nsISupportsString> scriptableURL =
      57           0 :             do_CreateInstance(NS_SUPPORTS_STRING_CONTRACTID);
      58           0 :         NS_ENSURE_TRUE(scriptableURL, NS_ERROR_FAILURE);
      59             : 
      60           0 :         scriptableURL->SetData(url);
      61           0 :         argsArray->AppendElement(scriptableURL, /*weak =*/ false);
      62             :     }
      63             : 
      64             :     nsCOMPtr<nsIWindowWatcher> wwatch =
      65           0 :         do_GetService(NS_WINDOWWATCHER_CONTRACTID);
      66           0 :     NS_ENSURE_TRUE(wwatch, NS_ERROR_FAILURE);
      67             : 
      68           0 :     nsCOMPtr<mozIDOMWindowProxy> opened;
      69           0 :     wwatch->OpenWindow(nullptr, "chrome://layoutdebug/content/",
      70             :                        "_blank", "chrome,dialog=no,all", argsArray,
      71           0 :                        getter_AddRefs(opened));
      72           0 :     aCmdLine->SetPreventDefault(true);
      73           0 :     return NS_OK;
      74             : }
      75             : 
      76             : NS_IMETHODIMP
      77           0 : nsLayoutDebugCLH::GetHelpInfo(nsACString& aResult)
      78             : {
      79           0 :     aResult.AssignLiteral("  -layoutdebug [<url>] Start with Layout Debugger\n");
      80           0 :     return NS_OK;
      81             : }
      82             : 

Generated by: LCOV version 1.13