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

Side by Side Diff: ui/views/cocoa/bridged_content_view.mm

Issue 1893523002: MacViews: Allow force touch in views::Textfield Base URL: https://chromium.googlesource.com/chromium/src.git@20160415-Mac-ForceTouch
Patch Set: Created 4 years, 8 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 | « ui/base/ime/text_input_client.h ('k') | 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 #import "ui/views/cocoa/bridged_content_view.h" 5 #import "ui/views/cocoa/bridged_content_view.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #import "base/mac/mac_util.h" 8 #import "base/mac/mac_util.h"
9 #import "base/mac/scoped_nsobject.h" 9 #import "base/mac/scoped_nsobject.h"
10 #include "base/strings/sys_string_conversions.h" 10 #include "base/strings/sys_string_conversions.h"
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 } else { 153 } else {
154 *actual_range = 154 *actual_range =
155 gfx::Range(requested_range.start(), i + composition_range.start()); 155 gfx::Range(requested_range.start(), i + composition_range.start());
156 return union_rect; 156 return union_rect;
157 } 157 }
158 } 158 }
159 *actual_range = requested_range; 159 *actual_range = requested_range;
160 return union_rect; 160 return union_rect;
161 } 161 }
162 162
163 NSAttributedString* AttributedStringFromRenderText(
164 const gfx::RenderText* render_text,
165 const gfx::Range& range) {
166 return ...
167 }
168
163 } // namespace 169 } // namespace
164 170
165 @interface BridgedContentView () 171 @interface BridgedContentView ()
166 172
167 // Translates keycodes and modifiers on |theEvent| to ui::KeyEvents and passes 173 // Translates keycodes and modifiers on |theEvent| to ui::KeyEvents and passes
168 // the event to the InputMethod for dispatch. 174 // the event to the InputMethod for dispatch.
169 - (void)handleKeyEvent:(NSEvent*)theEvent; 175 - (void)handleKeyEvent:(NSEvent*)theEvent;
170 176
171 // Handles an NSResponder Action Message by mapping it to a corresponding text 177 // Handles an NSResponder Action Message by mapping it to a corresponding text
172 // editing command from ui_strings.grd and, when not being sent to a 178 // editing command from ui_strings.grd and, when not being sent to a
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
396 402
397 ui::MouseEvent event(theEvent); 403 ui::MouseEvent event(theEvent);
398 404
399 // Aura updates tooltips with the help of aura::Window::AddPreTargetHandler(). 405 // Aura updates tooltips with the help of aura::Window::AddPreTargetHandler().
400 // Mac hooks in here. 406 // Mac hooks in here.
401 [self updateTooltipIfRequiredAt:event.location()]; 407 [self updateTooltipIfRequiredAt:event.location()];
402 408
403 hostedView_->GetWidget()->OnMouseEvent(&event); 409 hostedView_->GetWidget()->OnMouseEvent(&event);
404 } 410 }
405 411
412 - (void)forceTouchEvent:(NSEvent*)theEvent {
413 if (!textInputClient_ || !ui::ForceTouchInvokesQuickLook())
414 return;
415
416 ui::MouseEvent event(theEvent);
417 gfx::Range range;
418 gfx::Point baselinePoint;
419 const gfx::RenderText* renderText =
420 textInputClient_->GetStringAtPointInWindow(event.location(), &range,
421 &baselinePoint);
422 if (!renderText)
423 return;
424
425 NSAttributedString* attributedString =
426 AttributedStringFromRenderText(renderText, range);
427
428 dispatch_async(dispatch_get_main_queue(), ^{
429 [self showDefinitionForAttributedString:attributedString
430 atPoint:baselinePoint];
431 });
432 }
433
406 // NSView implementation. 434 // NSView implementation.
407 435
408 - (BOOL)acceptsFirstResponder { 436 - (BOOL)acceptsFirstResponder {
409 return YES; 437 return YES;
410 } 438 }
411 439
412 - (BOOL)becomeFirstResponder { 440 - (BOOL)becomeFirstResponder {
413 BOOL result = [super becomeFirstResponder]; 441 BOOL result = [super becomeFirstResponder];
414 if (result && hostedView_) 442 if (result && hostedView_)
415 hostedView_->GetWidget()->GetFocusManager()->RestoreFocusedView(); 443 hostedView_->GetWidget()->GetFocusManager()->RestoreFocusedView();
(...skipping 511 matching lines...) Expand 10 before | Expand all | Expand 10 after
927 } 955 }
928 956
929 return [super accessibilityAttributeValue:attribute]; 957 return [super accessibilityAttributeValue:attribute];
930 } 958 }
931 959
932 - (id)accessibilityHitTest:(NSPoint)point { 960 - (id)accessibilityHitTest:(NSPoint)point {
933 return [hostedView_->GetNativeViewAccessible() accessibilityHitTest:point]; 961 return [hostedView_->GetNativeViewAccessible() accessibilityHitTest:point];
934 } 962 }
935 963
936 @end 964 @end
OLDNEW
« no previous file with comments | « ui/base/ime/text_input_client.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698