Value DOMParserProtoFunc::tryCall(ExecState *exec, Object &thisObj, const List &args) { if (!thisObj.inherits(&DOMParser::info)) { Object err = Error::create(exec,TypeError); exec->setException(err); return err; } DOMParser *parser = static_cast<DOMParser *>(thisObj.imp()); switch (id) { case DOMParser::ParseFromString: { if (args.size() != 2) { return Undefined(); } TQString str = args[0].toString(exec).qstring(); TQString contentType = args[1].toString(exec).qstring().stripWhiteSpace(); if (contentType == "text/xml" || contentType == "application/xml" || contentType == "application/xhtml+xml") { DocumentImpl *docImpl = parser->doc->implementation()->createDocument(); docImpl->open(); docImpl->write(str); docImpl->finishParsing(); docImpl->close(); return getDOMNode(exec, docImpl); } } } return Undefined(); }
void MouseRelatedEventImpl::computeLayerPos() { m_layerX = m_clientX; m_layerY = m_clientY; DocumentImpl *doc = view()->document(); if (!doc || !doc->renderer()) { return; } khtml::RenderObject::NodeInfo renderInfo(true, false); doc->renderer()->layer()->hitTest(renderInfo, m_clientX, m_clientY); NodeImpl *node = renderInfo.innerNonSharedNode(); while (node && !node->renderer()) { node = node->parent(); } if (!node) { return; } node->renderer()->enclosingLayer()->updateLayerPosition(); for (khtml::RenderLayer *layer = node->renderer()->enclosingLayer(); layer != NULL; layer = layer->parent()) { m_layerX -= layer->xPos(); m_layerY -= layer->yPos(); } }
void MouseEventImpl::computeLayerPos() { m_layerX = m_pageX; m_layerY = m_pageY; DocumentImpl *doc = view() ? view()->document() : 0; if(doc) { khtml::RenderObject::NodeInfo renderInfo(true, false); doc->renderer()->layer()->nodeAtPoint(renderInfo, m_pageX, m_pageY); NodeImpl *node = renderInfo.innerNonSharedNode(); while(node && !node->renderer()) node = node->parent(); if(node) { node->renderer()->enclosingLayer()->updateLayerPosition(); for(RenderLayer *layer = node->renderer()->enclosingLayer(); layer; layer = layer->parent()) { m_layerX -= layer->xPos(); m_layerY -= layer->yPos(); } } } }
static void writeSelection(QTextStream &ts, const RenderObject *o) { NodeImpl *n = o->element(); if (!n || !n->isDocumentNode()) return; DocumentImpl *doc = static_cast<DocumentImpl *>(n); if (!doc->part()) return; Selection selection = doc->part()->selection(); if (selection.isNone()) return; if (!selection.start().node()->isContentEditable() || !selection.end().node()->isContentEditable()) return; Position startPosition = selection.start(); Position endPosition = selection.end(); QString startNodeTagName(getTagName(startPosition.node())); QString endNodeTagName(getTagName(endPosition.node())); NodeImpl *rootNode = doc->getElementById("root"); if (selection.isCaret()) { Position upstream = startPosition.upstream(DOM::StayInBlock); Position downstream = startPosition.downstream(DOM::StayInBlock); QString positionString = nodePositionRelativeToRoot(startPosition.node(), rootNode); QString upstreamString = nodePositionRelativeToRoot(upstream.node(), rootNode); QString downstreamString = nodePositionRelativeToRoot(downstream.node(), rootNode); ts << "selection is CARET:\n" << "start: position " << startPosition.offset() << " of " << positionString << "\n" "upstream: position " << upstream.offset() << " of " << upstreamString << "\n" "downstream: position " << downstream.offset() << " of " << downstreamString << "\n"; } else if (selection.isRange()) { QString startString = nodePositionRelativeToRoot(startPosition.node(), rootNode); Position upstreamStart = startPosition.upstream(DOM::StayInBlock); QString upstreamStartString = nodePositionRelativeToRoot(upstreamStart.node(), rootNode); Position downstreamStart = startPosition.downstream(DOM::StayInBlock); QString downstreamStartString = nodePositionRelativeToRoot(downstreamStart.node(), rootNode); QString endString = nodePositionRelativeToRoot(endPosition.node(), rootNode); Position upstreamEnd = endPosition.upstream(DOM::StayInBlock); QString upstreamEndString = nodePositionRelativeToRoot(upstreamEnd.node(), rootNode); Position downstreamEnd = endPosition.downstream(DOM::StayInBlock); QString downstreamEndString = nodePositionRelativeToRoot(downstreamEnd.node(), rootNode); ts << "selection is RANGE:\n" << "start: position " << startPosition.offset() << " of " << startString << "\n" << "upstream: position " << upstreamStart.offset() << " of " << upstreamStartString << "\n" "downstream: position " << downstreamStart.offset() << " of " << downstreamStartString << "\n" "end: position " << endPosition.offset() << " of " << endString << "\n" "upstream: position " << upstreamEnd.offset() << " of " << upstreamEndString << "\n" "downstream: position " << downstreamEnd.offset() << " of " << downstreamEndString << "\n"; } }
virtual DOM::Document_impl<stringT, string_adaptorT>* createDocument(const stringT& namespaceURI, const stringT& qualifiedName, DOM::DocumentType_impl<stringT, string_adaptorT>* docType) { DocumentImpl<stringT, string_adaptorT>* doc = new DocumentImpl<stringT, string_adaptorT>(namespaceURI, qualifiedName, docType, this); if(!string_adaptorT::empty(qualifiedName)) doc->appendChild(doc->createElementNS(namespaceURI, qualifiedName)); return doc; } // createDocument
void NodeIteratorImpl::setDocument(DocumentImpl *doc) { if (doc == m_doc) return; DocumentImpl *old = m_doc; m_doc = doc; if (m_doc) m_doc->ref(); if (old) old->deref(); }
void ElementImpl::updateId(const AtomicString& oldId, const AtomicString& newId) { if (!inDocument()) return; if (oldId == newId) return; DocumentImpl* doc = getDocument(); if (!oldId.isEmpty()) doc->removeElementById(oldId, this); if (!newId.isEmpty()) doc->addElementById(newId, this); }
HTMLDocument &HTMLDocument::operator = (const Node &other) { if(other.nodeType() != DOCUMENT_NODE) { if ( impl ) impl->deref(); impl = 0; } else { DocumentImpl *d = static_cast<DocumentImpl *>(other.handle()); if(!d->isHTMLDocument()) { if ( impl ) impl->deref(); impl = 0; } else { Node::operator =(other); } } return *this; }
DOMString StyleBaseImpl::baseURL() { // try to find the style sheet. If found look for its url. // If it has none, look for the parentsheet, or the parentNode and // try to find out about their url StyleSheetImpl *sheet = stylesheet(); if(!sheet) return DOMString(); if(!sheet->href().isNull()) return sheet->href(); // find parent if(sheet->parent()) return sheet->parent()->baseURL(); if(!sheet->ownerNode()) return DOMString(); DocumentImpl *doc = sheet->ownerNode()->getDocument(); return doc->baseURL(); }
void EventTargetImpl::setDocListenerFlag(unsigned flag) { DocumentImpl* doc = eventTargetDocument(); if (doc) doc->addListenerType(DocumentImpl::ListenerType(flag)); }
DocumentImpl* XSLTProcessorImpl::documentFromXMLDocPtr(xmlDocPtr resultDoc, xsltStylesheetPtr sheet) { // FIXME: For now we serialize and then reparse. It might be more optimal to write a DOM // converter. if (!resultDoc || !sheet) return 0; DocumentImpl* result = 0; xmlOutputBufferPtr outputBuf = xmlAllocOutputBuffer(NULL); if (outputBuf) { outputBuf->context = this; outputBuf->writecallback = bufferWrite; if (xsltSaveResultTo(outputBuf, resultDoc, sheet) < 0) return 0; // There are three types of output we need to be able to deal with: // HTML (create an HTML document), XML (create an XML document), and text (wrap in a <pre> and // make an XML document). KHTMLView* view = m_sourceDocument->view(); const xmlChar* method; XSLT_GET_IMPORT_PTR(method, sheet, method); if (method == NULL && resultDoc->type == XML_HTML_DOCUMENT_NODE) method = (const xmlChar*)"html"; if (xmlStrEqual(method, (const xmlChar*)"html")) result = m_sourceDocument->implementation()->createHTMLDocument(view); else result = m_sourceDocument->implementation()->createDocument(view); result->attach(); result->setURL(m_sourceDocument->URL()); result->setBaseURL(m_sourceDocument->baseURL()); result->setDecoder(m_sourceDocument->decoder()); // FIXME: Should just be UTF-16. result->docLoader()->setShowAnimations(m_sourceDocument->docLoader()->showAnimations()); result->setTransformSourceDocument(m_sourceDocument); if (xmlStrEqual(method, (const xmlChar*)"text")) { // Modify the output so that it is a well-formed XHTML document with a <pre> tag enclosing // the text. QString beforeString("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/strict.dtd\">\n<html xmlns=\"http://www.w3.org/1999/xhtml\">\n<body>\n<pre>\n<![CDATA["); QString afterString("]]>\n</pre>\n</body>\n</html>\n"); m_resultOutput = beforeString + m_resultOutput + afterString; } // Before parsing, we need to detach the old document completely and get the new document // in place. We have to do this only if we're rendering the result document. if (view) { view->clear(); view->part()->replaceDocImpl(result); } result->open(); result->determineParseMode(m_resultOutput); // Make sure we parse in the correct mode. result->write(m_resultOutput); result->finishParsing(); if (view) view->part()->checkCompleted(); else result->close(); // FIXME: Even viewless docs can load subresources. onload will fire too early. // This is probably a bug in XMLHttpRequestObjects as well. } return result; }
NodeImpl *AttrImpl::removeChild(NodeImpl *oldChild) { DocumentImpl *ownerDocument = getOwnerDocument(); if (ownerDocument->getErrorChecking()) { if (isReadOnly()) { throw DOM_DOMException( DOM_DOMException::NO_MODIFICATION_ALLOWED_ERR, null); } if (oldChild == null || oldChild->getParentNode() != this) { throw DOM_DOMException(DOM_DOMException::NOT_FOUND_ERR, null); } } // fix other ranges for change before deleting the node if (getOwnerDocument() != null) { typedef RefVectorOf<RangeImpl> RangeImpls; RangeImpls* ranges = this->getOwnerDocument()->getRanges(); if (ranges != null) { unsigned int sz = ranges->size(); if (sz != 0) { for (unsigned int i =0; i<sz; i++) { if (ranges->elementAt(i) != null) ranges->elementAt(i)->updateRangeForDeletedNode(oldChild); } } } } ChildNode * oldInternal = (ChildNode *) oldChild; // Patch linked list around oldChild // Note: lastChild == firstChild->previousSibling if (oldInternal == value.child) { // removing first child oldInternal->isFirstChild(false); value.child = oldInternal->nextSibling; // firstChild = oldInternal->nextSibling ChildNode *firstChild = value.child; if (firstChild != null) { firstChild->isFirstChild(true); firstChild->previousSibling = oldInternal->previousSibling; } } else { ChildNode *prev = oldInternal->previousSibling; ChildNode *next = oldInternal->nextSibling; prev->nextSibling = next; if (next == null) { // removing last child ChildNode *firstChild = value.child; firstChild->previousSibling = prev; } else { // removing some other child in the middle next->previousSibling = prev; } } // Remove oldInternal's references to tree oldInternal->ownerNode = getOwnerDocument(); oldInternal->isOwned(false); oldInternal->nextSibling = null; oldInternal->previousSibling = null; changed(); return oldInternal; };
NodeImpl *AttrImpl::insertBefore(NodeImpl *newChild, NodeImpl *refChild) { DocumentImpl *ownerDocument = getOwnerDocument(); bool errorChecking = ownerDocument->getErrorChecking(); if (newChild->isDocumentFragmentImpl()) { // SLOW BUT SAFE: We could insert the whole subtree without // juggling so many next/previous pointers. (Wipe out the // parent's child-list, patch the parent pointers, set the // ends of the list.) But we know some subclasses have special- // case behavior they add to insertBefore(), so we don't risk it. // This approch also takes fewer bytecodes. // NOTE: If one of the children is not a legal child of this // node, throw HIERARCHY_REQUEST_ERR before _any_ of the children // have been transferred. (Alternative behaviors would be to // reparent up to the first failure point or reparent all those // which are acceptable to the target node, neither of which is // as robust. PR-DOM-0818 isn't entirely clear on which it // recommends????? // No need to check kids for right-document; if they weren't, // they wouldn't be kids of that DocFrag. if (errorChecking) { for (NodeImpl *kid = newChild->getFirstChild(); // Prescan kid != null; kid = kid->getNextSibling()) { if (!DocumentImpl::isKidOK(this, kid)) { throw DOM_DOMException( DOM_DOMException::HIERARCHY_REQUEST_ERR, null); } } } while (newChild->hasChildNodes()) { // Move insertBefore(newChild->getFirstChild(), refChild); } return newChild; } // it's a no-op if refChild is the same as newChild if (refChild == newChild) { return newChild; } if (errorChecking) { if (isReadOnly()) { throw DOM_DOMException( DOM_DOMException::NO_MODIFICATION_ALLOWED_ERR, null); } if (newChild->getOwnerDocument() != ownerDocument) { throw DOM_DOMException(DOM_DOMException::WRONG_DOCUMENT_ERR, null); } if (!DocumentImpl::isKidOK(this, newChild)) { throw DOM_DOMException(DOM_DOMException::HIERARCHY_REQUEST_ERR, null); } // refChild must be a child of this node (or null) if (refChild != null && refChild->getParentNode() != this) { throw DOM_DOMException(DOM_DOMException::NOT_FOUND_ERR, null); } // Prevent cycles in the tree // newChild cannot be ancestor of this Node, // and actually cannot be this bool treeSafe = true; for (NodeImpl *a = this; treeSafe && a != null; a = a->getParentNode()) { treeSafe = (newChild != a); } if (!treeSafe) { throw DOM_DOMException(DOM_DOMException::HIERARCHY_REQUEST_ERR, null); } } makeChildNode(); // make sure we have a node and not a string // Convert to internal type, to avoid repeated casting ChildNode * newInternal = (ChildNode *)newChild; NodeImpl *oldparent = newInternal->getParentNode(); if (oldparent != null) { oldparent->removeChild(newInternal); } // Convert to internal type, to avoid repeated casting ChildNode *refInternal = (ChildNode *)refChild; // Attach up newInternal->ownerNode = this; newInternal->isOwned(true); // Attach before and after // Note: firstChild.previousSibling == lastChild!! ChildNode *firstChild = value.child; if (firstChild == null) { // this our first and only child value.child = newInternal; // firstChild = newInternal newInternal->isFirstChild(true); newInternal->previousSibling = newInternal; } else { if (refInternal == null) { // this is an append ChildNode *lastChild = firstChild->previousSibling; lastChild->nextSibling = newInternal; newInternal->previousSibling = lastChild; firstChild->previousSibling = newInternal; } else { // this is an insert if (refChild == firstChild) { // at the head of the list firstChild->isFirstChild(false); newInternal->nextSibling = firstChild; newInternal->previousSibling = firstChild->previousSibling; firstChild->previousSibling = newInternal; value.child = newInternal; // firstChild = newInternal; newInternal->isFirstChild(true); } else { // somewhere in the middle ChildNode *prev = refInternal->previousSibling; newInternal->nextSibling = refInternal; prev->nextSibling = newInternal; refInternal->previousSibling = newInternal; newInternal->previousSibling = prev; } } } changed(); if (this->getOwnerDocument() != null) { typedef RefVectorOf<RangeImpl> RangeImpls; RangeImpls* ranges = this->getOwnerDocument()->getRanges(); if ( ranges != null) { unsigned int sz = ranges->size(); for (unsigned int i =0; i<sz; i++) { ranges->elementAt(i)->updateRangeForInsertedNode(newInternal); } } } return newInternal; }
CSSValueImpl *CSSComputedStyleDeclarationImpl::getPropertyCSSValue(int propertyID, EUpdateLayout updateLayout) const { NodeImpl *node = m_node.handle(); if (!node) return 0; // Make sure our layout is up to date before we allow a query on these attributes. DocumentImpl* docimpl = node->getDocument(); if (docimpl && updateLayout) docimpl->updateLayout(); RenderObject *renderer = node->renderer(); if (!renderer) return 0; RenderStyle *style = renderer->style(); if (!style) return 0; switch (propertyID) { case CSS_PROP_BACKGROUND_COLOR: return new CSSPrimitiveValueImpl(style->backgroundColor().rgb()); case CSS_PROP_BACKGROUND_IMAGE: if (style->backgroundImage()) return new CSSPrimitiveValueImpl(style->backgroundImage()->url(), CSSPrimitiveValue::CSS_URI); return new CSSPrimitiveValueImpl(CSS_VAL_NONE); case CSS_PROP_BACKGROUND_REPEAT: switch (style->backgroundRepeat()) { case khtml::REPEAT: return new CSSPrimitiveValueImpl(CSS_VAL_REPEAT); case khtml::REPEAT_X: return new CSSPrimitiveValueImpl(CSS_VAL_REPEAT_X); case khtml::REPEAT_Y: return new CSSPrimitiveValueImpl(CSS_VAL_REPEAT_Y); case khtml::NO_REPEAT: return new CSSPrimitiveValueImpl(CSS_VAL_NO_REPEAT); } ASSERT_NOT_REACHED(); return 0; case CSS_PROP_BACKGROUND_ATTACHMENT: if (style->backgroundAttachment()) return new CSSPrimitiveValueImpl(CSS_VAL_SCROLL); else return new CSSPrimitiveValueImpl(CSS_VAL_FIXED); case CSS_PROP_BACKGROUND_POSITION: { DOMString string; Length length(style->backgroundXPosition()); if (length.isPercent()) string = numberAsString(length.length()) + "%"; else string = numberAsString(length.minWidth(renderer->contentWidth())); string += " "; length = style->backgroundYPosition(); if (length.isPercent()) string += numberAsString(length.length()) + "%"; else string += numberAsString(length.minWidth(renderer->contentWidth())); return new CSSPrimitiveValueImpl(string, CSSPrimitiveValue::CSS_STRING); } case CSS_PROP_BACKGROUND_POSITION_X: return valueForLength(style->backgroundXPosition()); case CSS_PROP_BACKGROUND_POSITION_Y: return valueForLength(style->backgroundYPosition()); #ifndef KHTML_NO_XBL case CSS_PROP__KHTML_BINDING: // FIXME: unimplemented break; #endif case CSS_PROP_BORDER_COLLAPSE: if (style->borderCollapse()) return new CSSPrimitiveValueImpl(CSS_VAL_COLLAPSE); else return new CSSPrimitiveValueImpl(CSS_VAL_SEPARATE); case CSS_PROP_BORDER_SPACING: { QString string(numberAsString(style->horizontalBorderSpacing()) + "px " + numberAsString(style->verticalBorderSpacing()) + "px"); return new CSSPrimitiveValueImpl(string, CSSPrimitiveValue::CSS_STRING); } case CSS_PROP__KHTML_BORDER_HORIZONTAL_SPACING: return new CSSPrimitiveValueImpl(style->horizontalBorderSpacing(), CSSPrimitiveValue::CSS_PX); case CSS_PROP__KHTML_BORDER_VERTICAL_SPACING: return new CSSPrimitiveValueImpl(style->verticalBorderSpacing(), CSSPrimitiveValue::CSS_PX); case CSS_PROP_BORDER_TOP_COLOR: return new CSSPrimitiveValueImpl(style->borderLeftColor().rgb()); case CSS_PROP_BORDER_RIGHT_COLOR: return new CSSPrimitiveValueImpl(style->borderRightColor().rgb()); case CSS_PROP_BORDER_BOTTOM_COLOR: return new CSSPrimitiveValueImpl(style->borderBottomColor().rgb()); case CSS_PROP_BORDER_LEFT_COLOR: return new CSSPrimitiveValueImpl(style->borderLeftColor().rgb()); case CSS_PROP_BORDER_TOP_STYLE: return valueForBorderStyle(style->borderTopStyle()); case CSS_PROP_BORDER_RIGHT_STYLE: return valueForBorderStyle(style->borderRightStyle()); case CSS_PROP_BORDER_BOTTOM_STYLE: return valueForBorderStyle(style->borderBottomStyle()); case CSS_PROP_BORDER_LEFT_STYLE: return valueForBorderStyle(style->borderLeftStyle()); case CSS_PROP_BORDER_TOP_WIDTH: return new CSSPrimitiveValueImpl(style->borderTopWidth(), CSSPrimitiveValue::CSS_PX); case CSS_PROP_BORDER_RIGHT_WIDTH: return new CSSPrimitiveValueImpl(style->borderRightWidth(), CSSPrimitiveValue::CSS_PX); case CSS_PROP_BORDER_BOTTOM_WIDTH: return new CSSPrimitiveValueImpl(style->borderBottomWidth(), CSSPrimitiveValue::CSS_PX); case CSS_PROP_BORDER_LEFT_WIDTH: return new CSSPrimitiveValueImpl(style->borderLeftWidth(), CSSPrimitiveValue::CSS_PX); case CSS_PROP_BOTTOM: return getPositionOffsetValue(renderer, CSS_PROP_BOTTOM); case CSS_PROP__KHTML_BOX_ALIGN: switch (style->boxAlign()) { case khtml::BSTRETCH: return new CSSPrimitiveValueImpl(CSS_VAL_STRETCH); case khtml::BSTART: return new CSSPrimitiveValueImpl(CSS_VAL_START); case khtml::BCENTER: return new CSSPrimitiveValueImpl(CSS_VAL_CENTER); case khtml::BEND: return new CSSPrimitiveValueImpl(CSS_VAL_END); case khtml::BBASELINE: return new CSSPrimitiveValueImpl(CSS_VAL_BASELINE); case khtml::BJUSTIFY: break; // not allowed } ASSERT_NOT_REACHED(); return 0; case CSS_PROP__KHTML_BOX_DIRECTION: switch (style->boxDirection()) { case khtml::BNORMAL: return new CSSPrimitiveValueImpl(CSS_VAL_NORMAL); case khtml::BREVERSE: return new CSSPrimitiveValueImpl(CSS_VAL_REVERSE); } ASSERT_NOT_REACHED(); return 0; case CSS_PROP__KHTML_BOX_FLEX: return new CSSPrimitiveValueImpl(style->boxFlex(), CSSPrimitiveValue::CSS_NUMBER); case CSS_PROP__KHTML_BOX_FLEX_GROUP: return new CSSPrimitiveValueImpl(style->boxFlexGroup(), CSSPrimitiveValue::CSS_NUMBER); case CSS_PROP__KHTML_BOX_LINES: switch (style->boxLines()) { case khtml::SINGLE: return new CSSPrimitiveValueImpl(CSS_VAL_SINGLE); case khtml::MULTIPLE: return new CSSPrimitiveValueImpl(CSS_VAL_MULTIPLE); } ASSERT_NOT_REACHED(); return 0; case CSS_PROP__KHTML_BOX_ORDINAL_GROUP: return new CSSPrimitiveValueImpl(style->boxOrdinalGroup(), CSSPrimitiveValue::CSS_NUMBER); case CSS_PROP__KHTML_BOX_ORIENT: switch (style->boxOrient()) { case khtml::HORIZONTAL: return new CSSPrimitiveValueImpl(CSS_VAL_HORIZONTAL); case khtml::VERTICAL: return new CSSPrimitiveValueImpl(CSS_VAL_VERTICAL); } ASSERT_NOT_REACHED(); return 0; case CSS_PROP__KHTML_BOX_PACK: switch (style->boxPack()) { case khtml::BSTART: return new CSSPrimitiveValueImpl(CSS_VAL_START); case khtml::BEND: return new CSSPrimitiveValueImpl(CSS_VAL_END); case khtml::BCENTER: return new CSSPrimitiveValueImpl(CSS_VAL_CENTER); case khtml::BJUSTIFY: return new CSSPrimitiveValueImpl(CSS_VAL_JUSTIFY); case khtml::BSTRETCH: case khtml::BBASELINE: break; // not allowed } ASSERT_NOT_REACHED(); return 0; case CSS_PROP_CAPTION_SIDE: switch (style->captionSide()) { case khtml::CAPLEFT: return new CSSPrimitiveValueImpl(CSS_VAL_LEFT); case khtml::CAPRIGHT: return new CSSPrimitiveValueImpl(CSS_VAL_RIGHT); case khtml::CAPTOP: return new CSSPrimitiveValueImpl(CSS_VAL_TOP); case khtml::CAPBOTTOM: return new CSSPrimitiveValueImpl(CSS_VAL_BOTTOM); } ASSERT_NOT_REACHED(); return 0; case CSS_PROP_CLEAR: switch (style->clear()) { case khtml::CNONE: return new CSSPrimitiveValueImpl(CSS_VAL_NONE); case khtml::CLEFT: return new CSSPrimitiveValueImpl(CSS_VAL_LEFT); case khtml::CRIGHT: return new CSSPrimitiveValueImpl(CSS_VAL_RIGHT); case khtml::CBOTH: return new CSSPrimitiveValueImpl(CSS_VAL_BOTH); } ASSERT_NOT_REACHED(); return 0; case CSS_PROP_CLIP: // FIXME: unimplemented break; case CSS_PROP_COLOR: return new CSSPrimitiveValueImpl(style->color().rgb()); case CSS_PROP_CONTENT: // FIXME: unimplemented break; case CSS_PROP_COUNTER_INCREMENT: // FIXME: unimplemented break; case CSS_PROP_COUNTER_RESET: // FIXME: unimplemented break; case CSS_PROP_CURSOR: switch (style->cursor()) { case khtml::CURSOR_AUTO: return new CSSPrimitiveValueImpl(CSS_VAL_AUTO); case khtml::CURSOR_CROSS: return new CSSPrimitiveValueImpl(CSS_VAL_CROSSHAIR); case khtml::CURSOR_DEFAULT: return new CSSPrimitiveValueImpl(CSS_VAL_DEFAULT); case khtml::CURSOR_POINTER: return new CSSPrimitiveValueImpl(CSS_VAL_POINTER); case khtml::CURSOR_MOVE: return new CSSPrimitiveValueImpl(CSS_VAL_MOVE); case khtml::CURSOR_E_RESIZE: return new CSSPrimitiveValueImpl(CSS_VAL_E_RESIZE); case khtml::CURSOR_NE_RESIZE: return new CSSPrimitiveValueImpl(CSS_VAL_NE_RESIZE); case khtml::CURSOR_NW_RESIZE: return new CSSPrimitiveValueImpl(CSS_VAL_NW_RESIZE); case khtml::CURSOR_N_RESIZE: return new CSSPrimitiveValueImpl(CSS_VAL_N_RESIZE); case khtml::CURSOR_SE_RESIZE: return new CSSPrimitiveValueImpl(CSS_VAL_SE_RESIZE); case khtml::CURSOR_SW_RESIZE: return new CSSPrimitiveValueImpl(CSS_VAL_SW_RESIZE); case khtml::CURSOR_S_RESIZE: return new CSSPrimitiveValueImpl(CSS_VAL_S_RESIZE); case khtml::CURSOR_W_RESIZE: return new CSSPrimitiveValueImpl(CSS_VAL_W_RESIZE); case khtml::CURSOR_TEXT: return new CSSPrimitiveValueImpl(CSS_VAL_TEXT); case khtml::CURSOR_WAIT: return new CSSPrimitiveValueImpl(CSS_VAL_WAIT); case khtml::CURSOR_HELP: return new CSSPrimitiveValueImpl(CSS_VAL_HELP); } ASSERT_NOT_REACHED(); return 0; case CSS_PROP_DIRECTION: switch (style->direction()) { case khtml::LTR: return new CSSPrimitiveValueImpl(CSS_VAL_LTR); case khtml::RTL: return new CSSPrimitiveValueImpl(CSS_VAL_RTL); } ASSERT_NOT_REACHED(); return 0; case CSS_PROP_DISPLAY: switch (style->display()) { case khtml::INLINE: return new CSSPrimitiveValueImpl(CSS_VAL_INLINE); case khtml::BLOCK: return new CSSPrimitiveValueImpl(CSS_VAL_BLOCK); case khtml::LIST_ITEM: return new CSSPrimitiveValueImpl(CSS_VAL_LIST_ITEM); case khtml::RUN_IN: return new CSSPrimitiveValueImpl(CSS_VAL_RUN_IN); case khtml::COMPACT: return new CSSPrimitiveValueImpl(CSS_VAL_COMPACT); case khtml::INLINE_BLOCK: return new CSSPrimitiveValueImpl(CSS_VAL_INLINE_BLOCK); case khtml::TABLE: return new CSSPrimitiveValueImpl(CSS_VAL_TABLE); case khtml::INLINE_TABLE: return new CSSPrimitiveValueImpl(CSS_VAL_INLINE_TABLE); case khtml::TABLE_ROW_GROUP: return new CSSPrimitiveValueImpl(CSS_VAL_TABLE_ROW_GROUP); case khtml::TABLE_HEADER_GROUP: return new CSSPrimitiveValueImpl(CSS_VAL_TABLE_HEADER_GROUP); case khtml::TABLE_FOOTER_GROUP: return new CSSPrimitiveValueImpl(CSS_VAL_TABLE_FOOTER_GROUP); case khtml::TABLE_ROW: return new CSSPrimitiveValueImpl(CSS_VAL_TABLE_ROW); case khtml::TABLE_COLUMN_GROUP: return new CSSPrimitiveValueImpl(CSS_VAL_TABLE_COLUMN_GROUP); case khtml::TABLE_COLUMN: return new CSSPrimitiveValueImpl(CSS_VAL_TABLE_COLUMN); case khtml::TABLE_CELL: return new CSSPrimitiveValueImpl(CSS_VAL_TABLE_CELL); case khtml::TABLE_CAPTION: return new CSSPrimitiveValueImpl(CSS_VAL_TABLE_CAPTION); case khtml::BOX: return new CSSPrimitiveValueImpl(CSS_VAL__KHTML_BOX); case khtml::INLINE_BOX: return new CSSPrimitiveValueImpl(CSS_VAL__KHTML_INLINE_BOX); case khtml::NONE: return new CSSPrimitiveValueImpl(CSS_VAL_NONE); } ASSERT_NOT_REACHED(); return 0; case CSS_PROP_EMPTY_CELLS: switch (style->emptyCells()) { case khtml::SHOW: return new CSSPrimitiveValueImpl(CSS_VAL_SHOW); case khtml::HIDE: return new CSSPrimitiveValueImpl(CSS_VAL_HIDE); } ASSERT_NOT_REACHED(); return 0; case CSS_PROP_FLOAT: switch (style->floating()) { case khtml::FNONE: return new CSSPrimitiveValueImpl(CSS_VAL_NONE); case khtml::FLEFT: return new CSSPrimitiveValueImpl(CSS_VAL_LEFT); case khtml::FRIGHT: return new CSSPrimitiveValueImpl(CSS_VAL_RIGHT); } ASSERT_NOT_REACHED(); return 0; case CSS_PROP_FONT_FAMILY: { FontDef def = style->htmlFont().getFontDef(); return new CSSPrimitiveValueImpl(def.firstFamily().family().domString(), CSSPrimitiveValue::CSS_STRING); } case CSS_PROP_FONT_SIZE: { FontDef def = style->htmlFont().getFontDef(); return new CSSPrimitiveValueImpl(def.specifiedSize, CSSPrimitiveValue::CSS_PX); } case CSS_PROP_FONT_STRETCH: // FIXME: unimplemented break; case CSS_PROP_FONT_STYLE: { // FIXME: handle oblique? FontDef def = style->htmlFont().getFontDef(); if (def.italic) return new CSSPrimitiveValueImpl(CSS_VAL_ITALIC); else return new CSSPrimitiveValueImpl(CSS_VAL_NORMAL); } case CSS_PROP_FONT_VARIANT: { FontDef def = style->htmlFont().getFontDef(); if (def.smallCaps) return new CSSPrimitiveValueImpl(CSS_VAL_SMALL_CAPS); else return new CSSPrimitiveValueImpl(CSS_VAL_NORMAL); } case CSS_PROP_FONT_WEIGHT: { // FIXME: this does not reflect the full range of weights // that can be expressed with CSS FontDef def = style->htmlFont().getFontDef(); if (def.weight == QFont::Bold) return new CSSPrimitiveValueImpl(CSS_VAL_BOLD); else return new CSSPrimitiveValueImpl(CSS_VAL_NORMAL); } case CSS_PROP_HEIGHT: return new CSSPrimitiveValueImpl(renderer->contentHeight(), CSSPrimitiveValue::CSS_PX); case CSS_PROP_LEFT: return getPositionOffsetValue(renderer, CSS_PROP_LEFT); case CSS_PROP_LETTER_SPACING: if (style->letterSpacing() == 0) return new CSSPrimitiveValueImpl(CSS_VAL_NORMAL); return new CSSPrimitiveValueImpl(style->letterSpacing(), CSSPrimitiveValue::CSS_PX); case CSS_PROP__APPLE_LINE_CLAMP: return new CSSPrimitiveValueImpl(style->lineClamp(), CSSPrimitiveValue::CSS_PERCENTAGE); case CSS_PROP_LINE_HEIGHT: { Length length(style->lineHeight()); if (length.value < 0) return new CSSPrimitiveValueImpl(CSS_VAL_NORMAL); if (length.isPercent()) { // This is imperfect, because it doesn't include the zoom factor and the real computation // for how high to be in pixels does include things like minimum font size and the zoom factor. // On the other hand, since font-size doesn't include the zoom factor, we really can't do // that here either. float fontSize = style->htmlFont().getFontDef().specifiedSize; return new CSSPrimitiveValueImpl((int)(length.length() * fontSize) / 100, CSSPrimitiveValue::CSS_PX); } else { return new CSSPrimitiveValueImpl(length.length(), CSSPrimitiveValue::CSS_PX); } } case CSS_PROP_LIST_STYLE_IMAGE: if (style->listStyleImage()) return new CSSPrimitiveValueImpl(style->listStyleImage()->url(), CSSPrimitiveValue::CSS_URI); return new CSSPrimitiveValueImpl(CSS_VAL_NONE); case CSS_PROP_LIST_STYLE_POSITION: switch (style->listStylePosition()) { case khtml::OUTSIDE: return new CSSPrimitiveValueImpl(CSS_VAL_OUTSIDE); case khtml::INSIDE: return new CSSPrimitiveValueImpl(CSS_VAL_INSIDE); } ASSERT_NOT_REACHED(); return 0; case CSS_PROP_LIST_STYLE_TYPE: switch (style->listStyleType()) { case khtml::LNONE: return new CSSPrimitiveValueImpl(CSS_VAL_NONE); case khtml::DISC: return new CSSPrimitiveValueImpl(CSS_VAL_DISC); case khtml::CIRCLE: return new CSSPrimitiveValueImpl(CSS_VAL_CIRCLE); case khtml::SQUARE: return new CSSPrimitiveValueImpl(CSS_VAL_SQUARE); case khtml::LDECIMAL: return new CSSPrimitiveValueImpl(CSS_VAL_DECIMAL); case khtml::DECIMAL_LEADING_ZERO: return new CSSPrimitiveValueImpl(CSS_VAL_DECIMAL_LEADING_ZERO); case khtml::LOWER_ROMAN: return new CSSPrimitiveValueImpl(CSS_VAL_LOWER_ROMAN); case khtml::UPPER_ROMAN: return new CSSPrimitiveValueImpl(CSS_VAL_UPPER_ROMAN); case khtml::LOWER_GREEK: return new CSSPrimitiveValueImpl(CSS_VAL_LOWER_GREEK); case khtml::LOWER_ALPHA: return new CSSPrimitiveValueImpl(CSS_VAL_LOWER_ALPHA); case khtml::LOWER_LATIN: return new CSSPrimitiveValueImpl(CSS_VAL_LOWER_LATIN); case khtml::UPPER_ALPHA: return new CSSPrimitiveValueImpl(CSS_VAL_UPPER_ALPHA); case khtml::UPPER_LATIN: return new CSSPrimitiveValueImpl(CSS_VAL_UPPER_LATIN); case khtml::HEBREW: return new CSSPrimitiveValueImpl(CSS_VAL_HEBREW); case khtml::ARMENIAN: return new CSSPrimitiveValueImpl(CSS_VAL_ARMENIAN); case khtml::GEORGIAN: return new CSSPrimitiveValueImpl(CSS_VAL_GEORGIAN); case khtml::CJK_IDEOGRAPHIC: return new CSSPrimitiveValueImpl(CSS_VAL_CJK_IDEOGRAPHIC); case khtml::HIRAGANA: return new CSSPrimitiveValueImpl(CSS_VAL_HIRAGANA); case khtml::KATAKANA: return new CSSPrimitiveValueImpl(CSS_VAL_KATAKANA); case khtml::HIRAGANA_IROHA: return new CSSPrimitiveValueImpl(CSS_VAL_HIRAGANA_IROHA); case khtml::KATAKANA_IROHA: return new CSSPrimitiveValueImpl(CSS_VAL_KATAKANA_IROHA); } ASSERT_NOT_REACHED(); return 0; case CSS_PROP_MARGIN_TOP: return valueForLength(style->marginTop()); case CSS_PROP_MARGIN_RIGHT: return valueForLength(style->marginRight()); case CSS_PROP_MARGIN_BOTTOM: return valueForLength(style->marginBottom()); case CSS_PROP_MARGIN_LEFT: return valueForLength(style->marginLeft()); case CSS_PROP__KHTML_MARQUEE: // FIXME: unimplemented break; case CSS_PROP__KHTML_MARQUEE_DIRECTION: switch (style->marqueeDirection()) { case khtml::MFORWARD: return new CSSPrimitiveValueImpl(CSS_VAL_FORWARDS); case khtml::MBACKWARD: return new CSSPrimitiveValueImpl(CSS_VAL_BACKWARDS); case khtml::MAUTO: return new CSSPrimitiveValueImpl(CSS_VAL_AUTO); case khtml::MUP: return new CSSPrimitiveValueImpl(CSS_VAL_UP); case khtml::MDOWN: return new CSSPrimitiveValueImpl(CSS_VAL_DOWN); case khtml::MLEFT: return new CSSPrimitiveValueImpl(CSS_VAL_LEFT); case khtml::MRIGHT: return new CSSPrimitiveValueImpl(CSS_VAL_RIGHT); } ASSERT_NOT_REACHED(); return 0; case CSS_PROP__KHTML_MARQUEE_INCREMENT: return valueForLength(style->marqueeIncrement()); case CSS_PROP__KHTML_MARQUEE_REPETITION: if (style->marqueeLoopCount() < 0) return new CSSPrimitiveValueImpl(CSS_VAL_INFINITE); return new CSSPrimitiveValueImpl(style->marqueeLoopCount(), CSSPrimitiveValue::CSS_NUMBER); case CSS_PROP__KHTML_MARQUEE_SPEED: // FIXME: unimplemented break; case CSS_PROP__KHTML_MARQUEE_STYLE: switch (style->marqueeBehavior()) { case khtml::MNONE: return new CSSPrimitiveValueImpl(CSS_VAL_NONE); case khtml::MSCROLL: return new CSSPrimitiveValueImpl(CSS_VAL_SCROLL); case khtml::MSLIDE: return new CSSPrimitiveValueImpl(CSS_VAL_SLIDE); case khtml::MALTERNATE: return new CSSPrimitiveValueImpl(CSS_VAL_ALTERNATE); case khtml::MUNFURL: return new CSSPrimitiveValueImpl(CSS_VAL_UNFURL); } ASSERT_NOT_REACHED(); return 0; case CSS_PROP__KHTML_USER_MODIFY: switch (style->userModify()) { case khtml::READ_ONLY: return new CSSPrimitiveValueImpl(CSS_VAL_READ_ONLY); case khtml::READ_WRITE: return new CSSPrimitiveValueImpl(CSS_VAL_READ_WRITE); } ASSERT_NOT_REACHED(); return 0; case CSS_PROP_MAX_HEIGHT: return valueForLength(style->maxHeight()); case CSS_PROP_MAX_WIDTH: return valueForLength(style->maxWidth()); case CSS_PROP_MIN_HEIGHT: return valueForLength(style->minHeight()); case CSS_PROP_MIN_WIDTH: return valueForLength(style->minWidth()); case CSS_PROP_OPACITY: return new CSSPrimitiveValueImpl(style->opacity(), CSSPrimitiveValue::CSS_NUMBER); case CSS_PROP_ORPHANS: return new CSSPrimitiveValueImpl(style->orphans(), CSSPrimitiveValue::CSS_NUMBER); case CSS_PROP_OUTLINE_COLOR: // FIXME: unimplemented break; case CSS_PROP_OUTLINE_OFFSET: // FIXME: unimplemented break; case CSS_PROP_OUTLINE_STYLE: if (style->outlineStyleIsAuto()) return new CSSPrimitiveValueImpl(CSS_VAL_AUTO); return valueForBorderStyle(style->outlineStyle()); case CSS_PROP_OUTLINE_WIDTH: // FIXME: unimplemented break; case CSS_PROP_OVERFLOW: switch (style->overflow()) { case khtml::OVISIBLE: return new CSSPrimitiveValueImpl(CSS_VAL_VISIBLE); case khtml::OHIDDEN: return new CSSPrimitiveValueImpl(CSS_VAL_HIDDEN); case khtml::OSCROLL: return new CSSPrimitiveValueImpl(CSS_VAL_SCROLL); case khtml::OAUTO: return new CSSPrimitiveValueImpl(CSS_VAL_AUTO); case khtml::OMARQUEE: return new CSSPrimitiveValueImpl(CSS_VAL_MARQUEE); case khtml::OOVERLAY: return new CSSPrimitiveValueImpl(CSS_VAL_OVERLAY); } ASSERT_NOT_REACHED(); return 0; case CSS_PROP_PADDING_TOP: return valueForLength(style->paddingTop()); case CSS_PROP_PADDING_RIGHT: return valueForLength(style->paddingRight()); case CSS_PROP_PADDING_BOTTOM: return valueForLength(style->paddingBottom()); case CSS_PROP_PADDING_LEFT: return valueForLength(style->paddingLeft()); case CSS_PROP_PAGE: // FIXME: unimplemented break; case CSS_PROP_PAGE_BREAK_AFTER: switch (style->pageBreakAfter()) { case khtml::PBAUTO: return new CSSPrimitiveValueImpl(CSS_VAL_AUTO); case khtml::PBALWAYS: return new CSSPrimitiveValueImpl(CSS_VAL_ALWAYS); case khtml::PBAVOID: return new CSSPrimitiveValueImpl(CSS_VAL_AVOID); } ASSERT_NOT_REACHED(); return 0; case CSS_PROP_PAGE_BREAK_BEFORE: switch (style->pageBreakBefore()) { case khtml::PBAUTO: return new CSSPrimitiveValueImpl(CSS_VAL_AUTO); case khtml::PBALWAYS: return new CSSPrimitiveValueImpl(CSS_VAL_ALWAYS); case khtml::PBAVOID: return new CSSPrimitiveValueImpl(CSS_VAL_AVOID); } ASSERT_NOT_REACHED(); return 0; case CSS_PROP_PAGE_BREAK_INSIDE: switch (style->pageBreakInside()) { case khtml::PBAUTO: return new CSSPrimitiveValueImpl(CSS_VAL_AUTO); case khtml::PBAVOID: return new CSSPrimitiveValueImpl(CSS_VAL_AVOID); case khtml::PBALWAYS: break; // not allowed } ASSERT_NOT_REACHED(); return 0; case CSS_PROP_POSITION: switch (style->position()) { case khtml::STATIC: return new CSSPrimitiveValueImpl(CSS_VAL_STATIC); case khtml::RELATIVE: return new CSSPrimitiveValueImpl(CSS_VAL_RELATIVE); case khtml::ABSOLUTE: return new CSSPrimitiveValueImpl(CSS_VAL_ABSOLUTE); case khtml::FIXED: return new CSSPrimitiveValueImpl(CSS_VAL_FIXED); } ASSERT_NOT_REACHED(); return 0; case CSS_PROP_QUOTES: // FIXME: unimplemented break; case CSS_PROP_RIGHT: return getPositionOffsetValue(renderer, CSS_PROP_RIGHT); case CSS_PROP_SIZE: // FIXME: unimplemented break; case CSS_PROP_TABLE_LAYOUT: switch (style->tableLayout()) { case khtml::TAUTO: return new CSSPrimitiveValueImpl(CSS_VAL_AUTO); case khtml::TFIXED: return new CSSPrimitiveValueImpl(CSS_VAL_FIXED); } ASSERT_NOT_REACHED(); return 0; case CSS_PROP_TEXT_ALIGN: return valueForTextAlign(style->textAlign()); case CSS_PROP_TEXT_DECORATION: { QString string; if (style->textDecoration() & khtml::UNDERLINE) string += "underline"; if (style->textDecoration() & khtml::OVERLINE) { if (string.length() > 0) string += " "; string += "overline"; } if (style->textDecoration() & khtml::LINE_THROUGH) { if (string.length() > 0) string += " "; string += "line-through"; } if (style->textDecoration() & khtml::BLINK) { if (string.length() > 0) string += " "; string += "blink"; } if (string.length() == 0) return new CSSPrimitiveValueImpl(CSS_VAL_NONE); return new CSSPrimitiveValueImpl(string, CSSPrimitiveValue::CSS_STRING); } case CSS_PROP__KHTML_TEXT_DECORATIONS_IN_EFFECT: { QString string; if (style->textDecorationsInEffect() & khtml::UNDERLINE) string += "underline"; if (style->textDecorationsInEffect() & khtml::OVERLINE) { if (string.length() > 0) string += " "; string += "overline"; } if (style->textDecorationsInEffect() & khtml::LINE_THROUGH) { if (string.length() > 0) string += " "; string += "line-through"; } if (style->textDecorationsInEffect() & khtml::BLINK) { if (string.length() > 0) string += " "; string += "blink"; } if (string.length() == 0) return new CSSPrimitiveValueImpl(CSS_VAL_NONE); return new CSSPrimitiveValueImpl(string, CSSPrimitiveValue::CSS_STRING); } case CSS_PROP_TEXT_INDENT: return valueForLength(style->textIndent()); case CSS_PROP_TEXT_SHADOW: return valueForShadow(style->textShadow()); case CSS_PROP__APPLE_TEXT_SIZE_ADJUST: if (style->textSizeAdjust()) return new CSSPrimitiveValueImpl(CSS_VAL_AUTO); else return new CSSPrimitiveValueImpl(CSS_VAL_NONE); case CSS_PROP_TEXT_TRANSFORM: switch (style->textTransform()) { case khtml::CAPITALIZE: return new CSSPrimitiveValueImpl(CSS_VAL_CAPITALIZE); case khtml::UPPERCASE: return new CSSPrimitiveValueImpl(CSS_VAL_UPPERCASE); case khtml::LOWERCASE: return new CSSPrimitiveValueImpl(CSS_VAL_LOWERCASE); case khtml::TTNONE: return new CSSPrimitiveValueImpl(CSS_VAL_NONE); } ASSERT_NOT_REACHED(); return 0; case CSS_PROP_TOP: return getPositionOffsetValue(renderer, CSS_PROP_TOP); case CSS_PROP_UNICODE_BIDI: switch (style->unicodeBidi()) { case khtml::UBNormal: return new CSSPrimitiveValueImpl(CSS_VAL_NORMAL); case khtml::Embed: return new CSSPrimitiveValueImpl(CSS_VAL_EMBED); case khtml::Override: return new CSSPrimitiveValueImpl(CSS_VAL_BIDI_OVERRIDE); } ASSERT_NOT_REACHED(); return 0; case CSS_PROP_VERTICAL_ALIGN: switch (style->verticalAlign()) { case khtml::BASELINE: return new CSSPrimitiveValueImpl(CSS_VAL_BASELINE); case khtml::MIDDLE: return new CSSPrimitiveValueImpl(CSS_VAL_MIDDLE); case khtml::SUB: return new CSSPrimitiveValueImpl(CSS_VAL_SUB); case khtml::SUPER: return new CSSPrimitiveValueImpl(CSS_VAL_SUPER); case khtml::TEXT_TOP: return new CSSPrimitiveValueImpl(CSS_VAL_TEXT_TOP); case khtml::TEXT_BOTTOM: return new CSSPrimitiveValueImpl(CSS_VAL_TEXT_BOTTOM); case khtml::TOP: return new CSSPrimitiveValueImpl(CSS_VAL_TOP); case khtml::BOTTOM: return new CSSPrimitiveValueImpl(CSS_VAL_BOTTOM); case khtml::BASELINE_MIDDLE: return new CSSPrimitiveValueImpl(CSS_VAL__KHTML_BASELINE_MIDDLE); case khtml::LENGTH: return valueForLength(style->verticalAlignLength()); } ASSERT_NOT_REACHED(); return 0; case CSS_PROP_VISIBILITY: switch (style->visibility()) { case khtml::VISIBLE: return new CSSPrimitiveValueImpl(CSS_VAL_VISIBLE); case khtml::HIDDEN: return new CSSPrimitiveValueImpl(CSS_VAL_HIDDEN); case khtml::COLLAPSE: return new CSSPrimitiveValueImpl(CSS_VAL_COLLAPSE); } ASSERT_NOT_REACHED(); return 0; case CSS_PROP_WHITE_SPACE: switch (style->whiteSpace()) { case khtml::NORMAL: return new CSSPrimitiveValueImpl(CSS_VAL_NORMAL); case khtml::PRE: return new CSSPrimitiveValueImpl(CSS_VAL_PRE); case khtml::NOWRAP: return new CSSPrimitiveValueImpl(CSS_VAL_NOWRAP); case khtml::KHTML_NOWRAP: return new CSSPrimitiveValueImpl(CSS_VAL__KHTML_NOWRAP); } ASSERT_NOT_REACHED(); return 0; case CSS_PROP_WIDOWS: return new CSSPrimitiveValueImpl(style->widows(), CSSPrimitiveValue::CSS_NUMBER); case CSS_PROP_WIDTH: return new CSSPrimitiveValueImpl(renderer->contentWidth(), CSSPrimitiveValue::CSS_PX); case CSS_PROP_WORD_SPACING: return new CSSPrimitiveValueImpl(style->wordSpacing(), CSSPrimitiveValue::CSS_PX); case CSS_PROP_WORD_WRAP: switch (style->wordWrap()) { case khtml::WBNORMAL: return new CSSPrimitiveValueImpl(CSS_VAL_NORMAL); case khtml::BREAK_WORD: return new CSSPrimitiveValueImpl(CSS_VAL_BREAK_WORD); } ASSERT_NOT_REACHED(); return 0; case CSS_PROP__KHTML_LINE_BREAK: switch (style->khtmlLineBreak()) { case khtml::LBNORMAL: return new CSSPrimitiveValueImpl(CSS_VAL_NORMAL); case khtml::AFTER_WHITE_SPACE: return new CSSPrimitiveValueImpl(CSS_VAL_AFTER_WHITE_SPACE); } ASSERT_NOT_REACHED(); return 0; case CSS_PROP__KHTML_NBSP_MODE: switch (style->nbspMode()) { case khtml::NBNORMAL: return new CSSPrimitiveValueImpl(CSS_VAL_NORMAL); case khtml::SPACE: return new CSSPrimitiveValueImpl(CSS_VAL_SPACE); } ASSERT_NOT_REACHED(); return 0; case CSS_PROP__KHTML_MATCH_NEAREST_MAIL_BLOCKQUOTE_COLOR: switch (style->matchNearestMailBlockquoteColor()) { case khtml::BCNORMAL: return new CSSPrimitiveValueImpl(CSS_VAL_NORMAL); case khtml::MATCH: return new CSSPrimitiveValueImpl(CSS_VAL_MATCH); } ASSERT_NOT_REACHED(); return 0; case CSS_PROP_Z_INDEX: if (style->hasAutoZIndex()) return new CSSPrimitiveValueImpl(CSS_VAL_NORMAL); return new CSSPrimitiveValueImpl(style->zIndex(), CSSPrimitiveValue::CSS_NUMBER); case CSS_PROP_BACKGROUND: // FIXME: unimplemented break; case CSS_PROP_BORDER: // FIXME: unimplemented break; case CSS_PROP_BORDER_COLOR: // FIXME: unimplemented break; case CSS_PROP_BORDER_STYLE: // FIXME: unimplemented break; case CSS_PROP_BORDER_TOP: // FIXME: unimplemented break; case CSS_PROP_BORDER_RIGHT: // FIXME: unimplemented break; case CSS_PROP_BORDER_BOTTOM: // FIXME: unimplemented break; case CSS_PROP_BORDER_LEFT: // FIXME: unimplemented break; case CSS_PROP_BORDER_WIDTH: // FIXME: unimplemented break; case CSS_PROP_FONT: // FIXME: unimplemented break; case CSS_PROP_LIST_STYLE: // FIXME: unimplemented break; case CSS_PROP_MARGIN: // FIXME: unimplemented break; case CSS_PROP_OUTLINE: // FIXME: unimplemented break; case CSS_PROP_PADDING: // FIXME: unimplemented break; #if !APPLE_CHANGES case CSS_PROP_SCROLLBAR_FACE_COLOR: // FIXME: unimplemented break; case CSS_PROP_SCROLLBAR_SHADOW_COLOR: // FIXME: unimplemented break; case CSS_PROP_SCROLLBAR_HIGHLIGHT_COLOR: // FIXME: unimplemented break; case CSS_PROP_SCROLLBAR_3DLIGHT_COLOR: // FIXME: unimplemented break; case CSS_PROP_SCROLLBAR_DARKSHADOW_COLOR: // FIXME: unimplemented break; case CSS_PROP_SCROLLBAR_TRACK_COLOR: // FIXME: unimplemented break; case CSS_PROP_SCROLLBAR_ARROW_COLOR: // FIXME: unimplemented break; #endif #if APPLE_CHANGES case CSS_PROP__APPLE_DASHBOARD_REGION: { QValueList<StyleDashboardRegion> regions = style->dashboardRegions(); uint i, count = regions.count(); if (count == 1 && regions[0].type == StyleDashboardRegion::None) return new CSSPrimitiveValueImpl (CSS_VAL_NONE); DashboardRegionImpl *firstRegion = new DashboardRegionImpl(), *region; region = firstRegion; for (i = 0; i < count; i++) { StyleDashboardRegion styleRegion = regions[i]; region->m_label = styleRegion.label; LengthBox offset = styleRegion.offset; region->setTop (new CSSPrimitiveValueImpl(offset.top.value, CSSPrimitiveValue::CSS_PX)); region->setRight (new CSSPrimitiveValueImpl(offset.right.value, CSSPrimitiveValue::CSS_PX)); region->setBottom (new CSSPrimitiveValueImpl(offset.bottom.value, CSSPrimitiveValue::CSS_PX)); region->setLeft (new CSSPrimitiveValueImpl(offset.left.value, CSSPrimitiveValue::CSS_PX)); region->m_isRectangle = (styleRegion.type == StyleDashboardRegion::Rectangle); region->m_isCircle = (styleRegion.type == StyleDashboardRegion::Circle); if (i != count-1) { DashboardRegionImpl *newRegion = new DashboardRegionImpl(); region->setNext (newRegion); region = newRegion; } } return new CSSPrimitiveValueImpl(firstRegion); } #endif } ERROR("unimplemented propertyID: %d", propertyID); return 0; }
void XMLTokenizer::finish() { m_source.setFinished(true); if(!m_noErrors) { // An error occurred during parsing of the code. Display an error page to the user (the DOM // tree is created manually and includes an excerpt from the code where the error is located) // ### for multiple error messages, display the code for each (can this happen?) // Clear the document int exceptioncode = 0; while(m_doc->hasChildNodes()) static_cast< NodeImpl * >(m_doc)->removeChild(m_doc->firstChild(), exceptioncode); QString line, errorLocPtr; if(m_handler.errorLine) { QString xmlCode = m_source.data(); QTextIStream stream(&xmlCode); for(unsigned long lineno = 0; lineno < m_handler.errorLine - 1; lineno++) stream.readLine(); line = stream.readLine(); for(unsigned long colno = 0; colno < m_handler.errorCol - 1; colno++) errorLocPtr += " "; errorLocPtr += "^"; } // Create elements for display DocumentImpl *doc = m_doc; NodeImpl *html = doc->createElementNS(XHTML_NAMESPACE, "html"); NodeImpl *body = doc->createElementNS(XHTML_NAMESPACE, "body"); NodeImpl *h1 = doc->createElementNS(XHTML_NAMESPACE, "h1"); NodeImpl *headingText = doc->createTextNode(i18n("XML parsing error")); NodeImpl *errorText = doc->createTextNode(m_handler.errorProtocol()); NodeImpl *hr = 0; NodeImpl *pre = 0; NodeImpl *lineText = 0; NodeImpl *errorLocText = 0; if(!line.isNull()) { hr = doc->createElementNS(XHTML_NAMESPACE, "hr"); pre = doc->createElementNS(XHTML_NAMESPACE, "pre"); lineText = doc->createTextNode(line + "\n"); errorLocText = doc->createTextNode(errorLocPtr); } // Construct DOM tree. We ignore exceptions as we assume they will not be thrown here (due to the // fact we are using a known tag set) doc->appendChild(html, exceptioncode); html->appendChild(body, exceptioncode); if(body) body->appendChild(h1, exceptioncode); h1->appendChild(headingText, exceptioncode); body->appendChild(errorText, exceptioncode); body->appendChild(hr, exceptioncode); body->appendChild(pre, exceptioncode); if(pre) { pre->appendChild(lineText, exceptioncode); pre->appendChild(errorLocText, exceptioncode); } // Close the renderers so that they update their display correctly // ### this should not be necessary, but requires changes in the rendering code... h1->close(); if(pre) pre->close(); body->close(); m_doc->recalcStyle(NodeImpl::Inherit); m_doc->updateRendering(); end(); } else { // Parsing was successful. Now locate all html <script> tags in the document and execute them // one by one addScripts(m_doc); m_scriptsIt = new QPtrListIterator< HTMLScriptElementImpl >(m_scripts); executeScripts(); } }