From kde-commits Fri Jun 27 09:06:28 2008 From: Viacheslav Tokarev Date: Fri, 27 Jun 2008 09:06:28 +0000 To: kde-commits Subject: branches/work/khtml-blaze Message-Id: <1214557588.428989.8383.nullmailer () svn ! kde ! org> X-MARC-Message: https://marc.info/?l=kde-commits&m=121455759822446 SVN commit 825055 by vtokarev: It seems element also compiles & works. Haven't checked special features yet. M +3 -0 CMakeLists.txt M +2 -2 rendering/RenderPath.cpp M +2 -2 rendering/RenderSVGHiddenContainer.cpp M +7 -6 svg/SVGElementInstance.cpp M +6 -2 svg/SVGElementInstance.h M +1 -0 svg/SVGElementInstanceList.cpp M +1 -0 svg/SVGSymbolElement.cpp M +27 -24 svg/SVGUseElement.cpp M +4 -0 svg/SVGUseElement.h M +1 -0 xml/Document.h M +5 -0 xml/dom_docimpl.cpp M +1 -0 xml/dom_elementimpl.h M +3 -0 xml/dom_nodeimpl.h --- branches/work/khtml-blaze/CMakeLists.txt #825054:825055 @@ -108,6 +108,9 @@ ${CMAKE_SOURCE_DIR}/khtml/svg/SVGDefsElement.cpp ${CMAKE_SOURCE_DIR}/khtml/svg/SVGClipPathElement.cpp ${CMAKE_SOURCE_DIR}/khtml/svg/SVGGElement.cpp + ${CMAKE_SOURCE_DIR}/khtml/svg/SVGElementInstance.cpp + ${CMAKE_SOURCE_DIR}/khtml/svg/SVGElementInstanceList.cpp + ${CMAKE_SOURCE_DIR}/khtml/svg/SVGUseElement.cpp ############################################################# ## GRAPHICS ################################################# ############################################################# --- branches/work/khtml-blaze/rendering/RenderPath.cpp #825054:825055 @@ -202,9 +202,9 @@ void RenderPath::paint(PaintInfo& paintInfo, int, int) { - kDebug() << "painting..." << endl; + /*kDebug() << "painting..." << endl; kDebug() << "matrix: " << localTransform() << endl; - kDebug() << "style: " << style()->svgStyle()->hasFill() << endl; + kDebug() << "style: " << style()->svgStyle()->hasFill() << endl;*/ /*kDebug() << "path: " << *m_path.platformPath() << endl;*/ paintInfo.p->save(); paintInfo.p->setWorldMatrix(localTransform(), true); --- branches/work/khtml-blaze/rendering/RenderSVGHiddenContainer.cpp #825054:825055 @@ -62,12 +62,12 @@ // Layout our kids to prevent a kid from being marked as needing layout // then never being asked to layout. for (RenderObject* child = firstChild(); child; child = child->nextSibling()) { - if (child->isText()) continue; + if (child->isText()) continue; // FIXME remove it, vtokarev if (selfNeedsLayout()) child->setNeedsLayout(true); child->layoutIfNeeded(); - ASSERT(!child->needsLayout()); + //FIXME khtml vtokarev ASSERT(!child->needsLayout()); } setNeedsLayout(false); --- branches/work/khtml-blaze/svg/SVGElementInstance.cpp #825054:825055 @@ -20,12 +20,13 @@ */ #include "config.h" +#include "wtf/Platform.h" #if ENABLE(SVG) #include "SVGElementInstance.h" -#include "Event.h" -#include "EventListener.h" +/*#include "Event.h" +#include "EventListener.h"*/ #include "SVGElementInstanceList.h" #include "SVGUseElement.h" @@ -161,16 +162,16 @@ } // For all other nodes this logic is sufficient. - RefPtr clone = m_element->cloneNode(true); - SVGUseElement::removeDisallowedElementsFromSubtree(clone.get()); + Node* clone = m_element->cloneNode(true); + SVGUseElement::removeDisallowedElementsFromSubtree(clone); SVGElement* svgClone = 0; if (clone && clone->isSVGElement()) - svgClone = static_cast(clone.get()); + svgClone = static_cast(clone); ASSERT(svgClone); // Replace node in the shadow tree ExceptionCode ec = 0; - m_shadowTreeElement->parentNode()->replaceChild(clone.release(), m_shadowTreeElement, ec); + m_shadowTreeElement->parentNode()->replaceChild(clone, m_shadowTreeElement, ec); ASSERT(ec == 0); m_shadowTreeElement = svgClone; --- branches/work/khtml-blaze/svg/SVGElementInstance.h #825054:825055 @@ -24,7 +24,8 @@ #if ENABLE(SVG) -#include "EventTarget.h" +/*#include "EventTarget.h"*/ +#include "Document.h" //khtml #include #include @@ -34,7 +35,7 @@ class SVGUseElement; class SVGElementInstanceList; - class SVGElementInstance : public EventTarget { + class SVGElementInstance /*: public EventTarget*/ { public: SVGElementInstance(SVGUseElement*, PassRefPtr originalElement); virtual ~SVGElementInstance(); @@ -59,6 +60,9 @@ // Model the TreeShared concept, integrated within EventTarget inheritance. virtual void refEventTarget() { ++m_refCount; } virtual void derefEventTarget() { if (--m_refCount <= 0 && !m_parent) delete this; } + // khtml compat + virtual void ref() { refEventTarget(); } + virtual void deref() { derefEventTarget(); } bool hasOneRef() { return m_refCount == 1; } int refCount() const { return m_refCount; } --- branches/work/khtml-blaze/svg/SVGElementInstanceList.cpp #825054:825055 @@ -20,6 +20,7 @@ */ #include "config.h" +#include "wtf/Platform.h" #if ENABLE(SVG) #include "SVGElementInstanceList.h" --- branches/work/khtml-blaze/svg/SVGSymbolElement.cpp #825054:825055 @@ -21,6 +21,7 @@ */ #include "config.h" +#include "wtf/Platform.h" #if ENABLE(SVG) #include "SVGSymbolElement.h" --- branches/work/khtml-blaze/svg/SVGUseElement.cpp #825054:825055 @@ -21,6 +21,7 @@ */ #include "config.h" +#include "wtf/Platform.h" // Dump SVGElementInstance object tree - useful to debug instanceRoot problems // #define DUMP_INSTANCE_TREE @@ -32,10 +33,10 @@ #include "SVGUseElement.h" #include "CSSStyleSelector.h" -#include "CString.h" +/*#include "CString.h"*/ #include "Document.h" -#include "Event.h" -#include "HTMLNames.h" +/*#include "Event.h" +#include "HTMLNames.h"*/ #include "RenderSVGTransformableContainer.h" #include "SVGElementInstance.h" #include "SVGElementInstanceList.h" @@ -43,11 +44,11 @@ #include "SVGLength.h" #include "SVGNames.h" #include "SVGPreserveAspectRatio.h" -#include "SVGSMILElement.h" +/*#include "SVGSMILElement.h"*/ #include "SVGSVGElement.h" #include "SVGSymbolElement.h" #include "XLinkNames.h" -#include "XMLSerializer.h" +/*#include "XMLSerializer.h"*/ #include namespace WebCore { @@ -150,7 +151,7 @@ void SVGUseElement::childrenChanged(bool changedByParser, Node* beforeChange, Node* afterChange, int childCountDelta) { - SVGElement::childrenChanged(changedByParser, beforeChange, afterChange, childCountDelta); + SVGElement::childrenChanged(/*changedByParser, beforeChange, afterChange, childCountDelta*/); if (!attached()) return; @@ -175,20 +176,20 @@ // as the shadow tree root element has no (direct) parent node. Yes, shadow trees are tricky. if (change >= Inherit || m_shadowTreeRootElement->changed()) { RenderStyle* newStyle = document()->styleSelector()->styleForElement(m_shadowTreeRootElement.get()); - StyleChange ch = m_shadowTreeRootElement->diff(m_shadowTreeRootElement->renderStyle(), newStyle); + StyleChange ch = m_shadowTreeRootElement->diff((m_shadowTreeRootElement->renderer() ? m_shadowTreeRootElement->renderer()->style() : 0)/*renderStyle()*/, newStyle); if (ch == Detach) { ASSERT(m_shadowTreeRootElement->attached()); m_shadowTreeRootElement->detach(); attachShadowTree(); // attach recalulates the style for all children. No need to do it twice. - m_shadowTreeRootElement->setChanged(NoStyleChange); + m_shadowTreeRootElement->setChanged(/*NoStyleChange*/); m_shadowTreeRootElement->setHasChangedChild(false); - newStyle->deref(document()->renderArena()); + /*newStyle->deref(document()->renderArena());*/ return; } - newStyle->deref(document()->renderArena()); + /*newStyle->deref(document()->renderArena());*/ } // Only change==Detach needs special treatment, for anything else recalcStyle() works. @@ -513,7 +514,8 @@ void SVGUseElement::removeDisallowedElementsFromSubtree(Node* subtree) { - ASSERT(!subtree->inDocument()); + // Implement me: khtml, NodeImpl::traverseNextSibling + /*ASSERT(!subtree->inDocument()); ExceptionCode ec; Node* node = subtree->firstChild(); while (node) { @@ -524,7 +526,7 @@ node = next; } else node = node->traverseNextNode(subtree); - } + }*/ } void SVGUseElement::buildShadowTree(SVGElement* target, SVGElementInstance* targetInstance) @@ -533,23 +535,23 @@ if (isDisallowedElement(target)) return; - RefPtr newChild = targetInstance->correspondingElement()->cloneNode(true); + NodeImpl* newChild = targetInstance->correspondingElement()->cloneNode(true); // We don't walk the target tree element-by-element, and clone each element, // but instead use cloneNode(deep=true). This is an optimization for the common // case where doesn't contain disallowed elements (ie. ). // Though if there are disallowed elements in the subtree, we have to remove them. // For instance: on containing (indirect case). - if (subtreeContainsDisallowedElement(newChild.get())) - removeDisallowedElementsFromSubtree(newChild.get()); + if (subtreeContainsDisallowedElement(newChild)) + removeDisallowedElementsFromSubtree(newChild); SVGElement* newChildPtr = 0; if (newChild->isSVGElement()) - newChildPtr = static_cast(newChild.get()); + newChildPtr = static_cast(newChild); ASSERT(newChildPtr); ExceptionCode ec = 0; - m_shadowTreeRootElement->appendChild(newChild.release(), ec); + m_shadowTreeRootElement->appendChild(newChild, ec); ASSERT(ec == 0); // Handle use referencing special case @@ -705,11 +707,11 @@ void SVGUseElement::attachShadowTree() { - if (!m_shadowTreeRootElement || m_shadowTreeRootElement->attached() || !document()->shouldCreateRenderers() || !attached() || !renderer()) + if (!m_shadowTreeRootElement || m_shadowTreeRootElement->attached() || /*khtml !document()->shouldCreateRenderers() ||*/ !attached() || !renderer()) return; // Inspired by RenderTextControl::createSubtreeIfNeeded(). - if (renderer()->canHaveChildren() && childShouldCreateRenderer(m_shadowTreeRootElement.get())) { + if (renderer()->childAllowed()/*canHaveChildren()*/ && childShouldCreateRenderer(m_shadowTreeRootElement.get())) { RenderStyle* style = m_shadowTreeRootElement->styleForRenderer(renderer()); if (m_shadowTreeRootElement->rendererIsNeeded(style)) { @@ -721,7 +723,7 @@ } } - style->deref(document()->renderArena()); + /*style->deref(document()->renderArena());*/ // This will take care of attaching all shadow tree child nodes. for (Node* child = m_shadowTreeRootElement->firstChild(); child; child = child->nextSibling()) @@ -739,9 +741,9 @@ if (originalElement->hasTagName(SVGNames::useTag)) { #if ENABLE(SVG) && ENABLE(SVG_USE) // gets replaced by - ASSERT(target->nodeName() == SVGNames::gTag); + /*ASSERT(target->nodeName() == SVGNames::gTag);*/ #else - ASSERT(target->nodeName() == SVGNames::gTag || target->nodeName() == SVGNames::useTag); + /*ASSERT(target->nodeName() == SVGNames::gTag || target->nodeName() == SVGNames::useTag);*/ #endif } else if (originalElement->hasTagName(SVGNames::symbolTag)) { // gets replaced by @@ -794,7 +796,8 @@ void SVGUseElement::transferUseAttributesToReplacedElement(SVGElement* from, SVGElement* to) const { - ASSERT(from); + // Implement me: khtml + /*ASSERT(from); ASSERT(to); to->attributes()->setAttributes(*from->attributes()); @@ -814,7 +817,7 @@ ASSERT(ec == 0); to->removeAttribute(XLinkNames::hrefAttr, ec); - ASSERT(ec == 0); + ASSERT(ec == 0);*/ } } --- branches/work/khtml-blaze/svg/SVGUseElement.h #825054:825055 @@ -67,6 +67,10 @@ static void removeDisallowedElementsFromSubtree(Node* element); + // KHTML ElementImpl pure virtual method + virtual quint32 id() const { return SVGNames::gTag.id(); } + virtual DOMString tagName() const { return SVGNames::gTag.tagName(); } + protected: virtual const SVGElement* contextElement() const { return this; } --- branches/work/khtml-blaze/xml/Document.h #825054:825055 @@ -64,6 +64,7 @@ //typedef RenderCanvas RenderView; typedef StyleSheetImpl StyleSheet; typedef QColor Color; + typedef NodeImpl EventTargetNode; } #endif --- branches/work/khtml-blaze/xml/dom_docimpl.cpp #825054:825055 @@ -103,6 +103,7 @@ #include #include #include +#include #include #include @@ -1207,6 +1208,10 @@ n = new WebCore::SVGGElement(name, docPtr()); } + if (id == WebCore::SVGNames::useTag.localNameId().id()) { + n = new WebCore::SVGUseElement(name, docPtr()); + } + if (id == makeId(svgNamespace, ID_STYLE)) { n = new WebCore::SVGStyleElement(name, docPtr()); } --- branches/work/khtml-blaze/xml/dom_elementimpl.h #825054:825055 @@ -175,6 +175,7 @@ Attr setAttributeNode( AttrImpl* newAttr, int& exceptioncode ); Attr removeAttributeNode( AttrImpl* oldAttr, int& exceptioncode ); + DOMString getIDAttribute() { return getAttribute("id"); } DOMString getAttributeNS( const DOMString &namespaceURI, const DOMString &localName, int& exceptioncode ) const; void removeAttributeNS( const DOMString &namespaceURI, const DOMString &localName, int& exceptioncode ); --- branches/work/khtml-blaze/xml/dom_nodeimpl.h #825054:825055 @@ -201,6 +201,8 @@ virtual bool isGenericFormElement() const { return false; } virtual bool containsOnlyWhitespace() const { return false; } virtual bool isSVGElement() const { return false; } + virtual bool isShadowNode() const { return false; } + virtual NodeImpl* shadowParentNode() { return 0; } bool isBlockFlow() const; DOMString textContent() const; @@ -310,6 +312,7 @@ bool focused() const { return m_focused; } bool hovered() const { return m_hovered; } bool attached() const { return m_attached; } + void setAttached(bool b=true) { m_attached = b; } bool closed() const { return m_closed; } bool changed() const { return m_changed; } bool hasChangedChild() const { return m_hasChangedChild; }