LCOV - code coverage report
Current view: top level - layout/style - CSS.cpp (source / functions) Hit Total Coverage
Test: output.info Lines: 0 38 0.0 %
Date: 2017-07-14 16:53:18 Functions: 0 4 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
       2             : /* This Source Code Form is subject to the terms of the Mozilla Public
       3             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       4             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
       5             : 
       6             : /* DOM object holding utility CSS functions */
       7             : 
       8             : #include "CSS.h"
       9             : 
      10             : #include "mozilla/dom/BindingDeclarations.h"
      11             : #include "mozilla/ServoBindings.h"
      12             : #include "nsCSSParser.h"
      13             : #include "nsGlobalWindow.h"
      14             : #include "nsIDocument.h"
      15             : #include "nsIURI.h"
      16             : #include "nsStyleUtil.h"
      17             : #include "xpcpublic.h"
      18             : 
      19             : namespace mozilla {
      20             : namespace dom {
      21             : 
      22             : struct SupportsParsingInfo
      23             : {
      24             :   nsIURI* mDocURI;
      25             :   nsIURI* mBaseURI;
      26             :   nsIPrincipal* mPrincipal;
      27             :   StyleBackendType mStyleBackendType;
      28             : };
      29             : 
      30             : static nsresult
      31           0 : GetParsingInfo(const GlobalObject& aGlobal,
      32             :                SupportsParsingInfo& aInfo)
      33             : {
      34           0 :   nsGlobalWindow* win = xpc::WindowOrNull(aGlobal.Get());
      35           0 :   if (!win) {
      36           0 :     return NS_ERROR_FAILURE;
      37             :   }
      38             : 
      39           0 :   nsCOMPtr<nsIDocument> doc = win->GetDoc();
      40           0 :   if (!doc) {
      41           0 :     return NS_ERROR_FAILURE;
      42             :   }
      43             : 
      44           0 :   aInfo.mDocURI = nsCOMPtr<nsIURI>(doc->GetDocumentURI()).get();
      45           0 :   aInfo.mBaseURI = nsCOMPtr<nsIURI>(doc->GetBaseURI()).get();
      46           0 :   aInfo.mPrincipal = win->GetPrincipal();
      47           0 :   aInfo.mStyleBackendType = doc->GetStyleBackendType();
      48           0 :   return NS_OK;
      49             : }
      50             : 
      51             : /* static */ bool
      52           0 : CSS::Supports(const GlobalObject& aGlobal,
      53             :               const nsAString& aProperty,
      54             :               const nsAString& aValue,
      55             :               ErrorResult& aRv)
      56             : {
      57             :   SupportsParsingInfo info;
      58             : 
      59           0 :   nsresult rv = GetParsingInfo(aGlobal, info);
      60           0 :   if (NS_FAILED(rv)) {
      61           0 :     aRv.Throw(rv);
      62           0 :     return false;
      63             :   }
      64             : 
      65           0 :   if (info.mStyleBackendType == StyleBackendType::Servo) {
      66           0 :     NS_ConvertUTF16toUTF8 property(aProperty);
      67           0 :     NS_ConvertUTF16toUTF8 value(aValue);
      68           0 :     return Servo_CSSSupports2(&property, &value);
      69             :   }
      70             : 
      71           0 :   nsCSSParser parser;
      72           0 :   return parser.EvaluateSupportsDeclaration(aProperty, aValue, info.mDocURI,
      73           0 :                                             info.mBaseURI, info.mPrincipal);
      74             : }
      75             : 
      76             : /* static */ bool
      77           0 : CSS::Supports(const GlobalObject& aGlobal,
      78             :               const nsAString& aCondition,
      79             :               ErrorResult& aRv)
      80             : {
      81             :   SupportsParsingInfo info;
      82             : 
      83           0 :   nsresult rv = GetParsingInfo(aGlobal, info);
      84           0 :   if (NS_FAILED(rv)) {
      85           0 :     aRv.Throw(rv);
      86           0 :     return false;
      87             :   }
      88             : 
      89           0 :   if (info.mStyleBackendType == StyleBackendType::Servo) {
      90           0 :     NS_ConvertUTF16toUTF8 cond(aCondition);
      91           0 :     return Servo_CSSSupports(&cond);
      92             :   }
      93             : 
      94           0 :   nsCSSParser parser;
      95           0 :   return parser.EvaluateSupportsCondition(aCondition, info.mDocURI,
      96             :                                           info.mBaseURI, info.mPrincipal,
      97           0 :                                           css::SupportsParsingSettings::ImpliedParentheses);
      98             : }
      99             : 
     100             : /* static */ void
     101           0 : CSS::Escape(const GlobalObject& aGlobal,
     102             :             const nsAString& aIdent,
     103             :             nsAString& aReturn)
     104             : {
     105           0 :   nsStyleUtil::AppendEscapedCSSIdent(aIdent, aReturn);
     106           0 : }
     107             : 
     108             : } // namespace dom
     109             : } // namespace mozilla

Generated by: LCOV version 1.13