OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. | 2 * Copyright (C) 2005, 2006, 2007, 2008 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 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
295 | 295 |
296 if (!frame->spellChecker().isContinuousSpellCheckingEnabled()) | 296 if (!frame->spellChecker().isContinuousSpellCheckingEnabled()) |
297 return; | 297 return; |
298 | 298 |
299 frame->spellChecker().cancelCheck(); | 299 frame->spellChecker().cancelCheck(); |
300 | 300 |
301 // Take a look at the selection that results after typing and determine whet
her we need to spellcheck. | 301 // Take a look at the selection that results after typing and determine whet
her we need to spellcheck. |
302 // Since the word containing the current selection is never marked, this doe
s a check to | 302 // Since the word containing the current selection is never marked, this doe
s a check to |
303 // see if typing made a new word that is not in the current selection. Basic
ally, you | 303 // see if typing made a new word that is not in the current selection. Basic
ally, you |
304 // get this by being at the end of a word and typing a space. | 304 // get this by being at the end of a word and typing a space. |
305 VisiblePosition start(endingSelection().start(), endingSelection().affinity(
)); | 305 VisiblePosition start = createVisiblePosition(endingSelection().start(), end
ingSelection().affinity()); |
306 VisiblePosition previous = previousPositionOf(start); | 306 VisiblePosition previous = previousPositionOf(start); |
307 | 307 |
308 VisiblePosition p1 = startOfWord(previous, LeftWordIfOnBoundary); | 308 VisiblePosition p1 = startOfWord(previous, LeftWordIfOnBoundary); |
309 | 309 |
310 if (commandType == InsertParagraphSeparator) { | 310 if (commandType == InsertParagraphSeparator) { |
311 VisiblePosition p2 = nextWordPosition(start); | 311 VisiblePosition p2 = nextWordPosition(start); |
312 VisibleSelection words(p1, endOfWord(p2)); | 312 VisibleSelection words(p1, endOfWord(p2)); |
313 frame->spellChecker().markMisspellingsAfterLineBreak(words); | 313 frame->spellChecker().markMisspellingsAfterLineBreak(words); |
314 } else if (previous.isNotNull()) { | 314 } else if (previous.isNotNull()) { |
315 VisiblePosition p2 = startOfWord(start, LeftWordIfOnBoundary); | 315 VisiblePosition p2 = startOfWord(start, LeftWordIfOnBoundary); |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
446 } | 446 } |
447 // When there are no visible positions in the editing root, delete i
ts entire contents. | 447 // When there are no visible positions in the editing root, delete i
ts entire contents. |
448 if (nextPositionOf(visibleStart, CannotCrossEditingBoundary).isNull(
) && makeEditableRootEmpty()) { | 448 if (nextPositionOf(visibleStart, CannotCrossEditingBoundary).isNull(
) && makeEditableRootEmpty()) { |
449 typingAddedToOpenCommand(DeleteKey); | 449 typingAddedToOpenCommand(DeleteKey); |
450 return; | 450 return; |
451 } | 451 } |
452 } | 452 } |
453 | 453 |
454 // If we have a caret selection at the beginning of a cell, we have noth
ing to do. | 454 // If we have a caret selection at the beginning of a cell, we have noth
ing to do. |
455 Node* enclosingTableCell = enclosingNodeOfType(visibleStart.deepEquivale
nt(), &isTableCell); | 455 Node* enclosingTableCell = enclosingNodeOfType(visibleStart.deepEquivale
nt(), &isTableCell); |
456 if (enclosingTableCell && visibleStart.deepEquivalent() == VisiblePositi
on(firstPositionInNode(enclosingTableCell)).deepEquivalent()) | 456 if (enclosingTableCell && visibleStart.deepEquivalent() == createVisible
Position(firstPositionInNode(enclosingTableCell)).deepEquivalent()) |
457 return; | 457 return; |
458 | 458 |
459 // If the caret is at the start of a paragraph after a table, move conte
nt into the last table cell. | 459 // If the caret is at the start of a paragraph after a table, move conte
nt into the last table cell. |
460 if (isStartOfParagraph(visibleStart) && isFirstPositionAfterTable(previo
usPositionOf(visibleStart, CannotCrossEditingBoundary))) { | 460 if (isStartOfParagraph(visibleStart) && isFirstPositionAfterTable(previo
usPositionOf(visibleStart, CannotCrossEditingBoundary))) { |
461 // Unless the caret is just before a table. We don't want to move a
table into the last table cell. | 461 // Unless the caret is just before a table. We don't want to move a
table into the last table cell. |
462 if (isLastPositionBeforeTable(visibleStart)) | 462 if (isLastPositionBeforeTable(visibleStart)) |
463 return; | 463 return; |
464 // Extend the selection backward into the last cell, then deletion w
ill handle the move. | 464 // Extend the selection backward into the last cell, then deletion w
ill handle the move. |
465 selection->modify(FrameSelection::AlterationExtend, DirectionBackwar
d, granularity); | 465 selection->modify(FrameSelection::AlterationExtend, DirectionBackwar
d, granularity); |
466 // If the caret is just after a table, select the table and don't delete
anything. | 466 // If the caret is just after a table, select the table and don't delete
anything. |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
536 // root editable element or at the start of a document. | 536 // root editable element or at the start of a document. |
537 OwnPtrWillBeRawPtr<FrameSelection> selection = FrameSelection::create(); | 537 OwnPtrWillBeRawPtr<FrameSelection> selection = FrameSelection::create(); |
538 selection->setSelection(endingSelection()); | 538 selection->setSelection(endingSelection()); |
539 selection->modify(FrameSelection::AlterationExtend, DirectionForward, gr
anularity); | 539 selection->modify(FrameSelection::AlterationExtend, DirectionForward, gr
anularity); |
540 if (killRing && selection->isCaret() && granularity != CharacterGranular
ity) | 540 if (killRing && selection->isCaret() && granularity != CharacterGranular
ity) |
541 selection->modify(FrameSelection::AlterationExtend, DirectionForward
, CharacterGranularity); | 541 selection->modify(FrameSelection::AlterationExtend, DirectionForward
, CharacterGranularity); |
542 | 542 |
543 Position downstreamEnd = mostForwardCaretPosition(endingSelection().end(
)); | 543 Position downstreamEnd = mostForwardCaretPosition(endingSelection().end(
)); |
544 VisiblePosition visibleEnd = endingSelection().visibleEnd(); | 544 VisiblePosition visibleEnd = endingSelection().visibleEnd(); |
545 Node* enclosingTableCell = enclosingNodeOfType(visibleEnd.deepEquivalent
(), &isTableCell); | 545 Node* enclosingTableCell = enclosingNodeOfType(visibleEnd.deepEquivalent
(), &isTableCell); |
546 if (enclosingTableCell && visibleEnd.deepEquivalent() == VisiblePosition
(lastPositionInNode(enclosingTableCell)).deepEquivalent()) | 546 if (enclosingTableCell && visibleEnd.deepEquivalent() == createVisiblePo
sition(lastPositionInNode(enclosingTableCell)).deepEquivalent()) |
547 return; | 547 return; |
548 if (visibleEnd.deepEquivalent() == endOfParagraph(visibleEnd).deepEquiva
lent()) | 548 if (visibleEnd.deepEquivalent() == endOfParagraph(visibleEnd).deepEquiva
lent()) |
549 downstreamEnd = mostForwardCaretPosition(nextPositionOf(visibleEnd,
CannotCrossEditingBoundary).deepEquivalent()); | 549 downstreamEnd = mostForwardCaretPosition(nextPositionOf(visibleEnd,
CannotCrossEditingBoundary).deepEquivalent()); |
550 // When deleting tables: Select the table first, then perform the deleti
on | 550 // When deleting tables: Select the table first, then perform the deleti
on |
551 if (isRenderedTableElement(downstreamEnd.computeContainerNode()) && down
streamEnd.computeOffsetInContainerNode() <= caretMinOffset(downstreamEnd.compute
ContainerNode())) { | 551 if (isRenderedTableElement(downstreamEnd.computeContainerNode()) && down
streamEnd.computeOffsetInContainerNode() <= caretMinOffset(downstreamEnd.compute
ContainerNode())) { |
552 setEndingSelection(VisibleSelection(endingSelection().end(), positio
nAfterNode(downstreamEnd.computeContainerNode()), TextAffinity::Downstream, endi
ngSelection().isDirectional())); | 552 setEndingSelection(VisibleSelection(endingSelection().end(), positio
nAfterNode(downstreamEnd.computeContainerNode()), TextAffinity::Downstream, endi
ngSelection().isDirectional())); |
553 typingAddedToOpenCommand(ForwardDeleteKey); | 553 typingAddedToOpenCommand(ForwardDeleteKey); |
554 return; | 554 return; |
555 } | 555 } |
556 | 556 |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
626 ASSERT_NOT_REACHED(); | 626 ASSERT_NOT_REACHED(); |
627 m_preservesTypingStyle = false; | 627 m_preservesTypingStyle = false; |
628 } | 628 } |
629 | 629 |
630 bool TypingCommand::isTypingCommand() const | 630 bool TypingCommand::isTypingCommand() const |
631 { | 631 { |
632 return true; | 632 return true; |
633 } | 633 } |
634 | 634 |
635 } // namespace blink | 635 } // namespace blink |
OLD | NEW |