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

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, 5 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 | « Source/core/editing/FrameSelection.h ('k') | Source/core/editing/SelectionController.h » ('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) 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 23 matching lines...) Expand all
34 #include "core/dom/CharacterData.h" 34 #include "core/dom/CharacterData.h"
35 #include "core/dom/Document.h" 35 #include "core/dom/Document.h"
36 #include "core/dom/Element.h" 36 #include "core/dom/Element.h"
37 #include "core/dom/ElementTraversal.h" 37 #include "core/dom/ElementTraversal.h"
38 #include "core/dom/NodeTraversal.h" 38 #include "core/dom/NodeTraversal.h"
39 #include "core/dom/Text.h" 39 #include "core/dom/Text.h"
40 #include "core/editing/Editor.h" 40 #include "core/editing/Editor.h"
41 #include "core/editing/GranularityStrategy.h" 41 #include "core/editing/GranularityStrategy.h"
42 #include "core/editing/InputMethodController.h" 42 #include "core/editing/InputMethodController.h"
43 #include "core/editing/RenderedPosition.h" 43 #include "core/editing/RenderedPosition.h"
44 #include "core/editing/SelectionController.h"
44 #include "core/editing/SpellChecker.h" 45 #include "core/editing/SpellChecker.h"
45 #include "core/editing/TypingCommand.h" 46 #include "core/editing/TypingCommand.h"
46 #include "core/editing/VisibleUnits.h" 47 #include "core/editing/VisibleUnits.h"
47 #include "core/editing/htmlediting.h" 48 #include "core/editing/htmlediting.h"
48 #include "core/editing/iterators/TextIterator.h" 49 #include "core/editing/iterators/TextIterator.h"
49 #include "core/editing/markup.h" 50 #include "core/editing/markup.h"
50 #include "core/events/Event.h" 51 #include "core/events/Event.h"
51 #include "core/frame/FrameView.h" 52 #include "core/frame/FrameView.h"
52 #include "core/frame/LocalDOMWindow.h" 53 #include "core/frame/LocalDOMWindow.h"
53 #include "core/frame/LocalFrame.h" 54 #include "core/frame/LocalFrame.h"
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after
320 if (m_frame->editor().behavior().shouldCenterAlignWhenSelectionIsReveale d()) 321 if (m_frame->editor().behavior().shouldCenterAlignWhenSelectionIsReveale d())
321 alignment = (align == AlignCursorOnScrollAlways) ? ScrollAlignment:: alignCenterAlways : ScrollAlignment::alignCenterIfNeeded; 322 alignment = (align == AlignCursorOnScrollAlways) ? ScrollAlignment:: alignCenterAlways : ScrollAlignment::alignCenterIfNeeded;
322 else 323 else
323 alignment = (align == AlignCursorOnScrollAlways) ? ScrollAlignment:: alignTopAlways : ScrollAlignment::alignToEdgeIfNeeded; 324 alignment = (align == AlignCursorOnScrollAlways) ? ScrollAlignment:: alignTopAlways : ScrollAlignment::alignToEdgeIfNeeded;
324 325
325 revealSelection(alignment, RevealExtent); 326 revealSelection(alignment, RevealExtent);
326 } 327 }
327 328
328 notifyAccessibilityForSelectionChange(); 329 notifyAccessibilityForSelectionChange();
329 notifyCompositorForSelectionChange(); 330 notifyCompositorForSelectionChange();
331 notifyEventHandlerForSelectionChange();
330 m_frame->localDOMWindow()->enqueueDocumentEvent(Event::create(EventTypeNames ::selectionchange)); 332 m_frame->localDOMWindow()->enqueueDocumentEvent(Event::create(EventTypeNames ::selectionchange));
331 } 333 }
332 334
333 static bool removingNodeRemovesPosition(Node& node, const Position& position) 335 static bool removingNodeRemovesPosition(Node& node, const Position& position)
334 { 336 {
335 if (!position.anchorNode()) 337 if (!position.anchorNode())
336 return false; 338 return false;
337 339
338 if (position.anchorNode() == node) 340 if (position.anchorNode() == node)
339 return true; 341 return true;
(...skipping 1161 matching lines...) Expand 10 before | Expand all | Expand 10 after
1501 } 1503 }
1502 1504
1503 void FrameSelection::notifyCompositorForSelectionChange() 1505 void FrameSelection::notifyCompositorForSelectionChange()
1504 { 1506 {
1505 if (!RuntimeEnabledFeatures::compositedSelectionUpdateEnabled()) 1507 if (!RuntimeEnabledFeatures::compositedSelectionUpdateEnabled())
1506 return; 1508 return;
1507 1509
1508 scheduleVisualUpdate(); 1510 scheduleVisualUpdate();
1509 } 1511 }
1510 1512
1513 void FrameSelection::notifyEventHandlerForSelectionChange()
1514 {
1515 m_frame->eventHandler().selectionController().notifySelectionChanged();
1516 }
1517
1511 void FrameSelection::focusedOrActiveStateChanged() 1518 void FrameSelection::focusedOrActiveStateChanged()
1512 { 1519 {
1513 bool activeAndFocused = isFocusedAndActive(); 1520 bool activeAndFocused = isFocusedAndActive();
1514 1521
1515 RefPtrWillBeRawPtr<Document> document = m_frame->document(); 1522 RefPtrWillBeRawPtr<Document> document = m_frame->document();
1516 document->updateLayoutTreeIfNeeded(); 1523 document->updateLayoutTreeIfNeeded();
1517 1524
1518 // Because LayoutObject::selectionBackgroundColor() and 1525 // Because LayoutObject::selectionBackgroundColor() and
1519 // LayoutObject::selectionForegroundColor() check if the frame is active, 1526 // LayoutObject::selectionForegroundColor() check if the frame is active,
1520 // we have to update places those colors were painted. 1527 // we have to update places those colors were painted.
(...skipping 522 matching lines...) Expand 10 before | Expand all | Expand 10 after
2043 2050
2044 void showTree(const blink::FrameSelection* sel) 2051 void showTree(const blink::FrameSelection* sel)
2045 { 2052 {
2046 if (sel) 2053 if (sel)
2047 sel->showTreeForThis(); 2054 sel->showTreeForThis();
2048 else 2055 else
2049 fprintf(stderr, "Cannot showTree for (nil) FrameSelection.\n"); 2056 fprintf(stderr, "Cannot showTree for (nil) FrameSelection.\n");
2050 } 2057 }
2051 2058
2052 #endif 2059 #endif
OLDNEW
« no previous file with comments | « Source/core/editing/FrameSelection.h ('k') | Source/core/editing/SelectionController.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698