Bug 120119 - Add some operator overloads to VisiblePosition
Summary: Add some operator overloads to VisiblePosition
Status: RESOLVED INVALID
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebCore Misc. (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL:
Keywords: InRadar
Depends on:
Blocks: 119829
  Show dependency treegraph
 
Reported: 2013-08-21 10:23 PDT by Roger Fong
Modified: 2013-08-22 17:35 PDT (History)
5 users (show)

See Also:


Attachments
patch (3.29 KB, patch)
2013-08-22 17:22 PDT, Roger Fong
rniwa: review-
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Roger Fong 2013-08-21 10:23:20 PDT
Having these here does no harm and they're quite useful for comparing VisiblePositions.
I need them for https://bugs.webkit.org/show_bug.cgi?id=119829
Comment 1 Radar WebKit Bug Importer 2013-08-21 10:53:02 PDT
<rdar://problem/14797554>
Comment 2 Roger Fong 2013-08-22 17:22:00 PDT
Created attachment 209410 [details]
patch
Comment 3 Ryosuke Niwa 2013-08-22 17:32:18 PDT
Comment on attachment 209410 [details]
patch

View in context: https://bugs.webkit.org/attachment.cgi?id=209410&action=review

> Source/WebCore/dom/Position.h:243
> +inline bool operator<(const Position& a, const Position& b)
> +{
> +    return a.anchorNode() == b.anchorNode() && a.deprecatedEditingOffset() < b.deprecatedEditingOffset() && a.anchorType() == b.anchorType();
> +}

I don't think this comparison operator makes sense.  Just because nodes aren't same doesn't mean they aren't comparable.

If anything, we should be calling comparePositions instead. r-.
Comment 4 Roger Fong 2013-08-22 17:35:46 PDT
(In reply to comment #3)
> (From update of attachment 209410 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=209410&action=review
> 
> > Source/WebCore/dom/Position.h:243
> > +inline bool operator<(const Position& a, const Position& b)
> > +{
> > +    return a.anchorNode() == b.anchorNode() && a.deprecatedEditingOffset() < b.deprecatedEditingOffset() && a.anchorType() == b.anchorType();
> > +}
> 
> I don't think this comparison operator makes sense.  Just because nodes aren't same doesn't mean they aren't comparable.
> 
> If anything, we should be calling comparePositions instead. r-.

didn't realize that method existed...will use that instead.