Changeset 161850 in webkit


Ignore:
Timestamp:
Jan 12, 2014 6:27:42 PM (10 years ago)
Author:
Darin Adler
Message:

Add type checking to isEqual methods
https://bugs.webkit.org/show_bug.cgi?id=126862

Reviewed by Anders Carlsson.

Source/WebCore:

  • page/ios/WebEventRegion.mm:

(-[WebEventRegion isEqual:]): Add type checking on the argument.
Add a FIXME about the lack of a hash method override. Formatted to match
the usual WebKit coding style.

Source/WebKit/ios:

  • WebCoreSupport/WebVisiblePosition.mm:

(-[WebVisiblePosition isEqual:]): Add type checking on the argument.
Add a FIXME about the lack of a hash method override. Simplified by
removing the unneeded local variables.

Source/WebKit/mac:

  • WebCoreSupport/WebSecurityOrigin.mm:

(-[WebSecurityOrigin isEqual:]): Added a FIXME about the lack of a hash method
override. Tweaked formatting.

  • WebView/WebDashboardRegion.mm:

(-[WebDashboardRegion isEqual:]): Added type checking on the argument. Added a
FIXME about the lack of a hash method override.

Source/WebKit2:

  • UIProcess/API/ios/WKInteractionView.mm:

(-[WKTextRange isEqual:]): Added type checking for the argument. The old
code asserted instead, and it's not clear what guarantees that assertion is
true. Added a FIXME about the lack of a hash method. Added another FIXME
about the fact that this method ignores much of the object state. Removed
an unneeded extra fetch of the isRange property. Deleted some dead code.
(-[WKTextPosition isEqual:]): Ditto.

Location:
trunk/Source
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r161848 r161850  
     12014-01-12  Darin Adler  <darin@apple.com>
     2
     3        Add type checking to isEqual methods
     4        https://bugs.webkit.org/show_bug.cgi?id=126862
     5
     6        Reviewed by Anders Carlsson.
     7
     8        * page/ios/WebEventRegion.mm:
     9        (-[WebEventRegion isEqual:]): Add type checking on the argument.
     10        Add a FIXME about the lack of a hash method override. Formatted to match
     11        the usual WebKit coding style.
     12
    1132014-01-12  Anders Carlsson  <andersca@apple.com>
    214
  • trunk/Source/WebCore/page/ios/WebEventRegion.mm

    r161806 r161850  
    6767}
    6868
     69// FIXME: Overriding isEqual: without overriding hash will cause trouble if this ever goes into an NSSet or is the key in an NSDictionary,
     70// since two equal objects could have different hashes.
    6971- (BOOL)isEqual:(id)other
    7072{
    71     return  CGPointEqualToPoint(p1, ((WebEventRegion *)other)->p1) &&
    72             CGPointEqualToPoint(p2, ((WebEventRegion *)other)->p2) &&
    73             CGPointEqualToPoint(p3, ((WebEventRegion *)other)->p3) &&
    74             CGPointEqualToPoint(p4, ((WebEventRegion *)other)->p4);
     73    if (![other isKindOfClass:[WebEventRegion class]])
     74        return NO;
     75    return CGPointEqualToPoint(p1, ((WebEventRegion *)other)->p1)
     76        && CGPointEqualToPoint(p2, ((WebEventRegion *)other)->p2)
     77        && CGPointEqualToPoint(p3, ((WebEventRegion *)other)->p3)
     78        && CGPointEqualToPoint(p4, ((WebEventRegion *)other)->p4);
    7579}
    7680
  • trunk/Source/WebKit/ios/ChangeLog

    r161468 r161850  
     12014-01-12  Darin Adler  <darin@apple.com>
     2
     3        Add type checking to isEqual methods
     4        https://bugs.webkit.org/show_bug.cgi?id=126862
     5
     6        Reviewed by Anders Carlsson.
     7
     8        * WebCoreSupport/WebVisiblePosition.mm:
     9        (-[WebVisiblePosition isEqual:]): Add type checking on the argument.
     10        Add a FIXME about the lack of a hash method override. Simplified by
     11        removing the unneeded local variables.
     12
    1132014-01-02  Andy Estes  <aestes@apple.com>
    214
  • trunk/Source/WebKit/ios/WebCoreSupport/WebVisiblePosition.mm

    r161185 r161850  
    8888}
    8989
    90 - (BOOL)isEqual:(WebVisiblePosition *)other
    91 {
    92     VisiblePosition myVP = [self _visiblePosition];
    93     VisiblePosition otherVP = [other _visiblePosition];
    94     return (myVP == otherVP);
     90// FIXME: Overriding isEqual: without overriding hash will cause trouble if this ever goes into an NSSet or is the key in an NSDictionary,
     91// since two equal objects could have different hashes.
     92- (BOOL)isEqual:(id)other
     93{
     94    if (![other isKindOfClass:[WebVisiblePosition class]])
     95        return NO;
     96    return [self _visiblePosition] == [(WebVisiblePosition *)other _visiblePosition];
    9597}
    9698
  • trunk/Source/WebKit/mac/ChangeLog

    r161796 r161850  
     12014-01-12  Darin Adler  <darin@apple.com>
     2
     3        Add type checking to isEqual methods
     4        https://bugs.webkit.org/show_bug.cgi?id=126862
     5
     6        Reviewed by Anders Carlsson.
     7
     8        * WebCoreSupport/WebSecurityOrigin.mm:
     9        (-[WebSecurityOrigin isEqual:]): Added a FIXME about the lack of a hash method
     10        override. Tweaked formatting.
     11
     12        * WebView/WebDashboardRegion.mm:
     13        (-[WebDashboardRegion isEqual:]): Added type checking on the argument. Added a
     14        FIXME about the lack of a hash method override.
     15
    1162014-01-11  Alexey Proskuryakov  <ap@apple.com>
    217
  • trunk/Source/WebKit/mac/WebCoreSupport/WebSecurityOrigin.mm

    r161185 r161850  
    9090}
    9191
     92// FIXME: Overriding isEqual: without overriding hash will cause trouble if this ever goes into an NSSet or is the key in an NSDictionary,
     93// since two equal objects could have different hashes.
    9294- (BOOL)isEqual:(id)anObject
    9395{
    94     if (![anObject isMemberOfClass:[WebSecurityOrigin class]]) {
     96    if (![anObject isMemberOfClass:[WebSecurityOrigin class]])
    9597        return NO;
    96     }
    9798   
    9899    return [self _core]->equal([anObject _core]);
  • trunk/Source/WebKit/mac/WebView/WebDashboardRegion.mm

    r149980 r161850  
    8181}
    8282
    83 // FIXME: Overriding isEqual: without overriding hash will cause trouble if this ever goes into a NSSet or is the key in an NSDictionary.
     83// FIXME: Overriding isEqual: without overriding hash will cause trouble if this ever goes into an NSSet or is the key in an NSDictionary,
     84// since two equal objects could have different hashes.
    8485- (BOOL)isEqual:(id)other
    8586{
     87    if (![other isKindOfClass:[WebDashboardRegion class]])
     88        return NO;
     89
    8690    return NSEqualRects(rect, [other dashboardRegionRect]) && NSEqualRects(clip, [other dashboardRegionClip]) && type == [other dashboardRegionType];
    8791}
  • trunk/Source/WebKit2/ChangeLog

    r161849 r161850  
     12014-01-12  Darin Adler  <darin@apple.com>
     2
     3        Add type checking to isEqual methods
     4        https://bugs.webkit.org/show_bug.cgi?id=126862
     5
     6        Reviewed by Anders Carlsson.
     7
     8        * UIProcess/API/ios/WKInteractionView.mm:
     9        (-[WKTextRange isEqual:]): Added type checking for the argument. The old
     10        code asserted instead, and it's not clear what guarantees that assertion is
     11        true. Added a FIXME about the lack of a hash method. Added another FIXME
     12        about the fact that this method ignores much of the object state. Removed
     13        an unneeded extra fetch of the isRange property. Deleted some dead code.
     14        (-[WKTextPosition isEqual:]): Ditto.
     15
    1162014-01-12  Anders Carlsson  <andersca@apple.com>
    217
  • trunk/Source/WebKit2/UIProcess/API/ios/WKInteractionView.mm

    r161358 r161850  
    15161516}
    15171517
     1518// FIXME: Overriding isEqual: without overriding hash will cause trouble if this ever goes into an NSSet or is the key in an NSDictionary,
     1519// since two equal items could have different hashes.
    15181520- (BOOL)isEqual:(id)other
    15191521{
    1520     assert([other isKindOfClass:[WKTextRange class]]);
     1522    if (![other isKindOfClass:[WKTextRange class]])
     1523        return NO;
     1524
    15211525    WKTextRange *otherRange = (WKTextRange *)other;
    1522    
     1526
    15231527    if (self == other)
    15241528        return YES;
    1525    
     1529
     1530    // FIXME: Probably incorrect for equality to ignore so much of the object state.
     1531    // It ignores isNone, isEditable, selectedTextLength, and selectionRects.
     1532
    15261533    if (self.isRange) {
    15271534        if (!otherRange.isRange)
    15281535            return NO;
    15291536        return CGRectEqualToRect(self.startRect, otherRange.startRect) && CGRectEqualToRect(self.endRect, otherRange.endRect);
    1530     } else if (!self.isRange) {
     1537    } else {
    15311538        if (otherRange.isRange)
    15321539            return NO;
     1540        // FIXME: Do we need to check isNone here?
    15331541        return CGRectEqualToRect(self.startRect, otherRange.startRect);
    15341542    }
    1535     return otherRange.isNone;
    15361543}
    15371544
     
    15491556}
    15501557
     1558// FIXME: Overriding isEqual: without overriding hash will cause trouble if this ever goes into a NSSet or is the key in an NSDictionary,
     1559// since two equal items could have different hashes.
    15511560- (BOOL)isEqual:(id)other
    15521561{
    1553     assert([other isKindOfClass:[self class]]);
     1562    if (![object isKindOfClass:[WKTextPosition class]])
     1563        return NO;
     1564
    15541565    return CGRectEqualToRect(self.positionRect, ((WKTextPosition *)other).positionRect);
    15551566}
Note: See TracChangeset for help on using the changeset viewer.