Example #1
0
void EndTransparencyLayer::apply(GraphicsContext& context) const
{
    context.endTransparencyLayer();
}
Example #2
0
void DrawLineForDocumentMarker::apply(GraphicsContext& context) const
{
    context.drawLineForDocumentMarker(m_point, m_width, m_style);
}
Example #3
0
void DrawFocusRingPath::apply(GraphicsContext& context) const
{
    context.drawFocusRing(m_path, m_width, m_offset, m_color);
}
Example #4
0
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);
}
Example #5
0
void DrawLine::apply(GraphicsContext& context) const
{
    context.drawLine(m_point1, m_point2);
}
Example #6
0
void ClipOutToPath::apply(GraphicsContext& context) const
{
    context.clipOut(m_path);
}
Example #7
0
void DrawTiledImage::apply(GraphicsContext& context) const
{
    context.drawTiledImage(m_image.get(), m_destination, m_source, m_tileSize, m_spacing, m_imagePaintingOptions);
}
Example #8
0
void Restore::apply(GraphicsContext& context) const
{
    context.restore();
}
Example #9
0
void Translate::apply(GraphicsContext& context) const
{
    context.translate(m_x, m_y);
}
Example #10
0
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);
    }
}
Example #11
0
void Save::apply(GraphicsContext& context) const
{
    context.save();
}
Example #12
0
void ApplyDeviceScaleFactor::apply(GraphicsContext& context) const
{
    context.applyDeviceScaleFactor(m_scaleFactor);
}
Example #13
0
void ApplyFillPattern::apply(GraphicsContext& context) const
{
    context.applyFillPattern();
}
Example #14
0
void ApplyStrokePattern::apply(GraphicsContext& context) const
{
    context.applyStrokePattern();
}
Example #15
0
void ClearShadow::apply(GraphicsContext& context) const
{
    context.clearShadow();
}
Example #16
0
void Rotate::apply(GraphicsContext& context) const
{
    context.rotate(m_angle);
}
Example #17
0
void ClipOut::apply(GraphicsContext& context) const
{
    context.clipOut(m_rect);
}
Example #18
0
void Scale::apply(GraphicsContext& context) const
{
    context.scale(m_size);
}
Example #19
0
void ClipPath::apply(GraphicsContext& context) const
{
    context.clipPath(m_path, m_windRule);
}
Example #20
0
void ConcatenateCTM::apply(GraphicsContext& context) const
{
    context.concatCTM(m_transform);
}
Example #21
0
void DrawTiledScaledImage::apply(GraphicsContext& context) const
{
    context.drawTiledImage(m_image.get(), m_destination, m_source, m_tileScaleFactor, m_hRule, m_vRule, m_imagePaintingOptions);
}
Example #22
0
void SetLineCap::apply(GraphicsContext& context) const
{
    context.setLineCap(m_lineCap);
}
Example #23
0
void DrawRect::apply(GraphicsContext& context) const
{
    context.drawRect(m_rect, m_borderThickness);
}
Example #24
0
void SetLineDash::apply(GraphicsContext& context) const
{
    context.setLineDash(m_dashArray, m_dashOffset);
}
Example #25
0
void DrawLinesForText::apply(GraphicsContext& context) const
{
    context.drawLinesForText(point(), m_widths, m_printing, m_doubleLines);
}
Example #26
0
void SetLineJoin::apply(GraphicsContext& context) const
{
    context.setLineJoin(m_lineJoin);
}
Example #27
0
void DrawEllipse::apply(GraphicsContext& context) const
{
    context.drawEllipse(m_rect);
}
Example #28
0
void SetMiterLimit::apply(GraphicsContext& context) const
{
    context.setMiterLimit(m_miterLimit);
}
Example #29
0
void DrawFocusRingRects::apply(GraphicsContext& context) const
{
    context.drawFocusRing(m_rects, m_width, m_offset, m_color);
}
Example #30
0
void BeginTransparencyLayer::apply(GraphicsContext& context) const
{
    context.beginTransparencyLayer(m_opacity);
}