Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(165)

Unified Diff: content/browser/renderer_host/render_widget_host_view_mac.mm

Issue 2493383002: [Merge to 2883] Revert of Fix RenderWidgetHostViewMac compliance with NSTextInputClient. (Closed)
Patch Set: Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | content/browser/renderer_host/render_widget_host_view_mac_unittest.mm » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/renderer_host/render_widget_host_view_mac.mm
diff --git a/content/browser/renderer_host/render_widget_host_view_mac.mm b/content/browser/renderer_host/render_widget_host_view_mac.mm
index aeee8788919e3abfda36e1accdb3e41f98fde247..c81f211e3a5205e6f96f712e7474a290b7b20e5b 100644
--- a/content/browser/renderer_host/render_widget_host_view_mac.mm
+++ b/content/browser/renderer_host/render_widget_host_view_mac.mm
@@ -2965,12 +2965,6 @@ extern NSString *NSTextInputReplacementRangeAttributeName;
return rect;
}
-- (NSRange)selectedRange {
- if (selectedRange_.location == NSNotFound || selectedRange_.length == 0)
- return NSMakeRange(NSNotFound, 0);
- return selectedRange_;
-}
-
- (NSRange)markedRange {
// An input method calls this method to check if an application really has
// a text being composed when hasMarkedText call returns true.
@@ -2983,17 +2977,9 @@ extern NSString *NSTextInputReplacementRangeAttributeName;
- (NSAttributedString*)attributedSubstringForProposedRange:(NSRange)range
actualRange:(NSRangePointer)actualRange {
- // Prepare |actualRange| as if the proposed range is invalid. If it is valid,
- // then |actualRange| will be updated again.
+ // TODO(thakis): Pipe |actualRange| through TextInputClientMac machinery.
if (actualRange)
- *actualRange = NSMakeRange(NSNotFound, 0);
-
- // The caller of this method is allowed to pass nonsensical ranges. These
- // can't even be converted into gfx::Ranges.
- if (range.location == NSNotFound || range.length == 0)
- return nil;
- if (range.length >= std::numeric_limits<NSUInteger>::max() - range.location)
- return nil;
+ *actualRange = range;
const gfx::Range requested_range(range);
if (requested_range.is_reversed())
@@ -3011,16 +2997,15 @@ extern NSString *NSTextInputReplacementRangeAttributeName;
expected_range = gfx::Range(offset, offset + expected_text->size());
}
- gfx::Range actual_range = expected_range.Intersect(requested_range);
- if (!actual_range.IsValid())
+ if (!expected_range.Contains(requested_range))
return nil;
// Gets the raw bytes to avoid unnecessary string copies for generating
// NSString.
const base::char16* bytes =
- &(*expected_text)[actual_range.start() - expected_range.start()];
+ &(*expected_text)[requested_range.start() - expected_range.start()];
// Avoid integer overflow.
- base::CheckedNumeric<size_t> requested_len = actual_range.length();
+ base::CheckedNumeric<size_t> requested_len = requested_range.length();
requested_len *= sizeof(base::char16);
NSUInteger bytes_len = base::strict_cast<NSUInteger, size_t>(
requested_len.ValueOrDefault(0));
@@ -3028,9 +3013,6 @@ extern NSString *NSTextInputReplacementRangeAttributeName;
[[NSString alloc] initWithBytes:bytes
length:bytes_len
encoding:NSUTF16LittleEndianStringEncoding]);
- if (actualRange)
- *actualRange = actual_range.ToNSRange();
-
return [[[NSAttributedString alloc] initWithString:ns_string] autorelease];
}
« no previous file with comments | « no previous file | content/browser/renderer_host/render_widget_host_view_mac_unittest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698