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 | 295 |
296 if (baseNode && baseNode == extentNode && baseNode->isTextNode() && base
Offset + text.length() == extentOffset) { | 296 if (baseNode && baseNode == extentNode && baseNode->isTextNode() && base
Offset + text.length() == extentOffset) { |
297 m_compositionNode = toText(baseNode); | 297 m_compositionNode = toText(baseNode); |
298 m_compositionStart = baseOffset; | 298 m_compositionStart = baseOffset; |
299 m_compositionEnd = extentOffset; | 299 m_compositionEnd = extentOffset; |
300 m_customCompositionUnderlines = underlines; | 300 m_customCompositionUnderlines = underlines; |
301 for (auto& underline : m_customCompositionUnderlines) { | 301 for (auto& underline : m_customCompositionUnderlines) { |
302 underline.startOffset += baseOffset; | 302 underline.startOffset += baseOffset; |
303 underline.endOffset += baseOffset; | 303 underline.endOffset += baseOffset; |
304 } | 304 } |
305 if (baseNode->renderer()) | 305 if (baseNode->layoutObject()) |
306 baseNode->renderer()->setShouldDoFullPaintInvalidation(); | 306 baseNode->layoutObject()->setShouldDoFullPaintInvalidation(); |
307 | 307 |
308 unsigned start = std::min(baseOffset + selectionStart, extentOffset)
; | 308 unsigned start = std::min(baseOffset + selectionStart, extentOffset)
; |
309 unsigned end = std::min(std::max(start, baseOffset + selectionEnd),
extentOffset); | 309 unsigned end = std::min(std::max(start, baseOffset + selectionEnd),
extentOffset); |
310 RefPtrWillBeRawPtr<Range> selectedRange = Range::create(baseNode->do
cument(), baseNode, start, baseNode, end); | 310 RefPtrWillBeRawPtr<Range> selectedRange = Range::create(baseNode->do
cument(), baseNode, start, baseNode, end); |
311 frame().selection().setSelectedRange(selectedRange.get(), DOWNSTREAM
, FrameSelection::NonDirectional, NotUserTriggered); | 311 frame().selection().setSelectedRange(selectedRange.get(), DOWNSTREAM
, FrameSelection::NonDirectional, NotUserTriggered); |
312 } | 312 } |
313 } | 313 } |
314 } | 314 } |
315 | 315 |
316 void InputMethodController::setCompositionFromExistingText(const Vector<Composit
ionUnderline>& underlines, unsigned compositionStart, unsigned compositionEnd) | 316 void InputMethodController::setCompositionFromExistingText(const Vector<Composit
ionUnderline>& underlines, unsigned compositionStart, unsigned compositionEnd) |
(...skipping 16 matching lines...) Expand all Loading... |
333 return; | 333 return; |
334 | 334 |
335 m_compositionStart = range->startOffset(); | 335 m_compositionStart = range->startOffset(); |
336 m_compositionEnd = range->endOffset(); | 336 m_compositionEnd = range->endOffset(); |
337 m_customCompositionUnderlines = underlines; | 337 m_customCompositionUnderlines = underlines; |
338 size_t numUnderlines = m_customCompositionUnderlines.size(); | 338 size_t numUnderlines = m_customCompositionUnderlines.size(); |
339 for (size_t i = 0; i < numUnderlines; ++i) { | 339 for (size_t i = 0; i < numUnderlines; ++i) { |
340 m_customCompositionUnderlines[i].startOffset += m_compositionStart; | 340 m_customCompositionUnderlines[i].startOffset += m_compositionStart; |
341 m_customCompositionUnderlines[i].endOffset += m_compositionStart; | 341 m_customCompositionUnderlines[i].endOffset += m_compositionStart; |
342 } | 342 } |
343 if (baseNode->renderer()) | 343 if (baseNode->layoutObject()) |
344 baseNode->renderer()->setShouldDoFullPaintInvalidation(); | 344 baseNode->layoutObject()->setShouldDoFullPaintInvalidation(); |
345 return; | 345 return; |
346 } | 346 } |
347 | 347 |
348 Editor::RevealSelectionScope revealSelectionScope(&editor()); | 348 Editor::RevealSelectionScope revealSelectionScope(&editor()); |
349 SelectionOffsetsScope selectionOffsetsScope(this); | 349 SelectionOffsetsScope selectionOffsetsScope(this); |
350 setSelectionOffsets(PlainTextRange(compositionStart, compositionEnd)); | 350 setSelectionOffsets(PlainTextRange(compositionStart, compositionEnd)); |
351 setComposition(frame().selectedText(), underlines, 0, 0); | 351 setComposition(frame().selectedText(), underlines, 0, 0); |
352 } | 352 } |
353 | 353 |
354 PassRefPtrWillBeRawPtr<Range> InputMethodController::compositionRange() const | 354 PassRefPtrWillBeRawPtr<Range> InputMethodController::compositionRange() const |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
425 TypingCommand::deleteSelection(*frame().document()); | 425 TypingCommand::deleteSelection(*frame().document()); |
426 } | 426 } |
427 | 427 |
428 DEFINE_TRACE(InputMethodController) | 428 DEFINE_TRACE(InputMethodController) |
429 { | 429 { |
430 visitor->trace(m_frame); | 430 visitor->trace(m_frame); |
431 visitor->trace(m_compositionNode); | 431 visitor->trace(m_compositionNode); |
432 } | 432 } |
433 | 433 |
434 } // namespace blink | 434 } // namespace blink |
OLD | NEW |