| 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 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 275 { | 275 { |
| 276 return canEdit(); | 276 return canEdit(); |
| 277 } | 277 } |
| 278 | 278 |
| 279 bool Editor::canDelete() const | 279 bool Editor::canDelete() const |
| 280 { | 280 { |
| 281 FrameSelection& selection = frame().selection(); | 281 FrameSelection& selection = frame().selection(); |
| 282 return selection.isRange() && selection.rootEditableElement(); | 282 return selection.isRange() && selection.rootEditableElement(); |
| 283 } | 283 } |
| 284 | 284 |
| 285 // TODO(xiaochengh): Merge it with |shouldDeleteRange|. |
| 285 bool Editor::canDeleteRange(const EphemeralRange& range) const | 286 bool Editor::canDeleteRange(const EphemeralRange& range) const |
| 286 { | 287 { |
| 288 DCHECK(!range.isCollapsed()) << range.startPosition(); |
| 289 |
| 287 Node* startContainer = range.startPosition().computeContainerNode(); | 290 Node* startContainer = range.startPosition().computeContainerNode(); |
| 288 Node* endContainer = range.endPosition().computeContainerNode(); | 291 Node* endContainer = range.endPosition().computeContainerNode(); |
| 289 if (!startContainer || !endContainer) | 292 if (!startContainer || !endContainer) |
| 290 return false; | 293 return false; |
| 291 | 294 |
| 292 if (!hasEditableStyle(*startContainer) || !hasEditableStyle(*endContainer)) | 295 return hasEditableStyle(*startContainer) && hasEditableStyle(*endContainer); |
| 293 return false; | |
| 294 | |
| 295 if (range.isCollapsed()) { | |
| 296 VisiblePosition start = createVisiblePositionDeprecated(range.startPosit
ion()); | |
| 297 VisiblePosition previous = previousPositionOf(start); | |
| 298 // FIXME: We sometimes allow deletions at the start of editable roots, l
ike when the caret is in an empty list item. | |
| 299 if (previous.isNull() || rootEditableElement(*previous.deepEquivalent().
anchorNode()) != rootEditableElement(*startContainer)) | |
| 300 return false; | |
| 301 } | |
| 302 return true; | |
| 303 } | 296 } |
| 304 | 297 |
| 305 bool Editor::smartInsertDeleteEnabled() const | 298 bool Editor::smartInsertDeleteEnabled() const |
| 306 { | 299 { |
| 307 if (Settings* settings = frame().settings()) | 300 if (Settings* settings = frame().settings()) |
| 308 return settings->smartInsertDeleteEnabled(); | 301 return settings->smartInsertDeleteEnabled(); |
| 309 return false; | 302 return false; |
| 310 } | 303 } |
| 311 | 304 |
| 312 bool Editor::canSmartCopyOrDelete() const | 305 bool Editor::canSmartCopyOrDelete() const |
| (...skipping 1122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1435 | 1428 |
| 1436 DEFINE_TRACE(Editor) | 1429 DEFINE_TRACE(Editor) |
| 1437 { | 1430 { |
| 1438 visitor->trace(m_frame); | 1431 visitor->trace(m_frame); |
| 1439 visitor->trace(m_lastEditCommand); | 1432 visitor->trace(m_lastEditCommand); |
| 1440 visitor->trace(m_undoStack); | 1433 visitor->trace(m_undoStack); |
| 1441 visitor->trace(m_mark); | 1434 visitor->trace(m_mark); |
| 1442 } | 1435 } |
| 1443 | 1436 |
| 1444 } // namespace blink | 1437 } // namespace blink |
| OLD | NEW |