RuleNodeCacheConditions.cpp 1.3 KB

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