OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 2006, 2007, 2008, 2011 Apple Inc. All rights reserved. | 2 * Copyright (C) 2006, 2007, 2008, 2011 Apple Inc. All rights reserved. |
3 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) | 3 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
7 * are met: | 7 * are met: |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
(...skipping 324 matching lines...) Loading... | |
335 // !hasComposition() && !text.isEmpty(). | 335 // !hasComposition() && !text.isEmpty(). |
336 // Sending a compositionupdate event at this time ensures that at least o ne | 336 // Sending a compositionupdate event at this time ensures that at least o ne |
337 // compositionupdate event is dispatched. | 337 // compositionupdate event is dispatched. |
338 // 2. Updating the existing composition node. | 338 // 2. Updating the existing composition node. |
339 // Send a compositionupdate event when this function updates the existing composition | 339 // Send a compositionupdate event when this function updates the existing composition |
340 // node, i.e. hasComposition() && !text.isEmpty(). | 340 // node, i.e. hasComposition() && !text.isEmpty(). |
341 // 3. Canceling the ongoing composition. | 341 // 3. Canceling the ongoing composition. |
342 // Send a compositionend event when function deletes the existing composi tion node, i.e. | 342 // Send a compositionend event when function deletes the existing composi tion node, i.e. |
343 // !hasComposition() && test.isEmpty(). | 343 // !hasComposition() && test.isEmpty(). |
344 if (text.isEmpty()) { | 344 if (text.isEmpty()) { |
345 if (hasComposition()) { | 345 if (hasComposition()) { |
yabinh
2016/08/03 06:27:01
If there is composing text, it will be confirmed.
| |
346 confirmComposition(emptyString()); | 346 confirmComposition(emptyString()); |
347 } else { | 347 } else { |
348 // It's weird to call |setComposition()| with empty text outside com position, however some IME | 348 // It's weird to call |setComposition()| with empty text outside com position, however some IME |
349 // (e.g. Japanese IBus-Anthy) did this, so we simply delete selectio n without sending extra events. | 349 // (e.g. Japanese IBus-Anthy) did this, so we simply delete selectio n without sending extra events. |
350 TypingCommand::deleteSelection(*frame().document(), TypingCommand::P reventSpellChecking); | 350 TypingCommand::deleteSelection(*frame().document(), TypingCommand::P reventSpellChecking); |
351 } | 351 } |
352 | 352 |
yabinh
2016/08/03 06:27:00
We don't need to change here, because there is no
| |
353 setEditableSelectionOffsets(selectedRange); | 353 setEditableSelectionOffsets(selectedRange); |
354 return; | 354 return; |
355 } | 355 } |
356 | 356 |
357 // We should send a 'compositionstart' event only when the given text is not empty because this | 357 // We should send a 'compositionstart' event only when the given text is not empty because this |
358 // function doesn't create a composition node when the text is empty. | 358 // function doesn't create a composition node when the text is empty. |
359 if (!hasComposition()) { | 359 if (!hasComposition()) { |
360 target->dispatchEvent(CompositionEvent::create(EventTypeNames::compositi onstart, frame().domWindow(), frame().selectedText())); | 360 target->dispatchEvent(CompositionEvent::create(EventTypeNames::compositi onstart, frame().domWindow(), frame().selectedText())); |
361 if (!frame().document()) | 361 if (!frame().document()) |
362 return; | 362 return; |
(...skipping 31 matching lines...) Loading... | |
394 m_isDirty = true; | 394 m_isDirty = true; |
395 m_hasComposition = true; | 395 m_hasComposition = true; |
396 if (!m_compositionRange) | 396 if (!m_compositionRange) |
397 m_compositionRange = Range::create(baseNode->document()); | 397 m_compositionRange = Range::create(baseNode->document()); |
398 m_compositionRange->setStart(baseNode, baseOffset); | 398 m_compositionRange->setStart(baseNode, baseOffset); |
399 m_compositionRange->setEnd(baseNode, extentOffset); | 399 m_compositionRange->setEnd(baseNode, extentOffset); |
400 | 400 |
401 if (baseNode->layoutObject()) | 401 if (baseNode->layoutObject()) |
402 baseNode->layoutObject()->setShouldDoFullPaintInvalidation(); | 402 baseNode->layoutObject()->setShouldDoFullPaintInvalidation(); |
403 | 403 |
404 setEditableSelectionOffsets(selectedRange); | 404 Element* rootEditableElement = frame().selection().rootEditableElement(); |
405 if (!rootEditableElement) | |
406 return; | |
407 const EphemeralRange& range = selectedRange.createRange(*rootEditableElement ); | |
408 frame().selection().setSelectedRange(range, TextAffinity::Downstream, Select ionDirectionalMode::NonDirectional, NotUserTriggered); | |
405 | 409 |
406 if (underlines.isEmpty()) { | 410 if (underlines.isEmpty()) { |
407 frame().document()->markers().addCompositionMarker(m_compositionRange->s tartPosition(), m_compositionRange->endPosition(), Color::black, false, LayoutTh eme::theme().platformDefaultCompositionBackgroundColor()); | 411 frame().document()->markers().addCompositionMarker(m_compositionRange->s tartPosition(), m_compositionRange->endPosition(), Color::black, false, LayoutTh eme::theme().platformDefaultCompositionBackgroundColor()); |
408 return; | 412 return; |
409 } | 413 } |
410 for (const auto& underline : underlines) { | 414 for (const auto& underline : underlines) { |
411 unsigned underlineStart = baseOffset + underline.startOffset; | 415 unsigned underlineStart = baseOffset + underline.startOffset; |
412 unsigned underlineEnd = baseOffset + underline.endOffset; | 416 unsigned underlineEnd = baseOffset + underline.endOffset; |
413 EphemeralRange ephemeralLineRange = EphemeralRange(Position(baseNode, un derlineStart), Position(baseNode, underlineEnd)); | 417 EphemeralRange ephemeralLineRange = EphemeralRange(Position(baseNode, un derlineStart), Position(baseNode, underlineEnd)); |
414 if (ephemeralLineRange.isNull()) | 418 if (ephemeralLineRange.isNull()) |
(...skipping 77 matching lines...) Loading... | |
492 if (!rootEditableElement) | 496 if (!rootEditableElement) |
493 return false; | 497 return false; |
494 | 498 |
495 // TODO(dglazkov): The use of updateStyleAndLayoutIgnorePendingStylesheets n eeds to be audited. | 499 // TODO(dglazkov): The use of updateStyleAndLayoutIgnorePendingStylesheets n eeds to be audited. |
496 // see http://crbug.com/590369 for more details. | 500 // see http://crbug.com/590369 for more details. |
497 rootEditableElement->document().updateStyleAndLayoutIgnorePendingStylesheets (); | 501 rootEditableElement->document().updateStyleAndLayoutIgnorePendingStylesheets (); |
498 | 502 |
499 const EphemeralRange range = selectionOffsets.createRange(*rootEditableEleme nt); | 503 const EphemeralRange range = selectionOffsets.createRange(*rootEditableEleme nt); |
500 if (range.isNull()) | 504 if (range.isNull()) |
501 return false; | 505 return false; |
502 | 506 |
yabinh
2016/08/03 06:27:00
It uses |CloseTyping| here.
| |
503 return frame().selection().setSelectedRange(range, VP_DEFAULT_AFFINITY, Sele ctionDirectionalMode::NonDirectional, FrameSelection::CloseTyping); | 507 return frame().selection().setSelectedRange(range, VP_DEFAULT_AFFINITY, Sele ctionDirectionalMode::NonDirectional, FrameSelection::CloseTyping); |
504 } | 508 } |
505 | 509 |
506 bool InputMethodController::setEditableSelectionOffsets(const PlainTextRange& se lectionOffsets) | 510 bool InputMethodController::setEditableSelectionOffsets(const PlainTextRange& se lectionOffsets) |
507 { | 511 { |
508 if (!editor().canEdit()) | 512 if (!editor().canEdit()) |
509 return false; | 513 return false; |
510 return setSelectionOffsets(selectionOffsets); | 514 return setSelectionOffsets(selectionOffsets); |
511 } | 515 } |
512 | 516 |
(...skipping 61 matching lines...) Loading... | |
574 TypingCommand::deleteSelection(*frame().document()); | 578 TypingCommand::deleteSelection(*frame().document()); |
575 } | 579 } |
576 | 580 |
577 DEFINE_TRACE(InputMethodController) | 581 DEFINE_TRACE(InputMethodController) |
578 { | 582 { |
579 visitor->trace(m_frame); | 583 visitor->trace(m_frame); |
580 visitor->trace(m_compositionRange); | 584 visitor->trace(m_compositionRange); |
581 } | 585 } |
582 | 586 |
583 } // namespace blink | 587 } // namespace blink |
OLD | NEW |