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 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
303 for (size_t i = 0; i < numUnderlines; ++i) { | 303 for (size_t i = 0; i < numUnderlines; ++i) { |
304 m_customCompositionUnderlines[i].startOffset += baseOffset; | 304 m_customCompositionUnderlines[i].startOffset += baseOffset; |
305 m_customCompositionUnderlines[i].endOffset += baseOffset; | 305 m_customCompositionUnderlines[i].endOffset += baseOffset; |
306 } | 306 } |
307 if (baseNode->renderer()) | 307 if (baseNode->renderer()) |
308 baseNode->renderer()->paintInvalidationForWholeRenderer(); | 308 baseNode->renderer()->paintInvalidationForWholeRenderer(); |
309 | 309 |
310 unsigned start = std::min(baseOffset + selectionStart, extentOffset)
; | 310 unsigned start = std::min(baseOffset + selectionStart, extentOffset)
; |
311 unsigned end = std::min(std::max(start, baseOffset + selectionEnd),
extentOffset); | 311 unsigned end = std::min(std::max(start, baseOffset + selectionEnd),
extentOffset); |
312 RefPtrWillBeRawPtr<Range> selectedRange = Range::create(baseNode->do
cument(), baseNode, start, baseNode, end); | 312 RefPtrWillBeRawPtr<Range> selectedRange = Range::create(baseNode->do
cument(), baseNode, start, baseNode, end); |
313 m_frame.selection().setSelectedRange(selectedRange.get(), DOWNSTREAM
, false, NotUserTriggered); | 313 m_frame.selection().setSelectedRange(selectedRange.get(), DOWNSTREAM
, FrameSelection::NonDirectional, NotUserTriggered); |
314 } | 314 } |
315 } | 315 } |
316 } | 316 } |
317 | 317 |
318 void InputMethodController::setCompositionFromExistingText(const Vector<Composit
ionUnderline>& underlines, unsigned compositionStart, unsigned compositionEnd) | 318 void InputMethodController::setCompositionFromExistingText(const Vector<Composit
ionUnderline>& underlines, unsigned compositionStart, unsigned compositionEnd) |
319 { | 319 { |
320 Node* editable = m_frame.selection().rootEditableElement(); | 320 Node* editable = m_frame.selection().rootEditableElement(); |
321 Position base = m_frame.selection().base().downstream(); | 321 Position base = m_frame.selection().base().downstream(); |
322 Node* baseNode = base.anchorNode(); | 322 Node* baseNode = base.anchorNode(); |
323 if (editable->firstChild() == baseNode && editable->lastChild() == baseNode
&& baseNode->isTextNode()) { | 323 if (editable->firstChild() == baseNode && editable->lastChild() == baseNode
&& baseNode->isTextNode()) { |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
376 if (selectionOffsets.isNull()) | 376 if (selectionOffsets.isNull()) |
377 return false; | 377 return false; |
378 Element* rootEditableElement = m_frame.selection().rootEditableElement(); | 378 Element* rootEditableElement = m_frame.selection().rootEditableElement(); |
379 if (!rootEditableElement) | 379 if (!rootEditableElement) |
380 return false; | 380 return false; |
381 | 381 |
382 RefPtrWillBeRawPtr<Range> range = selectionOffsets.createRangeForInputMethod
(*rootEditableElement); | 382 RefPtrWillBeRawPtr<Range> range = selectionOffsets.createRangeForInputMethod
(*rootEditableElement); |
383 if (!range) | 383 if (!range) |
384 return false; | 384 return false; |
385 | 385 |
386 return m_frame.selection().setSelectedRange(range.get(), VP_DEFAULT_AFFINITY
, false, FrameSelection::CloseTyping); | 386 return m_frame.selection().setSelectedRange(range.get(), VP_DEFAULT_AFFINITY
, FrameSelection::NonDirectional, FrameSelection::CloseTyping); |
387 } | 387 } |
388 | 388 |
389 bool InputMethodController::setEditableSelectionOffsets(const PlainTextRange& se
lectionOffsets) | 389 bool InputMethodController::setEditableSelectionOffsets(const PlainTextRange& se
lectionOffsets) |
390 { | 390 { |
391 if (!editor().canEdit()) | 391 if (!editor().canEdit()) |
392 return false; | 392 return false; |
393 return setSelectionOffsets(selectionOffsets); | 393 return setSelectionOffsets(selectionOffsets); |
394 } | 394 } |
395 | 395 |
396 void InputMethodController::extendSelectionAndDelete(int before, int after) | 396 void InputMethodController::extendSelectionAndDelete(int before, int after) |
397 { | 397 { |
398 if (!editor().canEdit()) | 398 if (!editor().canEdit()) |
399 return; | 399 return; |
400 PlainTextRange selectionOffsets(getSelectionOffsets()); | 400 PlainTextRange selectionOffsets(getSelectionOffsets()); |
401 if (selectionOffsets.isNull()) | 401 if (selectionOffsets.isNull()) |
402 return; | 402 return; |
403 setSelectionOffsets(PlainTextRange(std::max(static_cast<int>(selectionOffset
s.start()) - before, 0), selectionOffsets.end() + after)); | 403 setSelectionOffsets(PlainTextRange(std::max(static_cast<int>(selectionOffset
s.start()) - before, 0), selectionOffsets.end() + after)); |
404 TypingCommand::deleteSelection(*m_frame.document()); | 404 TypingCommand::deleteSelection(*m_frame.document()); |
405 } | 405 } |
406 | 406 |
407 } // namespace WebCore | 407 } // namespace WebCore |
OLD | NEW |