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 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
301 size_t numUnderlines = m_customCompositionUnderlines.size(); | 301 size_t numUnderlines = m_customCompositionUnderlines.size(); |
302 for (size_t i = 0; i < numUnderlines; ++i) { | 302 for (size_t i = 0; i < numUnderlines; ++i) { |
303 m_customCompositionUnderlines[i].startOffset += baseOffset; | 303 m_customCompositionUnderlines[i].startOffset += baseOffset; |
304 m_customCompositionUnderlines[i].endOffset += baseOffset; | 304 m_customCompositionUnderlines[i].endOffset += baseOffset; |
305 } | 305 } |
306 if (baseNode->renderer()) | 306 if (baseNode->renderer()) |
307 baseNode->renderer()->repaint(); | 307 baseNode->renderer()->repaint(); |
308 | 308 |
309 unsigned start = std::min(baseOffset + selectionStart, extentOffset)
; | 309 unsigned start = std::min(baseOffset + selectionStart, extentOffset)
; |
310 unsigned end = std::min(std::max(start, baseOffset + selectionEnd),
extentOffset); | 310 unsigned end = std::min(std::max(start, baseOffset + selectionEnd),
extentOffset); |
311 RefPtr<Range> selectedRange = Range::create(&baseNode->document(), b
aseNode, start, baseNode, end); | 311 RefPtr<Range> selectedRange = Range::create(baseNode->document(), ba
seNode, start, baseNode, end); |
312 m_frame->selection().setSelectedRange(selectedRange.get(), DOWNSTREA
M, false); | 312 m_frame->selection().setSelectedRange(selectedRange.get(), DOWNSTREA
M, false); |
313 } | 313 } |
314 } | 314 } |
315 } | 315 } |
316 | 316 |
317 void InputMethodController::setCompositionFromExistingText(const Vector<Composit
ionUnderline>& underlines, unsigned compositionStart, unsigned compositionEnd) | 317 void InputMethodController::setCompositionFromExistingText(const Vector<Composit
ionUnderline>& underlines, unsigned compositionStart, unsigned compositionEnd) |
318 { | 318 { |
319 Node* editable = m_frame->selection().rootEditableElement(); | 319 Node* editable = m_frame->selection().rootEditableElement(); |
320 Position base = m_frame->selection().base().downstream(); | 320 Position base = m_frame->selection().base().downstream(); |
321 Node* baseNode = base.anchorNode(); | 321 Node* baseNode = base.anchorNode(); |
(...skipping 28 matching lines...) Expand all Loading... |
350 | 350 |
351 PassRefPtr<Range> InputMethodController::compositionRange() const | 351 PassRefPtr<Range> InputMethodController::compositionRange() const |
352 { | 352 { |
353 if (!m_compositionNode) | 353 if (!m_compositionNode) |
354 return 0; | 354 return 0; |
355 unsigned length = m_compositionNode->length(); | 355 unsigned length = m_compositionNode->length(); |
356 unsigned start = std::min(m_compositionStart, length); | 356 unsigned start = std::min(m_compositionStart, length); |
357 unsigned end = std::min(std::max(start, m_compositionEnd), length); | 357 unsigned end = std::min(std::max(start, m_compositionEnd), length); |
358 if (start >= end) | 358 if (start >= end) |
359 return 0; | 359 return 0; |
360 return Range::create(&m_compositionNode->document(), m_compositionNode.get()
, start, m_compositionNode.get(), end); | 360 return Range::create(m_compositionNode->document(), m_compositionNode.get(),
start, m_compositionNode.get(), end); |
361 } | 361 } |
362 | 362 |
363 PlainTextOffsets InputMethodController::getSelectionOffsets() const | 363 PlainTextOffsets InputMethodController::getSelectionOffsets() const |
364 { | 364 { |
365 RefPtr<Range> range = m_frame->selection().selection().firstRange(); | 365 RefPtr<Range> range = m_frame->selection().selection().firstRange(); |
366 if (!range) | 366 if (!range) |
367 return PlainTextOffsets(); | 367 return PlainTextOffsets(); |
368 size_t location; | 368 size_t location; |
369 size_t length; | 369 size_t length; |
370 // FIXME: We should change TextIterator::getLocationAndLengthFromRange() ret
urns PlainTextOffsets. | 370 // FIXME: We should change TextIterator::getLocationAndLengthFromRange() ret
urns PlainTextOffsets. |
371 if (TextIterator::getLocationAndLengthFromRange(m_frame->selection().rootEdi
tableElementOrTreeScopeRootNode(), range.get(), location, length)) | 371 if (TextIterator::getLocationAndLengthFromRange(m_frame->selection().rootEdi
tableElementOrTreeScopeRootNode(), range.get(), location, length)) |
372 return PlainTextOffsets(location, location + length); | 372 return PlainTextOffsets(location, location + length); |
373 return PlainTextOffsets(); | 373 return PlainTextOffsets(); |
374 } | 374 } |
375 | 375 |
376 bool InputMethodController::setSelectionOffsets(const PlainTextOffsets& selectio
nOffsets) | 376 bool InputMethodController::setSelectionOffsets(const PlainTextOffsets& selectio
nOffsets) |
377 { | 377 { |
378 if (selectionOffsets.isNull()) | 378 if (selectionOffsets.isNull()) |
379 return false; | 379 return false; |
380 // FIXME: We should move Editor::setSelectionOffsets() into InputMethodContr
oller class. | 380 // FIXME: We should move Editor::setSelectionOffsets() into InputMethodContr
oller class. |
381 return editor().setSelectionOffsets(selectionOffsets.start(), selectionOffse
ts.end()); | 381 return editor().setSelectionOffsets(selectionOffsets.start(), selectionOffse
ts.end()); |
382 } | 382 } |
383 | 383 |
384 } // namespace WebCore | 384 } // namespace WebCore |
OLD | NEW |