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

Side by Side Diff: content/browser/accessibility/browser_accessibility_cocoa.mm

Issue 2396593002: Merge to M54: Temporarily work around crash when adding misspelling annotations to accessible strin… (Closed)
Patch Set: Created 4 years, 2 months 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <execinfo.h> 5 #include <execinfo.h>
6 #include <stddef.h> 6 #include <stddef.h>
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #import "content/browser/accessibility/browser_accessibility_cocoa.h" 9 #import "content/browser/accessibility/browser_accessibility_cocoa.h"
10 10
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after
283 // Be permissive with the start and end offsets. 283 // Be permissive with the start and end offsets.
284 if (start_object == end_object && end_offset < start_offset) 284 if (start_object == end_object && end_offset < start_offset)
285 std::swap(start_offset, end_offset); 285 std::swap(start_offset, end_offset);
286 286
287 int trim_length = 0; 287 int trim_length = 0;
288 if ((end_object->IsSimpleTextControl() || end_object->IsTextOnlyObject()) && 288 if ((end_object->IsSimpleTextControl() || end_object->IsTextOnlyObject()) &&
289 end_offset < static_cast<int>(end_object->GetText().length())) { 289 end_offset < static_cast<int>(end_object->GetText().length())) {
290 trim_length = static_cast<int>(end_object->GetText().length()) - end_offset; 290 trim_length = static_cast<int>(end_object->GetText().length()) - end_offset;
291 } 291 }
292 int range_length = [text length] - start_offset - trim_length; 292 int range_length = [text length] - start_offset - trim_length;
293
294 // http://crbug.com/651145
295 // This shouldn't happen, so this is a temporary workaround to prevent
296 // hard crashes.
297 if (range_length < 0)
298 return nil;
299
293 DCHECK_GE(range_length, 0); 300 DCHECK_GE(range_length, 0);
294 NSRange range = NSMakeRange(start_offset, range_length); 301 NSRange range = NSMakeRange(start_offset, range_length);
295 DCHECK_LE(NSMaxRange(range), [text length]); 302 DCHECK_LE(NSMaxRange(range), [text length]);
296 303
297 NSMutableAttributedString* attributed_text = 304 NSMutableAttributedString* attributed_text =
298 [[[NSMutableAttributedString alloc] initWithString:text] autorelease]; 305 [[[NSMutableAttributedString alloc] initWithString:text] autorelease];
299 std::vector<const BrowserAccessibility*> text_only_objects = 306 std::vector<const BrowserAccessibility*> text_only_objects =
300 BrowserAccessibilityManager::FindTextOnlyObjectsInRange(*start_object, 307 BrowserAccessibilityManager::FindTextOnlyObjectsInRange(*start_object,
301 *end_object); 308 *end_object);
302 AddMisspelledTextAttributes(text_only_objects, attributed_text); 309 AddMisspelledTextAttributes(text_only_objects, attributed_text);
(...skipping 2555 matching lines...) Expand 10 before | Expand all | Expand 10 after
2858 if (![self instanceActive]) 2865 if (![self instanceActive])
2859 return [super hash]; 2866 return [super hash];
2860 return browserAccessibility_->GetId(); 2867 return browserAccessibility_->GetId();
2861 } 2868 }
2862 2869
2863 - (BOOL)accessibilityShouldUseUniqueId { 2870 - (BOOL)accessibilityShouldUseUniqueId {
2864 return YES; 2871 return YES;
2865 } 2872 }
2866 2873
2867 @end 2874 @end
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698