Home | History | Annotate | Download | only in Shared
      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 
     33 using namespace WebCore;
     34 
     35 namespace WebKit {
     36 
     37 WebPopupItem::WebPopupItem()
     38     : m_type(Item)
     39     , m_textDirection(LTR)
     40     , m_hasTextDirectionOverride(false)
     41     , m_isEnabled(true)
     42 {
     43 }
     44 
     45 WebPopupItem::WebPopupItem(Type type)
     46     : m_type(type)
     47     , m_textDirection(LTR)
     48     , m_hasTextDirectionOverride(false)
     49     , m_isEnabled(true)
     50     , m_isLabel(false)
     51 {
     52 }
     53 
     54 WebPopupItem::WebPopupItem(Type type, const String& text, TextDirection textDirection, bool hasTextDirectionOverride, const String& toolTip, const String& accessibilityText, bool isEnabled, bool isLabel)
     55     : m_type(type)
     56     , m_text(text)
     57     , m_textDirection(textDirection)
     58     , m_hasTextDirectionOverride(hasTextDirectionOverride)
     59     , m_toolTip(toolTip)
     60     , m_accessibilityText(accessibilityText)
     61     , m_isEnabled(isEnabled)
     62     , m_isLabel(isLabel)
     63 {
     64 }
     65 
     66 void WebPopupItem::encode(CoreIPC::ArgumentEncoder* encoder) const
     67 {
     68     encoder->encode(CoreIPC::In(static_cast<uint32_t>(m_type), m_text, static_cast<uint64_t>(m_textDirection), m_hasTextDirectionOverride, m_toolTip, m_accessibilityText, m_isEnabled, m_isLabel));
     69 }
     70 
     71 bool WebPopupItem::decode(CoreIPC::ArgumentDecoder* decoder, WebPopupItem& item)
     72 {
     73     uint32_t type;
     74     String text;
     75     uint64_t textDirection;
     76     bool hasTextDirectionOverride;
     77     String toolTip;
     78     String accessibilityText;
     79     bool isEnabled;
     80     bool isLabel;
     81     if (!decoder->decode(CoreIPC::Out(type, text, textDirection, hasTextDirectionOverride, toolTip, accessibilityText, isEnabled, isLabel)))
     82         return false;
     83 
     84     item = WebPopupItem(static_cast<Type>(type), text, static_cast<TextDirection>(textDirection), hasTextDirectionOverride, toolTip, accessibilityText, isEnabled, isLabel);
     85     return true;
     86 }
     87 
     88 } // namespace WebKit
     89