OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "win8/metro_driver/ime/text_service.h" | 5 #include "win8/metro_driver/ime/text_service.h" |
6 | 6 |
7 #include <msctf.h> | 7 #include <msctf.h> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/win/scoped_variant.h" | 10 #include "base/win/scoped_variant.h" |
(...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
327 DCHECK_NE(TF_CLIENTID_NULL, client_id); | 327 DCHECK_NE(TF_CLIENTID_NULL, client_id); |
328 DCHECK(window_handle != NULL); | 328 DCHECK(window_handle != NULL); |
329 DCHECK(thread_manager_); | 329 DCHECK(thread_manager_); |
330 } | 330 } |
331 virtual ~TextServiceImpl() { | 331 virtual ~TextServiceImpl() { |
332 thread_manager_->Deactivate(); | 332 thread_manager_->Deactivate(); |
333 } | 333 } |
334 | 334 |
335 private: | 335 private: |
336 // TextService overrides: | 336 // TextService overrides: |
337 virtual void CancelComposition() OVERRIDE { | 337 virtual void CancelComposition() override { |
338 if (!current_document_) { | 338 if (!current_document_) { |
339 VLOG(0) << "|current_document_| is NULL due to the previous error."; | 339 VLOG(0) << "|current_document_| is NULL due to the previous error."; |
340 return; | 340 return; |
341 } | 341 } |
342 TextStore* text_store = current_document_->text_store(); | 342 TextStore* text_store = current_document_->text_store(); |
343 if (!text_store) | 343 if (!text_store) |
344 return; | 344 return; |
345 text_store->CancelComposition(); | 345 text_store->CancelComposition(); |
346 } | 346 } |
347 | 347 |
348 virtual void OnDocumentChanged( | 348 virtual void OnDocumentChanged( |
349 const std::vector<int32>& input_scopes, | 349 const std::vector<int32>& input_scopes, |
350 const std::vector<metro_viewer::CharacterBounds>& character_bounds) | 350 const std::vector<metro_viewer::CharacterBounds>& character_bounds) |
351 OVERRIDE { | 351 override { |
352 bool document_type_changed = input_scopes_ != input_scopes; | 352 bool document_type_changed = input_scopes_ != input_scopes; |
353 input_scopes_ = input_scopes; | 353 input_scopes_ = input_scopes; |
354 composition_character_bounds_ = character_bounds; | 354 composition_character_bounds_ = character_bounds; |
355 if (document_type_changed) | 355 if (document_type_changed) |
356 OnDocumentTypeChanged(input_scopes); | 356 OnDocumentTypeChanged(input_scopes); |
357 } | 357 } |
358 | 358 |
359 virtual void OnWindowActivated() OVERRIDE { | 359 virtual void OnWindowActivated() override { |
360 if (!current_document_) { | 360 if (!current_document_) { |
361 VLOG(0) << "|current_document_| is NULL due to the previous error."; | 361 VLOG(0) << "|current_document_| is NULL due to the previous error."; |
362 return; | 362 return; |
363 } | 363 } |
364 ITfDocumentMgr* document_manager = current_document_->document_manager(); | 364 ITfDocumentMgr* document_manager = current_document_->document_manager(); |
365 if (!document_manager) { | 365 if (!document_manager) { |
366 VLOG(0) << "|document_manager| is NULL due to the previous error."; | 366 VLOG(0) << "|document_manager| is NULL due to the previous error."; |
367 return; | 367 return; |
368 } | 368 } |
369 HRESULT hr = thread_manager_->SetFocus(document_manager); | 369 HRESULT hr = thread_manager_->SetFocus(document_manager); |
370 if (FAILED(hr)) { | 370 if (FAILED(hr)) { |
371 LOG(ERROR) << "ITfThreadMgr2::SetFocus failed. hr = " << hr; | 371 LOG(ERROR) << "ITfThreadMgr2::SetFocus failed. hr = " << hr; |
372 return; | 372 return; |
373 } | 373 } |
374 } | 374 } |
375 | 375 |
376 virtual void OnCompositionChanged( | 376 virtual void OnCompositionChanged( |
377 const base::string16& text, | 377 const base::string16& text, |
378 int32 selection_start, | 378 int32 selection_start, |
379 int32 selection_end, | 379 int32 selection_end, |
380 const std::vector<metro_viewer::UnderlineInfo>& underlines) OVERRIDE { | 380 const std::vector<metro_viewer::UnderlineInfo>& underlines) override { |
381 if (!delegate_) | 381 if (!delegate_) |
382 return; | 382 return; |
383 delegate_->OnCompositionChanged(text, | 383 delegate_->OnCompositionChanged(text, |
384 selection_start, | 384 selection_start, |
385 selection_end, | 385 selection_end, |
386 underlines); | 386 underlines); |
387 } | 387 } |
388 | 388 |
389 virtual void OnTextCommitted(const base::string16& text) OVERRIDE { | 389 virtual void OnTextCommitted(const base::string16& text) override { |
390 if (!delegate_) | 390 if (!delegate_) |
391 return; | 391 return; |
392 delegate_->OnTextCommitted(text); | 392 delegate_->OnTextCommitted(text); |
393 } | 393 } |
394 | 394 |
395 virtual RECT GetCaretBounds() { | 395 virtual RECT GetCaretBounds() { |
396 if (composition_character_bounds_.empty()) { | 396 if (composition_character_bounds_.empty()) { |
397 const RECT rect = {}; | 397 const RECT rect = {}; |
398 return rect; | 398 return rect; |
399 } | 399 } |
400 const metro_viewer::CharacterBounds& bounds = | 400 const metro_viewer::CharacterBounds& bounds = |
401 composition_character_bounds_[0]; | 401 composition_character_bounds_[0]; |
402 POINT left_top = { bounds.left, bounds.top }; | 402 POINT left_top = { bounds.left, bounds.top }; |
403 POINT right_bottom = { bounds.right, bounds.bottom }; | 403 POINT right_bottom = { bounds.right, bounds.bottom }; |
404 ClientToScreen(window_handle_, &left_top); | 404 ClientToScreen(window_handle_, &left_top); |
405 ClientToScreen(window_handle_, &right_bottom); | 405 ClientToScreen(window_handle_, &right_bottom); |
406 const RECT rect = { | 406 const RECT rect = { |
407 left_top.x, | 407 left_top.x, |
408 left_top.y, | 408 left_top.y, |
409 right_bottom.x, | 409 right_bottom.x, |
410 right_bottom.y, | 410 right_bottom.y, |
411 }; | 411 }; |
412 return rect; | 412 return rect; |
413 } | 413 } |
414 | 414 |
415 virtual bool GetCompositionCharacterBounds(uint32 index, | 415 virtual bool GetCompositionCharacterBounds(uint32 index, |
416 RECT* rect) OVERRIDE { | 416 RECT* rect) override { |
417 if (index >= composition_character_bounds_.size()) { | 417 if (index >= composition_character_bounds_.size()) { |
418 return false; | 418 return false; |
419 } | 419 } |
420 const metro_viewer::CharacterBounds& bounds = | 420 const metro_viewer::CharacterBounds& bounds = |
421 composition_character_bounds_[index]; | 421 composition_character_bounds_[index]; |
422 POINT left_top = { bounds.left, bounds.top }; | 422 POINT left_top = { bounds.left, bounds.top }; |
423 POINT right_bottom = { bounds.right, bounds.bottom }; | 423 POINT right_bottom = { bounds.right, bounds.bottom }; |
424 ClientToScreen(window_handle_, &left_top); | 424 ClientToScreen(window_handle_, &left_top); |
425 ClientToScreen(window_handle_, &right_bottom); | 425 ClientToScreen(window_handle_, &right_bottom); |
426 SetRect(rect, left_top.x, left_top.y, right_bottom.x, right_bottom.y); | 426 SetRect(rect, left_top.x, left_top.y, right_bottom.x, right_bottom.y); |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
484 thread_manager->Deactivate(); | 484 thread_manager->Deactivate(); |
485 return scoped_ptr<TextService>(); | 485 return scoped_ptr<TextService>(); |
486 } | 486 } |
487 return scoped_ptr<TextService>(new TextServiceImpl(thread_manager, | 487 return scoped_ptr<TextService>(new TextServiceImpl(thread_manager, |
488 client_id, | 488 client_id, |
489 window_handle, | 489 window_handle, |
490 delegate)); | 490 delegate)); |
491 } | 491 } |
492 | 492 |
493 } // namespace metro_driver | 493 } // namespace metro_driver |
OLD | NEW |