| 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 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 193 // the DOM Event specification. | 193 // the DOM Event specification. |
| 194 if (Element* target = m_frame.document()->focusedElement()) { | 194 if (Element* target = m_frame.document()->focusedElement()) { |
| 195 unsigned baseOffset = m_frame.selection().base().downstream().deprecated
EditingOffset(); | 195 unsigned baseOffset = m_frame.selection().base().downstream().deprecated
EditingOffset(); |
| 196 Vector<CompositionUnderline> underlines; | 196 Vector<CompositionUnderline> underlines; |
| 197 for (size_t i = 0; i < m_customCompositionUnderlines.size(); ++i) { | 197 for (size_t i = 0; i < m_customCompositionUnderlines.size(); ++i) { |
| 198 CompositionUnderline underline = m_customCompositionUnderlines[i]; | 198 CompositionUnderline underline = m_customCompositionUnderlines[i]; |
| 199 underline.startOffset -= baseOffset; | 199 underline.startOffset -= baseOffset; |
| 200 underline.endOffset -= baseOffset; | 200 underline.endOffset -= baseOffset; |
| 201 underlines.append(underline); | 201 underlines.append(underline); |
| 202 } | 202 } |
| 203 RefPtr<CompositionEvent> event = CompositionEvent::create(EventTypeNames
::compositionend, m_frame.domWindow(), text, underlines); | 203 RefPtrWillBeRawPtr<CompositionEvent> event = CompositionEvent::create(Ev
entTypeNames::compositionend, m_frame.domWindow(), text, underlines); |
| 204 target->dispatchEvent(event, IGNORE_EXCEPTION); | 204 target->dispatchEvent(event, IGNORE_EXCEPTION); |
| 205 } | 205 } |
| 206 | 206 |
| 207 // If text is empty, then delete the old composition here. If text is non-em
pty, InsertTextCommand::input | 207 // If text is empty, then delete the old composition here. If text is non-em
pty, InsertTextCommand::input |
| 208 // will delete the old composition with an optimized replace operation. | 208 // will delete the old composition with an optimized replace operation. |
| 209 if (text.isEmpty() && mode != CancelComposition) { | 209 if (text.isEmpty() && mode != CancelComposition) { |
| 210 ASSERT(m_frame.document()); | 210 ASSERT(m_frame.document()); |
| 211 TypingCommand::deleteSelection(*m_frame.document(), 0); | 211 TypingCommand::deleteSelection(*m_frame.document(), 0); |
| 212 } | 212 } |
| 213 | 213 |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 247 // a new composition node, i.e. | 247 // a new composition node, i.e. |
| 248 // m_compositionNode == 0 && !text.isEmpty(). | 248 // m_compositionNode == 0 && !text.isEmpty(). |
| 249 // Sending a compositionupdate event at this time ensures that at lea
st one | 249 // Sending a compositionupdate event at this time ensures that at lea
st one |
| 250 // compositionupdate event is dispatched. | 250 // compositionupdate event is dispatched. |
| 251 // 2. Updating the existing composition node. | 251 // 2. Updating the existing composition node. |
| 252 // Send a compositionupdate event when this function updates the exis
ting composition | 252 // Send a compositionupdate event when this function updates the exis
ting composition |
| 253 // node, i.e. m_compositionNode != 0 && !text.isEmpty(). | 253 // node, i.e. m_compositionNode != 0 && !text.isEmpty(). |
| 254 // 3. Canceling the ongoing composition. | 254 // 3. Canceling the ongoing composition. |
| 255 // Send a compositionend event when function deletes the existing com
position node, i.e. | 255 // Send a compositionend event when function deletes the existing com
position node, i.e. |
| 256 // m_compositionNode != 0 && test.isEmpty(). | 256 // m_compositionNode != 0 && test.isEmpty(). |
| 257 RefPtr<CompositionEvent> event; | 257 RefPtrWillBeRawPtr<CompositionEvent> event = nullptr; |
| 258 if (!hasComposition()) { | 258 if (!hasComposition()) { |
| 259 // We should send a compositionstart event only when the given text
is not empty because this | 259 // We should send a compositionstart event only when the given text
is not empty because this |
| 260 // function doesn't create a composition node when the text is empty
. | 260 // function doesn't create a composition node when the text is empty
. |
| 261 if (!text.isEmpty()) { | 261 if (!text.isEmpty()) { |
| 262 target->dispatchEvent(CompositionEvent::create(EventTypeNames::c
ompositionstart, m_frame.domWindow(), m_frame.selectedText(), underlines)); | 262 target->dispatchEvent(CompositionEvent::create(EventTypeNames::c
ompositionstart, m_frame.domWindow(), m_frame.selectedText(), underlines)); |
| 263 event = CompositionEvent::create(EventTypeNames::compositionupda
te, m_frame.domWindow(), text, underlines); | 263 event = CompositionEvent::create(EventTypeNames::compositionupda
te, m_frame.domWindow(), text, underlines); |
| 264 } | 264 } |
| 265 } else { | 265 } else { |
| 266 if (!text.isEmpty()) | 266 if (!text.isEmpty()) |
| 267 event = CompositionEvent::create(EventTypeNames::compositionupda
te, m_frame.domWindow(), text, underlines); | 267 event = CompositionEvent::create(EventTypeNames::compositionupda
te, m_frame.domWindow(), text, underlines); |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 |