Counter.h 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. /*
  2. * (C) 1999-2003 Lars Knoll (knoll@kde.org)
  3. * Copyright (C) 2004, 2005, 2006, 2008 Apple Inc. All rights reserved.
  4. *
  5. * This library is free software; you can redistribute it and/or
  6. * modify it under the terms of the GNU Library General Public
  7. * License as published by the Free Software Foundation; either
  8. * version 2 of the License, or (at your option) any later version.
  9. *
  10. * This library is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  13. * Library General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU Library General Public License
  16. * along with this library; see the file COPYING.LIB. If not, write to
  17. * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  18. * Boston, MA 02110-1301, USA.
  19. */
  20. #ifndef Counter_h
  21. #define Counter_h
  22. #include "CSSPrimitiveValue.h"
  23. #include <wtf/text/WTFString.h>
  24. namespace WebCore {
  25. class Counter : public RefCounted<Counter> {
  26. public:
  27. static PassRefPtr<Counter> create(PassRefPtr<CSSPrimitiveValue> identifier, PassRefPtr<CSSPrimitiveValue> listStyle, PassRefPtr<CSSPrimitiveValue> separator)
  28. {
  29. return adoptRef(new Counter(identifier, listStyle, separator));
  30. }
  31. String identifier() const { return m_identifier ? m_identifier->getStringValue() : String(); }
  32. String listStyle() const { return m_listStyle ? m_listStyle->getStringValue() : String(); }
  33. String separator() const { return m_separator ? m_separator->getStringValue() : String(); }
  34. int listStyleIdent() const { return m_listStyle ? m_listStyle->getIdent() : 0; }
  35. void setIdentifier(PassRefPtr<CSSPrimitiveValue> identifier) { m_identifier = identifier; }
  36. void setListStyle(PassRefPtr<CSSPrimitiveValue> listStyle) { m_listStyle = listStyle; }
  37. void setSeparator(PassRefPtr<CSSPrimitiveValue> separator) { m_separator = separator; }
  38. bool equals(const Counter& other) const
  39. {
  40. return identifier() == other.identifier()
  41. && listStyle() == other.listStyle()
  42. && separator() == other.separator();
  43. }
  44. PassRefPtr<Counter> cloneForCSSOM() const
  45. {
  46. return create(m_identifier ? m_identifier->cloneForCSSOM() : 0
  47. , m_listStyle ? m_listStyle->cloneForCSSOM() : 0
  48. , m_separator ? m_separator->cloneForCSSOM() : 0);
  49. }
  50. private:
  51. Counter(PassRefPtr<CSSPrimitiveValue> identifier, PassRefPtr<CSSPrimitiveValue> listStyle, PassRefPtr<CSSPrimitiveValue> separator)
  52. : m_identifier(identifier)
  53. , m_listStyle(listStyle)
  54. , m_separator(separator)
  55. {
  56. }
  57. RefPtr<CSSPrimitiveValue> m_identifier; // string
  58. RefPtr<CSSPrimitiveValue> m_listStyle; // ident
  59. RefPtr<CSSPrimitiveValue> m_separator; // string
  60. };
  61. } // namespace WebCore
  62. #endif // Counter_h