Changeset 47341 in webkit


Ignore:
Timestamp:
Aug 16, 2009 3:57:30 PM (15 years ago)
Author:
ddkilzer@apple.com
Message:

<http://webkit.org/b/28355> Replace MAX()/MIN() macros with type-safe std::max()/min() templates

Reviewed by Dan Bernstein.

WebCore:

  • accessibility/mac/AccessibilityObjectWrapper.mm: (AXAttributeStringSetSpelling): Changed MIN() to min().
  • platform/graphics/mac/FontMacATSUI.mm: (WebCore::Font::selectionRectForComplexText): Changed MAX() to max() and MIN() to min(). (WebCore::Font::floatWidthForComplexText): Ditto.
  • platform/graphics/mac/SimpleFontDataMac.mm: Added using std::max statement. (WebCore::SimpleFontData::platformInit): Changed MAX() to max().
  • platform/text/mac/TextCodecMac.cpp: (WebCore::TextCodecMac::decode): Changed MIN() to min().

WebKit/mac:

  • Plugins/WebBaseNetscapePluginStream.mm: Added using std::min statement. (WebNetscapePluginStream::deliverData): Changed MIN() to min(). Changed C-style cast to a static_cast.
  • Plugins/WebNetscapePluginView.mm: Added using std::min statement. (-[WebNetscapePluginView _postURL:target:len:buf:file:notifyData:sendNotification:allowHeaders:]): Changed MIN() to min(). Changed C-style cast to a static_cast.
  • WebView/WebHTMLView.mm: Added using std::max statement. (-[WebHTMLView _dragImageForURL:withLabel:]): Changed MAX() to max(). (-[WebHTMLView _scaleFactorForPrintOperation:]): Ditto.
  • WebView/WebTextCompletionController.mm: Added using std::max and using std::min statements. (-[WebTextCompletionController _placePopupWindow:]): Changed type of maxWidth variable from float to CGFloat to prevent a type mismatch on x86_64. Changed MAX() to max() and MIN() to min(). Added static_cast for a constant value since CGFloat is defined as a float on i386 and as a double on x86_64.
Location:
trunk
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r47340 r47341  
     12009-08-16  David Kilzer  <ddkilzer@apple.com>
     2
     3        <http://webkit.org/b/28355> Replace MAX()/MIN() macros with type-safe std::max()/min() templates
     4
     5        Reviewed by Dan Bernstein.
     6
     7        * accessibility/mac/AccessibilityObjectWrapper.mm:
     8        (AXAttributeStringSetSpelling): Changed MIN() to min().
     9        * platform/graphics/mac/FontMacATSUI.mm:
     10        (WebCore::Font::selectionRectForComplexText): Changed MAX() to
     11        max() and MIN() to min().
     12        (WebCore::Font::floatWidthForComplexText): Ditto.
     13        * platform/graphics/mac/SimpleFontDataMac.mm: Added using
     14        std::max statement.
     15        (WebCore::SimpleFontData::platformInit): Changed MAX() to max().
     16        * platform/text/mac/TextCodecMac.cpp:
     17        (WebCore::TextCodecMac::decode): Changed MIN() to min().
     18
    1192009-08-16  Nikolas Zimmermann  <nikolas.zimmermann@torchmobile.com>
    220
  • trunk/WebCore/accessibility/mac/AccessibilityObjectWrapper.mm

    r47140 r47341  
    379379        // add misspelling attribute for the intersection of the marker and the range
    380380        int rStart = range.location + (marker.startOffset - offset);
    381         int rLength = MIN(marker.endOffset, endOffset) - marker.startOffset;
     381        int rLength = min(marker.endOffset, endOffset) - marker.startOffset;
    382382        NSRange spellRange = NSMakeRange(rStart, rLength);
    383383        AXAttributeStringSetNumber(attrString, NSAccessibilityMisspelledTextAttribute, [NSNumber numberWithBool:YES], spellRange);
  • trunk/WebCore/platform/graphics/mac/FontMacATSUI.mm

    r44439 r47341  
    505505    }
    506506   
    507     float beforeWidth = MIN(FixedToFloat(firstGlyphBounds.lowerLeft.x), FixedToFloat(firstGlyphBounds.upperLeft.x));
    508     float afterWidth = MAX(FixedToFloat(firstGlyphBounds.lowerRight.x), FixedToFloat(firstGlyphBounds.upperRight.x));
     507    float beforeWidth = min(FixedToFloat(firstGlyphBounds.lowerLeft.x), FixedToFloat(firstGlyphBounds.upperLeft.x));
     508    float afterWidth = max(FixedToFloat(firstGlyphBounds.lowerRight.x), FixedToFloat(firstGlyphBounds.upperRight.x));
    509509   
    510510    FloatRect rect(point.x() + floorf(beforeWidth), point.y(), roundf(afterWidth) - floorf(beforeWidth), h);
     
    592592        LOG_ERROR("unexpected result from ATSUGetGlyphBounds(): actualNumBounds(%d) != 1", actualNumBounds);
    593593
    594     return MAX(FixedToFloat(firstGlyphBounds.upperRight.x), FixedToFloat(firstGlyphBounds.lowerRight.x)) -
    595            MIN(FixedToFloat(firstGlyphBounds.upperLeft.x), FixedToFloat(firstGlyphBounds.lowerLeft.x));
     594    return max(FixedToFloat(firstGlyphBounds.upperRight.x), FixedToFloat(firstGlyphBounds.lowerRight.x)) -
     595           min(FixedToFloat(firstGlyphBounds.upperLeft.x), FixedToFloat(firstGlyphBounds.lowerLeft.x));
    596596}
    597597
  • trunk/WebCore/platform/graphics/mac/SimpleFontDataMac.mm

    r44444 r47341  
    5151@end
    5252
     53using namespace std;
     54
    5355namespace WebCore {
    5456 
     
    270272        // poorly if we return an accurate height. Classic case is Times 13 point,
    271273        // which has an "x" that is 7x6 pixels.
    272         m_xHeight = MAX(NSMaxX(xBox), NSMaxY(xBox));
     274        m_xHeight = max(NSMaxX(xBox), NSMaxY(xBox));
    273275    } else
    274276        m_xHeight = [m_platformData.font() xHeight];
  • trunk/WebCore/platform/text/mac/TextCodecMac.cpp

    r44096 r47341  
    3737#include <wtf/Threading.h>
    3838
    39 using std::min;
     39using namespace std;
    4040
    4141namespace WebCore {
     
    142142        ASSERT(m_numBufferedBytes < sizeof(m_bufferedBytes));
    143143        const int spaceInBuffer = sizeof(m_bufferedBytes) - m_numBufferedBytes;
    144         const int bytesToPutInBuffer = MIN(spaceInBuffer, inputBufferLength);
     144        const int bytesToPutInBuffer = min(spaceInBuffer, inputBufferLength);
    145145        ASSERT(bytesToPutInBuffer != 0);
    146146        memcpy(m_bufferedBytes + m_numBufferedBytes, inputBuffer, bytesToPutInBuffer);
  • trunk/WebKit/mac/ChangeLog

    r47323 r47341  
     12009-08-16  David Kilzer  <ddkilzer@apple.com>
     2
     3        <http://webkit.org/b/28355> Replace MAX()/MIN() macros with type-safe std::max()/min() templates
     4
     5        Reviewed by Dan Bernstein.
     6
     7        * Plugins/WebBaseNetscapePluginStream.mm: Added using std::min
     8        statement.
     9        (WebNetscapePluginStream::deliverData): Changed MIN() to min().
     10        Changed C-style cast to a static_cast.
     11        * Plugins/WebNetscapePluginView.mm: Added using std::min
     12        statement.
     13        (-[WebNetscapePluginView _postURL:target:len:buf:file:notifyData:sendNotification:allowHeaders:]):
     14        Changed MIN() to min().  Changed C-style cast to a static_cast.
     15        * WebView/WebHTMLView.mm: Added using std::max statement.
     16        (-[WebHTMLView _dragImageForURL:withLabel:]): Changed MAX() to
     17        max().
     18        (-[WebHTMLView _scaleFactorForPrintOperation:]): Ditto.
     19        * WebView/WebTextCompletionController.mm: Added using std::max
     20        and using std::min statements.
     21        (-[WebTextCompletionController _placePopupWindow:]): Changed
     22        type of maxWidth variable from float to CGFloat to prevent a
     23        type mismatch on x86_64.  Changed MAX() to max() and MIN() to
     24        min().  Added static_cast for a constant value since CGFloat is
     25        defined as a float on i386 and as a double on x86_64.
     26
    1272009-08-15  Adam Bergkvist  <adam.bergkvist@ericsson.com>
    228
  • trunk/WebKit/mac/Plugins/WebBaseNetscapePluginStream.mm

    r46431 r47341  
    5050
    5151using namespace WebCore;
     52using namespace std;
    5253
    5354#define WEB_REASON_NONE -1
     
    523524            break;
    524525        } else {
    525             deliveryBytes = MIN(deliveryBytes, totalBytes - totalBytesDelivered);
     526            deliveryBytes = min(deliveryBytes, totalBytes - totalBytesDelivered);
    526527            NSData *subdata = [m_deliveryData.get() subdataWithRange:NSMakeRange(totalBytesDelivered, deliveryBytes)];
    527528            PluginStopDeferrer deferrer(m_pluginView.get());
     
    532533                return;
    533534            }
    534             deliveryBytes = MIN((unsigned)deliveryBytes, [subdata length]);
     535            deliveryBytes = min<int32>(deliveryBytes, [subdata length]);
    535536            m_offset += deliveryBytes;
    536537            totalBytesDelivered += deliveryBytes;
  • trunk/WebKit/mac/Plugins/WebNetscapePluginView.mm

    r46866 r47341  
    7979#import <objc/objc-runtime.h>
    8080
    81 using std::max;
    82 
    8381#define LoginWindowDidSwitchFromUserNotification    @"WebLoginWindowDidSwitchFromUserNotification"
    8482#define LoginWindowDidSwitchToUserNotification      @"WebLoginWindowDidSwitchToUserNotification"
     
    8684using namespace WebCore;
    8785using namespace WebKit;
     86using namespace std;
    8887
    8988static inline bool isDrawingModelQuickDraw(NPDrawingModel drawingModel)
     
    17951794
    17961795                if (contentLength != nil)
    1797                     dataLength = MIN((unsigned)[contentLength intValue], dataLength);
     1796                    dataLength = min<unsigned>([contentLength intValue], dataLength);
    17981797                [header removeObjectForKey:@"Content-Length"];
    17991798
  • trunk/WebKit/mac/WebView/WebHTMLView.mm

    r46949 r47341  
    126126using namespace HTMLNames;
    127127using namespace WTF;
     128using namespace std;
    128129
    129130@interface NSWindow (BorderViewAccess)
     
    16501651        imageSize.height += urlStringSize.height;
    16511652        if (urlStringSize.width > MAX_DRAG_LABEL_WIDTH) {
    1652             imageSize.width = MAX(MAX_DRAG_LABEL_WIDTH + DRAG_LABEL_BORDER_X * 2.0f, MIN_DRAG_LABEL_WIDTH_BEFORE_CLIP);
     1653            imageSize.width = max(MAX_DRAG_LABEL_WIDTH + DRAG_LABEL_BORDER_X * 2, MIN_DRAG_LABEL_WIDTH_BEFORE_CLIP);
    16531654            clipURLString = YES;
    16541655        } else {
    1655             imageSize.width = MAX(labelSize.width + DRAG_LABEL_BORDER_X * 2.0f, urlStringSize.width + DRAG_LABEL_BORDER_X * 2.0f);
     1656            imageSize.width = max(labelSize.width + DRAG_LABEL_BORDER_X * 2, urlStringSize.width + DRAG_LABEL_BORDER_X * 2);
    16561657        }
    16571658    }
     
    37163717    // If the new bottom is equal to the old bottom (when both are treated as floats), we just copy
    37173718    // oldBottom over to newBottom. This prevents rounding errors that can occur when converting newBottomFloat to a double.
    3718     if (fabs((float)oldBottom - newBottomFloat) <= std::numeric_limits<float>::epsilon())
     3719    if (fabs((float)oldBottom - newBottomFloat) <= numeric_limits<float>::epsilon())
    37193720        *newBottom = oldBottom;
    37203721    else
     
    37513752    float shrinkToFitScaleFactor = [self _availablePaperWidthForPrintOperation:printOperation]/viewWidth;
    37523753    float shrinkToAvoidOrphan = _private->avoidingPrintOrphan ? (1.0f / PrintingOrphanShrinkAdjustment) : 1.0f;
    3753     return userScaleFactor * MAX(maxShrinkToFitScaleFactor, shrinkToFitScaleFactor) * shrinkToAvoidOrphan;
     3754    return userScaleFactor * max(maxShrinkToFitScaleFactor, shrinkToFitScaleFactor) * shrinkToAvoidOrphan;
    37543755}
    37553756
  • trunk/WebKit/mac/WebView/WebTextCompletionController.mm

    r44316 r47341  
    4040
    4141using namespace WebCore;
     42using namespace std;
    4243
    4344// This class handles the complete: operation.
     
    132133    windowFrame.origin.y -= windowFrame.size.height;
    133134    NSDictionary *attributes = [NSDictionary dictionaryWithObjectsAndKeys:[NSFont systemFontOfSize:12.0f], NSFontAttributeName, nil];
    134     float maxWidth = 0.0f;
     135    CGFloat maxWidth = 0;
    135136    int maxIndex = -1;
    136137    int i;
     
    147148        maxWidth = ceilf([NSWindow frameRectForContentRect:NSMakeRect(0.0f, 0.0f, maxWidth, 100.0f) styleMask:NSBorderlessWindowMask].size.width);
    148149        maxWidth += 5.0f;
    149         windowFrame.size.width = MAX(maxWidth, windowFrame.size.width);
    150         maxWidth = MIN(400.0f, windowFrame.size.width);
     150        windowFrame.size.width = max(maxWidth, windowFrame.size.width);
     151        maxWidth = min<CGFloat>(400, windowFrame.size.width);
    151152    }
    152153    [_popupWindow setFrame:windowFrame display:NO];
Note: See TracChangeset for help on using the changeset viewer.