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

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-18T18:31:02 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 1117 matching lines...) Expand 10 before | Expand all | Expand 10 after
1481 } 1481 }
1482 1482
1483 void showTree(const blink::FrameSelection* sel) { 1483 void showTree(const blink::FrameSelection* sel) {
1484 if (sel) 1484 if (sel)
1485 sel->showTreeForThis(); 1485 sel->showTreeForThis();
1486 else 1486 else
1487 LOG(INFO) << "Cannot showTree for <null> FrameSelection."; 1487 LOG(INFO) << "Cannot showTree for <null> FrameSelection.";
1488 } 1488 }
1489 1489
1490 #endif 1490 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698