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

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

Issue 1620653002: Pass Only the Pasted Text to Spellchecker (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 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) 2005, 2006, 2008 Apple Inc. All rights reserved. 2 * Copyright (C) 2005, 2006, 2008 Apple Inc. All rights reserved.
3 * Copyright (C) 2009, 2010, 2011 Google Inc. All rights reserved. 3 * Copyright (C) 2009, 2010, 2011 Google Inc. All rights reserved.
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 1362 matching lines...) Expand 10 before | Expand all | Expand 10 after
1373 if (lastPositionToSelect.isNotNull()) 1373 if (lastPositionToSelect.isNotNull())
1374 end = lastPositionToSelect; 1374 end = lastPositionToSelect;
1375 1375
1376 mergeTextNodesAroundPosition(start, end); 1376 mergeTextNodesAroundPosition(start, end);
1377 } else if (lastPositionToSelect.isNotNull()) { 1377 } else if (lastPositionToSelect.isNotNull()) {
1378 start = end = lastPositionToSelect; 1378 start = end = lastPositionToSelect;
1379 } else { 1379 } else {
1380 return; 1380 return;
1381 } 1381 }
1382 1382
1383 m_startOfInsertedRange = start;
1384 m_endOfInsertedRange = end;
1385
1383 if (m_selectReplacement) 1386 if (m_selectReplacement)
1384 setEndingSelection(VisibleSelection(start, end, SEL_DEFAULT_AFFINITY, en dingSelection().isDirectional())); 1387 setEndingSelection(VisibleSelection(start, end, SEL_DEFAULT_AFFINITY, en dingSelection().isDirectional()));
1385 else 1388 else
1386 setEndingSelection(VisibleSelection(end, SEL_DEFAULT_AFFINITY, endingSel ection().isDirectional())); 1389 setEndingSelection(VisibleSelection(end, SEL_DEFAULT_AFFINITY, endingSel ection().isDirectional()));
1387 } 1390 }
1388 1391
1389 void ReplaceSelectionCommand::mergeTextNodesAroundPosition(Position& position, P osition& positionOnlyToBeUpdated) 1392 void ReplaceSelectionCommand::mergeTextNodesAroundPosition(Position& position, P osition& positionOnlyToBeUpdated)
1390 { 1393 {
1391 bool positionIsOffsetInAnchor = position.isOffsetInAnchor(); 1394 bool positionIsOffsetInAnchor = position.isOffsetInAnchor();
1392 bool positionOnlyToBeUpdatedIsOffsetInAnchor = positionOnlyToBeUpdated.isOff setInAnchor(); 1395 bool positionOnlyToBeUpdatedIsOffsetInAnchor = positionOnlyToBeUpdated.isOff setInAnchor();
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
1525 1528
1526 Position start = endingSelection().start(); 1529 Position start = endingSelection().start();
1527 Position end = replaceSelectedTextInNode(textNode->data()); 1530 Position end = replaceSelectedTextInNode(textNode->data());
1528 if (end.isNull()) 1531 if (end.isNull())
1529 return false; 1532 return false;
1530 1533
1531 if (nodeAfterInsertionPos && nodeAfterInsertionPos->parentNode() && isHTMLBR Element(*nodeAfterInsertionPos) 1534 if (nodeAfterInsertionPos && nodeAfterInsertionPos->parentNode() && isHTMLBR Element(*nodeAfterInsertionPos)
1532 && shouldRemoveEndBR(toHTMLBRElement(nodeAfterInsertionPos.get()), creat eVisiblePosition(positionBeforeNode(nodeAfterInsertionPos.get())))) 1535 && shouldRemoveEndBR(toHTMLBRElement(nodeAfterInsertionPos.get()), creat eVisiblePosition(positionBeforeNode(nodeAfterInsertionPos.get()))))
1533 removeNodeAndPruneAncestors(nodeAfterInsertionPos.get()); 1536 removeNodeAndPruneAncestors(nodeAfterInsertionPos.get());
1534 1537
1538 m_startOfInsertedRange = start;
1539 m_endOfInsertedRange = end;
1540
1535 VisibleSelection selectionAfterReplace(m_selectReplacement ? start : end, en d); 1541 VisibleSelection selectionAfterReplace(m_selectReplacement ? start : end, en d);
1536 1542
1537 setEndingSelection(selectionAfterReplace); 1543 setEndingSelection(selectionAfterReplace);
1538 1544
1539 return true; 1545 return true;
1540 } 1546 }
1541 1547
1542 bool ReplaceSelectionCommand::isReplaceSelectionCommand() const 1548 bool ReplaceSelectionCommand::isReplaceSelectionCommand() const
1543 { 1549 {
1544 return true; 1550 return true;
1545 } 1551 }
1546 1552
1553 EphemeralRange ReplaceSelectionCommand::insertedRange() const
1554 {
1555 return EphemeralRange(m_startOfInsertedRange, m_endOfInsertedRange);
1556 }
1557
1547 DEFINE_TRACE(ReplaceSelectionCommand) 1558 DEFINE_TRACE(ReplaceSelectionCommand)
1548 { 1559 {
1549 visitor->trace(m_startOfInsertedContent); 1560 visitor->trace(m_startOfInsertedContent);
1550 visitor->trace(m_endOfInsertedContent); 1561 visitor->trace(m_endOfInsertedContent);
1551 visitor->trace(m_insertionStyle); 1562 visitor->trace(m_insertionStyle);
1552 visitor->trace(m_documentFragment); 1563 visitor->trace(m_documentFragment);
1564 visitor->trace(m_startOfInsertedRange);
1565 visitor->trace(m_endOfInsertedRange);
1553 CompositeEditCommand::trace(visitor); 1566 CompositeEditCommand::trace(visitor);
1554 } 1567 }
1555 1568
1556 } // namespace blink 1569 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698