Chromium Code Reviews| 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 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 224 if (!selection.isNone() && !m_compositionRange->collapsed()) { | 224 if (!selection.isNone() && !m_compositionRange->collapsed()) { |
| 225 if (selection.start().compareTo(m_compositionRange->startPosition()) >= 0 | 225 if (selection.start().compareTo(m_compositionRange->startPosition()) >= 0 |
| 226 && selection.end().compareTo(m_compositionRange->endPosition()) <= 0 ) | 226 && selection.end().compareTo(m_compositionRange->endPosition()) <= 0 ) |
| 227 return; | 227 return; |
| 228 } | 228 } |
| 229 | 229 |
| 230 cancelComposition(); | 230 cancelComposition(); |
| 231 frame().chromeClient().didCancelCompositionOnSelectionChange(); | 231 frame().chromeClient().didCancelCompositionOnSelectionChange(); |
| 232 } | 232 } |
| 233 | 233 |
| 234 void InputMethodController::setComposition(const String& text, const Vector<Comp ositionUnderline>& underlines, unsigned selectionStart, unsigned selectionEnd) | 234 void InputMethodController::setComposition(const String& text, const Vector<Comp ositionUnderline>& underlines, int selectionStart, int selectionEnd) |
| 235 { | 235 { |
| 236 Editor::RevealSelectionScope revealSelectionScope(&editor()); | 236 Editor::RevealSelectionScope revealSelectionScope(&editor()); |
| 237 | 237 |
| 238 // Updates styles before setting selection for composition to prevent | 238 // Updates styles before setting selection for composition to prevent |
| 239 // inserting the previous composition text into text nodes oddly. | 239 // inserting the previous composition text into text nodes oddly. |
| 240 // See https://bugs.webkit.org/show_bug.cgi?id=46868 | 240 // See https://bugs.webkit.org/show_bug.cgi?id=46868 |
| 241 frame().document()->updateLayoutTree(); | 241 frame().document()->updateLayoutTree(); |
| 242 | 242 |
| 243 selectComposition(); | 243 selectComposition(); |
| 244 | 244 |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 312 m_isDirty = true; | 312 m_isDirty = true; |
| 313 m_hasComposition = true; | 313 m_hasComposition = true; |
| 314 if (!m_compositionRange) | 314 if (!m_compositionRange) |
| 315 m_compositionRange = Range::create(baseNode->document()); | 315 m_compositionRange = Range::create(baseNode->document()); |
| 316 m_compositionRange->setStart(baseNode, baseOffset); | 316 m_compositionRange->setStart(baseNode, baseOffset); |
| 317 m_compositionRange->setEnd(baseNode, extentOffset); | 317 m_compositionRange->setEnd(baseNode, extentOffset); |
| 318 | 318 |
| 319 if (baseNode->layoutObject()) | 319 if (baseNode->layoutObject()) |
| 320 baseNode->layoutObject()->setShouldDoFullPaintInvalidation(); | 320 baseNode->layoutObject()->setShouldDoFullPaintInvalidation(); |
| 321 | 321 |
| 322 unsigned start = std::min(baseOffset + selectionStart, extentOffset); | 322 // The case when cursor position exceeds left boundary is handled here |
| 323 unsigned end = std::min(std::max(start, baseOffset + selectionEnd), extentOf fset); | 323 int start = std::max(static_cast<int>(baseOffset) + selectionStart, 0); |
|
Changwan Ryu
2016/04/04 06:23:13
Why do you remove the logic around extentOffset?
yabinh
2016/04/04 08:31:51
extendoffset = length(text before composing region
| |
| 324 RefPtrWillBeRawPtr<Range> selectedRange = Range::create(baseNode->document() , baseNode, start, baseNode, end); | 324 int end = std::max(static_cast<int>(baseOffset) + selectionEnd, start); |
| 325 frame().selection().setSelectedRange(selectedRange.get(), TextAffinity::Down stream, SelectionDirectionalMode::NonDirectional, NotUserTriggered); | 325 |
| 326 Element* rootEditableElement = frame().selection().rootEditableElement(); | |
| 327 if (!rootEditableElement) | |
| 328 return; | |
| 329 | |
| 330 // The case when cursor position exceeds right boundary is handled here | |
| 331 const EphemeralRange selectedRange = PlainTextRange(start, end).createRange( *rootEditableElement); | |
|
Changwan Ryu
2016/04/04 06:23:13
Why did you remove RefPtrWillberawPtr?
yabinh
2016/04/04 08:31:51
RefPtrWillberawPtr is only used to create selected
| |
| 332 | |
| 333 frame().selection().setSelectedRange(selectedRange, TextAffinity::Downstream , SelectionDirectionalMode::NonDirectional, NotUserTriggered); | |
| 326 | 334 |
| 327 if (underlines.isEmpty()) { | 335 if (underlines.isEmpty()) { |
| 328 frame().document()->markers().addCompositionMarker(m_compositionRange->s tartPosition(), m_compositionRange->endPosition(), Color::black, false, LayoutTh eme::theme().platformDefaultCompositionBackgroundColor()); | 336 frame().document()->markers().addCompositionMarker(m_compositionRange->s tartPosition(), m_compositionRange->endPosition(), Color::black, false, LayoutTh eme::theme().platformDefaultCompositionBackgroundColor()); |
| 329 return; | 337 return; |
| 330 } | 338 } |
| 331 for (const auto& underline : underlines) { | 339 for (const auto& underline : underlines) { |
| 332 unsigned underlineStart = baseOffset + underline.startOffset; | 340 unsigned underlineStart = baseOffset + underline.startOffset; |
| 333 unsigned underlineEnd = baseOffset + underline.endOffset; | 341 unsigned underlineEnd = baseOffset + underline.endOffset; |
| 334 EphemeralRange ephemeralLineRange = EphemeralRange(Position(baseNode, un derlineStart), Position(baseNode, underlineEnd)); | 342 EphemeralRange ephemeralLineRange = EphemeralRange(Position(baseNode, un derlineStart), Position(baseNode, underlineEnd)); |
| 335 if (ephemeralLineRange.isNull()) | 343 if (ephemeralLineRange.isNull()) |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 453 TypingCommand::deleteSelection(*frame().document()); | 461 TypingCommand::deleteSelection(*frame().document()); |
| 454 } | 462 } |
| 455 | 463 |
| 456 DEFINE_TRACE(InputMethodController) | 464 DEFINE_TRACE(InputMethodController) |
| 457 { | 465 { |
| 458 visitor->trace(m_frame); | 466 visitor->trace(m_frame); |
| 459 visitor->trace(m_compositionRange); | 467 visitor->trace(m_compositionRange); |
| 460 } | 468 } |
| 461 | 469 |
| 462 } // namespace blink | 470 } // namespace blink |
| OLD | NEW |