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

Side by Side Diff: third_party/WebKit/Source/core/editing/FrameSelection.cpp

Issue 2424383002: Make SpellChecker::respondToChangedSelection() to take Position instead of VisibleSelection (Closed)
Patch Set: 2016-10-19T12:54:03 Created 4 years, 2 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2004, 2008, 2009, 2010 Apple Inc. All rights reserved. 2 * Copyright (C) 2004, 2008, 2009, 2010 Apple Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after
297 if (m_selectionEditor->visibleSelection<Strategy>() == s) { 297 if (m_selectionEditor->visibleSelection<Strategy>() == s) {
298 // Even if selection was not changed, selection offsets may have been 298 // Even if selection was not changed, selection offsets may have been
299 // changed. 299 // changed.
300 m_frame->inputMethodController().cancelCompositionIfSelectionIsInvalid(); 300 m_frame->inputMethodController().cancelCompositionIfSelectionIsInvalid();
301 notifyLayoutObjectOfSelectionChange(userTriggered); 301 notifyLayoutObjectOfSelectionChange(userTriggered);
302 return; 302 return;
303 } 303 }
304 304
305 const VisibleSelectionTemplate<Strategy> oldSelection = 305 const VisibleSelectionTemplate<Strategy> oldSelection =
306 visibleSelection<Strategy>(); 306 visibleSelection<Strategy>();
307 const VisibleSelection oldSelectionInDOMTree = selection(); 307 const Position& oldSelectionStart = selection().start();
308 308
309 m_selectionEditor->setVisibleSelection(s, options); 309 m_selectionEditor->setVisibleSelection(s, options);
310 m_frameCaret->setCaretRectNeedsUpdate(); 310 m_frameCaret->setCaretRectNeedsUpdate();
311 311
312 if (!s.isNone() && !(options & DoNotSetFocus)) { 312 if (!s.isNone() && !(options & DoNotSetFocus)) {
313 setFocusedNodeIfNeeded(); 313 setFocusedNodeIfNeeded();
314 // |setFocusedNodeIfNeeded()| dispatches sync events "FocusOut" and 314 // |setFocusedNodeIfNeeded()| dispatches sync events "FocusOut" and
315 // "FocusIn", |m_frame| may associate to another document. 315 // "FocusIn", |m_frame| may associate to another document.
316 if (!isAvailable() || document() != currentDocument) { 316 if (!isAvailable() || document() != currentDocument) {
317 // Once we get test case to reach here, we should change this 317 // Once we get test case to reach here, we should change this
(...skipping 25 matching lines...) Expand all
343 notifyLayoutObjectOfSelectionChange(userTriggered); 343 notifyLayoutObjectOfSelectionChange(userTriggered);
344 // If the selections are same in the DOM tree but not in the flat tree, 344 // If the selections are same in the DOM tree but not in the flat tree,
345 // don't fire events. For example, if the selection crosses shadow tree 345 // don't fire events. For example, if the selection crosses shadow tree
346 // boundary, selection for the DOM tree is shrunk while that for the 346 // boundary, selection for the DOM tree is shrunk while that for the
347 // flat tree is not. Additionally, this case occurs in some edge cases. 347 // flat tree is not. Additionally, this case occurs in some edge cases.
348 // See also: editing/pasteboard/4076267-3.html 348 // See also: editing/pasteboard/4076267-3.html
349 if (oldSelection == m_selectionEditor->visibleSelection<Strategy>()) { 349 if (oldSelection == m_selectionEditor->visibleSelection<Strategy>()) {
350 m_frame->inputMethodController().cancelCompositionIfSelectionIsInvalid(); 350 m_frame->inputMethodController().cancelCompositionIfSelectionIsInvalid();
351 return; 351 return;
352 } 352 }
353 m_frame->editor().respondToChangedSelection(oldSelectionInDOMTree, options); 353 m_frame->editor().respondToChangedSelection(oldSelectionStart, options);
354 if (userTriggered == UserTriggered) { 354 if (userTriggered == UserTriggered) {
355 ScrollAlignment alignment; 355 ScrollAlignment alignment;
356 356
357 if (m_frame->editor().behavior().shouldCenterAlignWhenSelectionIsRevealed()) 357 if (m_frame->editor().behavior().shouldCenterAlignWhenSelectionIsRevealed())
358 alignment = (align == CursorAlignOnScroll::Always) 358 alignment = (align == CursorAlignOnScroll::Always)
359 ? ScrollAlignment::alignCenterAlways 359 ? ScrollAlignment::alignCenterAlways
360 : ScrollAlignment::alignCenterIfNeeded; 360 : ScrollAlignment::alignCenterIfNeeded;
361 else 361 else
362 alignment = (align == CursorAlignOnScroll::Always) 362 alignment = (align == CursorAlignOnScroll::Always)
363 ? ScrollAlignment::alignTopAlways 363 ? ScrollAlignment::alignTopAlways
(...skipping 1137 matching lines...) Expand 10 before | Expand all | Expand 10 after
1501 } 1501 }
1502 1502
1503 void showTree(const blink::FrameSelection* sel) { 1503 void showTree(const blink::FrameSelection* sel) {
1504 if (sel) 1504 if (sel)
1505 sel->showTreeForThis(); 1505 sel->showTreeForThis();
1506 else 1506 else
1507 LOG(INFO) << "Cannot showTree for <null> FrameSelection."; 1507 LOG(INFO) << "Cannot showTree for <null> FrameSelection.";
1508 } 1508 }
1509 1509
1510 #endif 1510 #endif
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/editing/Editor.cpp ('k') | third_party/WebKit/Source/core/editing/spellcheck/SpellChecker.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698