Chromium Code Reviews| 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 bool Editor::canDeleteRange(const EphemeralRange& range) const | 285 bool Editor::canDeleteRange(const EphemeralRange& range) const |
|
yosin_UTC9
2016/09/20 07:58:39
Since |canDeleteRange()| is called only from |shou
Xiaocheng
2016/09/20 08:12:35
TODO added.
| |
| 286 { | 286 { |
| 287 DCHECK(!range.isCollapsed()); | |
|
yosin_UTC9
2016/09/20 07:58:39
nit: Could you add |<< *range| for |DCHECK()|?
Xiaocheng
2016/09/20 08:12:34
Done.
| |
| 288 | |
| 287 Node* startContainer = range.startPosition().computeContainerNode(); | 289 Node* startContainer = range.startPosition().computeContainerNode(); |
| 288 Node* endContainer = range.endPosition().computeContainerNode(); | 290 Node* endContainer = range.endPosition().computeContainerNode(); |
| 289 if (!startContainer || !endContainer) | 291 if (!startContainer || !endContainer) |
| 290 return false; | 292 return false; |
| 291 | 293 |
| 292 if (!hasEditableStyle(*startContainer) || !hasEditableStyle(*endContainer)) | 294 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 } | 295 } |
| 304 | 296 |
| 305 bool Editor::smartInsertDeleteEnabled() const | 297 bool Editor::smartInsertDeleteEnabled() const |
| 306 { | 298 { |
| 307 if (Settings* settings = frame().settings()) | 299 if (Settings* settings = frame().settings()) |
| 308 return settings->smartInsertDeleteEnabled(); | 300 return settings->smartInsertDeleteEnabled(); |
| 309 return false; | 301 return false; |
| 310 } | 302 } |
| 311 | 303 |
| 312 bool Editor::canSmartCopyOrDelete() const | 304 bool Editor::canSmartCopyOrDelete() const |
| (...skipping 1122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1435 | 1427 |
| 1436 DEFINE_TRACE(Editor) | 1428 DEFINE_TRACE(Editor) |
| 1437 { | 1429 { |
| 1438 visitor->trace(m_frame); | 1430 visitor->trace(m_frame); |
| 1439 visitor->trace(m_lastEditCommand); | 1431 visitor->trace(m_lastEditCommand); |
| 1440 visitor->trace(m_undoStack); | 1432 visitor->trace(m_undoStack); |
| 1441 visitor->trace(m_mark); | 1433 visitor->trace(m_mark); |
| 1442 } | 1434 } |
| 1443 | 1435 |
| 1444 } // namespace blink | 1436 } // namespace blink |
| OLD | NEW |