| 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 755 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 766 return target; | 766 return target; |
| 767 } | 767 } |
| 768 | 768 |
| 769 Element* Editor::findEventTargetFromSelection() const { | 769 Element* Editor::findEventTargetFromSelection() const { |
| 770 return findEventTargetFrom( | 770 return findEventTargetFrom( |
| 771 frame().selection().computeVisibleSelectionInDOMTreeDeprecated()); | 771 frame().selection().computeVisibleSelectionInDOMTreeDeprecated()); |
| 772 } | 772 } |
| 773 | 773 |
| 774 void Editor::applyStyle(StylePropertySet* style, | 774 void Editor::applyStyle(StylePropertySet* style, |
| 775 InputEvent::InputType inputType) { | 775 InputEvent::InputType inputType) { |
| 776 switch (frame().selection().getSelectionType()) { | 776 switch (frame() |
| 777 .selection() |
| 778 .computeVisibleSelectionInDOMTreeDeprecated() |
| 779 .getSelectionType()) { |
| 777 case NoSelection: | 780 case NoSelection: |
| 778 // do nothing | 781 // do nothing |
| 779 break; | 782 break; |
| 780 case CaretSelection: | 783 case CaretSelection: |
| 781 computeAndSetTypingStyle(style, inputType); | 784 computeAndSetTypingStyle(style, inputType); |
| 782 break; | 785 break; |
| 783 case RangeSelection: | 786 case RangeSelection: |
| 784 if (style) { | 787 if (style) { |
| 785 DCHECK(frame().document()); | 788 DCHECK(frame().document()); |
| 786 ApplyStyleCommand::create(*frame().document(), | 789 ApplyStyleCommand::create(*frame().document(), |
| (...skipping 634 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1421 // Some editing operations change the selection visually without affecting its | 1424 // Some editing operations change the selection visually without affecting its |
| 1422 // position within the DOM. For example when you press return in the following | 1425 // position within the DOM. For example when you press return in the following |
| 1423 // (the caret is marked by ^): | 1426 // (the caret is marked by ^): |
| 1424 // <div contentEditable="true"><div>^Hello</div></div> | 1427 // <div contentEditable="true"><div>^Hello</div></div> |
| 1425 // WebCore inserts <div><br></div> *before* the current block, which correctly | 1428 // WebCore inserts <div><br></div> *before* the current block, which correctly |
| 1426 // moves the paragraph down but which doesn't change the caret's DOM position | 1429 // moves the paragraph down but which doesn't change the caret's DOM position |
| 1427 // (["hello", 0]). In these situations the above FrameSelection::setSelection | 1430 // (["hello", 0]). In these situations the above FrameSelection::setSelection |
| 1428 // call does not call EditorClient::respondToChangedSelection(), which, on the | 1431 // call does not call EditorClient::respondToChangedSelection(), which, on the |
| 1429 // Mac, sends selection change notifications and starts a new kill ring | 1432 // Mac, sends selection change notifications and starts a new kill ring |
| 1430 // sequence, but we want to do these things (matches AppKit). | 1433 // sequence, but we want to do these things (matches AppKit). |
| 1431 if (selectionDidNotChangeDOMPosition) | 1434 if (selectionDidNotChangeDOMPosition) { |
| 1432 client().respondToChangedSelection(m_frame, | 1435 client().respondToChangedSelection( |
| 1433 frame().selection().getSelectionType()); | 1436 m_frame, |
| 1437 frame() |
| 1438 .selection() |
| 1439 .computeVisibleSelectionInDOMTreeDeprecated() |
| 1440 .getSelectionType()); |
| 1441 } |
| 1434 } | 1442 } |
| 1435 | 1443 |
| 1436 IntRect Editor::firstRectForRange(const EphemeralRange& range) const { | 1444 IntRect Editor::firstRectForRange(const EphemeralRange& range) const { |
| 1437 DCHECK(!frame().document()->needsLayoutTreeUpdate()); | 1445 DCHECK(!frame().document()->needsLayoutTreeUpdate()); |
| 1438 DocumentLifecycle::DisallowTransitionScope disallowTransition( | 1446 DocumentLifecycle::DisallowTransitionScope disallowTransition( |
| 1439 frame().document()->lifecycle()); | 1447 frame().document()->lifecycle()); |
| 1440 | 1448 |
| 1441 LayoutUnit extraWidthToEndOfLine; | 1449 LayoutUnit extraWidthToEndOfLine; |
| 1442 DCHECK(range.isNotNull()); | 1450 DCHECK(range.isNotNull()); |
| 1443 | 1451 |
| (...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1751 | 1759 |
| 1752 DEFINE_TRACE(Editor) { | 1760 DEFINE_TRACE(Editor) { |
| 1753 visitor->trace(m_frame); | 1761 visitor->trace(m_frame); |
| 1754 visitor->trace(m_lastEditCommand); | 1762 visitor->trace(m_lastEditCommand); |
| 1755 visitor->trace(m_undoStack); | 1763 visitor->trace(m_undoStack); |
| 1756 visitor->trace(m_mark); | 1764 visitor->trace(m_mark); |
| 1757 visitor->trace(m_typingStyle); | 1765 visitor->trace(m_typingStyle); |
| 1758 } | 1766 } |
| 1759 | 1767 |
| 1760 } // namespace blink | 1768 } // namespace blink |
| OLD | NEW |