ServoElementSnapshot.cpp 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. /* -*- Mode: C++; tab-width: 8; 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. #include "mozilla/ServoElementSnapshot.h"
  6. #include "mozilla/dom/Element.h"
  7. #include "nsIContentInlines.h"
  8. #include "nsContentUtils.h"
  9. namespace mozilla {
  10. ServoElementSnapshot::ServoElementSnapshot(Element* aElement)
  11. : mContains(Flags(0))
  12. , mState(0)
  13. , mExplicitRestyleHint(nsRestyleHint(0))
  14. , mExplicitChangeHint(nsChangeHint(0))
  15. {
  16. mIsHTMLElementInHTMLDocument =
  17. aElement->IsHTMLElement() && aElement->IsInHTMLDocument();
  18. mIsInChromeDocument =
  19. nsContentUtils::IsChromeDoc(aElement->OwnerDoc());
  20. }
  21. void
  22. ServoElementSnapshot::AddAttrs(Element* aElement)
  23. {
  24. MOZ_ASSERT(aElement);
  25. if (HasAny(Flags::Attributes)) {
  26. return;
  27. }
  28. uint32_t attrCount = aElement->GetAttrCount();
  29. const nsAttrName* attrName;
  30. for (uint32_t i = 0; i < attrCount; ++i) {
  31. attrName = aElement->GetAttrNameAt(i);
  32. const nsAttrValue* attrValue =
  33. aElement->GetParsedAttr(attrName->LocalName(), attrName->NamespaceID());
  34. mAttrs.AppendElement(ServoAttrSnapshot(*attrName, *attrValue));
  35. }
  36. mContains |= Flags::Attributes;
  37. }
  38. } // namespace mozilla