static VXdoc& _transform(Request& r, const String* stylesheet_source, VXdoc& vdoc, xsltStylesheetPtr stylesheet, const xmlChar** transform_params) { xmlDoc& xmldoc=vdoc.get_xmldoc(); xsltTransformContext_auto_ptr transformContext( xsltNewTransformContext(stylesheet, &xmldoc)); // make params literal if (transformContext->globalVars == NULL) // strangly not initialized by xsltNewTransformContext transformContext->globalVars = xmlHashCreate(20); xsltQuoteUserParams(transformContext.get(), (const char**)transform_params); // do transform xmlDoc *transformed=xsltApplyStylesheetUser( stylesheet, &xmldoc, 0/*already quoted-inserted transform_params*/, 0/*const char* output*/, 0/*FILE *profile*/, transformContext.get()); if(!transformed || xmlHaveGenericErrors()) throw XmlException(stylesheet_source, r); //gdome_xml_doc_mkref dislikes XML_HTML_DOCUMENT_NODE type, fixing transformed->type=XML_DOCUMENT_NODE; // constructing result VXdoc& result=*new VXdoc(r.charsets, *transformed); /* grabbing options <xsl:output !method = "xml" | "html" | "text" X| qname-but-not-ncname !version = nmtoken !encoding = string !omit-xml-declaration = "yes" | "no" !standalone = "yes" | "no" !doctype-public = string !doctype-system = string Xcdata-section-elements = qnames !indent = "yes" | "no" !media-type = string /> */ XDocOutputOptions& oo=result.output_options; oo.method=stylesheet->method?&r.transcode(stylesheet->method):0; oo.encoding=stylesheet->encoding?&r.transcode(stylesheet->encoding):0; oo.mediaType=stylesheet->mediaType?&r.transcode(stylesheet->mediaType):0; oo.indent=stylesheet->indent; oo.version=stylesheet->version?&r.transcode(stylesheet->version):0; oo.standalone=stylesheet->standalone; oo.omitXmlDeclaration=stylesheet->omitXmlDeclaration; // return return result; }
void SVGRootPainter::paintReplaced(const PaintInfo& paintInfo, const LayoutPoint& paintOffset) { // An empty viewport disables rendering. if (pixelSnappedSize(paintOffset).isEmpty()) return; // SVG outlines are painted during PaintPhaseForeground. if (shouldPaintSelfOutline(paintInfo.phase)) return; // An empty viewBox also disables rendering. // (http://www.w3.org/TR/SVG/coords.html#ViewBoxAttribute) SVGSVGElement* svg = toSVGSVGElement(m_layoutSVGRoot.node()); DCHECK(svg); if (svg->hasEmptyViewBox()) return; // Apply initial viewport clip. Optional<BoxClipper> boxClipper; if (m_layoutSVGRoot.shouldApplyViewportClip()) { // TODO(pdr): Clip the paint info cull rect here. boxClipper.emplace(m_layoutSVGRoot, paintInfo, paintOffset, ForceContentsClip); } PaintInfo paintInfoBeforeFiltering(paintInfo); AffineTransform transformToBorderBox = transformToPixelSnappedBorderBox(paintOffset); paintInfoBeforeFiltering.updateCullRect(transformToBorderBox); SVGTransformContext transformContext(paintInfoBeforeFiltering.context, m_layoutSVGRoot, transformToBorderBox); SVGPaintContext paintContext(m_layoutSVGRoot, paintInfoBeforeFiltering); if (paintContext.paintInfo().phase == PaintPhaseForeground && !paintContext.applyClipMaskAndFilterIfNecessary()) return; BoxPainter(m_layoutSVGRoot).paint(paintContext.paintInfo(), LayoutPoint()); PaintTiming& timing = PaintTiming::from(m_layoutSVGRoot.node()->document().topDocument()); timing.markFirstContentfulPaint(); }
void SVGImagePainter::paint(const PaintInfo& paintInfo) { if (paintInfo.phase != PaintPhaseForeground || m_layoutSVGImage.style()->visibility() != EVisibility::Visible || !m_layoutSVGImage.imageResource()->hasImage()) return; FloatRect boundingBox = m_layoutSVGImage.visualRectInLocalSVGCoordinates(); if (!paintInfo.cullRect().intersectsCullRect( m_layoutSVGImage.localToSVGParentTransform(), boundingBox)) return; PaintInfo paintInfoBeforeFiltering(paintInfo); // Images cannot have children so do not call updateCullRect. SVGTransformContext transformContext( paintInfoBeforeFiltering.context, m_layoutSVGImage, m_layoutSVGImage.localToSVGParentTransform()); { SVGPaintContext paintContext(m_layoutSVGImage, paintInfoBeforeFiltering); if (paintContext.applyClipMaskAndFilterIfNecessary() && !LayoutObjectDrawingRecorder::useCachedDrawingIfPossible( paintContext.paintInfo().context, m_layoutSVGImage, paintContext.paintInfo().phase)) { LayoutObjectDrawingRecorder recorder( paintContext.paintInfo().context, m_layoutSVGImage, paintContext.paintInfo().phase, boundingBox); paintForeground(paintContext.paintInfo()); } } if (m_layoutSVGImage.style()->outlineWidth()) { PaintInfo outlinePaintInfo(paintInfoBeforeFiltering); outlinePaintInfo.phase = PaintPhaseSelfOutlineOnly; ObjectPainter(m_layoutSVGImage) .paintOutline(outlinePaintInfo, LayoutPoint(boundingBox.location())); } }
void SVGForeignObjectPainter::paint(const PaintInfo& paintInfo) { if (paintInfo.phase != PaintPhaseForeground && paintInfo.phase != PaintPhaseSelection) return; PaintInfo paintInfoBeforeFiltering(paintInfo); paintInfoBeforeFiltering.updateCullRect( m_layoutSVGForeignObject.localSVGTransform()); SVGTransformContext transformContext( paintInfoBeforeFiltering.context, m_layoutSVGForeignObject, m_layoutSVGForeignObject.localSVGTransform()); Optional<FloatClipRecorder> clipRecorder; if (SVGLayoutSupport::isOverflowHidden(&m_layoutSVGForeignObject)) clipRecorder.emplace(paintInfoBeforeFiltering.context, m_layoutSVGForeignObject, paintInfoBeforeFiltering.phase, m_layoutSVGForeignObject.viewportRect()); SVGPaintContext paintContext(m_layoutSVGForeignObject, paintInfoBeforeFiltering); bool continueRendering = true; if (paintContext.paintInfo().phase == PaintPhaseForeground) continueRendering = paintContext.applyClipMaskAndFilterIfNecessary(); if (continueRendering) { // Paint all phases of FO elements atomically as though the FO element // established its own stacking context. The delegate forwards calls to // paint() in LayoutObject::paintAllPhasesAtomically() to // BlockPainter::paint(), instead of m_layoutSVGForeignObject.paint() (which // would call this method again). BlockPainterDelegate delegate(m_layoutSVGForeignObject); ObjectPainter(delegate).paintAllPhasesAtomically(paintContext.paintInfo(), LayoutPoint()); } }