Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(73)

Side by Side Diff: Source/core/editing/InputMethodController.cpp

Issue 23848007: Fixing the bounds check in cancelCompositionIfSelectionIsInvalid. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Adding two more test cases Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | Source/web/tests/WebViewTest.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 void InputMethodController::cancelCompositionIfSelectionIsInvalid() 165 void InputMethodController::cancelCompositionIfSelectionIsInvalid()
166 { 166 {
167 if (!hasComposition() || editor().preventRevealSelection()) 167 if (!hasComposition() || editor().preventRevealSelection())
168 return; 168 return;
169 169
170 // Check if selection start and selection end are valid. 170 // Check if selection start and selection end are valid.
171 Position start = m_frame->selection().start(); 171 Position start = m_frame->selection().start();
172 Position end = m_frame->selection().end(); 172 Position end = m_frame->selection().end();
173 if (start.containerNode() == m_compositionNode 173 if (start.containerNode() == m_compositionNode
174 && end.containerNode() == m_compositionNode 174 && end.containerNode() == m_compositionNode
175 && static_cast<unsigned>(start.computeOffsetInContainerNode()) > m_compo sitionStart 175 && static_cast<unsigned>(start.computeOffsetInContainerNode()) >= m_comp ositionStart
176 && static_cast<unsigned>(end.computeOffsetInContainerNode()) < m_composi tionEnd) 176 && static_cast<unsigned>(end.computeOffsetInContainerNode()) <= m_compos itionEnd)
177 return; 177 return;
178 178
179 cancelComposition(); 179 cancelComposition();
180 editorClient().didCancelCompositionOnSelectionChange(); 180 editorClient().didCancelCompositionOnSelectionChange();
181 } 181 }
182 182
183 void InputMethodController::finishComposition(const String& text, FinishComposit ionMode mode) 183 void InputMethodController::finishComposition(const String& text, FinishComposit ionMode mode)
184 { 184 {
185 ASSERT(mode == ConfirmComposition || mode == CancelComposition); 185 ASSERT(mode == ConfirmComposition || mode == CancelComposition);
186 UserTypingGestureIndicator typingGestureIndicator(m_frame); 186 UserTypingGestureIndicator typingGestureIndicator(m_frame);
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
OLDNEW
« no previous file with comments | « no previous file | Source/web/tests/WebViewTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698