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

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

Issue 1301173002: Avoid sync IPCs for firstRectForCharacterRange/attributedSubstringForProposedRange. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: nits. Created 5 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/browser/renderer_host/render_widget_host_view_mac.h ('k') | no next file » | 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 66f1c31650f7799701f8aba763b515e7c340aaeb..42b6099e1a9b22e957d7bc706f9c95cea0eb7dc9 100644
--- a/content/browser/renderer_host/render_widget_host_view_mac.mm
+++ b/content/browser/renderer_host/render_widget_host_view_mac.mm
@@ -1225,6 +1225,7 @@ void RenderWidgetHostViewMac::SelectionBoundsChanged(
const ViewHostMsg_SelectionBounds_Params& params) {
if (params.anchor_rect == params.focus_rect)
caret_rect_ = params.anchor_rect;
+ first_selection_rect_ = params.anchor_rect;
}
void RenderWidgetHostViewMac::SetShowingContextMenu(bool showing) {
@@ -1453,6 +1454,12 @@ bool RenderWidgetHostViewMac::GetCachedFirstRectForCharacterRange(
return true;
}
+ if (composition_range_.is_empty()) {
+ *actual_range = selection_range_.ToNSRange();
+ *rect = NSRectFromCGRect(first_selection_rect_.ToCGRect());
+ return true;
+ }
+
const gfx::Range request_range_in_composition =
ConvertCharacterRangeToCompositionRange(gfx::Range(range));
if (request_range_in_composition == gfx::Range::InvalidRange())
@@ -2887,10 +2894,32 @@ extern NSString *NSTextInputReplacementRangeAttributeName;
// TODO(thakis): Pipe |actualRange| through TextInputClientMac machinery.
if (actualRange)
*actualRange = range;
- NSAttributedString* str =
- TextInputClientMac::GetInstance()->GetAttributedSubstringFromRange(
- renderWidgetHostView_->render_widget_host_, range);
- return str;
+
+ const gfx::Range requested_range(range);
+ if (requested_range.is_reversed())
+ return nil;
+
+ gfx::Range expected_range;
+ base::string16 expected_text;
+
+ if (!renderWidgetHostView_->composition_range().is_empty()) {
+ expected_text = markedText_;
+ expected_range = renderWidgetHostView_->composition_range();
+ } else {
+ expected_text = renderWidgetHostView_->selection_text();
+ size_t offset = renderWidgetHostView_->selection_text_offset();
+ expected_range = gfx::Range(offset, offset + expected_text.size());
+ }
+
+ if (!expected_range.Contains(requested_range))
+ return nil;
+
+ expected_text = expected_text.substr(
+ requested_range.start() - expected_range.start(),
+ requested_range.length());
+
+ return [[NSAttributedString alloc] initWithString:
Alexei Svitkine (slow) 2015/08/24 15:34:43 You need to autorelease this object, otherwise you
Shu Chen 2015/08/25 03:43:10 Done.
+ base::SysUTF16ToNSString(expected_text)];
Alexei Svitkine (slow) 2015/08/24 15:34:43 Isn't this losing the formatting? If I remember c
Shu Chen 2015/08/25 03:43:10 Yes. I've explained in the cl description and in #
}
- (NSInteger)conversationIdentifier {
« no previous file with comments | « content/browser/renderer_host/render_widget_host_view_mac.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698