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

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

Issue 1049233003: Keep the selection of the text field when changed by JS. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 8 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 281 matching lines...) Expand 10 before | Expand all | Expand 10 after
292 if (m_frame->editor().behavior().shouldCenterAlignWhenSelectionIsReveale d()) 292 if (m_frame->editor().behavior().shouldCenterAlignWhenSelectionIsReveale d())
293 alignment = (align == AlignCursorOnScrollAlways) ? ScrollAlignment:: alignCenterAlways : ScrollAlignment::alignCenterIfNeeded; 293 alignment = (align == AlignCursorOnScrollAlways) ? ScrollAlignment:: alignCenterAlways : ScrollAlignment::alignCenterIfNeeded;
294 else 294 else
295 alignment = (align == AlignCursorOnScrollAlways) ? ScrollAlignment:: alignTopAlways : ScrollAlignment::alignToEdgeIfNeeded; 295 alignment = (align == AlignCursorOnScrollAlways) ? ScrollAlignment:: alignTopAlways : ScrollAlignment::alignToEdgeIfNeeded;
296 296
297 revealSelection(alignment, RevealExtent); 297 revealSelection(alignment, RevealExtent);
298 } 298 }
299 299
300 notifyAccessibilityForSelectionChange(); 300 notifyAccessibilityForSelectionChange();
301 notifyCompositorForSelectionChange(); 301 notifyCompositorForSelectionChange();
302 notifyEventHandlerForSelectionChange();
302 m_frame->localDOMWindow()->enqueueDocumentEvent(Event::create(EventTypeNames ::selectionchange)); 303 m_frame->localDOMWindow()->enqueueDocumentEvent(Event::create(EventTypeNames ::selectionchange));
303 } 304 }
304 305
305 static bool removingNodeRemovesPosition(Node& node, const Position& position) 306 static bool removingNodeRemovesPosition(Node& node, const Position& position)
306 { 307 {
307 if (!position.anchorNode()) 308 if (!position.anchorNode())
308 return false; 309 return false;
309 310
310 if (position.anchorNode() == node) 311 if (position.anchorNode() == node)
311 return true; 312 return true;
(...skipping 1141 matching lines...) Expand 10 before | Expand all | Expand 10 after
1453 } 1454 }
1454 1455
1455 void FrameSelection::notifyCompositorForSelectionChange() 1456 void FrameSelection::notifyCompositorForSelectionChange()
1456 { 1457 {
1457 if (!RuntimeEnabledFeatures::compositedSelectionUpdateEnabled()) 1458 if (!RuntimeEnabledFeatures::compositedSelectionUpdateEnabled())
1458 return; 1459 return;
1459 1460
1460 scheduleVisualUpdate(); 1461 scheduleVisualUpdate();
1461 } 1462 }
1462 1463
1464 void FrameSelection::notifyEventHandlerForSelectionChange()
1465 {
1466 m_frame->eventHandler().notifySelectionChanged();
1467 }
1468
1463 void FrameSelection::focusedOrActiveStateChanged() 1469 void FrameSelection::focusedOrActiveStateChanged()
1464 { 1470 {
1465 bool activeAndFocused = isFocusedAndActive(); 1471 bool activeAndFocused = isFocusedAndActive();
1466 1472
1467 RefPtrWillBeRawPtr<Document> document = m_frame->document(); 1473 RefPtrWillBeRawPtr<Document> document = m_frame->document();
1468 document->updateRenderTreeIfNeeded(); 1474 document->updateRenderTreeIfNeeded();
1469 1475
1470 // Because LayoutObject::selectionBackgroundColor() and 1476 // Because LayoutObject::selectionBackgroundColor() and
1471 // LayoutObject::selectionForegroundColor() check if the frame is active, 1477 // LayoutObject::selectionForegroundColor() check if the frame is active,
1472 // we have to update places those colors were painted. 1478 // we have to update places those colors were painted.
(...skipping 476 matching lines...) Expand 10 before | Expand all | Expand 10 after
1949 sel.showTreeForThis(); 1955 sel.showTreeForThis();
1950 } 1956 }
1951 1957
1952 void showTree(const blink::FrameSelection* sel) 1958 void showTree(const blink::FrameSelection* sel)
1953 { 1959 {
1954 if (sel) 1960 if (sel)
1955 sel->showTreeForThis(); 1961 sel->showTreeForThis();
1956 } 1962 }
1957 1963
1958 #endif 1964 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698