Line data Source code
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 50 : RuleNodeCacheConditions::Matches(nsStyleContext* aStyleContext) const
22 : {
23 50 : MOZ_ASSERT(Cacheable());
24 53 : if ((mBits & eHaveFontSize) &&
25 3 : mFontSize != aStyleContext->StyleFont()->mFont.size) {
26 0 : return false;
27 : }
28 197 : if ((mBits & eHaveWritingMode) &&
29 191 : (GetWritingMode() != WritingMode(aStyleContext).GetBits())) {
30 0 : return false;
31 : }
32 50 : return true;
33 : }
34 :
35 : #ifdef DEBUG
36 : void
37 0 : RuleNodeCacheConditions::List() const
38 : {
39 0 : printf("{ ");
40 0 : bool first = true;
41 0 : if (mBits & eHaveFontSize) {
42 0 : printf("FontSize(%d)", mFontSize);
43 0 : first = false;
44 : }
45 0 : if (mBits & eHaveWritingMode) {
46 0 : if (!first) {
47 0 : printf(", ");
48 : }
49 0 : printf("WritingMode(0x%x)", GetWritingMode());
50 : }
51 0 : printf(" }");
52 0 : }
53 : #endif
|