1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 2 /* vim: set ts=2 et sw=2 tw=78: */ 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 /* 8 * an object that stores the result of determining whether a style struct that 9 * was computed can be cached in the rule tree, and if so, what the cache 10 * key is 11 */ 12 13 #include "RuleNodeCacheConditions.h" 14 15 #include "nsStyleContext.h" 16 #include "WritingModes.h" 17 18 using namespace mozilla; 19 20 bool 21 RuleNodeCacheConditions::Matches(nsStyleContext* aStyleContext) const 22 { 23 MOZ_ASSERT(Cacheable()); 24 if ((mBits & eHaveFontSize) && 25 mFontSize != aStyleContext->StyleFont()->mFont.size) { 26 return false; 27 } 28 if ((mBits & eHaveWritingMode) && 29 (GetWritingMode() != WritingMode(aStyleContext).GetBits())) { 30 return false; 31 } 32 return true; 33 } 34 35 #ifdef DEBUG 36 void 37 RuleNodeCacheConditions::List() const 38 { 39 printf("{ "); 40 bool first = true; 41 if (mBits & eHaveFontSize) { 42 printf("FontSize(%d)", mFontSize); 43 first = false; 44 } 45 if (mBits & eHaveWritingMode) { 46 if (!first) { 47 printf(", "); 48 } 49 printf("WritingMode(0x%x)", GetWritingMode()); 50 } 51 printf(" }"); 52 } 53 #endif 54