| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2006, 2007, 2008, 2011 Apple Inc. All rights reserved. | 2 * Copyright (C) 2006, 2007, 2008, 2011 Apple Inc. All rights reserved. |
| 3 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) | 3 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) |
| 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 537 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 548 bool Editor::shouldDeleteRange(const EphemeralRange& range) const | 548 bool Editor::shouldDeleteRange(const EphemeralRange& range) const |
| 549 { | 549 { |
| 550 if (range.isCollapsed()) | 550 if (range.isCollapsed()) |
| 551 return false; | 551 return false; |
| 552 | 552 |
| 553 return canDeleteRange(range); | 553 return canDeleteRange(range); |
| 554 } | 554 } |
| 555 | 555 |
| 556 void Editor::notifyComponentsOnChangedSelection(const VisibleSelection& oldSelec
tion, FrameSelection::SetSelectionOptions options) | 556 void Editor::notifyComponentsOnChangedSelection(const VisibleSelection& oldSelec
tion, FrameSelection::SetSelectionOptions options) |
| 557 { | 557 { |
| 558 client().respondToChangedSelection(m_frame, frame().selection().selectionTyp
e()); | 558 client().respondToChangedSelection(m_frame, frame().selection().getSelection
Type()); |
| 559 setStartNewKillRingSequence(true); | 559 setStartNewKillRingSequence(true); |
| 560 } | 560 } |
| 561 | 561 |
| 562 void Editor::respondToChangedContents(const VisibleSelection& endingSelection) | 562 void Editor::respondToChangedContents(const VisibleSelection& endingSelection) |
| 563 { | 563 { |
| 564 if (frame().settings() && frame().settings()->accessibilityEnabled()) { | 564 if (frame().settings() && frame().settings()->accessibilityEnabled()) { |
| 565 Node* node = endingSelection.start().anchorNode(); | 565 Node* node = endingSelection.start().anchorNode(); |
| 566 if (AXObjectCache* cache = frame().document()->existingAXObjectCache()) | 566 if (AXObjectCache* cache = frame().document()->existingAXObjectCache()) |
| 567 cache->handleEditableTextContentChanged(node); | 567 cache->handleEditableTextContentChanged(node); |
| 568 } | 568 } |
| (...skipping 22 matching lines...) Expand all Loading... |
| 591 return target; | 591 return target; |
| 592 } | 592 } |
| 593 | 593 |
| 594 Element* Editor::findEventTargetFromSelection() const | 594 Element* Editor::findEventTargetFromSelection() const |
| 595 { | 595 { |
| 596 return findEventTargetFrom(frame().selection().selection()); | 596 return findEventTargetFrom(frame().selection().selection()); |
| 597 } | 597 } |
| 598 | 598 |
| 599 void Editor::applyStyle(StylePropertySet* style, EditAction editingAction) | 599 void Editor::applyStyle(StylePropertySet* style, EditAction editingAction) |
| 600 { | 600 { |
| 601 switch (frame().selection().selectionType()) { | 601 switch (frame().selection().getSelectionType()) { |
| 602 case NoSelection: | 602 case NoSelection: |
| 603 // do nothing | 603 // do nothing |
| 604 break; | 604 break; |
| 605 case CaretSelection: | 605 case CaretSelection: |
| 606 computeAndSetTypingStyle(style, editingAction); | 606 computeAndSetTypingStyle(style, editingAction); |
| 607 break; | 607 break; |
| 608 case RangeSelection: | 608 case RangeSelection: |
| 609 if (style) { | 609 if (style) { |
| 610 ASSERT(frame().document()); | 610 ASSERT(frame().document()); |
| 611 ApplyStyleCommand::create(*frame().document(), EditingStyle::create(
style).get(), editingAction)->apply(); | 611 ApplyStyleCommand::create(*frame().document(), EditingStyle::create(
style).get(), editingAction)->apply(); |
| (...skipping 499 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1111 frame().selection().setSelection(newSelection, options); | 1111 frame().selection().setSelection(newSelection, options); |
| 1112 | 1112 |
| 1113 // Some editing operations change the selection visually without affecting i
ts position within the DOM. | 1113 // Some editing operations change the selection visually without affecting i
ts position within the DOM. |
| 1114 // For example when you press return in the following (the caret is marked b
y ^): | 1114 // For example when you press return in the following (the caret is marked b
y ^): |
| 1115 // <div contentEditable="true"><div>^Hello</div></div> | 1115 // <div contentEditable="true"><div>^Hello</div></div> |
| 1116 // WebCore inserts <div><br></div> *before* the current block, which correct
ly moves the paragraph down but which doesn't | 1116 // WebCore inserts <div><br></div> *before* the current block, which correct
ly moves the paragraph down but which doesn't |
| 1117 // change the caret's DOM position (["hello", 0]). In these situations the a
bove FrameSelection::setSelection call | 1117 // change the caret's DOM position (["hello", 0]). In these situations the a
bove FrameSelection::setSelection call |
| 1118 // does not call EditorClient::respondToChangedSelection(), which, on the Ma
c, sends selection change notifications and | 1118 // does not call EditorClient::respondToChangedSelection(), which, on the Ma
c, sends selection change notifications and |
| 1119 // starts a new kill ring sequence, but we want to do these things (matches
AppKit). | 1119 // starts a new kill ring sequence, but we want to do these things (matches
AppKit). |
| 1120 if (selectionDidNotChangeDOMPosition) | 1120 if (selectionDidNotChangeDOMPosition) |
| 1121 client().respondToChangedSelection(m_frame, frame().selection().selectio
nType()); | 1121 client().respondToChangedSelection(m_frame, frame().selection().getSelec
tionType()); |
| 1122 } | 1122 } |
| 1123 | 1123 |
| 1124 IntRect Editor::firstRectForRange(const EphemeralRange& range) const | 1124 IntRect Editor::firstRectForRange(const EphemeralRange& range) const |
| 1125 { | 1125 { |
| 1126 LayoutUnit extraWidthToEndOfLine; | 1126 LayoutUnit extraWidthToEndOfLine; |
| 1127 ASSERT(range.isNotNull()); | 1127 ASSERT(range.isNotNull()); |
| 1128 | 1128 |
| 1129 IntRect startCaretRect = RenderedPosition(createVisiblePosition(range.startP
osition()).deepEquivalent(), TextAffinity::Downstream).absoluteRect(&extraWidthT
oEndOfLine); | 1129 IntRect startCaretRect = RenderedPosition(createVisiblePosition(range.startP
osition()).deepEquivalent(), TextAffinity::Downstream).absoluteRect(&extraWidthT
oEndOfLine); |
| 1130 if (startCaretRect.isEmpty()) | 1130 if (startCaretRect.isEmpty()) |
| 1131 return IntRect(); | 1131 return IntRect(); |
| (...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1377 } | 1377 } |
| 1378 | 1378 |
| 1379 DEFINE_TRACE(Editor) | 1379 DEFINE_TRACE(Editor) |
| 1380 { | 1380 { |
| 1381 visitor->trace(m_frame); | 1381 visitor->trace(m_frame); |
| 1382 visitor->trace(m_lastEditCommand); | 1382 visitor->trace(m_lastEditCommand); |
| 1383 visitor->trace(m_mark); | 1383 visitor->trace(m_mark); |
| 1384 } | 1384 } |
| 1385 | 1385 |
| 1386 } // namespace blink | 1386 } // namespace blink |
| OLD | NEW |