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 26#include "config.h" 27 28#include "WebPopupItem.h" 29 30#include "ArgumentCoders.h" 31#include "Arguments.h" 32 33using namespace WebCore; 34 35namespace WebKit { 36 37WebPopupItem::WebPopupItem() 38 : m_type(Item) 39 , m_textDirection(LTR) 40 , m_hasTextDirectionOverride(false) 41 , m_isEnabled(true) 42 , m_isSelected(false) 43{ 44} 45 46WebPopupItem::WebPopupItem(Type type) 47 : m_type(type) 48 , m_textDirection(LTR) 49 , m_hasTextDirectionOverride(false) 50 , m_isEnabled(true) 51 , m_isLabel(false) 52 , m_isSelected(false) 53{ 54} 55 56WebPopupItem::WebPopupItem(Type type, const String& text, TextDirection textDirection, bool hasTextDirectionOverride, const String& toolTip, const String& accessibilityText, bool isEnabled, bool isLabel, bool isSelected) 57 : m_type(type) 58 , m_text(text) 59 , m_textDirection(textDirection) 60 , m_hasTextDirectionOverride(hasTextDirectionOverride) 61 , m_toolTip(toolTip) 62 , m_accessibilityText(accessibilityText) 63 , m_isEnabled(isEnabled) 64 , m_isLabel(isLabel) 65 , m_isSelected(isSelected) 66{ 67} 68 69void WebPopupItem::encode(CoreIPC::ArgumentEncoder& encoder) const 70{ 71 encoder.encodeEnum(m_type); 72 encoder << m_text; 73 encoder.encodeEnum(m_textDirection); 74 encoder << m_hasTextDirectionOverride; 75 encoder << m_toolTip; 76 encoder << m_accessibilityText; 77 encoder << m_isEnabled; 78 encoder << m_isLabel; 79 encoder << m_isSelected; 80} 81 82bool WebPopupItem::decode(CoreIPC::ArgumentDecoder& decoder, WebPopupItem& item) 83{ 84 Type type; 85 if (!decoder.decodeEnum(type)) 86 return false; 87 88 String text; 89 if (!decoder.decode(text)) 90 return false; 91 92 TextDirection textDirection; 93 if (!decoder.decodeEnum(textDirection)) 94 return false; 95 96 bool hasTextDirectionOverride; 97 if (!decoder.decode(hasTextDirectionOverride)) 98 return false; 99 100 String toolTip; 101 if (!decoder.decode(toolTip)) 102 return false; 103 104 String accessibilityText; 105 if (!decoder.decode(accessibilityText)) 106 return false; 107 108 bool isEnabled; 109 if (!decoder.decode(isEnabled)) 110 return false; 111 112 bool isLabel; 113 if (!decoder.decode(isLabel)) 114 return false; 115 116 bool isSelected; 117 if (!decoder.decode(isSelected)) 118 return false; 119 120 item = WebPopupItem(type, text, textDirection, hasTextDirectionOverride, toolTip, accessibilityText, isEnabled, isLabel, isSelected); 121 return true; 122} 123 124} // namespace WebKit 125