LCOV - code coverage report
Current view: top level - layout/style - StyleSetHandleInlines.h (source / functions) Hit Total Coverage
Test: output.info Lines: 67 104 64.4 %
Date: 2017-07-14 16:53:18 Functions: 28 41 68.3 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
       2             : /* vim: set ts=8 sts=2 et sw=2 tw=80: */
       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             : #ifndef mozilla_StyleSetHandleInlines_h
       8             : #define mozilla_StyleSetHandleInlines_h
       9             : 
      10             : #include "mozilla/StyleSheetInlines.h"
      11             : #include "mozilla/ServoStyleSet.h"
      12             : #include "nsStyleSet.h"
      13             : 
      14             : #define FORWARD_CONCRETE(method_, geckoargs_, servoargs_) \
      15             :   if (IsGecko()) { \
      16             :     return AsGecko()->method_ geckoargs_; \
      17             :   } else { \
      18             :     return AsServo()->method_ servoargs_; \
      19             :   }
      20             : 
      21             : #define FORWARD(method_, args_) FORWARD_CONCRETE(method_, args_, args_)
      22             : 
      23             : namespace mozilla {
      24             : 
      25             : void
      26           4 : StyleSetHandle::Ptr::Delete()
      27             : {
      28           4 :   if (mValue) {
      29           4 :     if (IsGecko()) {
      30           4 :       delete AsGecko();
      31             :     } else {
      32           0 :       delete AsServo();
      33             :     }
      34             :   }
      35           4 : }
      36             : 
      37             : void
      38          28 : StyleSetHandle::Ptr::Init(nsPresContext* aPresContext,
      39             :                           nsBindingManager* aBindingManager)
      40             : {
      41          28 :   FORWARD(Init, (aPresContext, aBindingManager));
      42             : }
      43             : 
      44             : void
      45           4 : StyleSetHandle::Ptr::BeginShutdown()
      46             : {
      47           4 :   FORWARD(BeginShutdown, ());
      48             : }
      49             : 
      50             : void
      51           4 : StyleSetHandle::Ptr::Shutdown()
      52             : {
      53           4 :   FORWARD(Shutdown, ());
      54             : }
      55             : 
      56             : bool
      57          10 : StyleSetHandle::Ptr::GetAuthorStyleDisabled() const
      58             : {
      59          10 :   FORWARD(GetAuthorStyleDisabled, ());
      60             : }
      61             : 
      62             : nsresult
      63           0 : StyleSetHandle::Ptr::SetAuthorStyleDisabled(bool aStyleDisabled)
      64             : {
      65           0 :   FORWARD(SetAuthorStyleDisabled, (aStyleDisabled));
      66             : }
      67             : 
      68             : void
      69          93 : StyleSetHandle::Ptr::BeginUpdate()
      70             : {
      71          93 :   FORWARD(BeginUpdate, ());
      72             : }
      73             : 
      74             : nsresult
      75          93 : StyleSetHandle::Ptr::EndUpdate()
      76             : {
      77          93 :   FORWARD(EndUpdate, ());
      78             : }
      79             : 
      80             : // resolve a style context
      81             : already_AddRefed<nsStyleContext>
      82         299 : StyleSetHandle::Ptr::ResolveStyleFor(dom::Element* aElement,
      83             :                                      nsStyleContext* aParentContext,
      84             :                                      LazyComputeBehavior aMayCompute)
      85             : {
      86         299 :   FORWARD(ResolveStyleFor, (aElement, aParentContext, aMayCompute));
      87             : }
      88             : 
      89             : already_AddRefed<nsStyleContext>
      90         878 : StyleSetHandle::Ptr::ResolveStyleFor(dom::Element* aElement,
      91             :                                      nsStyleContext* aParentContext,
      92             :                                      LazyComputeBehavior aMayCompute,
      93             :                                      TreeMatchContext* aTreeMatchContext)
      94             : {
      95         878 :   if (IsGecko()) {
      96         878 :     MOZ_ASSERT(aTreeMatchContext);
      97         878 :     return AsGecko()->ResolveStyleFor(aElement, aParentContext, aMayCompute, *aTreeMatchContext);
      98             :   } else {
      99           0 :     return AsServo()->ResolveStyleFor(aElement, aParentContext, aMayCompute);
     100             :   }
     101             : }
     102             : 
     103             : already_AddRefed<nsStyleContext>
     104         181 : StyleSetHandle::Ptr::ResolveStyleForText(nsIContent* aTextNode,
     105             :                                          nsStyleContext* aParentContext)
     106             : {
     107         181 :   FORWARD(ResolveStyleForText, (aTextNode, aParentContext));
     108             : }
     109             : 
     110             : already_AddRefed<nsStyleContext>
     111          35 : StyleSetHandle::Ptr::ResolveStyleForPlaceholder()
     112             : {
     113          35 :   FORWARD(ResolveStyleForPlaceholder, ());
     114             : }
     115             : 
     116             : already_AddRefed<nsStyleContext>
     117           0 : StyleSetHandle::Ptr::ResolveStyleForFirstLetterContinuation(nsStyleContext* aParentContext)
     118             : {
     119           0 :   FORWARD(ResolveStyleForFirstLetterContinuation, (aParentContext));
     120             : }
     121             : 
     122             : already_AddRefed<nsStyleContext>
     123           4 : StyleSetHandle::Ptr::ResolvePseudoElementStyle(dom::Element* aParentElement,
     124             :                                                CSSPseudoElementType aType,
     125             :                                                nsStyleContext* aParentContext,
     126             :                                                dom::Element* aPseudoElement)
     127             : {
     128           4 :   FORWARD(ResolvePseudoElementStyle, (aParentElement, aType, aParentContext,
     129             :                                       aPseudoElement));
     130             : }
     131             : 
     132             : already_AddRefed<nsStyleContext>
     133         144 : StyleSetHandle::Ptr::ResolveInheritingAnonymousBoxStyle(nsIAtom* aPseudoTag,
     134             :                                                         nsStyleContext* aParentContext)
     135             : {
     136         144 :   FORWARD(ResolveInheritingAnonymousBoxStyle, (aPseudoTag, aParentContext));
     137             : }
     138             : 
     139             : already_AddRefed<nsStyleContext>
     140           0 : StyleSetHandle::Ptr::ResolveNonInheritingAnonymousBoxStyle(nsIAtom* aPseudoTag)
     141             : {
     142           0 :   FORWARD(ResolveNonInheritingAnonymousBoxStyle, (aPseudoTag));
     143             : }
     144             : 
     145             : // manage the set of style sheets in the style set
     146             : nsresult
     147          17 : StyleSetHandle::Ptr::AppendStyleSheet(SheetType aType, StyleSheet* aSheet)
     148             : {
     149          17 :   FORWARD_CONCRETE(AppendStyleSheet, (aType, aSheet->AsGecko()),
     150             :                                      (aType, aSheet->AsServo()));
     151             : }
     152             : 
     153             : nsresult
     154          93 : StyleSetHandle::Ptr::PrependStyleSheet(SheetType aType, StyleSheet* aSheet)
     155             : {
     156          93 :   FORWARD_CONCRETE(PrependStyleSheet, (aType, aSheet->AsGecko()),
     157             :                                       (aType, aSheet->AsServo()));
     158             : }
     159             : 
     160             : nsresult
     161           2 : StyleSetHandle::Ptr::RemoveStyleSheet(SheetType aType, StyleSheet* aSheet)
     162             : {
     163           2 :   FORWARD_CONCRETE(RemoveStyleSheet, (aType, aSheet->AsGecko()),
     164             :                                      (aType, aSheet->AsServo()));
     165             : }
     166             : 
     167             : nsresult
     168           0 : StyleSetHandle::Ptr::ReplaceSheets(SheetType aType,
     169             :                        const nsTArray<RefPtr<StyleSheet>>& aNewSheets)
     170             : {
     171           0 :   if (IsGecko()) {
     172           0 :     nsTArray<RefPtr<CSSStyleSheet>> newSheets(aNewSheets.Length());
     173           0 :     for (auto& sheet : aNewSheets) {
     174           0 :       newSheets.AppendElement(sheet->AsGecko());
     175             :     }
     176           0 :     return AsGecko()->ReplaceSheets(aType, newSheets);
     177             :   } else {
     178           0 :     nsTArray<RefPtr<ServoStyleSheet>> newSheets(aNewSheets.Length());
     179           0 :     for (auto& sheet : aNewSheets) {
     180           0 :       newSheets.AppendElement(sheet->AsServo());
     181             :     }
     182           0 :     return AsServo()->ReplaceSheets(aType, newSheets);
     183             :   }
     184             : }
     185             : 
     186             : nsresult
     187           0 : StyleSetHandle::Ptr::InsertStyleSheetBefore(SheetType aType,
     188             :                                 StyleSheet* aNewSheet,
     189             :                                 StyleSheet* aReferenceSheet)
     190             : {
     191           0 :   FORWARD_CONCRETE(
     192             :     InsertStyleSheetBefore,
     193             :     (aType, aNewSheet->AsGecko(), aReferenceSheet->AsGecko()),
     194             :     (aType, aNewSheet->AsServo(), aReferenceSheet->AsServo()));
     195             : }
     196             : 
     197             : int32_t
     198          28 : StyleSetHandle::Ptr::SheetCount(SheetType aType) const
     199             : {
     200          28 :   FORWARD(SheetCount, (aType));
     201             : }
     202             : 
     203             : StyleSheet*
     204           0 : StyleSetHandle::Ptr::StyleSheetAt(SheetType aType, int32_t aIndex) const
     205             : {
     206           0 :   FORWARD(StyleSheetAt, (aType, aIndex));
     207             : }
     208             : 
     209             : void
     210           0 : StyleSetHandle::Ptr::AppendAllXBLStyleSheets(nsTArray<StyleSheet*>& aArray) const
     211             : {
     212           0 :   FORWARD(AppendAllXBLStyleSheets, (aArray));
     213             : }
     214             : 
     215             : nsresult
     216           0 : StyleSetHandle::Ptr::RemoveDocStyleSheet(StyleSheet* aSheet)
     217             : {
     218           0 :   FORWARD_CONCRETE(RemoveDocStyleSheet, (aSheet->AsGecko()),
     219             :                                         (aSheet->AsServo()));
     220             : }
     221             : 
     222             : nsresult
     223          11 : StyleSetHandle::Ptr::AddDocStyleSheet(StyleSheet* aSheet,
     224             :                                       nsIDocument* aDocument)
     225             : {
     226          11 :   FORWARD_CONCRETE(AddDocStyleSheet, (aSheet->AsGecko(), aDocument),
     227             :                                      (aSheet->AsServo(), aDocument));
     228             : }
     229             : 
     230             : void
     231          48 : StyleSetHandle::Ptr::RecordStyleSheetChange(StyleSheet* aSheet,
     232             :                                             StyleSheet::ChangeType aChangeType)
     233             : {
     234          48 :   FORWARD_CONCRETE(RecordStyleSheetChange, (aSheet->AsGecko(), aChangeType),
     235             :                                            (aSheet->AsServo(), aChangeType));
     236             : }
     237             : 
     238             : void
     239           0 : StyleSetHandle::Ptr::RecordShadowStyleChange(mozilla::dom::ShadowRoot* aShadowRoot)
     240             : {
     241           0 :   FORWARD(RecordShadowStyleChange, (aShadowRoot));
     242             : }
     243             : 
     244             : bool
     245          62 : StyleSetHandle::Ptr::StyleSheetsHaveChanged() const
     246             : {
     247          62 :   FORWARD(StyleSheetsHaveChanged, ());
     248             : }
     249             : bool
     250          21 : StyleSetHandle::Ptr::MediumFeaturesChanged()
     251             : {
     252          21 :   FORWARD(MediumFeaturesChanged, ());
     253             : }
     254             : void
     255          23 : StyleSetHandle::Ptr::InvalidateStyleForCSSRuleChanges()
     256             : {
     257          23 :   FORWARD(InvalidateStyleForCSSRuleChanges, ());
     258             : }
     259             : 
     260             : // check whether there is ::before/::after style for an element
     261             : already_AddRefed<nsStyleContext>
     262         797 : StyleSetHandle::Ptr::ProbePseudoElementStyle(dom::Element* aParentElement,
     263             :                                              CSSPseudoElementType aType,
     264             :                                              nsStyleContext* aParentContext)
     265             : {
     266         797 :   FORWARD(ProbePseudoElementStyle, (aParentElement, aType, aParentContext));
     267             : }
     268             : 
     269             : already_AddRefed<nsStyleContext>
     270         460 : StyleSetHandle::Ptr::ProbePseudoElementStyle(dom::Element* aParentElement,
     271             :                                              CSSPseudoElementType aType,
     272             :                                              nsStyleContext* aParentContext,
     273             :                                              TreeMatchContext* aTreeMatchContext)
     274             : {
     275         460 :   if (IsGecko()) {
     276         460 :     MOZ_ASSERT(aTreeMatchContext);
     277             :     return AsGecko()->ProbePseudoElementStyle(aParentElement, aType, aParentContext,
     278         460 :                                               *aTreeMatchContext);
     279             :   }
     280           0 :   return AsServo()->ProbePseudoElementStyle(aParentElement, aType, aParentContext);
     281             : }
     282             : 
     283             : nsRestyleHint
     284          51 : StyleSetHandle::Ptr::HasStateDependentStyle(dom::Element* aElement,
     285             :                                             EventStates aStateMask)
     286             : {
     287          51 :   FORWARD(HasStateDependentStyle, (aElement, aStateMask));
     288             : }
     289             : 
     290             : nsRestyleHint
     291           0 : StyleSetHandle::Ptr::HasStateDependentStyle(dom::Element* aElement,
     292             :                                             CSSPseudoElementType aPseudoType,
     293             :                                             dom::Element* aPseudoElement,
     294             :                                             EventStates aStateMask)
     295             : {
     296           0 :   FORWARD(HasStateDependentStyle, (aElement, aPseudoType, aPseudoElement,
     297             :                                    aStateMask));
     298             : }
     299             : 
     300             : void
     301         308 : StyleSetHandle::Ptr::RootStyleContextAdded()
     302             : {
     303         308 :   if (IsGecko()) {
     304         308 :     AsGecko()->RootStyleContextAdded();
     305             :   } else {
     306             :     // Not needed.
     307             :   }
     308         308 : }
     309             : 
     310             : void
     311         121 : StyleSetHandle::Ptr::RootStyleContextRemoved()
     312             : {
     313         121 :   if (IsGecko()) {
     314         121 :     RootStyleContextAdded();
     315             :   } else {
     316             :     // Not needed.
     317             :   }
     318         121 : }
     319             : 
     320             : bool
     321           9 : StyleSetHandle::Ptr::
     322             : AppendFontFaceRules(nsTArray<nsFontFaceRuleContainer>& aArray)
     323             : {
     324           9 :   FORWARD(AppendFontFaceRules, (aArray));
     325             : }
     326             : 
     327             : nsCSSCounterStyleRule*
     328           0 : StyleSetHandle::Ptr::CounterStyleRuleForName(nsIAtom* aName)
     329             : {
     330           0 :   FORWARD(CounterStyleRuleForName, (aName));
     331             : }
     332             : 
     333             : bool
     334           0 : StyleSetHandle::Ptr::EnsureUniqueInnerOnCSSSheets()
     335             : {
     336           0 :   FORWARD(EnsureUniqueInnerOnCSSSheets, ());
     337             : }
     338             : 
     339             : void
     340           0 : StyleSetHandle::Ptr::SetNeedsRestyleAfterEnsureUniqueInner()
     341             : {
     342           0 :   FORWARD(SetNeedsRestyleAfterEnsureUniqueInner, ());
     343             : }
     344             : 
     345             : } // namespace mozilla
     346             : 
     347             : #undef FORWARD
     348             : 
     349             : #endif // mozilla_StyleSetHandleInlines_h

Generated by: LCOV version 1.13