void EndTransparencyLayer::apply(GraphicsContext& context) const { context.endTransparencyLayer(); }
void DrawLineForDocumentMarker::apply(GraphicsContext& context) const { context.drawLineForDocumentMarker(m_point, m_width, m_style); }
void DrawFocusRingPath::apply(GraphicsContext& context) const { context.drawFocusRing(m_path, m_width, m_offset, m_color); }
void DrawPattern::apply(GraphicsContext& context) const { context.drawPattern(m_image.get(), m_destination, m_tileRect, m_patternTransform, m_phase, m_spacing, m_op, m_blendMode); }
void DrawLine::apply(GraphicsContext& context) const { context.drawLine(m_point1, m_point2); }
void ClipOutToPath::apply(GraphicsContext& context) const { context.clipOut(m_path); }
void DrawTiledImage::apply(GraphicsContext& context) const { context.drawTiledImage(m_image.get(), m_destination, m_source, m_tileSize, m_spacing, m_imagePaintingOptions); }
void Restore::apply(GraphicsContext& context) const { context.restore(); }
void Translate::apply(GraphicsContext& context) const { context.translate(m_x, m_y); }
void RenderImage::paintReplaced(PaintInfo& paintInfo, int tx, int ty) { int cWidth = contentWidth(); int cHeight = contentHeight(); int leftBorder = borderLeft(); int topBorder = borderTop(); int leftPad = paddingLeft(); int topPad = paddingTop(); GraphicsContext* context = paintInfo.context; if (!m_imageResource->hasImage() || m_imageResource->errorOccurred()) { if (paintInfo.phase == PaintPhaseSelection) return; if (cWidth > 2 && cHeight > 2) { // Draw an outline rect where the image should be. #ifdef ANDROID_FIX // see http://b/issue?id=2052757 context->save(); #endif context->setStrokeStyle(SolidStroke); context->setStrokeColor(Color::lightGray, style()->colorSpace()); context->setFillColor(Color::transparent, style()->colorSpace()); context->drawRect(IntRect(tx + leftBorder + leftPad, ty + topBorder + topPad, cWidth, cHeight)); #ifdef ANDROID_FIX // see http://b/issue?id=2052757 context->restore(); #endif bool errorPictureDrawn = false; int imageX = 0; int imageY = 0; // When calculating the usable dimensions, exclude the pixels of // the ouline rect so the error image/alt text doesn't draw on it. #ifdef CAPP_WEB_IMG_ALT_TEXT int usableWidth = cWidth; int usableHeight = cHeight; #else int usableWidth = cWidth - 2; int usableHeight = cHeight - 2; #endif RefPtr<Image> image = m_imageResource->image(); #ifdef CAPP_WEB_IMG_ALT_TEXT if (m_altText.isEmpty() && m_imageResource->errorOccurred() && !image->isNull() && (usableWidth >= image->width()) && (usableHeight >= image->height())) { #else if (m_imageResource->errorOccurred() && !image->isNull() && usableWidth >= image->width() && usableHeight >= image->height()) { #endif // Center the error image, accounting for border and padding. int centerX = (usableWidth - image->width()) / 2; if (centerX < 0) centerX = 0; int centerY = (usableHeight - image->height()) / 2; if (centerY < 0) centerY = 0; imageX = leftBorder + leftPad + centerX + 1; imageY = topBorder + topPad + centerY + 1; context->drawImage(image.get(), style()->colorSpace(), IntPoint(tx + imageX, ty + imageY)); errorPictureDrawn = true; } if (!m_altText.isEmpty()) { String text = document()->displayStringModifiedByEncoding(m_altText); context->setFillColor(style()->visitedDependentColor(CSSPropertyColor), style()->colorSpace()); int ax = tx + leftBorder + leftPad; int ay = ty + topBorder + topPad; const Font& font = style()->font(); const FontMetrics& fontMetrics = font.fontMetrics(); int ascent = fontMetrics.ascent(); // Only draw the alt text if it'll fit within the content box, // and only if it fits above the error image. TextRun textRun(text.characters(), text.length()); int textWidth = font.width(textRun); if (errorPictureDrawn) { if (usableWidth >= textWidth && fontMetrics.height() <= imageY) context->drawText(font, textRun, IntPoint(ax, ay + ascent)); #ifdef CAPP_WEB_IMG_ALT_TEXT } else if (cHeight >= fontMetrics.height()) { if(usableWidth >= textWidth) { context->drawText(style()->font(), textRun, IntPoint(ax, ay + ascent)); } else { String subString; unsigned int i, width, iLast; int spaceI, spaceW, noLines; noLines = usableHeight / fontMetrics.height(); for (i = 0, iLast = 0; i <= m_altText.length() && noLines; ) { noLines--; for (width = 0, spaceI = -1, spaceW = -1; ; i++) { width += font.primaryFont()->platformWidthForGlyph(m_altText[i]); if (' ' == m_altText.characterStartingAt(i)) { spaceI = i; spaceW = width; } if(width >= usableWidth || i > m_altText.length()) { if (noLines == 0 && i < m_altText.length()) { subString = m_altText.substring(iLast, i - iLast - 3); subString.append(String("...")); } else { if (spaceI > 0 && i < m_altText.length()) { i = spaceI + 1; width = spaceW; } subString = m_altText.substring(iLast, i - iLast); } iLast = i; width = (width < usableWidth)? width: usableWidth; break; } } TextRun run(subString); context->drawText(font, run, IntPoint(ax + ((usableWidth - width) / 2), ay + ascent)); ay += fontMetrics.height(); } } } #else } else if (usableWidth >= textWidth && cHeight >= fontMetrics.height()) context->drawText(font, textRun, IntPoint(ax, ay + ascent)); #endif } } } else if (m_imageResource->hasImage() && cWidth > 0 && cHeight > 0) { RefPtr<Image> img = m_imageResource->image(cWidth, cHeight); if (!img || img->isNull()) return; #if PLATFORM(MAC) if (style()->highlight() != nullAtom && !paintInfo.context->paintingDisabled()) paintCustomHighlight(tx - x(), ty - y(), style()->highlight(), true); #endif IntSize contentSize(cWidth, cHeight); IntRect rect(IntPoint(tx + leftBorder + leftPad, ty + topBorder + topPad), contentSize); paintIntoRect(context, rect); } }
void Save::apply(GraphicsContext& context) const { context.save(); }
void ApplyDeviceScaleFactor::apply(GraphicsContext& context) const { context.applyDeviceScaleFactor(m_scaleFactor); }
void ApplyFillPattern::apply(GraphicsContext& context) const { context.applyFillPattern(); }
void ApplyStrokePattern::apply(GraphicsContext& context) const { context.applyStrokePattern(); }
void ClearShadow::apply(GraphicsContext& context) const { context.clearShadow(); }
void Rotate::apply(GraphicsContext& context) const { context.rotate(m_angle); }
void ClipOut::apply(GraphicsContext& context) const { context.clipOut(m_rect); }
void Scale::apply(GraphicsContext& context) const { context.scale(m_size); }
void ClipPath::apply(GraphicsContext& context) const { context.clipPath(m_path, m_windRule); }
void ConcatenateCTM::apply(GraphicsContext& context) const { context.concatCTM(m_transform); }
void DrawTiledScaledImage::apply(GraphicsContext& context) const { context.drawTiledImage(m_image.get(), m_destination, m_source, m_tileScaleFactor, m_hRule, m_vRule, m_imagePaintingOptions); }
void SetLineCap::apply(GraphicsContext& context) const { context.setLineCap(m_lineCap); }
void DrawRect::apply(GraphicsContext& context) const { context.drawRect(m_rect, m_borderThickness); }
void SetLineDash::apply(GraphicsContext& context) const { context.setLineDash(m_dashArray, m_dashOffset); }
void DrawLinesForText::apply(GraphicsContext& context) const { context.drawLinesForText(point(), m_widths, m_printing, m_doubleLines); }
void SetLineJoin::apply(GraphicsContext& context) const { context.setLineJoin(m_lineJoin); }
void DrawEllipse::apply(GraphicsContext& context) const { context.drawEllipse(m_rect); }
void SetMiterLimit::apply(GraphicsContext& context) const { context.setMiterLimit(m_miterLimit); }
void DrawFocusRingRects::apply(GraphicsContext& context) const { context.drawFocusRing(m_rects, m_width, m_offset, m_color); }
void BeginTransparencyLayer::apply(GraphicsContext& context) const { context.beginTransparencyLayer(m_opacity); }