Changeset 64004 in webkit


Ignore:
Timestamp:
Jul 23, 2010 5:09:52 PM (14 years ago)
Author:
jamesr@google.com
Message:

2010-07-23 James Robinson <jamesr@chromium.org>

Reviewed by Dimitri Glazkov.

CanvasRenderingContext2D has lots of style errors
https://bugs.webkit.org/show_bug.cgi?id=42918

CanvasRenderingContext2D.h and .cpp have lots of style errors. I'm planning to post patches
to both of these files soon, so to minimize merge conflicts and additional style violations
it seems best to fix all of these errors in bulk before posting any functional changes. In
particular the header file is incorrectly indented so any correctly formatted addition will
be out of place.

  • html/canvas/CanvasRenderingContext2D.cpp: (WebCore::CanvasRenderingContext2D::CanvasRenderingContext2D): (WebCore::CanvasRenderingContext2D::setFillStyle): (WebCore::CanvasRenderingContext2D::transform): (WebCore::CanvasRenderingContext2D::setTransform): (WebCore::CanvasRenderingContext2D::arcTo): (WebCore::CanvasRenderingContext2D::arc): (WebCore::validateRectForCanvas): (WebCore::CanvasRenderingContext2D::strokeRect): (WebCore::CanvasRenderingContext2D::drawImage): (WebCore::CanvasRenderingContext2D::createRadialGradient): (WebCore::CanvasRenderingContext2D::createPattern): (WebCore::CanvasRenderingContext2D::willDraw): (WebCore::CanvasRenderingContext2D::createImageData): (WebCore::CanvasRenderingContext2D::putImageData): (WebCore::CanvasRenderingContext2D::setFont): (WebCore::CanvasRenderingContext2D::drawTextInternal):
  • html/canvas/CanvasRenderingContext2D.h: (WebCore::CanvasRenderingContext2D::is2d): (WebCore::CanvasRenderingContext2D::getLineCap): (WebCore::CanvasRenderingContext2D::getLineJoin): (WebCore::CanvasRenderingContext2D::state): (WebCore::CanvasRenderingContext2D::):
Location:
trunk/WebCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r64001 r64004  
     12010-07-23  James Robinson  <jamesr@chromium.org>
     2
     3        Reviewed by Dimitri Glazkov.
     4
     5        CanvasRenderingContext2D has lots of style errors
     6        https://bugs.webkit.org/show_bug.cgi?id=42918
     7
     8        CanvasRenderingContext2D.h and .cpp have lots of style errors.  I'm planning to post patches
     9        to both of these files soon, so to minimize merge conflicts and additional style violations
     10        it seems best to fix all of these errors in bulk before posting any functional changes.  In
     11        particular the header file is incorrectly indented so any correctly formatted addition will
     12        be out of place.
     13
     14        * html/canvas/CanvasRenderingContext2D.cpp:
     15        (WebCore::CanvasRenderingContext2D::CanvasRenderingContext2D):
     16        (WebCore::CanvasRenderingContext2D::setFillStyle):
     17        (WebCore::CanvasRenderingContext2D::transform):
     18        (WebCore::CanvasRenderingContext2D::setTransform):
     19        (WebCore::CanvasRenderingContext2D::arcTo):
     20        (WebCore::CanvasRenderingContext2D::arc):
     21        (WebCore::validateRectForCanvas):
     22        (WebCore::CanvasRenderingContext2D::strokeRect):
     23        (WebCore::CanvasRenderingContext2D::drawImage):
     24        (WebCore::CanvasRenderingContext2D::createRadialGradient):
     25        (WebCore::CanvasRenderingContext2D::createPattern):
     26        (WebCore::CanvasRenderingContext2D::willDraw):
     27        (WebCore::CanvasRenderingContext2D::createImageData):
     28        (WebCore::CanvasRenderingContext2D::putImageData):
     29        (WebCore::CanvasRenderingContext2D::setFont):
     30        (WebCore::CanvasRenderingContext2D::drawTextInternal):
     31        * html/canvas/CanvasRenderingContext2D.h:
     32        (WebCore::CanvasRenderingContext2D::is2d):
     33        (WebCore::CanvasRenderingContext2D::getLineCap):
     34        (WebCore::CanvasRenderingContext2D::getLineJoin):
     35        (WebCore::CanvasRenderingContext2D::state):
     36        (WebCore::CanvasRenderingContext2D::):
     37
    1382010-07-23  Adam Barth  <abarth@webkit.org>
    239
  • trunk/WebCore/html/canvas/CanvasRenderingContext2D.cpp

    r63727 r64004  
    3333
    3434#include "AffineTransform.h"
     35#include "CSSMutableStyleDeclaration.h"
    3536#include "CSSParser.h"
     37#include "CSSPropertyNames.h"
     38#include "CSSStyleSelector.h"
    3639#include "CachedImage.h"
    3740#include "CanvasGradient.h"
    3841#include "CanvasPattern.h"
    3942#include "CanvasStyle.h"
    40 #include "CSSMutableStyleDeclaration.h"
    41 #include "CSSPropertyNames.h"
    42 #include "CSSStyleSelector.h"
    4343#include "ExceptionCode.h"
    4444#include "FloatConversion.h"
     
    4848#include "HTMLMediaElement.h"
    4949#include "HTMLNames.h"
     50#include "HTMLVideoElement.h"
    5051#include "ImageBuffer.h"
    5152#include "ImageData.h"
     
    5758#include "StrokeStyleApplier.h"
    5859#include "TextMetrics.h"
    59 #include "HTMLVideoElement.h"
     60
    6061#include <stdio.h>
     62
    6163#include <wtf/ByteArray.h>
    6264#include <wtf/MathExtras.h>
     
    7981    {
    8082    }
    81    
     83
    8284    virtual void strokeStyle(GraphicsContext* c)
    8385    {
     
    101103{
    102104#if !ENABLE(DASHBOARD_SUPPORT)
    103    ASSERT_UNUSED(usesDashboardCompatibilityMode, !usesDashboardCompatibilityMode);
     105    ASSERT_UNUSED(usesDashboardCompatibilityMode, !usesDashboardCompatibilityMode);
    104106#endif
    105107
     
    203205    if (state().m_fillStyle && state().m_fillStyle->isEquivalentColor(*style))
    204206        return;
    205  
     207
    206208    if (canvas()->originClean()) {
    207209        if (CanvasPattern* pattern = style->canvasPattern()) {
     
    447449        return;
    448450
    449     if (!isfinite(m11) | !isfinite(m21) | !isfinite(dx) |
    450         !isfinite(m12) | !isfinite(m22) | !isfinite(dy))
     451    if (!isfinite(m11) | !isfinite(m21) | !isfinite(dx) | !isfinite(m12) | !isfinite(m22) | !isfinite(dy))
    451452        return;
    452453
     
    468469    if (!c)
    469470        return;
    470    
    471     if (!isfinite(m11) | !isfinite(m21) | !isfinite(dx) |
    472         !isfinite(m12) | !isfinite(m22) | !isfinite(dy))
     471
     472    if (!isfinite(m11) | !isfinite(m21) | !isfinite(dx) | !isfinite(m12) | !isfinite(m22) | !isfinite(dy))
    473473        return;
    474474
     
    622622    if (!isfinite(x1) | !isfinite(y1) | !isfinite(x2) | !isfinite(y2) | !isfinite(r))
    623623        return;
    624    
     624
    625625    if (r < 0) {
    626626        ec = INDEX_SIZE_ERR;
    627627        return;
    628628    }
    629    
    630     if (!state().m_invertibleCTM)
    631         return;
    632    
     629
     630    if (!state().m_invertibleCTM)
     631        return;
     632
    633633    FloatPoint p1 = FloatPoint(x1, y1);
    634634    FloatPoint p2 = FloatPoint(x2, y2);
     
    647647    if (!isfinite(x) | !isfinite(y) | !isfinite(r) | !isfinite(sa) | !isfinite(ea))
    648648        return;
    649    
     649
    650650    if (r < 0) {
    651651        ec = INDEX_SIZE_ERR;
     
    660660    m_path.addArc(FloatPoint(x, y), r, sa, ea, anticlockwise);
    661661}
    662    
     662
    663663static bool validateRectForCanvas(float& x, float& y, float& width, float& height)
    664664{
     
    673673        x -= width;
    674674    }
    675    
     675
    676676    if (height < 0) {
    677677        height = -height;
    678678        y -= height;
    679679    }
    680    
     680
    681681    return true;
    682682}
     
    836836    if (!validateRectForCanvas(x, y, width, height))
    837837        return;
    838     
     838 
    839839    if (!(lineWidth >= 0))
    840840        return;
     
    10831083
    10841084    FloatRect imageRect = FloatRect(FloatPoint(), size(image));
    1085     if (!imageRect.contains(normalizeRect(srcRect)) || srcRect.width() == 0 || srcRect.height() == 0) {
     1085    if (!imageRect.contains(normalizeRect(srcRect)) || !srcRect.width() || !srcRect.height()) {
    10861086        ec = INDEX_SIZE_ERR;
    10871087        return;
     
    11541154    }
    11551155
    1156     if (!srcCanvasRect.contains(normalizeRect(srcRect)) || srcRect.width() == 0 || srcRect.height() == 0) {
     1156    if (!srcCanvasRect.contains(normalizeRect(srcRect)) || !srcRect.width() || !srcRect.height()) {
    11571157        ec = INDEX_SIZE_ERR;
    11581158        return;
     
    11691169    if (!state().m_invertibleCTM)
    11701170        return;
    1171         
     1171 
    11721172    FloatRect sourceRect = c->roundToDevicePixels(srcRect);
    11731173    FloatRect destRect = c->roundToDevicePixels(dstRect);
    1174        
     1174
    11751175    // FIXME: Do this through platform-independent GraphicsContext API.
    11761176    ImageBuffer* buffer = sourceCanvas->buffer();
     
    12241224        return;
    12251225    }
    1226    
     1226
    12271227    ec = 0;
    12281228
     
    12311231
    12321232    FloatRect videoRect = FloatRect(FloatPoint(), size(video));
    1233     if (!videoRect.contains(normalizeRect(srcRect)) || srcRect.width() == 0 || srcRect.height() == 0) {
     1233    if (!videoRect.contains(normalizeRect(srcRect)) || !srcRect.width() || !srcRect.height()) {
    12341234        ec = INDEX_SIZE_ERR;
    12351235        return;
    12361236    }
    1237    
     1237
    12381238    if (!dstRect.width() || !dstRect.height())
    12391239        return;
    1240    
     1240
    12411241    GraphicsContext* c = drawingContext();
    12421242    if (!c)
     
    12581258    c->clip(destRect);
    12591259    c->translate(destRect.x(), destRect.y());
    1260     c->scale(FloatSize(destRect.width()/sourceRect.width(), destRect.height()/sourceRect.height()));
     1260    c->scale(FloatSize(destRect.width() / sourceRect.width(), destRect.height() / sourceRect.height()));
    12611261    c->translate(-sourceRect.x(), -sourceRect.y());
    12621262    video->paintCurrentFrameInContext(c, IntRect(IntPoint(), size(video)));
     
    13331333PassRefPtr<CanvasGradient> CanvasRenderingContext2D::createRadialGradient(float x0, float y0, float r0, float x1, float y1, float r1, ExceptionCode& ec)
    13341334{
    1335     if (!isfinite(x0) || !isfinite(y0) || !isfinite(r0) ||
    1336         !isfinite(x1) || !isfinite(y1) || !isfinite(r1)) {
     1335    if (!isfinite(x0) || !isfinite(y0) || !isfinite(r0) || !isfinite(x1) || !isfinite(y1) || !isfinite(r1)) {
    13371336        ec = NOT_SUPPORTED_ERR;
    13381337        return 0;
     
    13781377        return 0;
    13791378    }
    1380    
     1379
    13811380    bool repeatX, repeatY;
    13821381    ec = 0;
     
    14001399        dirtyRect = ctm.mapRect(r);
    14011400    }
    1402    
     1401
    14031402    if (options & CanvasWillDrawApplyShadow && alphaChannel(state().m_shadowColor)) {
    14041403        // The shadow gets applied after transformation
     
    14081407        dirtyRect.unite(shadowRect);
    14091408    }
    1410    
     1409
    14111410    if (options & CanvasWillDrawApplyClip) {
    14121411        // FIXME: apply the current clip to the rectangle. Unfortunately we can't get the clip
     
    14141413        // we'd have to keep the clip path around.
    14151414    }
    1416    
     1415
    14171416    canvas()->willDraw(dirtyRect);
    14181417}
     
    14591458    if (scaledSize.height() < 1)
    14601459        scaledSize.setHeight(1);
    1461    
     1460
    14621461    return createEmptyImageData(scaledSize);
    14631462}
     
    14991498}
    15001499
    1501 void CanvasRenderingContext2D::putImageData(ImageData* data, float dx, float dy, float dirtyX, float dirtyY, 
     1500void CanvasRenderingContext2D::putImageData(ImageData* data, float dx, float dy, float dirtyX, float dirtyY,
    15021501                                            float dirtyWidth, float dirtyHeight, ExceptionCode& ec)
    15031502{
     
    15061505        return;
    15071506    }
    1508     if (!isfinite(dx) || !isfinite(dy) || !isfinite(dirtyX) ||
    1509         !isfinite(dirtyY) || !isfinite(dirtyWidth) || !isfinite(dirtyHeight)) {
     1507    if (!isfinite(dx) || !isfinite(dy) || !isfinite(dirtyX) || !isfinite(dirtyY) || !isfinite(dirtyWidth) || !isfinite(dirtyHeight)) {
    15101508        ec = NOT_SUPPORTED_ERR;
    15111509        return;
     
    15341532    if (sourceRect.isEmpty())
    15351533        return;
    1536     willDraw(sourceRect, 0);  // ignore transform, shadow and clip
     1534    willDraw(sourceRect, 0); // ignore transform, shadow and clip
    15371535    sourceRect.move(-destOffset);
    15381536    IntPoint destPoint(destOffset.width(), destOffset.height());
    1539    
     1537
    15401538    buffer->putUnmultipliedImageData(data, sourceRect, destPoint);
    15411539}
     
    15501548    RefPtr<CSSMutableStyleDeclaration> tempDecl = CSSMutableStyleDeclaration::create();
    15511549    CSSParser parser(!m_usesCSSCompatibilityParseMode);
    1552        
     1550
    15531551    String declarationText("font: ");
    15541552    declarationText += newFont;
     
    15561554    if (!tempDecl->length())
    15571555        return;
    1558            
     1556
    15591557    // The parse succeeded.
    15601558    state().m_unparsedFont = newFont;
    1561    
     1559
    15621560    // Map the <canvas> font into the text style. If the font uses keywords like larger/smaller, these will work
    15631561    // relative to the canvas.
     
    15691567    CSSStyleSelector* styleSelector = canvas()->styleSelector();
    15701568    styleSelector->applyPropertyToStyle(CSSPropertyFont, tempDecl->getPropertyCSSValue(CSSPropertyFont).get(), newStyle.get());
    1571    
     1569
    15721570    state().m_font = newStyle->font();
    15731571    state().m_font.update(styleSelector->fontSelector());
     
    15961594    state().m_textAlign = align;
    15971595}
    1598        
     1596
    15991597String CanvasRenderingContext2D::textBaseline() const
    16001598{
     
    16441642    if (!state().m_invertibleCTM)
    16451643        return;
    1646    
     1644
    16471645    const Font& font = accessFont();
    16481646
     
    16611659    FloatPoint location(x, y);
    16621660    switch (state().m_textBaseline) {
    1663         case TopTextBaseline:
    1664         case HangingTextBaseline:
    1665             location.setY(y + font.ascent());
    1666             break;
    1667         case BottomTextBaseline:
    1668         case IdeographicTextBaseline:
    1669             location.setY(y - font.descent());
    1670             break;
    1671         case MiddleTextBaseline:
    1672             location.setY(y - font.descent() + font.height() / 2);
    1673             break;
    1674         case AlphabeticTextBaseline:
    1675         default:
    1676              // Do nothing.
    1677             break;
    1678     }
    1679    
     1661    case TopTextBaseline:
     1662    case HangingTextBaseline:
     1663        location.setY(y + font.ascent());
     1664        break;
     1665    case BottomTextBaseline:
     1666    case IdeographicTextBaseline:
     1667        location.setY(y - font.descent());
     1668        break;
     1669    case MiddleTextBaseline:
     1670        location.setY(y - font.descent() + font.height() / 2);
     1671        break;
     1672    case AlphabeticTextBaseline:
     1673    default:
     1674         // Do nothing.
     1675        break;
     1676    }
     1677
    16801678    float width = font.width(TextRun(text, false, 0, 0, rtl, override));
    16811679
     
    16851683    else if (align == EndTextAlign)
    16861684        align = rtl ? LeftTextAlign : RightTextAlign;
    1687    
     1685
    16881686    switch (align) {
    1689         case CenterTextAlign:
    1690             location.setX(location.x() - width / 2);
    1691             break;
    1692         case RightTextAlign:
    1693             location.setX(location.x() - width);
    1694             break;
    1695         default:
    1696             break;
    1697     }
    1698    
     1687    case CenterTextAlign:
     1688        location.setX(location.x() - width / 2);
     1689        break;
     1690    case RightTextAlign:
     1691        location.setX(location.x() - width);
     1692        break;
     1693    default:
     1694        break;
     1695    }
     1696
    16991697    // The slop built in to this mask rect matches the heuristic used in FontCGWin.cpp for GDI text.
    17001698    FloatRect textRect = FloatRect(location.x() - font.height() / 2, location.y() - font.ascent() - font.lineGap(),
     
    17101708        canvas()->willDraw(FloatRect(0, 0, canvas()->width(), canvas()->height()));
    17111709    }
    1712    
     1710
    17131711#if PLATFORM(CG)
    17141712    CanvasStyle* drawStyle = fill ? state().m_fillStyle.get() : state().m_strokeStyle.get();
     
    17301728        maskImageContext->setTextDrawingMode(fill ? cTextFill : cTextStroke);
    17311729        maskImageContext->translate(-maskRect.x(), -maskRect.y());
    1732        
     1730
    17331731        maskImageContext->drawBidiText(font, textRun, location);
    1734        
     1732
    17351733        c->save();
    17361734        c->clipToImageBuffer(maskRect, maskImage.get());
  • trunk/WebCore/html/canvas/CanvasRenderingContext2D.h

    r63344 r64004  
    3535#include "Path.h"
    3636#include "PlatformString.h"
     37
     38#include <wtf/Vector.h>
    3739#include <wtf/text/StringHash.h>
    38 #include <wtf/Vector.h>
    3940
    4041#if PLATFORM(CG)
     
    4445namespace WebCore {
    4546
    46     class CanvasGradient;
    47     class CanvasPattern;
    48     class CanvasStyle;
    49     class FloatRect;
    50     class GraphicsContext;
    51     class HTMLCanvasElement;
    52     class HTMLImageElement;
    53     class HTMLVideoElement;
    54     class ImageData;
    55     class KURL;
    56     class TextMetrics;
    57 
    58     typedef int ExceptionCode;
    59 
    60     class CanvasRenderingContext2D : public CanvasRenderingContext {
    61     public:
    62         CanvasRenderingContext2D(HTMLCanvasElement*, bool usesCSSCompatibilityParseMode, bool usesDashboardCompatibilityMode);
    63 
    64         virtual ~CanvasRenderingContext2D();
    65        
    66         virtual bool is2d() const { return true; }
    67 
    68         CanvasStyle* strokeStyle() const;
    69         void setStrokeStyle(PassRefPtr<CanvasStyle>);
    70 
    71         CanvasStyle* fillStyle() const;
    72         void setFillStyle(PassRefPtr<CanvasStyle>);
    73 
    74         float lineWidth() const;
    75         void setLineWidth(float);
    76 
    77         String lineCap() const;
    78         void setLineCap(const String&);
    79 
    80         String lineJoin() const;
    81         void setLineJoin(const String&);
    82 
    83         float miterLimit() const;
    84         void setMiterLimit(float);
    85 
    86         float shadowOffsetX() const;
    87         void setShadowOffsetX(float);
    88 
    89         float shadowOffsetY() const;
    90         void setShadowOffsetY(float);
    91 
    92         float shadowBlur() const;
    93         void setShadowBlur(float);
    94 
    95         String shadowColor() const;
    96         void setShadowColor(const String&);
    97 
    98         float globalAlpha() const;
    99         void setGlobalAlpha(float);
    100 
    101         String globalCompositeOperation() const;
    102         void setGlobalCompositeOperation(const String&);
    103 
    104         void save();
    105         void restore();
    106 
    107         void scale(float sx, float sy);
    108         void rotate(float angleInRadians);
    109         void translate(float tx, float ty);
    110         void transform(float m11, float m12, float m21, float m22, float dx, float dy);
    111         void setTransform(float m11, float m12, float m21, float m22, float dx, float dy);
    112 
    113         void setStrokeColor(const String& color);
    114         void setStrokeColor(float grayLevel);
    115         void setStrokeColor(const String& color, float alpha);
    116         void setStrokeColor(float grayLevel, float alpha);
    117         void setStrokeColor(float r, float g, float b, float a);
    118         void setStrokeColor(float c, float m, float y, float k, float a);
    119 
    120         void setFillColor(const String& color);
    121         void setFillColor(float grayLevel);
    122         void setFillColor(const String& color, float alpha);
    123         void setFillColor(float grayLevel, float alpha);
    124         void setFillColor(float r, float g, float b, float a);
    125         void setFillColor(float c, float m, float y, float k, float a);
    126 
    127         void beginPath();
    128         void closePath();
    129 
    130         void moveTo(float x, float y);
    131         void lineTo(float x, float y);
    132         void quadraticCurveTo(float cpx, float cpy, float x, float y);
    133         void bezierCurveTo(float cp1x, float cp1y, float cp2x, float cp2y, float x, float y);
    134         void arcTo(float x0, float y0, float x1, float y1, float radius, ExceptionCode&);
    135         void arc(float x, float y, float r, float sa, float ea, bool clockwise, ExceptionCode&);
    136         void rect(float x, float y, float width, float height);
    137 
    138         void fill();
    139         void stroke();
    140         void clip();
    141 
    142         bool isPointInPath(const float x, const float y);
    143 
    144         void clearRect(float x, float y, float width, float height);
    145         void fillRect(float x, float y, float width, float height);
    146         void strokeRect(float x, float y, float width, float height);
    147         void strokeRect(float x, float y, float width, float height, float lineWidth);
    148 
    149         void setShadow(float width, float height, float blur);
    150         void setShadow(float width, float height, float blur, const String& color);
    151         void setShadow(float width, float height, float blur, float grayLevel);
    152         void setShadow(float width, float height, float blur, const String& color, float alpha);
    153         void setShadow(float width, float height, float blur, float grayLevel, float alpha);
    154         void setShadow(float width, float height, float blur, float r, float g, float b, float a);
    155         void setShadow(float width, float height, float blur, float c, float m, float y, float k, float a);
    156 
    157         void clearShadow();
    158 
    159         void drawImage(HTMLImageElement*, float x, float y, ExceptionCode&);
    160         void drawImage(HTMLImageElement*, float x, float y, float width, float height, ExceptionCode&);
    161         void drawImage(HTMLImageElement*, float sx, float sy, float sw, float sh, float dx, float dy, float dw, float dh, ExceptionCode&);
    162         void drawImage(HTMLImageElement*, const FloatRect& srcRect, const FloatRect& dstRect, ExceptionCode&);
    163         void drawImage(HTMLCanvasElement*, float x, float y, ExceptionCode&);
    164         void drawImage(HTMLCanvasElement*, float x, float y, float width, float height, ExceptionCode&);
    165         void drawImage(HTMLCanvasElement*, float sx, float sy, float sw, float sh, float dx, float dy, float dw, float dh, ExceptionCode&);
    166         void drawImage(HTMLCanvasElement*, const FloatRect& srcRect, const FloatRect& dstRect, ExceptionCode&);
     47class CanvasGradient;
     48class CanvasPattern;
     49class CanvasStyle;
     50class FloatRect;
     51class GraphicsContext;
     52class HTMLCanvasElement;
     53class HTMLImageElement;
     54class HTMLVideoElement;
     55class ImageData;
     56class KURL;
     57class TextMetrics;
     58
     59typedef int ExceptionCode;
     60
     61class CanvasRenderingContext2D : public CanvasRenderingContext {
     62public:
     63    CanvasRenderingContext2D(HTMLCanvasElement*, bool usesCSSCompatibilityParseMode, bool usesDashboardCompatibilityMode);
     64
     65    virtual ~CanvasRenderingContext2D();
     66
     67    virtual bool is2d() const { return true; }
     68
     69    CanvasStyle* strokeStyle() const;
     70    void setStrokeStyle(PassRefPtr<CanvasStyle>);
     71
     72    CanvasStyle* fillStyle() const;
     73    void setFillStyle(PassRefPtr<CanvasStyle>);
     74
     75    float lineWidth() const;
     76    void setLineWidth(float);
     77
     78    String lineCap() const;
     79    void setLineCap(const String&);
     80
     81    String lineJoin() const;
     82    void setLineJoin(const String&);
     83
     84    float miterLimit() const;
     85    void setMiterLimit(float);
     86
     87    float shadowOffsetX() const;
     88    void setShadowOffsetX(float);
     89
     90    float shadowOffsetY() const;
     91    void setShadowOffsetY(float);
     92
     93    float shadowBlur() const;
     94    void setShadowBlur(float);
     95
     96    String shadowColor() const;
     97    void setShadowColor(const String&);
     98
     99    float globalAlpha() const;
     100    void setGlobalAlpha(float);
     101
     102    String globalCompositeOperation() const;
     103    void setGlobalCompositeOperation(const String&);
     104
     105    void save();
     106    void restore();
     107
     108    void scale(float sx, float sy);
     109    void rotate(float angleInRadians);
     110    void translate(float tx, float ty);
     111    void transform(float m11, float m12, float m21, float m22, float dx, float dy);
     112    void setTransform(float m11, float m12, float m21, float m22, float dx, float dy);
     113
     114    void setStrokeColor(const String& color);
     115    void setStrokeColor(float grayLevel);
     116    void setStrokeColor(const String& color, float alpha);
     117    void setStrokeColor(float grayLevel, float alpha);
     118    void setStrokeColor(float r, float g, float b, float a);
     119    void setStrokeColor(float c, float m, float y, float k, float a);
     120
     121    void setFillColor(const String& color);
     122    void setFillColor(float grayLevel);
     123    void setFillColor(const String& color, float alpha);
     124    void setFillColor(float grayLevel, float alpha);
     125    void setFillColor(float r, float g, float b, float a);
     126    void setFillColor(float c, float m, float y, float k, float a);
     127
     128    void beginPath();
     129    void closePath();
     130
     131    void moveTo(float x, float y);
     132    void lineTo(float x, float y);
     133    void quadraticCurveTo(float cpx, float cpy, float x, float y);
     134    void bezierCurveTo(float cp1x, float cp1y, float cp2x, float cp2y, float x, float y);
     135    void arcTo(float x0, float y0, float x1, float y1, float radius, ExceptionCode&);
     136    void arc(float x, float y, float r, float sa, float ea, bool clockwise, ExceptionCode&);
     137    void rect(float x, float y, float width, float height);
     138
     139    void fill();
     140    void stroke();
     141    void clip();
     142
     143    bool isPointInPath(const float x, const float y);
     144
     145    void clearRect(float x, float y, float width, float height);
     146    void fillRect(float x, float y, float width, float height);
     147    void strokeRect(float x, float y, float width, float height);
     148    void strokeRect(float x, float y, float width, float height, float lineWidth);
     149
     150    void setShadow(float width, float height, float blur);
     151    void setShadow(float width, float height, float blur, const String& color);
     152    void setShadow(float width, float height, float blur, float grayLevel);
     153    void setShadow(float width, float height, float blur, const String& color, float alpha);
     154    void setShadow(float width, float height, float blur, float grayLevel, float alpha);
     155    void setShadow(float width, float height, float blur, float r, float g, float b, float a);
     156    void setShadow(float width, float height, float blur, float c, float m, float y, float k, float a);
     157
     158    void clearShadow();
     159
     160    void drawImage(HTMLImageElement*, float x, float y, ExceptionCode&);
     161    void drawImage(HTMLImageElement*, float x, float y, float width, float height, ExceptionCode&);
     162    void drawImage(HTMLImageElement*, float sx, float sy, float sw, float sh, float dx, float dy, float dw, float dh, ExceptionCode&);
     163    void drawImage(HTMLImageElement*, const FloatRect& srcRect, const FloatRect& dstRect, ExceptionCode&);
     164    void drawImage(HTMLCanvasElement*, float x, float y, ExceptionCode&);
     165    void drawImage(HTMLCanvasElement*, float x, float y, float width, float height, ExceptionCode&);
     166    void drawImage(HTMLCanvasElement*, float sx, float sy, float sw, float sh, float dx, float dy, float dw, float dh, ExceptionCode&);
     167    void drawImage(HTMLCanvasElement*, const FloatRect& srcRect, const FloatRect& dstRect, ExceptionCode&);
    167168#if ENABLE(VIDEO)
    168         void drawImage(HTMLVideoElement*, float x, float y, ExceptionCode&);
    169         void drawImage(HTMLVideoElement*, float x, float y, float width, float height, ExceptionCode&);
    170         void drawImage(HTMLVideoElement*, float sx, float sy, float sw, float sh, float dx, float dy, float dw, float dh, ExceptionCode&);
    171         void drawImage(HTMLVideoElement*, const FloatRect& srcRect, const FloatRect& dstRect, ExceptionCode&);
    172 #endif
    173 
    174         void drawImageFromRect(HTMLImageElement*, float sx, float sy, float sw, float sh,
    175             float dx, float dy, float dw, float dh, const String& compositeOperation);
    176 
    177         void setAlpha(float);
    178 
    179         void setCompositeOperation(const String&);
    180 
    181         PassRefPtr<CanvasGradient> createLinearGradient(float x0, float y0, float x1, float y1, ExceptionCode&);
    182         PassRefPtr<CanvasGradient> createRadialGradient(float x0, float y0, float r0, float x1, float y1, float r1, ExceptionCode&);
    183         PassRefPtr<CanvasPattern> createPattern(HTMLImageElement*, const String& repetitionType, ExceptionCode&);
    184         PassRefPtr<CanvasPattern> createPattern(HTMLCanvasElement*, const String& repetitionType, ExceptionCode&);
    185        
    186         PassRefPtr<ImageData> createImageData(PassRefPtr<ImageData> imageData, ExceptionCode&) const;
    187         PassRefPtr<ImageData> createImageData(float width, float height, ExceptionCode&) const;
    188         PassRefPtr<ImageData> getImageData(float sx, float sy, float sw, float sh, ExceptionCode&) const;
    189         void putImageData(ImageData*, float dx, float dy, ExceptionCode&);
    190         void putImageData(ImageData*, float dx, float dy, float dirtyX, float dirtyY, float dirtyWidth, float dirtyHeight, ExceptionCode&);
    191        
    192         void reset();
    193 
    194         String font() const;
    195         void setFont(const String&);
    196         void updateFont();
    197        
    198         String textAlign() const;
    199         void setTextAlign(const String&);
    200        
    201         String textBaseline() const;
    202         void setTextBaseline(const String&);
    203        
    204         void fillText(const String& text, float x, float y);
    205         void fillText(const String& text, float x, float y, float maxWidth);
    206         void strokeText(const String& text, float x, float y);
    207         void strokeText(const String& text, float x, float y, float maxWidth);
    208         PassRefPtr<TextMetrics> measureText(const String& text);
    209 
    210         LineCap getLineCap() const { return state().m_lineCap; }
    211         LineJoin getLineJoin() const { return state().m_lineJoin; }
    212 
    213     private:
    214         struct State {
    215             State();
    216            
    217             String m_unparsedStrokeColor;
    218             String m_unparsedFillColor;
    219             RefPtr<CanvasStyle> m_strokeStyle;
    220             RefPtr<CanvasStyle> m_fillStyle;
    221             float m_lineWidth;
    222             LineCap m_lineCap;
    223             LineJoin m_lineJoin;
    224             float m_miterLimit;
    225             FloatSize m_shadowOffset;
    226             float m_shadowBlur;
    227             RGBA32 m_shadowColor;
    228             float m_globalAlpha;
    229             CompositeOperator m_globalComposite;
    230             AffineTransform m_transform;
    231             bool m_invertibleCTM;
    232            
    233             // Text state.
    234             TextAlign m_textAlign;
    235             TextBaseline m_textBaseline;
    236            
    237             String m_unparsedFont;
    238             Font m_font;
    239             bool m_realizedFont;
    240         };
    241         Path m_path;
    242 
    243         State& state() { return m_stateStack.last(); }
    244         const State& state() const { return m_stateStack.last(); }
    245 
    246         void applyShadow();
    247 
    248         enum CanvasWillDrawOption {
    249             CanvasWillDrawApplyTransform = 1,
    250             CanvasWillDrawApplyShadow = 1 << 1,
    251             CanvasWillDrawApplyClip = 1 << 2,
    252             CanvasWillDrawApplyAll = 0xffffffff
    253         };
    254        
    255         void willDraw(const FloatRect&, unsigned options = CanvasWillDrawApplyAll);
    256 
    257         GraphicsContext* drawingContext() const;
    258 
    259         void applyStrokePattern();
    260         void applyFillPattern();
    261 
    262         void drawTextInternal(const String& text, float x, float y, bool fill, float maxWidth = 0, bool useMaxWidth = false);
    263 
    264         const Font& accessFont();
     169    void drawImage(HTMLVideoElement*, float x, float y, ExceptionCode&);
     170    void drawImage(HTMLVideoElement*, float x, float y, float width, float height, ExceptionCode&);
     171    void drawImage(HTMLVideoElement*, float sx, float sy, float sw, float sh, float dx, float dy, float dw, float dh, ExceptionCode&);
     172    void drawImage(HTMLVideoElement*, const FloatRect& srcRect, const FloatRect& dstRect, ExceptionCode&);
     173#endif
     174
     175    void drawImageFromRect(HTMLImageElement*, float sx, float sy, float sw, float sh,
     176        float dx, float dy, float dw, float dh, const String& compositeOperation);
     177
     178    void setAlpha(float);
     179
     180    void setCompositeOperation(const String&);
     181
     182    PassRefPtr<CanvasGradient> createLinearGradient(float x0, float y0, float x1, float y1, ExceptionCode&);
     183    PassRefPtr<CanvasGradient> createRadialGradient(float x0, float y0, float r0, float x1, float y1, float r1, ExceptionCode&);
     184    PassRefPtr<CanvasPattern> createPattern(HTMLImageElement*, const String& repetitionType, ExceptionCode&);
     185    PassRefPtr<CanvasPattern> createPattern(HTMLCanvasElement*, const String& repetitionType, ExceptionCode&);
     186
     187    PassRefPtr<ImageData> createImageData(PassRefPtr<ImageData> imageData, ExceptionCode&) const;
     188    PassRefPtr<ImageData> createImageData(float width, float height, ExceptionCode&) const;
     189    PassRefPtr<ImageData> getImageData(float sx, float sy, float sw, float sh, ExceptionCode&) const;
     190    void putImageData(ImageData*, float dx, float dy, ExceptionCode&);
     191    void putImageData(ImageData*, float dx, float dy, float dirtyX, float dirtyY, float dirtyWidth, float dirtyHeight, ExceptionCode&);
     192
     193    void reset();
     194
     195    String font() const;
     196    void setFont(const String&);
     197    void updateFont();
     198
     199    String textAlign() const;
     200    void setTextAlign(const String&);
     201
     202    String textBaseline() const;
     203    void setTextBaseline(const String&);
     204
     205    void fillText(const String& text, float x, float y);
     206    void fillText(const String& text, float x, float y, float maxWidth);
     207    void strokeText(const String& text, float x, float y);
     208    void strokeText(const String& text, float x, float y, float maxWidth);
     209    PassRefPtr<TextMetrics> measureText(const String& text);
     210
     211    LineCap getLineCap() const { return state().m_lineCap; }
     212    LineJoin getLineJoin() const { return state().m_lineJoin; }
     213
     214private:
     215    struct State {
     216        State();
     217
     218        String m_unparsedStrokeColor;
     219        String m_unparsedFillColor;
     220        RefPtr<CanvasStyle> m_strokeStyle;
     221        RefPtr<CanvasStyle> m_fillStyle;
     222        float m_lineWidth;
     223        LineCap m_lineCap;
     224        LineJoin m_lineJoin;
     225        float m_miterLimit;
     226        FloatSize m_shadowOffset;
     227        float m_shadowBlur;
     228        RGBA32 m_shadowColor;
     229        float m_globalAlpha;
     230        CompositeOperator m_globalComposite;
     231        AffineTransform m_transform;
     232        bool m_invertibleCTM;
     233
     234        // Text state.
     235        TextAlign m_textAlign;
     236        TextBaseline m_textBaseline;
     237
     238        String m_unparsedFont;
     239        Font m_font;
     240        bool m_realizedFont;
     241    };
     242    Path m_path;
     243
     244    State& state() { return m_stateStack.last(); }
     245    const State& state() const { return m_stateStack.last(); }
     246
     247    void applyShadow();
     248
     249    enum CanvasWillDrawOption {
     250        CanvasWillDrawApplyTransform = 1,
     251        CanvasWillDrawApplyShadow = 1 << 1,
     252        CanvasWillDrawApplyClip = 1 << 2,
     253        CanvasWillDrawApplyAll = 0xffffffff
     254    };
     255
     256    void willDraw(const FloatRect&, unsigned options = CanvasWillDrawApplyAll);
     257
     258    GraphicsContext* drawingContext() const;
     259
     260    void applyStrokePattern();
     261    void applyFillPattern();
     262
     263    void drawTextInternal(const String& text, float x, float y, bool fill, float maxWidth = 0, bool useMaxWidth = false);
     264
     265    const Font& accessFont();
    265266
    266267#if ENABLE(DASHBOARD_SUPPORT)
    267         void clearPathForDashboardBackwardCompatibilityMode();
    268 #endif
    269        
    270         void prepareGradientForDashboard(CanvasGradient* gradient) const;
    271 
    272         HashSet<String> m_cleanOrigins;
    273 
    274         void checkOrigin(const KURL&);
    275         void checkOrigin(const String&);
    276 
    277         Vector<State, 1> m_stateStack;
    278         bool m_usesCSSCompatibilityParseMode;
     268    void clearPathForDashboardBackwardCompatibilityMode();
     269#endif
     270
     271    void prepareGradientForDashboard(CanvasGradient* gradient) const;
     272
     273    HashSet<String> m_cleanOrigins;
     274
     275    void checkOrigin(const KURL&);
     276    void checkOrigin(const String&);
     277
     278    Vector<State, 1> m_stateStack;
     279    bool m_usesCSSCompatibilityParseMode;
    279280#if ENABLE(DASHBOARD_SUPPORT)
    280         bool m_usesDashboardCompatibilityMode;
    281 #endif
    282     };
     281    bool m_usesDashboardCompatibilityMode;
     282#endif
     283};
    283284
    284285} // namespace WebCore
Note: See TracChangeset for help on using the changeset viewer.