Beispiel #1
0
JSValue *Clipboard::getValueProperty(ExecState *exec, int token) const
{
    switch (token) {
        case DropEffect:
            assert(clipboard->isForDragging() || clipboard->dropEffect().isNull());
            return jsStringOrUndefined(clipboard->dropEffect());
        case EffectAllowed:
            assert(clipboard->isForDragging() || clipboard->effectAllowed().isNull());
            return jsStringOrUndefined(clipboard->effectAllowed());
        case Types:
        {
            DeprecatedStringList qTypes = clipboard->types();
            if (qTypes.isEmpty())
                return jsNull(); 
            else {
                List list;
                for (DeprecatedStringList::Iterator it = qTypes.begin(); it != qTypes.end(); ++it) {
                    list.append(jsString(UString(*it)));
                }
                return exec->lexicalInterpreter()->builtinArray()->construct(exec, list);
            }
        }
        default:
            return NULL;
    }
}
DeprecatedStringList DeprecatedStringList::split(const DeprecatedString &separator, const DeprecatedString &s, bool allowEmptyEntries)
{
    DeprecatedStringList result;

    int startPos = 0;
    int endPos;
    while ((endPos = s.find(separator, startPos)) != -1) {
        if (allowEmptyEntries || startPos != endPos)
            result.append(s.mid(startPos, endPos - startPos));
        startPos = endPos + separator.length();
    }
    if (allowEmptyEntries || startPos != (int)s.length())
        result.append(s.mid(startPos));
            
    return result;
}
void SVGFEGaussianBlurElement::parseMappedAttribute(MappedAttribute *attr)
{
    const String& value = attr->value();
    if (attr->name() == SVGNames::stdDeviationAttr) {
        DeprecatedStringList numbers = DeprecatedStringList::split(' ', value.deprecatedString());
        stdDeviationX()->setBaseVal(numbers[0].toDouble());
        if(numbers.count() == 1)
            stdDeviationY()->setBaseVal(numbers[0].toDouble());
        else
            stdDeviationY()->setBaseVal(numbers[1].toDouble());
    }
    else if (attr->name() == SVGNames::inAttr)
        in1()->setBaseVal(value.impl());
    else
        SVGFilterPrimitiveStandardAttributes::parseMappedAttribute(attr);
}
Beispiel #4
0
KCanvasFEMerge *SVGFEMergeElement::filterEffect() const
{
    if (!m_filterEffect)
        m_filterEffect = static_cast<KCanvasFEMerge *>(renderingDevice()->createFilterEffect(FE_MERGE));
    if (!m_filterEffect)
        return 0;
    setStandardAttributes(m_filterEffect);

    DeprecatedStringList mergeInputs;
    for(Node *n = firstChild(); n != 0; n = n->nextSibling())
    {
        if(n->hasTagName(SVGNames::feMergeNodeTag))
        {
            String mergeInput = static_cast<SVGFEMergeNodeElement *>(n)->in1()->baseVal();
            mergeInputs.append(mergeInput.deprecatedString());
        }
    }

    m_filterEffect->setMergeInputs(mergeInputs);

    return m_filterEffect;
}
void SVGFESpecularLightingElement::parseMappedAttribute(MappedAttribute *attr)
{    
    const String& value = attr->value();
    if (attr->name() == SVGNames::inAttr)
        in1()->setBaseVal(value.impl());
    else if (attr->name() == SVGNames::surfaceScaleAttr)
        surfaceScale()->setBaseVal(value.deprecatedString().toDouble());
    else if (attr->name() == SVGNames::specularConstantAttr)
        specularConstant()->setBaseVal(value.deprecatedString().toDouble());
    else if (attr->name() == SVGNames::specularExponentAttr)
        specularExponent()->setBaseVal(value.deprecatedString().toDouble());
    else if (attr->name() == SVGNames::kernelUnitLengthAttr) {
        DeprecatedStringList numbers = DeprecatedStringList::split(' ', value.deprecatedString());
        kernelUnitLengthX()->setBaseVal(numbers[0].toDouble());
        if (numbers.count() == 1)
            kernelUnitLengthY()->setBaseVal(numbers[0].toDouble());
        else
            kernelUnitLengthY()->setBaseVal(numbers[1].toDouble());
    } else if (attr->name() == SVGNames::lighting_colorAttr)
        lightingColor()->setBaseVal(new SVGColor(value.impl()));
    else
        SVGFilterPrimitiveStandardAttributes::parseMappedAttribute(attr);
}
Beispiel #6
0
void SVGTransformable::parseTransformAttribute(SVGTransformList *list, const AtomicString& transform)
{
    // Split string for handling 1 transform statement at a time
    DeprecatedStringList subtransforms = DeprecatedStringList::split(')', transform.deprecatedString().simplifyWhiteSpace());
    DeprecatedStringList::ConstIterator it = subtransforms.begin();
    DeprecatedStringList::ConstIterator end = subtransforms.end();
    for (; it != end; ++it) {
        DeprecatedStringList subtransform = DeprecatedStringList::split('(', (*it));
        
        if (subtransform.count() < 2)
            break; // invalid transform, ignore.

        subtransform[0] = subtransform[0].stripWhiteSpace().lower();
        subtransform[1] = subtransform[1].simplifyWhiteSpace();
        RegularExpression reg("([-]?\\d*\\.?\\d+(?:e[-]?\\d+)?)");

        int pos = 0;
        DeprecatedStringList params;
        
        while (pos >= 0) {
            pos = reg.search(subtransform[1], pos);
            if (pos != -1) {
                params += reg.cap(1);
                pos += reg.matchedLength();
            }
        }
        
        if (params.count() < 1)
            break;

        if (subtransform[0].startsWith(";") || subtransform[0].startsWith(","))
            subtransform[0] = subtransform[0].right(subtransform[0].length() - 1);

        RefPtr<SVGTransform> t(new SVGTransform());

        if (subtransform[0] == "rotate") {
            if (params.count() == 3)
                t->setRotate(params[0].toDouble(),
                             params[1].toDouble(),
                              params[2].toDouble());
            else if (params.count() == 1)
                t->setRotate(params[0].toDouble(), 0, 0);
        } else if (subtransform[0] == "translate") {
            if (params.count() == 2)
                t->setTranslate(params[0].toDouble(), params[1].toDouble());
            else if (params.count() == 1) // Spec: if only one param given, assume 2nd param to be 0
                t->setTranslate(params[0].toDouble(), 0);
        } else if (subtransform[0] == "scale") {
            if (params.count() == 2)
                t->setScale(params[0].toDouble(), params[1].toDouble());
            else if (params.count() == 1) // Spec: if only one param given, assume uniform scaling
                t->setScale(params[0].toDouble(), params[0].toDouble());
        } else if (subtransform[0] == "skewx" && (params.count() == 1))
            t->setSkewX(params[0].toDouble());
        else if (subtransform[0] == "skewy" && (params.count() == 1))
            t->setSkewY(params[0].toDouble());
        else if (subtransform[0] == "matrix" && (params.count() == 6)) {
            SVGMatrix *ret = new SVGMatrix(params[0].toDouble(),
                                                   params[1].toDouble(),
                                                   params[2].toDouble(),
                                                   params[3].toDouble(),
                                                   params[4].toDouble(),
                                                   params[5].toDouble());
            t->setMatrix(ret);
        }
        
        if (t->type() == SVG_TRANSFORM_UNKNOWN)
            break; // failed to parse a valid transform, abort.
        
        list->appendItem(t.release().release());
    }
}
Beispiel #7
0
bool HTMLFormElement::formData(FormData &form_data) const
{
    DeprecatedCString enc_string = ""; // used for non-multipart data

    DeprecatedString str = m_acceptcharset.deprecatedString();
    str.replace(',', ' ');
    DeprecatedStringList charsets = DeprecatedStringList::split(' ', str);
    TextEncoding encoding(InvalidEncoding);
    Frame *frame = document()->frame();
    for (DeprecatedStringList::Iterator it = charsets.begin(); it != charsets.end(); ++it) {
        if ((encoding = TextEncoding((*it).latin1())).isValid())
            break;
    }

    if (!encoding.isValid()) {
        if (frame)
            encoding = TextEncoding(frame->encoding().latin1());
        else
            encoding = TextEncoding(Latin1Encoding);
    }

    for (unsigned i = 0; i < formElements.size(); ++i) {
        HTMLGenericFormElement* current = formElements[i];
        FormDataList lst(encoding);

        if (!current->disabled() && current->appendFormData(lst, m_multipart)) {
            for (DeprecatedValueListConstIterator<FormDataListItem> it = lst.begin(); it != lst.end(); ++it) {
                if (!m_multipart) {
                    // handle ISINDEX / <input name=isindex> special
                    // but only if its the first entry
                    if ( enc_string.isEmpty() && (*it).m_data == "isindex" ) {
                        ++it;
                        enc_string += encodeCString( (*it).m_data );
                    }
                    else {
                        if(!enc_string.isEmpty())
                            enc_string += '&';

                        enc_string += encodeCString((*it).m_data);
                        enc_string += "=";
                        ++it;
                        enc_string += encodeCString((*it).m_data);
                    }
                }
                else
                {
                    DeprecatedCString hstr("--");
                    hstr += m_boundary.deprecatedString().latin1();
                    hstr += "\r\n";
                    hstr += "Content-Disposition: form-data; name=\"";
                    hstr += (*it).m_data.data();
                    hstr += "\"";

                    // if the current type is FILE, then we also need to
                    // include the filename
                    if (current->hasLocalName(inputTag) &&
                        static_cast<HTMLInputElement*>(current)->inputType() == HTMLInputElement::FILE) {
                        DeprecatedString path = static_cast<HTMLInputElement*>(current)->value().deprecatedString();

                        // FIXME: This won't work if the filename includes a " mark,
                        // or control characters like CR or LF. This also does strange
                        // things if the filename includes characters you can't encode
                        // in the website's character set.
                        hstr += "; filename=\"";
                        hstr += encoding.fromUnicode(path.mid(path.findRev('/') + 1), true);
                        hstr += "\"";

                        if (!static_cast<HTMLInputElement*>(current)->value().isEmpty()) {
                            DeprecatedString mimeType = frame ? frame->mimeTypeForFileName(path).deprecatedString() : DeprecatedString();
                            if (!mimeType.isEmpty()) {
                                hstr += "\r\nContent-Type: ";
                                hstr += mimeType.ascii();
                            }
                        }
                    }

                    hstr += "\r\n\r\n";
                    ++it;

                    // append body
                    form_data.appendData(hstr.data(), hstr.length());
                    const FormDataListItem &item = *it;
                    size_t dataSize = item.m_data.size();
                    if (dataSize != 0)
                        form_data.appendData(item.m_data, dataSize - 1);
                    else if (!item.m_path.isEmpty())
                        form_data.appendFile(item.m_path);
                    form_data.appendData("\r\n", 2);
                }
            }
        }
    }


    if (m_multipart)
        enc_string = ("--" + m_boundary.deprecatedString() + "--\r\n").ascii();

    form_data.appendData(enc_string.data(), enc_string.length());
    return true;
}