ShadowValue.cpp 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. /**
  2. * (C) 1999-2003 Lars Knoll (knoll@kde.org)
  3. * Copyright (C) 2004, 2005, 2006, 2009 Apple Computer, Inc.
  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. #include "config.h"
  21. #include "ShadowValue.h"
  22. #include "CSSPrimitiveValue.h"
  23. #include <wtf/text/StringBuilder.h>
  24. #include <wtf/text/WTFString.h>
  25. namespace WebCore {
  26. // Used for text-shadow and box-shadow
  27. ShadowValue::ShadowValue(PassRefPtr<CSSPrimitiveValue> _x,
  28. PassRefPtr<CSSPrimitiveValue> _y,
  29. PassRefPtr<CSSPrimitiveValue> _blur,
  30. PassRefPtr<CSSPrimitiveValue> _spread,
  31. PassRefPtr<CSSPrimitiveValue> _style,
  32. PassRefPtr<CSSPrimitiveValue> _color)
  33. : CSSValue(ShadowClass)
  34. , x(_x)
  35. , y(_y)
  36. , blur(_blur)
  37. , spread(_spread)
  38. , style(_style)
  39. , color(_color)
  40. {
  41. }
  42. String ShadowValue::customCssText() const
  43. {
  44. StringBuilder text;
  45. if (color)
  46. text.append(color->cssText());
  47. if (x) {
  48. if (!text.isEmpty())
  49. text.append(' ');
  50. text.append(x->cssText());
  51. }
  52. if (y) {
  53. if (!text.isEmpty())
  54. text.append(' ');
  55. text.append(y->cssText());
  56. }
  57. if (blur) {
  58. if (!text.isEmpty())
  59. text.append(' ');
  60. text.append(blur->cssText());
  61. }
  62. if (spread) {
  63. if (!text.isEmpty())
  64. text.append(' ');
  65. text.append(spread->cssText());
  66. }
  67. if (style) {
  68. if (!text.isEmpty())
  69. text.append(' ');
  70. text.append(style->cssText());
  71. }
  72. return text.toString();
  73. }
  74. bool ShadowValue::equals(const ShadowValue& other) const
  75. {
  76. return compareCSSValuePtr(color, other.color)
  77. && compareCSSValuePtr(x, other.x)
  78. && compareCSSValuePtr(y, other.y)
  79. && compareCSSValuePtr(blur, other.blur)
  80. && compareCSSValuePtr(spread, other.spread)
  81. && compareCSSValuePtr(style, other.style);
  82. }
  83. }