Example #1
0
void WMLOptionElement::parseMappedAttribute(Attribute* attr)
{
    if (attr->name() == HTMLNames::valueAttr)
        m_data.setValue(parseValueSubstitutingVariableReferences(attr->value()));
    else if (attr->name() == HTMLNames::titleAttr)
        m_data.setLabel(parseValueSubstitutingVariableReferences(attr->value()));
    else if (attr->name() == onpickAttr) {
        // Register intrinsic event in card
        RefPtr<WMLIntrinsicEvent> event = WMLIntrinsicEvent::create(document(), attr->value());

        createEventHandlerIfNeeded();
        eventHandler()->registerIntrinsicEvent(WMLIntrinsicEventOnPick, event);
    } else
        WMLFormControlElement::parseMappedAttribute(attr);
}
void WMLSetvarElement::parseMappedAttribute(Attribute* attr)
{
    if (attr->name() == HTMLNames::nameAttr) {
        if (!isValidVariableName(parseValueSubstitutingVariableReferences(attr->value(), WMLErrorInvalidVariableName))) {
            reportWMLError(document(), WMLErrorInvalidVariableName);
            return;
        }
    } else
        WMLElement::parseMappedAttribute(attr);
}
void WMLOptGroupElement::parseMappedAttribute(MappedAttribute* attr)
{
    if (attr->name() == HTMLNames::titleAttr) {
        m_title = parseValueSubstitutingVariableReferences(attr->value());
        return;
    }

    WMLElement::parseMappedAttribute(attr);
    recalcSelectOptions();
}
void WMLSelectElement::calculateDefaultOptionIndices()
{
    WMLPageState* pageState = wmlPageStateForDocument(document());
    if (!pageState)
        return;

    String variable;

    // Spec: If the 'iname' attribute is specified and names a variable that is set,
    // then the default option index is the validated value of that variable. 
    String iname = this->iname();
    if (!iname.isEmpty()) {
        variable = pageState->getVariable(iname);
        if (!variable.isEmpty())
            m_defaultOptionIndices = parseIndexValueString(variable);
    }

    // Spec: If the default option index is empty and the 'ivalue' attribute is specified,
    // then the default option index is the validated attribute value.
    String ivalue = this->ivalue();
    if (m_defaultOptionIndices.isEmpty() && !ivalue.isEmpty())
        m_defaultOptionIndices = parseIndexValueString(ivalue);

    // Spec: If the default option index is empty, and the 'name' attribute is specified
    // and the 'name' ttribute names a variable that is set, then for each value in the 'name'
    // variable that is present as a value in the select's option elements, the index of the
    // first option element containing that value is added to the default index if that
    // index has not been previously added. 
    String name = this->name();
    if (m_defaultOptionIndices.isEmpty() && !name.isEmpty()) {
        variable = pageState->getVariable(name);
        if (!variable.isEmpty())
            m_defaultOptionIndices = valueStringToOptionIndices(variable);
    }

    String value = parseValueSubstitutingVariableReferences(getAttribute(HTMLNames::valueAttr));

    // Spec: If the default option index is empty and the 'value' attribute is specified then
    // for each  value in the 'value' attribute that is present as a value in the select's
    // option elements, the index of the first option element containing that value is added
    // to the default index if that index has not been previously added. 
    if (m_defaultOptionIndices.isEmpty() && !value.isEmpty())
        m_defaultOptionIndices = valueStringToOptionIndices(value);

    // Spec: If the default option index is empty and the select is a multi-choice, then the
    // default option index is set to zero. If the select is single-choice, then the default
    // option index is set to one.
    if (m_defaultOptionIndices.isEmpty())
        m_defaultOptionIndices.append((unsigned) !m_data.multiple());
}
String WMLSetvarElement::value() const
{
    return parseValueSubstitutingVariableReferences(getAttribute(HTMLNames::valueAttr));
}
String WMLSetvarElement::name() const
{
    return parseValueSubstitutingVariableReferences(getAttribute(HTMLNames::nameAttr), WMLErrorInvalidVariableName);
}
String WMLSelectElement::ivalue() const
{
    return parseValueSubstitutingVariableReferences(getAttribute(ivalueAttr));
}
//SAMSUNG_WML_FIX +
String WMLFormControlElement::name() const
{
    return parseValueSubstitutingVariableReferences(getAttribute(HTMLNames::nameAttr));
}