📄 svgsvgelement.cpp
字号:
void SVGSVGElement::svgAttributeChanged(const QualifiedName& attrName){ SVGStyledElement::svgAttributeChanged(attrName); if (!renderer()) return; if (attrName == SVGNames::xAttr || attrName == SVGNames::yAttr || attrName == SVGNames::widthAttr || attrName == SVGNames::heightAttr || SVGTests::isKnownAttribute(attrName) || SVGLangSpace::isKnownAttribute(attrName) || SVGExternalResourcesRequired::isKnownAttribute(attrName) || SVGFitToViewBox::isKnownAttribute(attrName) || SVGZoomAndPan::isKnownAttribute(attrName) || SVGStyledLocatableElement::isKnownAttribute(attrName)) renderer()->setNeedsLayout(true);}unsigned long SVGSVGElement::suspendRedraw(unsigned long /* max_wait_milliseconds */){ // FIXME: Implement me (see bug 11275) return 0;}void SVGSVGElement::unsuspendRedraw(unsigned long /* suspend_handle_id */, ExceptionCode&){ // if suspend_handle_id is not found, throw exception // FIXME: Implement me (see bug 11275)}void SVGSVGElement::unsuspendRedrawAll(){ // FIXME: Implement me (see bug 11275)}void SVGSVGElement::forceRedraw(){ // FIXME: Implement me (see bug 11275)}NodeList* SVGSVGElement::getIntersectionList(const FloatRect&, SVGElement*){ // FIXME: Implement me (see bug 11274) return 0;}NodeList* SVGSVGElement::getEnclosureList(const FloatRect&, SVGElement*){ // FIXME: Implement me (see bug 11274) return 0;}bool SVGSVGElement::checkIntersection(SVGElement*, const FloatRect& rect){ // TODO : take into account pointer-events? // FIXME: Why is element ignored?? // FIXME: Implement me (see bug 11274) return rect.intersects(getBBox());}bool SVGSVGElement::checkEnclosure(SVGElement*, const FloatRect& rect){ // TODO : take into account pointer-events? // FIXME: Why is element ignored?? // FIXME: Implement me (see bug 11274) return rect.contains(getBBox());}void SVGSVGElement::deselectAll(){ document()->frame()->selection()->clear();}float SVGSVGElement::createSVGNumber(){ return 0.0f;}SVGLength SVGSVGElement::createSVGLength(){ return SVGLength();}PassRefPtr<SVGAngle> SVGSVGElement::createSVGAngle(){ return SVGAngle::create();}FloatPoint SVGSVGElement::createSVGPoint(){ return FloatPoint();}TransformationMatrix SVGSVGElement::createSVGMatrix(){ return TransformationMatrix();}FloatRect SVGSVGElement::createSVGRect(){ return FloatRect();}SVGTransform SVGSVGElement::createSVGTransform(){ return SVGTransform();}SVGTransform SVGSVGElement::createSVGTransformFromMatrix(const TransformationMatrix& matrix){ return SVGTransform(matrix);}TransformationMatrix SVGSVGElement::getCTM() const{ TransformationMatrix mat; if (!isOutermostSVG()) mat.translate(x().value(this), y().value(this)); if (attributes()->getAttributeItem(SVGNames::viewBoxAttr)) { TransformationMatrix viewBox = viewBoxToViewTransform(width().value(this), height().value(this)); mat = viewBox * mat; } return mat;}TransformationMatrix SVGSVGElement::getScreenCTM() const{ document()->updateLayoutIgnorePendingStylesheets(); FloatPoint rootLocation; if (RenderObject* renderer = this->renderer()) { if (isOutermostSVG()) { // FIXME: This doesn't work correctly with CSS transforms. FloatPoint point; if (renderer->parent()) point = renderer->localToAbsolute(point, true); rootLocation.move(point.x(), point.y()); } else rootLocation.move(x().value(this), y().value(this)); } TransformationMatrix mat = SVGStyledLocatableElement::getScreenCTM(); mat.translate(rootLocation.x(), rootLocation.y()); if (attributes()->getAttributeItem(SVGNames::viewBoxAttr)) { TransformationMatrix viewBox = viewBoxToViewTransform(width().value(this), height().value(this)); mat = viewBox * mat; } return mat;}RenderObject* SVGSVGElement::createRenderer(RenderArena* arena, RenderStyle*){ if (isOutermostSVG()) return new (arena) RenderSVGRoot(this); else return new (arena) RenderSVGViewportContainer(this);}void SVGSVGElement::insertedIntoDocument(){ document()->accessSVGExtensions()->addTimeContainer(this); SVGStyledLocatableElement::insertedIntoDocument();}void SVGSVGElement::removedFromDocument(){ document()->accessSVGExtensions()->removeTimeContainer(this); SVGStyledLocatableElement::removedFromDocument();}void SVGSVGElement::pauseAnimations(){ if (!m_timeContainer->isPaused()) m_timeContainer->pause();}void SVGSVGElement::unpauseAnimations(){ if (m_timeContainer->isPaused()) m_timeContainer->resume();}bool SVGSVGElement::animationsPaused() const{ return m_timeContainer->isPaused();}float SVGSVGElement::getCurrentTime() const{ return narrowPrecisionToFloat(m_timeContainer->elapsed().value());}void SVGSVGElement::setCurrentTime(float /* seconds */){ // FIXME: Implement me, bug 12073}bool SVGSVGElement::hasRelativeValues() const{ return (x().isRelative() || width().isRelative() || y().isRelative() || height().isRelative());}bool SVGSVGElement::isOutermostSVG() const{ // This is true whenever this is the outermost SVG, even if there are HTML elements outside it return !parentNode()->isSVGElement();}TransformationMatrix SVGSVGElement::viewBoxToViewTransform(float viewWidth, float viewHeight) const{ FloatRect viewBoxRect; if (useCurrentView()) { if (currentView()) // what if we should use it but it is not set? viewBoxRect = currentView()->viewBox(); } else viewBoxRect = viewBox(); if (!viewBoxRect.width() || !viewBoxRect.height()) return TransformationMatrix(); TransformationMatrix ctm = preserveAspectRatio()->getCTM(viewBoxRect.x(), viewBoxRect.y(), viewBoxRect.width(), viewBoxRect.height(), 0, 0, viewWidth, viewHeight); if (useCurrentView() && currentView()) return currentView()->transform()->concatenate().matrix() * ctm; return ctm;}void SVGSVGElement::inheritViewAttributes(SVGViewElement* viewElement){ setUseCurrentView(true); if (viewElement->hasAttribute(SVGNames::viewBoxAttr)) currentView()->setViewBox(viewElement->viewBox()); else currentView()->setViewBox(viewBox()); if (viewElement->hasAttribute(SVGNames::preserveAspectRatioAttr)) { currentView()->preserveAspectRatio()->setAlign(viewElement->preserveAspectRatio()->align()); currentView()->preserveAspectRatio()->setMeetOrSlice(viewElement->preserveAspectRatio()->meetOrSlice()); } else { currentView()->preserveAspectRatio()->setAlign(preserveAspectRatio()->align()); currentView()->preserveAspectRatio()->setMeetOrSlice(preserveAspectRatio()->meetOrSlice()); } if (viewElement->hasAttribute(SVGNames::zoomAndPanAttr)) currentView()->setZoomAndPan(viewElement->zoomAndPan()); renderer()->setNeedsLayout(true);} void SVGSVGElement::documentWillBecomeInactive(){ pauseAnimations();}void SVGSVGElement::documentDidBecomeActive(){ unpauseAnimations();}}#endif // ENABLE(SVG)// vim:ts=4:noet
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -