Changeset 47359 in webkit


Ignore:
Timestamp:
Aug 17, 2009 7:01:23 AM (15 years ago)
Author:
treat@webkit.org
Message:

Style fixes based on cpp_style.py and WebKit Style guide for
GraphicsContext.cpp/h, GraphicsContextCairo.cpp and GraphicsContextQt.cpp.

Patch by Mike Fenton <mike.fenton@torchmobile.com> on 2009-08-13
Reviewed by Adam Treat.

https://bugs.webkit.org/show_bug.cgi?id=28268

  • platform/graphics/GraphicsContext.cpp:

(WebCore::GraphicsContext::save):
(WebCore::GraphicsContext::restore):
(GraphicsContext::drawText):
(GraphicsContext::initFocusRing):
(GraphicsContext::focusRingBoundingRect):
(GraphicsContext::drawImage):

  • platform/graphics/GraphicsContext.h:
  • platform/graphics/cairo/GraphicsContextCairo.cpp:

(WebCore::GraphicsContext::drawLine):
(WebCore::GraphicsContext::strokeArc):
(WebCore::GraphicsContext::setLineCap):
(WebCore::GraphicsContext::setLineJoin):
(WebCore::toCairoOperator):

  • platform/graphics/qt/GraphicsContextQt.cpp:
Location:
trunk/WebCore
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r47357 r47359  
     12009-08-13  Mike Fenton  <mike.fenton@torchmobile.com>
     2
     3        Reviewed by Adam Treat.
     4
     5        Style fixes based on cpp_style.py and WebKit Style guide for
     6        GraphicsContext.cpp/h, GraphicsContextCairo.cpp and GraphicsContextQt.cpp.
     7
     8        https://bugs.webkit.org/show_bug.cgi?id=28268
     9
     10        * platform/graphics/GraphicsContext.cpp:
     11        (WebCore::GraphicsContext::save):
     12        (WebCore::GraphicsContext::restore):
     13        (GraphicsContext::drawText):
     14        (GraphicsContext::initFocusRing):
     15        (GraphicsContext::focusRingBoundingRect):
     16        (GraphicsContext::drawImage):
     17        * platform/graphics/GraphicsContext.h:
     18        * platform/graphics/cairo/GraphicsContextCairo.cpp:
     19        (WebCore::GraphicsContext::drawLine):
     20        (WebCore::GraphicsContext::strokeArc):
     21        (WebCore::GraphicsContext::setLineCap):
     22        (WebCore::GraphicsContext::setLineJoin):
     23        (WebCore::toCairoOperator):
     24        * platform/graphics/qt/GraphicsContextQt.cpp:
     25
    1262009-08-17  Darin Adler  <darin@apple.com>
    227
  • trunk/WebCore/platform/graphics/GraphicsContext.cpp

    r47146 r47359  
    2828
    2929#include "BidiResolver.h"
     30#include "Font.h"
    3031#include "Generator.h"
    3132#include "GraphicsContextPrivate.h"
    32 #include "Font.h"
    3333
    3434using namespace std;
     
    9090
    9191    m_common->stack.append(m_common->state);
    92    
     92
    9393    savePlatformState();
    9494}
     
    105105    m_common->state = m_common->stack.last();
    106106    m_common->stack.removeLast();
    107    
     107
    108108    restorePlatformState();
    109109}
     
    306306
    307307void GraphicsContext::drawImage(Image* image, const IntPoint& p, CompositeOperator op)
    308 {       
     308{
    309309    drawImage(image, p, IntRect(0, 0, -1, -1), op);
    310310}
     
    330330    if (paintingDisabled())
    331331        return;
    332    
     332
    333333    font.drawText(this, run, point, from, to);
    334334}
     
    384384        return;
    385385    clearFocusRing();
    386    
     386
    387387    m_common->m_focusRingWidth = width;
    388388    m_common->m_focusRingOffset = offset;
     
    397397{
    398398    IntRect result = IntRect(0, 0, 0, 0);
    399    
     399
    400400    const Vector<IntRect>& rects = focusRingRects();
    401401    unsigned rectCount = rects.size();
    402402    for (unsigned i = 0; i < rectCount; i++)
    403403        result.unite(rects[i]);
    404        
     404
    405405    return result;
    406406}
     
    437437    float tw = dest.width();
    438438    float th = dest.height();
    439        
     439
    440440    if (tsw == -1)
    441441        tsw = image->width();
  • trunk/WebCore/platform/graphics/GraphicsContext.h

    r47146 r47359  
    5050class wxWindowDC;
    5151
    52 // wxGraphicsContext allows us to support Path, etc. 
    53 // but on some platforms, e.g. Linux, it requires fairly 
     52// wxGraphicsContext allows us to support Path, etc.
     53// but on some platforms, e.g. Linux, it requires fairly
    5454// new software.
    5555#if USE(WXGC)
     
    123123    const int cTextStroke = 2;
    124124    const int cTextClip = 4;
    125    
     125
    126126    enum StrokeStyle {
    127127        NoStroke,
     
    131131    };
    132132
    133 // FIXME: This is a place-holder until we decide to add
    134 // real color space support to WebCore.  At that time, ColorSpace will be a
    135 // class and instances will be held  off of Colors.   There will be
    136 // special singleton Gradient and Pattern color spaces to mark when
    137 // a fill or stroke is using a gradient or pattern instead of a solid color.
    138 // https://bugs.webkit.org/show_bug.cgi?id=20558
     133    // FIXME: This is a place-holder until we decide to add
     134    // real color space support to WebCore.  At that time, ColorSpace will be a
     135    // class and instances will be held  off of Colors.   There will be
     136    // special singleton Gradient and Pattern color spaces to mark when
     137    // a fill or stroke is using a gradient or pattern instead of a solid color.
     138    // https://bugs.webkit.org/show_bug.cgi?id=20558
    139139    enum ColorSpace {
    140140        SolidColorSpace,
     
    155155        GraphicsContext(PlatformGraphicsContext*);
    156156        ~GraphicsContext();
    157        
     157
    158158#if !PLATFORM(WINCE) || PLATFORM(QT)
    159159        PlatformGraphicsContext* platformContext() const;
    160160#endif
    161        
     161
    162162        float strokeThickness() const;
    163163        void setStrokeThickness(float);
     
    235235        void drawTiledImage(Image*, const IntRect& destRect, const IntPoint& srcPoint, const IntSize& tileSize,
    236236                       CompositeOperator = CompositeSourceOver);
    237         void drawTiledImage(Image*, const IntRect& destRect, const IntRect& srcRect, 
     237        void drawTiledImage(Image*, const IntRect& destRect, const IntRect& srcRect,
    238238                            Image::TileRule hRule = Image::StretchTile, Image::TileRule vRule = Image::StretchTile,
    239239                            CompositeOperator = CompositeSourceOver);
     
    259259
    260260        FloatRect roundToDevicePixels(const FloatRect&);
    261        
     261
    262262        void drawLineForText(const IntPoint&, int width, bool printing);
    263263        void drawLineForMisspellingOrBadGrammar(const IntPoint&, int width, bool grammar);
    264        
     264
    265265        bool paintingDisabled() const;
    266266        void setPaintingDisabled(bool);
    267        
     267
    268268        bool updatingControlTints() const;
    269269        void setUpdatingControlTints(bool);
     
    304304        void translate(float x, float y);
    305305        IntPoint origin();
    306        
     306
    307307        void setURLForRect(const KURL&, const IntRect&);
    308308
  • trunk/WebCore/platform/graphics/cairo/GraphicsContextCairo.cpp

    r45285 r47359  
    3232#if PLATFORM(CAIRO)
    3333
    34 #include "TransformationMatrix.h"
    3534#include "CairoPath.h"
    3635#include "FloatRect.h"
     
    4241#include "Pattern.h"
    4342#include "SimpleFontData.h"
     43#include "TransformationMatrix.h"
    4444
    4545#include <cairo.h>
     
    5454#include <cairo-win32.h>
    5555#endif
     56#include "GraphicsContextPlatformPrivateCairo.h"
    5657#include "GraphicsContextPrivate.h"
    57 #include "GraphicsContextPlatformPrivateCairo.h"
    5858
    5959#ifndef M_PI
     
    240240            patternOffset = 1.0;
    241241        else {
    242             bool evenNumberOfSegments = numSegments%2 == 0;
     242            bool evenNumberOfSegments = !(numSegments % 2);
    243243            if (remainder)
    244244                evenNumberOfSegments = !evenNumberOfSegments;
     
    246246                if (remainder) {
    247247                    patternOffset += patWidth - remainder;
    248                     patternOffset += remainder/2;
    249                 }
    250                 else
    251                     patternOffset = patWidth/2;
    252             }
    253             else if (!evenNumberOfSegments) {
     248                    patternOffset += remainder / 2;
     249                } else
     250                    patternOffset = patWidth / 2;
     251            } else if (!evenNumberOfSegments) {
    254252                if (remainder)
    255                     patternOffset = (patWidth - remainder)/2;
     253                    patternOffset = (patWidth - remainder) / 2;
    256254            }
    257255        }
     
    319317    if (w != h)
    320318        cairo_scale(cr, 1., scaleFactor);
    321    
     319
    322320    cairo_arc_negative(cr, x + hRadius, (y + vRadius) * reverseScaleFactor, hRadius, -fa * M_PI/180, -falen * M_PI/180);
    323321
     
    327325    float width = strokeThickness();
    328326    int patWidth = 0;
    329    
     327
    330328    switch (strokeStyle()) {
    331         case DottedStroke:
    332             patWidth = static_cast<int>(width / 2);
    333             break;
    334         case DashedStroke:
    335             patWidth = 3 * static_cast<int>(width / 2);
    336             break;
    337         default:
    338             break;
     329    case DottedStroke:
     330        patWidth = static_cast<int>(width / 2);
     331        break;
     332    case DashedStroke:
     333        patWidth = 3 * static_cast<int>(width / 2);
     334        break;
     335    default:
     336        break;
    339337    }
    340338
     
    350348        else // We are elliptical and will have to estimate the distance
    351349            distance = static_cast<int>((M_PI * sqrtf((hRadius * hRadius + vRadius * vRadius) / 2.0)) / 2.0);
    352        
     350
    353351        int remainder = distance % patWidth;
    354352        int coverage = distance - remainder;
     
    360358            patternOffset = 1.0;
    361359        else {
    362             bool evenNumberOfSegments = numSegments % 2 == 0;
     360            bool evenNumberOfSegments = !(numSegments % 2);
    363361            if (remainder)
    364362                evenNumberOfSegments = !evenNumberOfSegments;
     
    829827    cairo_line_cap_t cairoCap = CAIRO_LINE_CAP_BUTT;
    830828    switch (lineCap) {
    831         case ButtCap:
    832             // no-op
    833             break;
    834         case RoundCap:
    835             cairoCap = CAIRO_LINE_CAP_ROUND;
    836             break;
    837         case SquareCap:
    838             cairoCap = CAIRO_LINE_CAP_SQUARE;
    839             break;
     829    case ButtCap:
     830        // no-op
     831        break;
     832    case RoundCap:
     833        cairoCap = CAIRO_LINE_CAP_ROUND;
     834        break;
     835    case SquareCap:
     836        cairoCap = CAIRO_LINE_CAP_SQUARE;
     837        break;
    840838    }
    841839    cairo_set_line_cap(m_data->cr, cairoCap);
     
    854852    cairo_line_join_t cairoJoin = CAIRO_LINE_JOIN_MITER;
    855853    switch (lineJoin) {
    856         case MiterJoin:
    857             // no-op
    858             break;
    859         case RoundJoin:
    860             cairoJoin = CAIRO_LINE_JOIN_ROUND;
    861             break;
    862         case BevelJoin:
    863             cairoJoin = CAIRO_LINE_JOIN_BEVEL;
    864             break;
     854    case MiterJoin:
     855        // no-op
     856        break;
     857    case RoundJoin:
     858        cairoJoin = CAIRO_LINE_JOIN_ROUND;
     859        break;
     860    case BevelJoin:
     861        cairoJoin = CAIRO_LINE_JOIN_BEVEL;
     862        break;
    865863    }
    866864    cairo_set_line_join(m_data->cr, cairoJoin);
     
    888886{
    889887    switch (op) {
    890         case CompositeClear:
    891             return CAIRO_OPERATOR_CLEAR;
    892         case CompositeCopy:
    893             return CAIRO_OPERATOR_SOURCE;
    894         case CompositeSourceOver:
    895             return CAIRO_OPERATOR_OVER;
    896         case CompositeSourceIn:
    897             return CAIRO_OPERATOR_IN;
    898         case CompositeSourceOut:
    899             return CAIRO_OPERATOR_OUT;
    900         case CompositeSourceAtop:
    901             return CAIRO_OPERATOR_ATOP;
    902         case CompositeDestinationOver:
    903             return CAIRO_OPERATOR_DEST_OVER;
    904         case CompositeDestinationIn:
    905             return CAIRO_OPERATOR_DEST_IN;
    906         case CompositeDestinationOut:
    907             return CAIRO_OPERATOR_DEST_OUT;
    908         case CompositeDestinationAtop:
    909             return CAIRO_OPERATOR_DEST_ATOP;
    910         case CompositeXOR:
    911             return CAIRO_OPERATOR_XOR;
    912         case CompositePlusDarker:
    913             return CAIRO_OPERATOR_SATURATE;
    914         case CompositeHighlight:
    915             // There is no Cairo equivalent for CompositeHighlight.
    916             return CAIRO_OPERATOR_OVER;
    917         case CompositePlusLighter:
    918             return CAIRO_OPERATOR_ADD;
    919         default:
    920             return CAIRO_OPERATOR_SOURCE;
     888    case CompositeClear:
     889        return CAIRO_OPERATOR_CLEAR;
     890    case CompositeCopy:
     891        return CAIRO_OPERATOR_SOURCE;
     892    case CompositeSourceOver:
     893        return CAIRO_OPERATOR_OVER;
     894    case CompositeSourceIn:
     895        return CAIRO_OPERATOR_IN;
     896    case CompositeSourceOut:
     897        return CAIRO_OPERATOR_OUT;
     898    case CompositeSourceAtop:
     899        return CAIRO_OPERATOR_ATOP;
     900    case CompositeDestinationOver:
     901        return CAIRO_OPERATOR_DEST_OVER;
     902    case CompositeDestinationIn:
     903        return CAIRO_OPERATOR_DEST_IN;
     904    case CompositeDestinationOut:
     905        return CAIRO_OPERATOR_DEST_OUT;
     906    case CompositeDestinationAtop:
     907        return CAIRO_OPERATOR_DEST_ATOP;
     908    case CompositeXOR:
     909        return CAIRO_OPERATOR_XOR;
     910    case CompositePlusDarker:
     911        return CAIRO_OPERATOR_SATURATE;
     912    case CompositeHighlight:
     913        // There is no Cairo equivalent for CompositeHighlight.
     914        return CAIRO_OPERATOR_OVER;
     915    case CompositePlusLighter:
     916        return CAIRO_OPERATOR_ADD;
     917    default:
     918        return CAIRO_OPERATOR_SOURCE;
    921919    }
    922920}
  • trunk/WebCore/platform/graphics/qt/GraphicsContextQt.cpp

    r47190 r47359  
    3535
    3636#include "config.h"
     37#include "GraphicsContext.h"
    3738
    3839#ifdef Q_WS_WIN
     
    4344#include "FloatConversion.h"
    4445#include "Font.h"
    45 #include "GraphicsContext.h"
    4646#include "GraphicsContextPrivate.h"
    4747#include "ImageBuffer.h"
     
    12201220
    12211221#ifdef Q_WS_WIN
    1222 #include <windows.h>
    12231222
    12241223HDC GraphicsContext::getWindowsContext(const IntRect& dstRect, bool supportAlphaBlend, bool mayCreateBitmap)
Note: See TracChangeset for help on using the changeset viewer.