WebPopupItem.cpp 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. /*
  2. * Copyright (C) 2010, 2011 Apple Inc. All rights reserved.
  3. *
  4. * Redistribution and use in source and binary forms, with or without
  5. * modification, are permitted provided that the following conditions
  6. * are met:
  7. * 1. Redistributions of source code must retain the above copyright
  8. * notice, this list of conditions and the following disclaimer.
  9. * 2. Redistributions in binary form must reproduce the above copyright
  10. * notice, this list of conditions and the following disclaimer in the
  11. * documentation and/or other materials provided with the distribution.
  12. *
  13. * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
  14. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
  15. * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  16. * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
  17. * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  18. * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  19. * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  20. * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  21. * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  22. * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
  23. * THE POSSIBILITY OF SUCH DAMAGE.
  24. */
  25. #include "config.h"
  26. #include "WebPopupItem.h"
  27. #include "ArgumentCoders.h"
  28. #include "Arguments.h"
  29. using namespace WebCore;
  30. namespace WebKit {
  31. WebPopupItem::WebPopupItem()
  32. : m_type(Item)
  33. , m_textDirection(LTR)
  34. , m_hasTextDirectionOverride(false)
  35. , m_isEnabled(true)
  36. , m_isSelected(false)
  37. {
  38. }
  39. WebPopupItem::WebPopupItem(Type type)
  40. : m_type(type)
  41. , m_textDirection(LTR)
  42. , m_hasTextDirectionOverride(false)
  43. , m_isEnabled(true)
  44. , m_isLabel(false)
  45. , m_isSelected(false)
  46. {
  47. }
  48. WebPopupItem::WebPopupItem(Type type, const String& text, TextDirection textDirection, bool hasTextDirectionOverride, const String& toolTip, const String& accessibilityText, bool isEnabled, bool isLabel, bool isSelected)
  49. : m_type(type)
  50. , m_text(text)
  51. , m_textDirection(textDirection)
  52. , m_hasTextDirectionOverride(hasTextDirectionOverride)
  53. , m_toolTip(toolTip)
  54. , m_accessibilityText(accessibilityText)
  55. , m_isEnabled(isEnabled)
  56. , m_isLabel(isLabel)
  57. , m_isSelected(isSelected)
  58. {
  59. }
  60. void WebPopupItem::encode(CoreIPC::ArgumentEncoder& encoder) const
  61. {
  62. encoder.encodeEnum(m_type);
  63. encoder << m_text;
  64. encoder.encodeEnum(m_textDirection);
  65. encoder << m_hasTextDirectionOverride;
  66. encoder << m_toolTip;
  67. encoder << m_accessibilityText;
  68. encoder << m_isEnabled;
  69. encoder << m_isLabel;
  70. encoder << m_isSelected;
  71. }
  72. bool WebPopupItem::decode(CoreIPC::ArgumentDecoder& decoder, WebPopupItem& item)
  73. {
  74. Type type;
  75. if (!decoder.decodeEnum(type))
  76. return false;
  77. String text;
  78. if (!decoder.decode(text))
  79. return false;
  80. TextDirection textDirection;
  81. if (!decoder.decodeEnum(textDirection))
  82. return false;
  83. bool hasTextDirectionOverride;
  84. if (!decoder.decode(hasTextDirectionOverride))
  85. return false;
  86. String toolTip;
  87. if (!decoder.decode(toolTip))
  88. return false;
  89. String accessibilityText;
  90. if (!decoder.decode(accessibilityText))
  91. return false;
  92. bool isEnabled;
  93. if (!decoder.decode(isEnabled))
  94. return false;
  95. bool isLabel;
  96. if (!decoder.decode(isLabel))
  97. return false;
  98. bool isSelected;
  99. if (!decoder.decode(isSelected))
  100. return false;
  101. item = WebPopupItem(type, text, textDirection, hasTextDirectionOverride, toolTip, accessibilityText, isEnabled, isLabel, isSelected);
  102. return true;
  103. }
  104. } // namespace WebKit