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 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
263 | 263 |
264 m_compositionNode = nullptr; | 264 m_compositionNode = nullptr; |
265 m_customCompositionUnderlines.clear(); | 265 m_customCompositionUnderlines.clear(); |
266 | 266 |
267 if (text.isEmpty()) | 267 if (text.isEmpty()) |
268 return; | 268 return; |
269 ASSERT(frame().document()); | 269 ASSERT(frame().document()); |
270 TypingCommand::insertText(*frame().document(), text, TypingCommand::SelectIn
sertedText | TypingCommand::PreventSpellChecking, TypingCommand::TextComposition
Update); | 270 TypingCommand::insertText(*frame().document(), text, TypingCommand::SelectIn
sertedText | TypingCommand::PreventSpellChecking, TypingCommand::TextComposition
Update); |
271 | 271 |
272 // Find out what node has the composition now. | 272 // Find out what node has the composition now. |
273 Position base = frame().selection().base().downstream(); | 273 Position base = mostForwardCaretPosition(frame().selection().base()); |
274 Node* baseNode = base.anchorNode(); | 274 Node* baseNode = base.anchorNode(); |
275 if (!baseNode || !baseNode->isTextNode()) | 275 if (!baseNode || !baseNode->isTextNode()) |
276 return; | 276 return; |
277 | 277 |
278 Position extent = frame().selection().extent(); | 278 Position extent = frame().selection().extent(); |
279 Node* extentNode = extent.anchorNode(); | 279 Node* extentNode = extent.anchorNode(); |
280 if (baseNode != extentNode) | 280 if (baseNode != extentNode) |
281 return; | 281 return; |
282 | 282 |
283 unsigned extentOffset = extent.computeOffsetInContainerNode(); | 283 unsigned extentOffset = extent.computeOffsetInContainerNode(); |
(...skipping 14 matching lines...) Expand all Loading... |
298 | 298 |
299 unsigned start = std::min(baseOffset + selectionStart, extentOffset); | 299 unsigned start = std::min(baseOffset + selectionStart, extentOffset); |
300 unsigned end = std::min(std::max(start, baseOffset + selectionEnd), extentOf
fset); | 300 unsigned end = std::min(std::max(start, baseOffset + selectionEnd), extentOf
fset); |
301 RefPtrWillBeRawPtr<Range> selectedRange = Range::create(baseNode->document()
, baseNode, start, baseNode, end); | 301 RefPtrWillBeRawPtr<Range> selectedRange = Range::create(baseNode->document()
, baseNode, start, baseNode, end); |
302 frame().selection().setSelectedRange(selectedRange.get(), TextAffinity::Down
stream, FrameSelection::NonDirectional, NotUserTriggered); | 302 frame().selection().setSelectedRange(selectedRange.get(), TextAffinity::Down
stream, FrameSelection::NonDirectional, NotUserTriggered); |
303 } | 303 } |
304 | 304 |
305 void InputMethodController::setCompositionFromExistingText(const Vector<Composit
ionUnderline>& underlines, unsigned compositionStart, unsigned compositionEnd) | 305 void InputMethodController::setCompositionFromExistingText(const Vector<Composit
ionUnderline>& underlines, unsigned compositionStart, unsigned compositionEnd) |
306 { | 306 { |
307 Element* editable = frame().selection().rootEditableElement(); | 307 Element* editable = frame().selection().rootEditableElement(); |
308 Position base = frame().selection().base().downstream(); | 308 Position base = mostForwardCaretPosition(frame().selection().base()); |
309 Node* baseNode = base.anchorNode(); | 309 Node* baseNode = base.anchorNode(); |
310 if (baseNode && editable->firstChild() == baseNode && editable->lastChild()
== baseNode && baseNode->isTextNode()) { | 310 if (baseNode && editable->firstChild() == baseNode && editable->lastChild()
== baseNode && baseNode->isTextNode()) { |
311 m_compositionNode = nullptr; | 311 m_compositionNode = nullptr; |
312 m_customCompositionUnderlines.clear(); | 312 m_customCompositionUnderlines.clear(); |
313 | 313 |
314 if (!base.isOffsetInAnchor()) | 314 if (!base.isOffsetInAnchor()) |
315 return; | 315 return; |
316 if (baseNode != frame().selection().extent().anchorNode()) | 316 if (baseNode != frame().selection().extent().anchorNode()) |
317 return; | 317 return; |
318 | 318 |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
422 TypingCommand::deleteSelection(*frame().document()); | 422 TypingCommand::deleteSelection(*frame().document()); |
423 } | 423 } |
424 | 424 |
425 DEFINE_TRACE(InputMethodController) | 425 DEFINE_TRACE(InputMethodController) |
426 { | 426 { |
427 visitor->trace(m_frame); | 427 visitor->trace(m_frame); |
428 visitor->trace(m_compositionNode); | 428 visitor->trace(m_compositionNode); |
429 } | 429 } |
430 | 430 |
431 } // namespace blink | 431 } // namespace blink |
OLD | NEW |