| 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 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 295 if (baseNode && baseNode == extentNode && baseNode->isTextNode() && base
Offset + text.length() == extentOffset) { | 295 if (baseNode && baseNode == extentNode && baseNode->isTextNode() && base
Offset + text.length() == extentOffset) { |
| 296 m_compositionNode = toText(baseNode); | 296 m_compositionNode = toText(baseNode); |
| 297 m_compositionStart = baseOffset; | 297 m_compositionStart = baseOffset; |
| 298 m_compositionEnd = extentOffset; | 298 m_compositionEnd = extentOffset; |
| 299 m_customCompositionUnderlines = underlines; | 299 m_customCompositionUnderlines = underlines; |
| 300 size_t numUnderlines = m_customCompositionUnderlines.size(); | 300 size_t numUnderlines = m_customCompositionUnderlines.size(); |
| 301 for (size_t i = 0; i < numUnderlines; ++i) { | 301 for (size_t i = 0; i < numUnderlines; ++i) { |
| 302 m_customCompositionUnderlines[i].startOffset += baseOffset; | 302 m_customCompositionUnderlines[i].startOffset += baseOffset; |
| 303 m_customCompositionUnderlines[i].endOffset += baseOffset; | 303 m_customCompositionUnderlines[i].endOffset += baseOffset; |
| 304 } | 304 } |
| 305 |
| 306 // TODO(ojan): What was this for? Do we need it in sky since we |
| 307 // don't need to support legacy IMEs? |
| 305 if (baseNode->renderer()) | 308 if (baseNode->renderer()) |
| 306 baseNode->renderer()->setShouldDoFullPaintInvalidation(true); | 309 baseNode->renderer()->scheduleVisualUpdate(); |
| 307 | 310 |
| 308 unsigned start = std::min(baseOffset + selectionStart, extentOffset)
; | 311 unsigned start = std::min(baseOffset + selectionStart, extentOffset)
; |
| 309 unsigned end = std::min(std::max(start, baseOffset + selectionEnd),
extentOffset); | 312 unsigned end = std::min(std::max(start, baseOffset + selectionEnd),
extentOffset); |
| 310 RefPtr<Range> selectedRange = Range::create(baseNode->document(), ba
seNode, start, baseNode, end); | 313 RefPtr<Range> selectedRange = Range::create(baseNode->document(), ba
seNode, start, baseNode, end); |
| 311 m_frame.selection().setSelectedRange(selectedRange.get(), DOWNSTREAM
, FrameSelection::NonDirectional, NotUserTriggered); | 314 m_frame.selection().setSelectedRange(selectedRange.get(), DOWNSTREAM
, FrameSelection::NonDirectional, NotUserTriggered); |
| 312 } | 315 } |
| 313 } | 316 } |
| 314 } | 317 } |
| 315 | 318 |
| 316 void InputMethodController::setCompositionFromExistingText(const Vector<Composit
ionUnderline>& underlines, unsigned compositionStart, unsigned compositionEnd) | 319 void InputMethodController::setCompositionFromExistingText(const Vector<Composit
ionUnderline>& underlines, unsigned compositionStart, unsigned compositionEnd) |
| (...skipping 13 matching lines...) Expand all Loading... |
| 330 m_compositionNode = toText(baseNode); | 333 m_compositionNode = toText(baseNode); |
| 331 RefPtr<Range> range = PlainTextRange(compositionStart, compositionEnd).c
reateRange(*editable); | 334 RefPtr<Range> range = PlainTextRange(compositionStart, compositionEnd).c
reateRange(*editable); |
| 332 m_compositionStart = range->startOffset(); | 335 m_compositionStart = range->startOffset(); |
| 333 m_compositionEnd = range->endOffset(); | 336 m_compositionEnd = range->endOffset(); |
| 334 m_customCompositionUnderlines = underlines; | 337 m_customCompositionUnderlines = underlines; |
| 335 size_t numUnderlines = m_customCompositionUnderlines.size(); | 338 size_t numUnderlines = m_customCompositionUnderlines.size(); |
| 336 for (size_t i = 0; i < numUnderlines; ++i) { | 339 for (size_t i = 0; i < numUnderlines; ++i) { |
| 337 m_customCompositionUnderlines[i].startOffset += m_compositionStart; | 340 m_customCompositionUnderlines[i].startOffset += m_compositionStart; |
| 338 m_customCompositionUnderlines[i].endOffset += m_compositionStart; | 341 m_customCompositionUnderlines[i].endOffset += m_compositionStart; |
| 339 } | 342 } |
| 343 |
| 344 // TODO(ojan): What was this for? Do we need it in sky since we |
| 345 // don't need to support legacy IMEs? |
| 340 if (baseNode->renderer()) | 346 if (baseNode->renderer()) |
| 341 baseNode->renderer()->setShouldDoFullPaintInvalidation(true); | 347 baseNode->renderer()->scheduleVisualUpdate(); |
| 348 |
| 342 return; | 349 return; |
| 343 } | 350 } |
| 344 | 351 |
| 345 Editor::RevealSelectionScope revealSelectionScope(&editor()); | 352 Editor::RevealSelectionScope revealSelectionScope(&editor()); |
| 346 SelectionOffsetsScope selectionOffsetsScope(this); | 353 SelectionOffsetsScope selectionOffsetsScope(this); |
| 347 setSelectionOffsets(PlainTextRange(compositionStart, compositionEnd)); | 354 setSelectionOffsets(PlainTextRange(compositionStart, compositionEnd)); |
| 348 setComposition(m_frame.selectedText(), underlines, 0, 0); | 355 setComposition(m_frame.selectedText(), underlines, 0, 0); |
| 349 } | 356 } |
| 350 | 357 |
| 351 PassRefPtr<Range> InputMethodController::compositionRange() const | 358 PassRefPtr<Range> InputMethodController::compositionRange() const |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 416 if (!setSelectionOffsets(PlainTextRange(std::max(static_cast<int>(select
ionOffsets.start()) - before, 0), selectionOffsets.end() + after))) | 423 if (!setSelectionOffsets(PlainTextRange(std::max(static_cast<int>(select
ionOffsets.start()) - before, 0), selectionOffsets.end() + after))) |
| 417 return; | 424 return; |
| 418 if (before == 0) | 425 if (before == 0) |
| 419 break; | 426 break; |
| 420 ++before; | 427 ++before; |
| 421 } while (m_frame.selection().start() == m_frame.selection().end() && before
<= static_cast<int>(selectionOffsets.start())); | 428 } while (m_frame.selection().start() == m_frame.selection().end() && before
<= static_cast<int>(selectionOffsets.start())); |
| 422 TypingCommand::deleteSelection(*m_frame.document()); | 429 TypingCommand::deleteSelection(*m_frame.document()); |
| 423 } | 430 } |
| 424 | 431 |
| 425 } // namespace blink | 432 } // namespace blink |
| OLD | NEW |