void HTMLTokenizer::notifyFinished(CachedObject *finishedObj) { if (view && finishedObj == cachedScript) { #ifdef TOKEN_DEBUG kdDebug( 6036 ) << "Finished loading an external script" << endl; #endif loadingExtScript = false; DOMString scriptSource = cachedScript->script(); #ifdef TOKEN_DEBUG kdDebug( 6036 ) << "External script is:" << endl << scriptSource.string() << endl; #endif cachedScript->deref(this); cachedScript = 0; executingScript = true; view->part()->executeScript(scriptSource.string()); executingScript = false; // 'script' is true when we are called synchronously from // parseScript(). In that case parseScript() will take care // of 'scriptOutput'. if (!script) { QString rest = scriptOutput+pendingSrc; scriptOutput = pendingSrc = ""; write(rest); } } }
bool CSSStyleSheetImpl::parseString(const DOMString &string, bool strict) { strictParsing = strict; const QString preprocessed = preprocess(string.string()); #ifdef CSS_STYLESHEET_DEBUG kdDebug( 6080 ) << "parsing sheet, len=" << string.length() << ", sheet is " << string.string() << endl; #endif const QChar *curP = preprocessed.unicode(); const QChar *endP = preprocessed.unicode() + preprocessed.length(); #ifdef CSS_STYLESHEET_DEBUG kdDebug( 6080 ) << "preprocessed sheet, len=" << preprocessed.length() << ", sheet is " << preprocessed << endl; #endif while (curP && (curP < endP)) { CSSRuleImpl *rule = parseRule(curP, endP); if(rule) { m_lstChildren->append(rule); rule->setParent(this); // rule->init(); } } return true; }
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( const DOMString &propName, const DOMString &value, const DOMString &priority ) { int id = getPropertyID(propName.string().lower().ascii(), propName.length()); if (!id) return; bool important = false; QString str = priority.string().lower(); if(str.contains("important")) important = true; setProperty(id, value, important); }
void CSSStyleDeclaration::setProperty( const DOMString &propName, const DOMString &value, const DOMString &priority ) { if(!impl) return; int id = getPropertyID(propName.string().lower().ascii(), propName.length()); if (!id) return; bool important = false; QString str = priority.string(); if (str.find("important", 0, false) != -1) important = true; static_cast<CSSStyleDeclarationImpl *>(impl)->setProperty( id, value, important ); }
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(); }
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; } } } } }
DOMString CSSStyleDeclarationImpl::getPropertyPriority( const DOMString &propertyName ) { int id = getPropertyID(propertyName.string().ascii(), propertyName.length()); if(getPropertyPriority(id)) return DOMString("important"); return DOMString(); }
void ElementImpl::formatForDebugger(char *buffer, unsigned length) const { DOMString result; DOMString s; s = nodeName(); if (s.length() > 0) { result += s; } s = getAttribute(ATTR_ID); if (s.length() > 0) { if (result.length() > 0) result += "; "; result += "id="; result += s; } s = getAttribute(ATTR_CLASS); if (s.length() > 0) { if (result.length() > 0) result += "; "; result += "class="; result += s; } strncpy(buffer, result.string().latin1(), length - 1); }
CSSValue CSSStyleDeclaration::getPropertyCSSValue( const DOMString &propertyName ) const { if(!impl) return 0; int id = getPropertyID(propertyName.string().ascii(), propertyName.length()); if (!id) return 0; return static_cast<CSSStyleDeclarationImpl *>(impl)->getPropertyCSSValue(id); }
void TextEvent::initTextEvent(const DOMString &typeArg, bool canBubbleArg, bool cancelableArg, const AbstractView &viewArg, long /*detailArg*/, const DOMString &outputStringArg, unsigned long keyValArg, unsigned long virtKeyValArg, bool /*inputGeneratedArg*/, bool numPadArg) { if (!impl) throw DOMException(DOMException::INVALID_STATE_ERR); if (impl->isTextInputEvent()) { //Initialize based on the outputStringArg or virtKeyValArg. QString text = outputStringArg.string(); if (outputStringArg.length() == 0 && virtKeyValArg) { text += QChar((unsigned short)virtKeyValArg); } TextEventImpl* tImpl = static_cast<TextEventImpl*>(impl); tImpl->initTextEvent(typeArg, canBubbleArg, cancelableArg, viewArg, text); } else { KeyboardEventImpl* kbImpl = static_cast<KeyboardEventImpl*>(impl); kbImpl->initKeyboardEvent(typeArg, canBubbleArg, cancelableArg, viewArg, keyValArg, virtKeyValArg, 0, numPadArg ? KeyboardEventImpl::DOM_KEY_LOCATION_NUMPAD : KeyboardEventImpl::DOM_KEY_LOCATION_STANDARD); } }
DOMString CSSStyleDeclaration::removeProperty(const DOMString &property) { int id = getPropertyID(property.string().ascii(), property.length()); if(!impl || !id) return DOMString(); return static_cast< CSSStyleDeclarationImpl * >(impl)->removeProperty(id); }
int XmlNamespaceTable::getNamespaceID(const DOMString& uri, bool readonly) { if (uri == XHTML_NAMESPACE) return xhtmlNamespace; if (uri.isEmpty()) return noNamespace; QString uriStr = uri.string(); if (!gNamespaceTable) { gNamespaceTable = new QDict<XmlNamespaceEntry>; gNamespaceTable->insert(XHTML_NAMESPACE, new XmlNamespaceEntry(xhtmlNamespace, XHTML_NAMESPACE)); } XmlNamespaceEntry* ns = gNamespaceTable->find(uriStr); if (ns) return ns->m_id; if (!readonly) { static int id = xhtmlNamespace+1; ns = new XmlNamespaceEntry(id++, uri); gNamespaceTable->insert(uriStr, ns); return ns->m_id; } return -1; }
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 HTMLAppletElementImpl::attach() { KHTMLView* w = getDocument()->view(); #ifndef Q_WS_QWS // FIXME? DOMString codeBase = getAttribute( ATTR_CODEBASE ); DOMString code = getAttribute( ATTR_CODE ); if ( !codeBase.isEmpty() ) url = codeBase.string(); if ( !code.isEmpty() ) url = code.string(); if (!w || !w->part()->javaEnabled()) #endif m_renderAlternative = true; HTMLObjectBaseElementImpl::attach(); }
void XMLTokenizer::notifyFinished(CachedObject *finishedObj) { if (finishedObj == m_cachedScript) { DOMString scriptSource = m_cachedScript->script(); m_cachedScript->deref(this); m_cachedScript = 0; m_view->part()->executeScript(scriptSource.string()); executeScripts(); } }
bool CSSStyleSheetImpl::parseString(const DOMString &string, bool strict) { #ifdef CSS_STYLESHEET_DEBUG qDebug() << "parsing sheet, len=" << string.length() << ", sheet is " << string.string(); #endif strictParsing = strict; CSSParser p(strict); p.parseSheet(this, string); return true; }
RenderObject *HTMLAppletElementImpl::createRenderer(RenderArena *arena, RenderStyle *style) { #ifndef Q_WS_QWS // FIXME(E)? I don't think this is possible with Qt Embedded... KHTMLPart *part = getDocument()->part(); if( part && part->javaEnabled() ) { QMap<QString, QString> args; args.insert( "code", getAttribute(ATTR_CODE).string()); DOMString codeBase = getAttribute(ATTR_CODEBASE); if(!codeBase.isNull()) args.insert( "codeBase", codeBase.string() ); DOMString name = getDocument()->htmlMode() != DocumentImpl::XHtml ? getAttribute(ATTR_NAME) : getAttribute(ATTR_ID); if(!name.isNull()) args.insert( "name", name.string() ); DOMString archive = getAttribute(ATTR_ARCHIVE); if(!archive.isNull()) args.insert( "archive", archive.string() ); args.insert( "baseURL", getDocument()->baseURL() ); DOMString mayScript = getAttribute(ATTR_MAYSCRIPT); if (!mayScript.isNull()) args.insert("mayScript", mayScript.string()); // Other arguments (from <PARAM> tags) are added later. return new (getDocument()->renderArena()) RenderApplet(this, args); } // ### remove me. we should never show an empty applet, instead // render the alternative content given by the webpage return new (getDocument()->renderArena()) RenderEmptyApplet(this); #else return 0; #endif }
void XMLTokenizer::notifyFinished(CachedObject *finishedObj) { // This is called when a script has finished loading that was requested from executeScripts(). We execute // the script, and then call executeScripts() again to continue iterating through the list of scripts in // the document if(finishedObj == m_cachedScript) { DOMString scriptSource = m_cachedScript->script(); m_cachedScript->deref(this); m_cachedScript = 0; if(m_view) m_view->part()->executeScript(DOM::Node(), scriptSource.string()); executeScripts(); } }
void HTMLScriptElementImpl::evaluateScript(const TQString &URL, const DOMString &script) { if (m_evaluated) return; TDEHTMLPart *part = getDocument()->part(); if (part) { KJSProxy *proxy = KJSProxy::proxy(part); if (proxy) { m_evaluated = true; proxy->evaluate(URL, 0, script.string(), 0); DocumentImpl::updateDocumentsRendering(); } } }
void HTMLStyleElementImpl::reparseSheet() { DOMString text = ""; NodeImpl *n; for (n = _first; n; n = n->nextSibling()) { if (n->nodeType() == Node::TEXT_NODE || n->nodeType() == Node::CDATA_SECTION_NODE || n->nodeType() == Node::COMMENT_NODE) text += static_cast<CharacterDataImpl*>(n)->data(); } kdDebug( 6030 ) << "style: parsing sheet '" << text.string() << "'" << endl; if(m_sheet) m_sheet->deref(); m_sheet = new CSSStyleSheetImpl(this); m_sheet->ref(); m_sheet->parseString( text, (document->parseMode() == DocumentImpl::Strict) ); }
void HTMLDocument::setCookie( const DOMString & value ) { #ifdef __BEOS__ printf( "Warning: HTMLDocument::setCookie() cookies disabled\n" ); #else long windowId = view()->winId(); QByteArray params; QDataStream stream(params, IO_WriteOnly); QString fake_header("Set-Cookie: "); fake_header.append(value.string()); fake_header.append("\n"); stream << URL().string() << fake_header.utf8() << windowId; if (!kapp->dcopClient()->send("kcookiejar", "kcookiejar", "addCookies(QString,QCString,long int)", params)) { kdWarning(6010) << "Can't communicate with cookiejar!" << endl; } #endif }
void Position::formatForDebugger(char *buffer, unsigned length) const { DOMString result; DOMString s; if (isNull()) { result = "<null>"; } else { char s[FormatBufferSize]; result += "offset "; result += QString::number(m_offset); result += " of "; m_node->formatForDebugger(s, FormatBufferSize); result += s; } strncpy(buffer, result.string().latin1(), length - 1); }
bool HTMLElementImpl::setInnerHTML( const DOMString &html ) { // the following is in accordance with the definition as used by IE 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_STYLE: case ID_TABLE: case ID_TBODY: case ID_TFOOT: case ID_THEAD: case ID_TITLE: case ID_TR: return false; default: break; } if ( !getDocument()->isHTMLDocument() ) return false; DocumentFragmentImpl *fragment = new DocumentFragmentImpl( docPtr() ); HTMLTokenizer *tok = new HTMLTokenizer( docPtr(), fragment ); tok->begin(); tok->write( html.string(), true ); tok->end(); delete tok; removeChildren(); int ec = 0; appendChild( fragment, ec ); delete fragment; return !ec; }
void HTMLDocumentImpl::setCookie(const DOMString &value) { long windowId = 0; KHTMLView *v = view(); if(v && v->topLevelWidget()) windowId = v->topLevelWidget()->winId(); QByteArray params; QDataStream stream(params, IO_WriteOnly); QCString fake_header("Set-Cookie: "); fake_header.append(value.string().latin1()); fake_header.append("\n"); stream << URL().url() << fake_header << windowId; if(!kapp->dcopClient()->send("kcookiejar", "kcookiejar", "addCookies(QString,QCString,long int)", params)) { // Maybe it wasn't running (e.g. we're opening local html files) KApplication::startServiceByDesktopName("kcookiejar"); if(!kapp->dcopClient()->send("kcookiejar", "kcookiejar", "addCookies(QString,QCString,long int)", params)) kdWarning(6010) << "Can't communicate with cookiejar!" << endl; } }
unsigned long CSSStyleSheetImpl::insertRule( const DOMString &rule, unsigned long index, int &exceptioncode ) { exceptioncode = 0; if(index > m_lstChildren->count()) { exceptioncode = DOMException::INDEX_SIZE_ERR; return 0; } const QString preprocessed = preprocess(rule.string()); const QChar *curP = preprocessed.unicode(); const QChar *endP = preprocessed.unicode() + preprocessed.length(); CSSRuleImpl *r = parseRule(curP, endP); if(!r) { exceptioncode = CSSException::SYNTAX_ERR + CSSException::_EXCEPTION_OFFSET; return 0; } // ### // HIERARCHY_REQUEST_ERR: Raised if the rule cannot be inserted at the specified index e.g. if an //@import rule is inserted after a standard rule set or other at-rule. m_lstChildren->insert(index, r); return index; }
bool KeyboardEventImpl::getModifierState (const DOMString& keyIdentifierArg) const { unsigned mask = keyModifiersToCode()->toRight(keyIdentifierArg.string().toLatin1()); return m_modifier & mask; }
void HTMLElement::addCSSProperty( const DOMString &property, const DOMString &value ) { int id = getPropertyID(property.string().lower().ascii(), property.length()); if(id && impl) static_cast<HTMLElementImpl*>(impl)->addCSSProperty(id, value); }
void HTMLElement::removeCSSProperty( const DOMString &property ) { int id = getPropertyID(property.string().lower().ascii(), property.length()); if(id && impl) static_cast<HTMLElementImpl*>(impl)->removeCSSProperty(id); }
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") 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) m_cachedSheet->ref( this ); } } } }