Skip to content

Commit

Permalink
Use Foundation MIN,MAX in place of C++ std::min,max (flutter#3578)
Browse files Browse the repository at this point in the history
Maintains consistency with other Objective-C code in the engine and
allows us to eliminate a #include.
  • Loading branch information
cbracken authored Apr 8, 2017
1 parent 77a4fed commit 8df4ec7
Showing 1 changed file with 4 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
#include "flutter/shell/platform/darwin/ios/framework/Source/FlutterTextInputPlugin.h"

#include <UIKit/UIKit.h>
#include <algorithm>

static const char _kTextAffinityDownstream[] = "TextAffinity.downstream";
static const char _kTextAffinityUpstream[] = "TextAffinity.upstream";
Expand Down Expand Up @@ -98,8 +97,8 @@ - (BOOL)hasText {
}

- (void)insertText:(NSString*)text {
int start = std::max(0, std::min(_selectionBase, _selectionExtent));
int end = std::max(0, std::max(_selectionBase, _selectionExtent));
int start = MAX(0, MIN(_selectionBase, _selectionExtent));
int end = MAX(0, MIN(_selectionBase, _selectionExtent));
int len = end - start;
[self.text replaceCharactersInRange:NSMakeRange(start, len) withString:text];
int caret = start + text.length;
Expand All @@ -110,8 +109,8 @@ - (void)insertText:(NSString*)text {
}

- (void)deleteBackward {
int start = std::max(0, std::min(_selectionBase, _selectionExtent));
int end = std::max(0, std::max(_selectionBase, _selectionExtent));
int start = MAX(0, MIN(_selectionBase, _selectionExtent));
int end = MAX(0, MIN(_selectionBase, _selectionExtent));
NSRange deleteRange = NSMakeRange(start, end - start);
if (deleteRange.length > 0) {
deleteRange = [self.text rangeOfComposedCharacterSequencesForRange:deleteRange];
Expand Down

0 comments on commit 8df4ec7

Please sign in to comment.