void MutationEventImpl::initMutationEvent(const DOMString &typeArg, bool canBubbleArg, bool cancelableArg, const Node &relatedNodeArg, const DOMString &prevValueArg, const DOMString &newValueArg, const DOMString &attrNameArg, unsigned short attrChangeArg) { EventImpl::initEvent(typeArg,canBubbleArg,cancelableArg); if (m_relatedNode) m_relatedNode->deref(); if (m_prevValue) m_prevValue->deref(); if (m_newValue) m_newValue->deref(); if (m_attrName) m_attrName->deref(); m_relatedNode = relatedNodeArg.handle(); if (m_relatedNode) m_relatedNode->ref(); m_prevValue = prevValueArg.implementation(); if (m_prevValue) m_prevValue->ref(); m_newValue = newValueArg.implementation(); if (m_newValue) m_newValue->ref(); m_attrName = attrNameArg.implementation(); if (m_newValue) m_newValue->ref(); m_attrChange = attrChangeArg; }
void HTMLNamedAttrMapImpl::parseClassAttribute(const DOMString& classStr) { m_classList.clear(); if (!element->hasClass()) return; DOMString classAttr = element->getDocument()->inCompatMode() ? (classStr.implementation()->isLower() ? classStr : DOMString(classStr.implementation()->lower())) : classStr; if (classAttr.find(' ') == -1) m_classList.setString(AtomicString(classAttr)); else { QString val = classAttr.string(); QStringList list = QStringList::split(' ', val); AtomicStringList* curr = 0; for (QStringList::Iterator it = list.begin(); it != list.end(); ++it) { const QString& singleClass = *it; if (!singleClass.isEmpty()) { if (curr) { curr->setNext(new AtomicStringList(AtomicString(singleClass))); curr = curr->next(); } else { m_classList.setString(AtomicString(singleClass)); curr = &m_classList; } } } } }
void HTMLElementImpl::addCSSLength(int id, const DOMString &value, bool numOnly, bool multiLength) { if (!m_hasCombinedStyle) { createNonCSSDecl(); } // strip attribute garbage to avoid CSS parsing errors // ### create specialized hook that avoids parsing every // value twice! if (value.implementation()) { // match \s*[+-]?\d*(\.\d*)?[%\*]? unsigned i = 0, j = 0; QChar *s = value.implementation()->s; unsigned l = value.implementation()->l; while (i < l && s[i].isSpace()) { ++i; } if (i < l && (s[i] == '+' || s[i] == '-')) { ++i; } while (i < l && s[i].isDigit()) { ++i, ++j; } // no digits! if (j == 0) { return; } int v = qBound(-8192, QString::fromRawData(s, i).toInt(), 8191); const char *suffix = "px"; if (!numOnly || multiLength) { // look if we find a % or * while (i < l) { if (multiLength && s[i] == '*') { suffix = ""; break; } if (s[i] == '%') { suffix = "%"; break; } ++i; } } if (numOnly) { suffix = ""; } QString ns = QString::number(v) + suffix; nonCSSStyleDecls()->setLengthProperty(id, DOMString(ns), false, multiLength); setChanged(); return; } nonCSSStyleDecls()->setLengthProperty(id, value, false, multiLength); setChanged(); }
NodeImpl::Id NamedAttrMapImpl::mapId(const DOMString& namespaceURI, const DOMString& localName, bool readonly) { assert(element); if (!element) return 0; return element->getDocument()->attrId(namespaceURI.implementation(), localName.implementation(), readonly); }
ProcessingInstructionImpl::ProcessingInstructionImpl(DocumentImpl *doc, DOMString _target, DOMString _data) : NodeBaseImpl(doc) { m_target = _target.implementation(); if (m_target) m_target->ref(); m_data = _data.implementation(); if (m_data) m_data->ref(); }
void ElementImpl::setAttribute(NodeImpl::Id id, const DOMString &value, const DOMString &qName, int &exceptioncode) { // NO_MODIFICATION_ALLOWED_ERR: Raised when the node is readonly if(isReadOnly()) { exceptioncode = DOMException::NO_MODIFICATION_ALLOWED_ERR; return; } attributes()->setValue(id, value.implementation(), (qName.isEmpty() ? 0 : qName.implementation())); }
NotationImpl::NotationImpl(DocumentPtr *doc, DOMString _name, DOMString _publicId, DOMString _systemId) : NodeBaseImpl(doc) { m_name = _name.implementation(); if (m_name) m_name->ref(); m_publicId = _publicId.implementation(); if (m_publicId) m_publicId->ref(); m_systemId = _systemId.implementation(); if (m_systemId) m_systemId->ref(); }
ProcessingInstructionImpl::ProcessingInstructionImpl(DocumentPtr *doc, DOMString _target, DOMString _data) : NodeBaseImpl(doc) { m_target = _target.implementation(); if (m_target) m_target->ref(); m_data = _data.implementation(); if (m_data) m_data->ref(); m_sheet = 0; m_cachedSheet = 0; m_localHref = 0; }
EntityImpl::EntityImpl(DocumentImpl *doc, DOMString _publicId, DOMString _systemId, DOMString _notationName) : NodeBaseImpl(doc) { m_publicId = _publicId.implementation(); if (m_publicId) m_publicId->ref(); m_systemId = _systemId.implementation(); if (m_systemId) m_systemId->ref(); m_notationName = _notationName.implementation(); if (m_notationName) m_notationName->ref(); m_name = 0; }
void AttrImpl::setPrefix(const DOMString &_prefix, int &exceptioncode) { checkSetPrefix(_prefix, exceptioncode); if(exceptioncode) return; if(m_prefix == _prefix.implementation()) return; if(m_prefix) m_prefix->deref(); m_prefix = _prefix.implementation(); if(m_prefix) m_prefix->ref(); }
bool HTMLElementImpl::setInnerText( const DOMString &text ) { // following the IE specs. if( endTag[id()] == FORBIDDEN ) return false; // IE disallows innerHTML on inline elements. I don't see why we should have this restriction, as our // dhtml engine can cope with it. Lars //if ( isInline() ) return false; switch( id() ) { case ID_COL: case ID_COLGROUP: case ID_FRAMESET: case ID_HEAD: case ID_HTML: case ID_TABLE: case ID_TBODY: case ID_TFOOT: case ID_THEAD: case ID_TR: return false; default: break; } removeChildren(); TextImpl *t = new TextImpl( docPtr(), text.implementation() ); int ec = 0; appendChild( t, ec ); if ( !ec ) return true; return false; }
void HTMLElementImpl::addCSSLength(int id, const DOMString &value, bool numOnly, bool multiLength) { if(!m_styleDecls) createDecl(); // strip attribute garbage.. DOMStringImpl* v = value.implementation(); if ( v ) { unsigned int l = 0; while ( l < v->l && v->s[l].unicode() <= ' ') l++; for ( ;l < v->l; l++ ) { char cc = v->s[l].latin1(); if ( cc > '9' || ( cc < '0' && ( numOnly || (cc != '%' && cc != '.' && !( multiLength && cc == '*') ) ) ) ) break; } if ( l != v->l ) { m_styleDecls->setLengthProperty( id, DOMString( v->s, l ), false, true, multiLength ); setChanged(); return; } } m_styleDecls->setLengthProperty(id, value, false, true, multiLength); setChanged(); }
void KeyboardEventImpl::initKeyboardEvent(const DOMString &typeArg, bool canBubbleArg, bool cancelableArg, const AbstractView &viewArg, const DOMString &keyIdentifierArg, unsigned long keyLocationArg, bool ctrlKeyArg, bool altKeyArg, bool shiftKeyArg, bool metaKeyArg, bool altGraphKeyArg) { if (m_keyIdentifier) m_keyIdentifier->deref(); UIEventImpl::initUIEvent(typeArg, canBubbleArg, cancelableArg, viewArg, 0); m_keyIdentifier = keyIdentifierArg.implementation(); if (m_keyIdentifier) m_keyIdentifier->ref(); m_keyLocation = keyLocationArg; m_ctrlKey = ctrlKeyArg; m_shiftKey = shiftKeyArg; m_altKey = altKeyArg; m_metaKey = metaKeyArg; m_altGraphKey = altGraphKeyArg; }
NodeImpl *KHTMLParser::handleIsindex( Token *t ) { NodeImpl *n; HTMLFormElementImpl *myform = form; if ( !myform ) { myform = new HTMLFormElementImpl(document, true); n = myform; } else n = new HTMLDivElementImpl( document, ID_DIV ); NodeImpl *child = new HTMLHRElementImpl( document ); n->addChild( child ); AttributeImpl* a = t->attrs ? t->attrs->getAttributeItem(ATTR_PROMPT) : 0; DOMString text = i18n("This is a searchable index. Enter search keywords: "); if (a) text = a->value(); child = new TextImpl(document, text.implementation()); n->addChild( child ); child = new HTMLIsIndexElementImpl(document, myform); static_cast<ElementImpl *>(child)->setAttribute(ATTR_TYPE, "khtml_isindex"); n->addChild( child ); child = new HTMLHRElementImpl( document ); n->addChild( child ); return n; }
void HTMLElementImpl::addCSSLength(HTMLAttributeImpl* attr, int id, const DOMString &value) { // FIXME: This function should not spin up the CSS parser, but should instead just figure out the correct // length unit and make the appropriate parsed value. if (!attr->decl()) createMappedDecl(attr); // strip attribute garbage.. DOMStringImpl* v = value.implementation(); if ( v ) { unsigned int l = 0; while ( l < v->l && v->s[l].unicode() <= ' ') l++; for ( ;l < v->l; l++ ) { char cc = v->s[l].latin1(); if ( cc > '9' || ( cc < '0' && cc != '*' && cc != '%' && cc != '.') ) break; } if ( l != v->l ) { attr->decl()->setLengthProperty(id, DOMString( v->s, l ), false); return; } } attr->decl()->setLengthProperty(id, value, false); }
void ProcessingInstructionImpl::setData( const DOMString &_data ) { if (m_data) m_data->deref(); m_data = _data.implementation(); if (m_data) m_data->ref(); }
void AttrImpl::setPrefix(const DOMString &_prefix, int &exceptioncode ) { checkSetPrefix(_prefix, exceptioncode); if (exceptioncode) return; m_attribute->setPrefix(_prefix.implementation()); }
void ElementImpl::setAttributeNS(const DOMString &namespaceURI, const DOMString &qualifiedName, const DOMString &value, int &exceptioncode) { // NO_MODIFICATION_ALLOWED_ERR: Raised when the node is readonly if(isReadOnly()) { exceptioncode = DOMException::NO_MODIFICATION_ALLOWED_ERR; return; } int colonPos; if(!DOM::checkQualifiedName(qualifiedName, namespaceURI, &colonPos, false /*nameCanBeNull*/, false /*nameCanBeEmpty*/, &exceptioncode)) return; DOMString prefix, localName; splitPrefixLocalName(qualifiedName.implementation(), prefix, localName, colonPos); NodeImpl::Id id = getDocument()->getId(AttributeId, namespaceURI.implementation(), prefix.implementation(), localName.implementation(), false, true /*lookupHTML*/); attributes()->setValue(id, value.implementation(), 0, prefix.implementation(), true /*nsAware*/, !namespaceURI.isNull() /*hasNS*/); }
MutationEventImpl::MutationEventImpl(EventId _id, bool canBubbleArg, bool cancelableArg, const Node &relatedNodeArg, const DOMString &prevValueArg, const DOMString &newValueArg, const DOMString &attrNameArg, unsigned short attrChangeArg) : EventImpl(_id, canBubbleArg, cancelableArg) { m_relatedNode = relatedNodeArg.handle(); if(m_relatedNode) m_relatedNode->ref(); m_prevValue = prevValueArg.implementation(); if(m_prevValue) m_prevValue->ref(); m_newValue = newValueArg.implementation(); if(m_newValue) m_newValue->ref(); m_attrName = attrNameArg.implementation(); if(m_attrName) m_attrName->ref(); m_attrChange = attrChangeArg; }
DOMString khtml::parseURL(const DOMString &url) { DOMStringImpl *i = url.implementation(); if(!i) return DOMString(); int o = 0; int l = i->l; while(o < l && (i->s[o] <= ' ')) { o++; l--; } while(l > 0 && (i->s[o + l - 1] <= ' ')) l--; if(l >= 5 && (i->s[o].lower() == 'u') && (i->s[o + 1].lower() == 'r') && (i->s[o + 2].lower() == 'l') && i->s[o + 3].latin1() == '(' && i->s[o + l - 1].latin1() == ')') { o += 4; l -= 5; } while(o < l && (i->s[o] <= ' ')) { o++; l--; } while(l > 0 && (i->s[o + l - 1] <= ' ')) l--; if(l >= 2 && i->s[o] == i->s[o + l - 1] && (i->s[o].latin1() == '\'' || i->s[o].latin1() == '\"')) { o++; l -= 2; } while(o < l && (i->s[o] <= ' ')) { o++; l--; } while(l > 0 && (i->s[o + l - 1] <= ' ')) l--; DOMStringImpl *j = new DOMStringImpl(i->s + o, l); int nl = 0; for(int k = o; k < o + l; k++) if(i->s[k].unicode() > '\r') j->s[nl++] = i->s[k]; j->l = nl; return j; }
void IDTableBase::addHiddenMapping(unsigned id, const DOMString& name) { DOMStringImpl* nameImpl = name.implementation(); if (nameImpl) nameImpl->ref(); if (id >= m_mappings.size()) m_mappings.resize(id + 1); m_mappings[id] = Mapping(nameImpl); m_mappings[id].refCount = 1; // Pin it. }
void ElementImpl::removedFromDocument() { if(hasID()) { DOMString id = getAttribute(ATTR_ID); updateId(id.implementation(), 0); } NodeBaseImpl::removedFromDocument(); }
void ElementImpl::insertedIntoDocument() { // need to do superclass processing first so inDocument() is true // by the time we reach updateId NodeBaseImpl::insertedIntoDocument(); if(hasID()) { DOMString id = getAttribute(ATTR_ID); updateId(0, id.implementation()); } }
void AttrImpl::setValue(const DOMString &v, int &exceptioncode) { exceptioncode = 0; // ### according to the DOM docs, we should create an unparsed Text child // node here // do not interprete entities in the string, its literal! // NO_MODIFICATION_ALLOWED_ERR: Raised when the node is readonly if(isReadOnly()) { exceptioncode = DOMException::NO_MODIFICATION_ALLOWED_ERR; return; } // ### what to do on 0 ? if(v.isNull()) { exceptioncode = DOMException::DOMSTRING_SIZE_ERR; return; } if(m_value == v.implementation()) return; if(m_element && m_attrId == ATTR_ID) m_element->updateId(m_value, v.implementation()); m_value->deref(); m_value = v.implementation(); m_value->ref(); if(m_element) { m_element->parseAttribute(m_attrId, m_value); m_element->attributeChanged(m_attrId); } }
void ProcessingInstructionImpl::setData( const DOMString &_data, int &exceptioncode ) { // NO_MODIFICATION_ALLOWED_ERR: Raised when the node is readonly. if (isReadOnly()) { exceptioncode = DOMException::NO_MODIFICATION_ALLOWED_ERR; return; } if (m_data) m_data->deref(); m_data = _data.implementation(); if (m_data) m_data->ref(); }
void HTMLScriptElementImpl::setText(const DOMString &value) { int exceptioncode = 0; int numChildren = childNodeCount(); if (numChildren == 1 && firstChild()->isTextNode()) { static_cast<DOM::TextImpl *>(firstChild())->setData(value, exceptioncode); return; } if (numChildren > 0) { removeChildren(); } appendChild(getDocument()->createTextNode(value.implementation()), exceptioncode); }
void EventImpl::initEvent(const DOMString &eventTypeArg, bool canBubbleArg, bool cancelableArg) { // ### ensure this is not called after we have been dispatched (also for subclasses) if (m_type) m_type->deref(); m_type = eventTypeArg.implementation(); if (m_type) m_type->ref(); m_id = typeToId(eventTypeArg); m_canBubble = canBubbleArg; m_cancelable = cancelableArg; }
void CSSPrimitiveValueImpl::setStringValue( unsigned short stringType, const DOMString &stringValue, int &exceptioncode ) { exceptioncode = 0; cleanup(); //if(m_type < CSSPrimitiveValue::CSS_STRING) throw DOMException(DOMException::INVALID_ACCESS_ERR); //if(m_type > CSSPrimitiveValue::CSS_ATTR) throw DOMException(DOMException::INVALID_ACCESS_ERR); if(m_type < CSSPrimitiveValue::CSS_STRING || m_type >> CSSPrimitiveValue::CSS_ATTR) { exceptioncode = CSSException::SYNTAX_ERR + CSSException::_EXCEPTION_OFFSET; return; } if(stringType != CSSPrimitiveValue::CSS_IDENT) { m_value.string = stringValue.implementation(); m_value.string->ref(); m_type = stringType; } // ### parse ident }
EventImpl::EventImpl(EventId _id, bool canBubbleArg, bool cancelableArg) { DOMString t = EventImpl::idToType(_id); m_type = t.implementation(); if (m_type) m_type->ref(); m_canBubble = canBubbleArg; m_cancelable = cancelableArg; m_propagationStopped = false; m_defaultPrevented = false; m_id = _id; m_currentTarget = 0; m_eventPhase = 0; m_target = 0; m_createTime = QDateTime::currentDateTime(); m_defaultHandled = false; }
void ProcessingInstructionImpl::checkStyleSheet() { if(m_target && DOMString(m_target) == "xml-stylesheet") { // see http://www.w3.org/TR/xml-stylesheet/ // ### check that this occurs only in the prolog // ### support stylesheet included in a fragment of this (or another) document // ### make sure this gets called when adding from javascript XMLAttributeReader attrReader(DOMString(m_data).string()); bool attrsOk; QXmlAttributes attrs = attrReader.readAttrs(attrsOk); if(!attrsOk) return; if(attrs.value("type") != "text/css" && !attrs.value("type").isEmpty()) return; DOMString href = attrs.value("href"); if(href.length() > 1) { if(href[0] == '#') { if(m_localHref) m_localHref->deref(); m_localHref = href.implementation()->split(1); if(m_localHref) m_localHref->ref(); } else { // ### some validation on the URL? // ### FIXME charset if(m_cachedSheet) m_cachedSheet->deref(this); m_cachedSheet = getDocument()->docLoader()->requestStyleSheet(getDocument()->completeURL(href.string()), QString::null); if(m_cachedSheet) { getDocument()->addPendingSheet(); // before ref, because during the ref it might load! m_cachedSheet->ref(this); } } } } }