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