void CSSStyleDeclarationImpl::setProperty ( const DOMString &propertyString)
{
    DOMString ppPropertyString = preprocess(propertyString.string(),true);
    QPtrList<CSSProperty> *props = parseProperties(ppPropertyString.unicode(),
						ppPropertyString.unicode()+ppPropertyString.length());
    if(!props || !props->count())
	return;

    props->setAutoDelete(false);

    if(!m_lstValues) {
	m_lstValues = new QPtrList<CSSProperty>;
	m_lstValues->setAutoDelete( true );
    }

    CSSProperty *prop = props->first();
    while( prop ) {
	removeProperty(prop->m_id, false);
	m_lstValues->append(prop);
 	prop = props->next();
    }

    delete props;
    setChanged();
}
Ejemplo n.º 2
0
void CSSStyleDeclarationImpl::setProperty ( const DOMString &propertyString)
{
    QList<CSSProperty> *props = parseProperties(propertyString.unicode(),
						propertyString.unicode()+propertyString.length());
    if(!props || !props->count())
    {
	kdDebug( 6080 ) << "no properties returned!" << endl;
	return;
    }

    props->setAutoDelete(false);

    unsigned int i = 0;
    if(!m_lstValues) {
	m_lstValues = new QList<CSSProperty>;
	m_lstValues->setAutoDelete( true );
    }
    while(i < props->count())
    {
	//kdDebug( 6080 ) << "setting property" << endl;
	CSSProperty *prop = props->at(i);
	removeProperty(prop->m_id);
	m_lstValues->append(prop);
	i++;
    }
    delete props;
    if (m_node)
	m_node->setChanged(true);
}
Ejemplo n.º 3
0
bool DOM::strncmp( const DOMString &a, const DOMString &b, unsigned int len)
{
    if(a.length() < len || b.length() < len) return false;

    if(memcmp(a.unicode(), b.unicode(), len*sizeof(QChar)))
        return true;
    return false;
}
Ejemplo n.º 4
0
bool DOM::operator==( const DOMString &a, const DOMString &b )
{
    unsigned int l = a.length();

    if( l != b.length() ) return false;

    if(!memcmp(a.unicode(), b.unicode(), l*sizeof(QChar)))
	return true;
    return false;
}
Ejemplo n.º 5
0
int DOM::strncasecmp( const DOMString &s1, const DOMString &s2, unsigned int l )
{
    const QChar *a = s1.unicode();
    const QChar *b = s2.unicode();

    while ( l-- )
    {
        if( a->lower() != b->lower() )
            return a->lower() - b->lower();
        a++,b++;
    }
    return 0;
}
Ejemplo n.º 6
0
bool DOM::strcasecmp( const DOMString &as, const DOMString &bs )
{
    if ( as.length() != bs.length() ) return true;

    const QChar *a = as.unicode();
    const QChar *b = bs.unicode();
    if ( a == b )  return false;
    if ( !( a && b ) )  return true;
    int l = as.length();
    while ( l-- ) {
        if ( *a != *b && a->lower() != b->lower() ) return true;
	a++,b++;
    }
    return false;
}
Ejemplo n.º 7
0
DOMString ElementImpl::toString() const
{
    QString result = openTagStartToString().string(); // Accumulate in QString, since DOMString can't append well.

    if(hasChildNodes())
    {
        result += ">";

        for(NodeImpl *child = firstChild(); child != NULL; child = child->nextSibling())
        {
            DOMString kid = child->toString();
            result += QConstString(kid.unicode(), kid.length()).string();
        }

        result += "</";
        result += tagName().string();
        result += ">";
    }
    else if(result.length() == 1)
    {
        // ensure we dont get results like < /> can happen when serialize document
        result = "";
    }
    else
    {
        result += " />";
    }

    return result;
}
Ejemplo n.º 8
0
void KeyboardEventImpl::initKeyboardEvent(const DOMString &typeArg, bool canBubbleArg, bool cancelableArg, const AbstractView &viewArg,
        const DOMString &keyIdentifierArg, unsigned long keyLocationArg, const DOMString &modifiersList)
{
    unsigned keyVal = 0;
    unsigned virtKeyVal = 0;

    m_keyLocation = keyLocationArg;

    // Figure out the code information from the key identifier.
    if(keyIdentifierArg.length() == 1)
    {
        // Likely to be normal unicode id, unless it's one of the few
        // special values.
        unsigned short code = keyIdentifierArg.unicode()[0];
        if(code > 0x20 && code != 0x7F)
            keyVal = code;
    }

    if(!keyVal) // One of special keys, likely.
        virtKeyVal = keyIdentifiersToVirtKeys()->toRight(keyIdentifierArg.string().latin1());

    // Process modifier list.
    QStringList mods = QStringList::split(' ', modifiersList.string().stripWhiteSpace().simplifyWhiteSpace());

    unsigned modifiers = 0;
    for(QStringList::Iterator i = mods.begin(); i != mods.end(); ++i)
        if(unsigned mask = keyModifiersToCode()->toRight((*i).latin1()))
            modifiers |= mask;

    initKeyBaseEvent(typeArg, canBubbleArg, cancelableArg, viewArg, keyVal, virtKeyVal, modifiers);
}
void CSSStyleDeclarationImpl::setProperty(int id, const DOMString &value, bool important, bool nonCSSHint)
{
    if(!m_lstValues) {
	m_lstValues = new QPtrList<CSSProperty>;
	m_lstValues->setAutoDelete(true);
    }
    removeProperty(id, nonCSSHint );

    DOMString ppValue = preprocess(value.string(),true);
    bool success = parseValue(ppValue.unicode(), ppValue.unicode()+ppValue.length(), id, important, nonCSSHint, m_lstValues);

    if(!success)
	kdDebug( 6080 ) << "CSSStyleDeclarationImpl::setProperty invalid property: [" << getPropertyName(id).string()
					<< "] value: [" << value.string() << "]"<< endl;
    else
        setChanged();
}
void HTMLFontElementImpl::parseAttribute(AttributeImpl *attr)
{
    switch(attr->id())
    {
    case ATTR_SIZE:
    {
        DOMString s = attr->value();
        if(!s.isNull()) {
            int num = s.toInt();
            if ( *s.unicode() == '+' || *s.unicode() == '-' ) {
                num += 3;
            }
            int size = 0;
            switch (num)
            {
            case 1: size = CSS_VAL_X_SMALL; break;
            case 2: size = CSS_VAL_SMALL;   break;
            case 3: size = CSS_VAL_MEDIUM;  break;
            case 4: size = CSS_VAL_LARGE;   break;
            case 5: size = CSS_VAL_X_LARGE; break;
            case 6: size = CSS_VAL_XX_LARGE;break;
            default:
                if (num >= 6)
                    size = CSS_VAL__KONQ_XXX_LARGE;
                else if (num < 1)
                    size = CSS_VAL_XX_SMALL;
            }
            if ( size )
                addCSSProperty(CSS_PROP_FONT_SIZE, size);
        }
        break;
    }
    case ATTR_COLOR:
        addCSSProperty(CSS_PROP_COLOR, attr->value());
        // HTML4 compatibility hack
        addCSSProperty(CSS_PROP_TEXT_DECORATION_COLOR, attr->value());
        break;
    case ATTR_FACE:
        addCSSProperty(CSS_PROP_FONT_FAMILY, attr->value());
        break;
    default:
        HTMLElementImpl::parseAttribute(attr);
    }
}
Ejemplo n.º 11
0
void TextEventImpl::initTextEvent(const DOMString &typeArg, bool canBubbleArg, bool cancelableArg, const AbstractView &viewArg, const DOMString &text)
{
    m_outputString = text;

    // See whether we can get a key out of this.
    unsigned keyCode = 0;
    if(text.length() == 1)
        keyCode = text.unicode()[0].unicode();
    initKeyBaseEvent(typeArg, canBubbleArg, cancelableArg, viewArg, keyCode, 0, 0);
}
Ejemplo n.º 12
0
void CSSStyleDeclarationImpl::setProperty(int id, const DOMString &value, bool important, bool nonCSSHint)
{
    if(!m_lstValues) {
	m_lstValues = new QList<CSSProperty>;
	m_lstValues->setAutoDelete(true);
    }
    removeProperty(id);
    int pos = m_lstValues->count();
    parseValue(value.unicode(), value.unicode()+value.length(), id, important, m_lstValues);

    if( nonCSSHint && pos < (int)m_lstValues->count() ) {
	CSSProperty *p = m_lstValues->at(pos);
	while ( p ) {
	    p->nonCSSHint = true;
	    p = m_lstValues->next();
	}
    } else if(pos == m_lstValues->count() )
	kdDebug() << "CSSStyleDeclarationImpl::setProperty invalid property=" << id << "value: " << value.string() << endl;
    if (m_node)
	m_node->setChanged(true);
}
Ejemplo n.º 13
0
UString::UString(const DOMString &d)
{
  if (d.isNull()) {
    attach(&Rep::null);
    return;
  }

  unsigned int len = d.length();
  UChar *dat = new UChar[len];
  memcpy(dat, d.unicode(), len * sizeof(UChar));
  rep = UString::Rep::create(dat, len);
}
Ejemplo n.º 14
0
void CSSStyleDeclarationImpl::setLengthProperty(int id, const DOMString &value,
						bool important, bool nonCSSHint)
{
    strictParsing = false;
    setProperty( id, value, important, nonCSSHint);
    strictParsing = true;
#if 0 // ### FIXME after 2.0
    if(!value.unicode() || value.length() == 0)
	return;

    if(!m_lstValues)
    {
	m_lstValues = new QList<CSSProperty>;
	m_lstValues->setAutoDelete(true);
    }

    CSSValueImpl *v = parseUnit(value.unicode(), value.unicode()+value.length(),
				INTEGER | PERCENT | LENGTH, );
    if(!v)
    {
	kdDebug( 6080 ) << "invalid length" << endl;
	return;
    }

    CSSPrimitiveValueImpl *p = static_cast<CSSPrimitiveValueImpl *>(v);
    if(p->primitiveType() == CSSPrimitiveValue::CSS_NUMBER)
    {
	// set the parsed number in pixels
	p->setPrimitiveType(CSSPrimitiveValue::CSS_PX);
    }
    CSSProperty *prop = new CSSProperty();
    prop->m_id = id;
    prop->setValue(v);
    prop->m_bImportant = important;
    prop->nonCSSHint = nonCSSHint;

    m_lstValues->append(prop);
#endif
}
Ejemplo n.º 15
0
bool DOM::strcasecmp( const DOMString &as, const char* bs )
{
    const QChar *a = as.unicode();
    int l = as.length();
    if ( !bs ) return ( l != 0 );
    while ( l-- ) {
        if ( a->toLatin1() != *bs ) {
            char cc = ( ( *bs >= 'A' ) && ( *bs <= 'Z' ) ) ? ( ( *bs ) + 'a' - 'A' ) : ( *bs );
            if ( a->toLower().toLatin1() != cc ) return true;
        }
        a++, bs++;
    }
    return ( *bs != '\0' );
}
Ejemplo n.º 16
0
void HTMLElementImpl::parseAttribute(AttributeImpl *attr)
{
    DOMString indexstring;
    switch( attr->id() )
    {
    case ATTR_ALIGN:
        if (attr->val()) {
            if ( strcasecmp(attr->value(), "middle" ) == 0 )
                addCSSProperty( CSS_PROP_TEXT_ALIGN, CSS_VAL_CENTER );
            else
                addCSSProperty(CSS_PROP_TEXT_ALIGN, attr->value().lower());
        }
        else
            removeCSSProperty(CSS_PROP_TEXT_ALIGN);
        break;
// the core attributes...
    case ATTR_ID:
        // unique id
        setHasID();
        document()->incDOMTreeVersion(DocumentImpl::TV_IDNameHref);
        break;
    case ATTR_CLASS:
        if (attr->val()) {
            DOMString v = attr->value();
            const QChar* characters = v.unicode();
            unsigned length = v.length();
            unsigned i;
            for (i = 0; i < length && characters[i].isSpace(); ++i) { }
            setHasClass(i < length);
            attributes()->setClass(v);
        } else {
            setHasClass(false);
        }
        document()->incDOMTreeVersion(DocumentImpl::TV_Class);
        break;
    case ATTR_NAME:
        document()->incDOMTreeVersion(DocumentImpl::TV_IDNameHref);
        break;
    case ATTR_CONTENTEDITABLE:
        setContentEditable(attr);
        break;
    case ATTR_STYLE:
        getInlineStyleDecls()->updateFromAttribute(attr->value());
        setChanged();
        break;
    case ATTR_TABINDEX:
        indexstring=getAttribute(ATTR_TABINDEX);
        if (attr->val())
            setTabIndex(attr->value().toInt());
        else
            setNoTabIndex();
        break;
// i18n attributes
    case ATTR_LANG:
        break;
    case ATTR_DIR:
        addCSSProperty(CSS_PROP_DIRECTION, attr->value().lower());
        break;
// standard events
    case ATTR_ONCLICK:
        setHTMLEventListener(EventImpl::KHTML_ECMA_CLICK_EVENT,
                             document()->createHTMLEventListener(attr->value().string(), "onclick", this));
        break;
    case ATTR_ONDBLCLICK:
        setHTMLEventListener(EventImpl::KHTML_ECMA_DBLCLICK_EVENT,
                             document()->createHTMLEventListener(attr->value().string(), "ondblclick", this));
        break;
    case ATTR_ONMOUSEDOWN:
        setHTMLEventListener(EventImpl::MOUSEDOWN_EVENT,
                             document()->createHTMLEventListener(attr->value().string(), "onmousedown", this));
        break;
    case ATTR_ONMOUSEMOVE:
        setHTMLEventListener(EventImpl::MOUSEMOVE_EVENT,
                             document()->createHTMLEventListener(attr->value().string(), "onmousemove", this));
        break;
    case ATTR_ONMOUSEOUT:
        setHTMLEventListener(EventImpl::MOUSEOUT_EVENT,
                             document()->createHTMLEventListener(attr->value().string(), "onmouseout", this));
        break;
    case ATTR_ONMOUSEOVER:
        setHTMLEventListener(EventImpl::MOUSEOVER_EVENT,
                             document()->createHTMLEventListener(attr->value().string(), "onmouseover", this));
        break;
    case ATTR_ONMOUSEUP:
        setHTMLEventListener(EventImpl::MOUSEUP_EVENT,
                             document()->createHTMLEventListener(attr->value().string(), "onmouseup", this));
        break;
    case ATTR_ONKEYDOWN:
        setHTMLEventListener(EventImpl::KEYDOWN_EVENT,
                             document()->createHTMLEventListener(attr->value().string(), "onkeydown", this));
        break;
    case ATTR_ONKEYPRESS:
        setHTMLEventListener(EventImpl::KEYPRESS_EVENT,
                             document()->createHTMLEventListener(attr->value().string(), "onkeypress", this));
        break;
    case ATTR_ONKEYUP:
        setHTMLEventListener(EventImpl::KEYUP_EVENT,
                             document()->createHTMLEventListener(attr->value().string(), "onkeyup", this));
        break;
    case ATTR_ONFOCUS:
        setHTMLEventListener(EventImpl::FOCUS_EVENT,
                             document()->createHTMLEventListener(attr->value().string(), "onfocus", this));
        break;
    case ATTR_ONBLUR:
        setHTMLEventListener(EventImpl::BLUR_EVENT,
                             document()->createHTMLEventListener(attr->value().string(), "onblur", this));
        break;
    case ATTR_ONSCROLL:
        setHTMLEventListener(EventImpl::SCROLL_EVENT,
                             document()->createHTMLEventListener(attr->value().string(), "onscroll", this));
        break;
// other misc attributes
    default:
#ifdef UNSUPPORTED_ATTR
        kDebug(6030) << "UATTR: <" << this->nodeName().string() << "> ["
                     << attr->name().string() << "]=[" << attr->value().string() << "]" << endl;
#endif
        break;
    }
}