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

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: 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..fd786f1da8f5d99679ad499ea65b652fac9dbdb9 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,26 @@ 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;
+ gfx::Range expected_range;
+ std::wstring expected_text; // Using wide string for string truncation.
+ std::string result_text("");
+
+ if (!renderWidgetHostView_->composition_range().is_empty()) {
+ expected_range = renderWidgetHostView_->composition_range();
+ expected_text = base::UTF16ToWide(markedText_);
+ } else if (!renderWidgetHostView_->selection_range().is_empty()) {
yukawa 2015/08/20 09:14:49 I think we can take advantage of |RenderWidgetHost
Shu Chen 2015/08/21 03:13:11 Done.
+ expected_range = renderWidgetHostView_->selection_range();
+ expected_text = base::UTF8ToWide(renderWidgetHostView_->selected_text());
+ }
+
+ if (expected_range.start() <= range.location &&
yukawa 2015/08/20 09:14:49 Don't we need to return nil when there is no inter
Shu Chen 2015/08/21 03:13:11 Done. I think we don't need to update |actualRange
+ expected_range.end() >= range.location + range.length) {
+ result_text = base::WideToUTF8(expected_text.substr(
+ range.location - expected_range.start(), range.length));
+ }
+
+ NSString *nstr = [[NSString alloc] initWithUTF8String:result_text.c_str()];
+ return [[NSAttributedString alloc] initWithString:nstr];
}
- (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