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 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
309 Node* node = body->firstChild(); | 309 Node* node = body->firstChild(); |
310 if (!isHTMLImageElement(node)) | 310 if (!isHTMLImageElement(node)) |
311 return 0; | 311 return 0; |
312 return toHTMLImageElement(node); | 312 return toHTMLImageElement(node); |
313 } | 313 } |
314 | 314 |
315 bool Editor::canCopy() const { | 315 bool Editor::canCopy() const { |
316 if (imageElementFromImageDocument(frame().document())) | 316 if (imageElementFromImageDocument(frame().document())) |
317 return true; | 317 return true; |
318 FrameSelection& selection = frame().selection(); | 318 FrameSelection& selection = frame().selection(); |
319 return selection.isRange() && !selection.isInPasswordField(); | 319 return selection.computeVisibleSelectionInDOMTreeDeprecated().isRange() && |
| 320 !selection.isInPasswordField(); |
320 } | 321 } |
321 | 322 |
322 bool Editor::canPaste() const { | 323 bool Editor::canPaste() const { |
323 return canEdit(); | 324 return canEdit(); |
324 } | 325 } |
325 | 326 |
326 bool Editor::canDelete() const { | 327 bool Editor::canDelete() const { |
327 FrameSelection& selection = frame().selection(); | 328 FrameSelection& selection = frame().selection(); |
328 return selection.isRange() && selection.rootEditableElement(); | 329 return selection.computeVisibleSelectionInDOMTreeDeprecated().isRange() && |
| 330 selection.rootEditableElement(); |
329 } | 331 } |
330 | 332 |
331 bool Editor::smartInsertDeleteEnabled() const { | 333 bool Editor::smartInsertDeleteEnabled() const { |
332 if (Settings* settings = frame().settings()) | 334 if (Settings* settings = frame().settings()) |
333 return settings->getSmartInsertDeleteEnabled(); | 335 return settings->getSmartInsertDeleteEnabled(); |
334 return false; | 336 return false; |
335 } | 337 } |
336 | 338 |
337 bool Editor::canSmartCopyOrDelete() const { | 339 bool Editor::canSmartCopyOrDelete() const { |
338 return smartInsertDeleteEnabled() && | 340 return smartInsertDeleteEnabled() && |
339 frame().selection().granularity() == WordGranularity; | 341 frame().selection().granularity() == WordGranularity; |
340 } | 342 } |
341 | 343 |
342 bool Editor::isSelectTrailingWhitespaceEnabled() const { | 344 bool Editor::isSelectTrailingWhitespaceEnabled() const { |
343 if (Settings* settings = frame().settings()) | 345 if (Settings* settings = frame().settings()) |
344 return settings->getSelectTrailingWhitespaceEnabled(); | 346 return settings->getSelectTrailingWhitespaceEnabled(); |
345 return false; | 347 return false; |
346 } | 348 } |
347 | 349 |
348 bool Editor::deleteWithDirection(DeleteDirection direction, | 350 bool Editor::deleteWithDirection(DeleteDirection direction, |
349 TextGranularity granularity, | 351 TextGranularity granularity, |
350 bool killRing, | 352 bool killRing, |
351 bool isTypingAction) { | 353 bool isTypingAction) { |
352 if (!canEdit()) | 354 if (!canEdit()) |
353 return false; | 355 return false; |
354 | 356 |
355 EditingState editingState; | 357 EditingState editingState; |
356 if (frame().selection().isRange()) { | 358 if (frame() |
| 359 .selection() |
| 360 .computeVisibleSelectionInDOMTreeDeprecated() |
| 361 .isRange()) { |
357 if (isTypingAction) { | 362 if (isTypingAction) { |
358 DCHECK(frame().document()); | 363 DCHECK(frame().document()); |
359 TypingCommand::deleteKeyPressed( | 364 TypingCommand::deleteKeyPressed( |
360 *frame().document(), | 365 *frame().document(), |
361 canSmartCopyOrDelete() ? TypingCommand::SmartDelete : 0, granularity); | 366 canSmartCopyOrDelete() ? TypingCommand::SmartDelete : 0, granularity); |
362 revealSelectionAfterEditingOperation(); | 367 revealSelectionAfterEditingOperation(); |
363 } else { | 368 } else { |
364 if (killRing) | 369 if (killRing) |
365 addToKillRing(selectedRange()); | 370 addToKillRing(selectedRange()); |
366 deleteSelectionWithSmartDelete( | 371 deleteSelectionWithSmartDelete( |
(...skipping 1368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1735 | 1740 |
1736 DEFINE_TRACE(Editor) { | 1741 DEFINE_TRACE(Editor) { |
1737 visitor->trace(m_frame); | 1742 visitor->trace(m_frame); |
1738 visitor->trace(m_lastEditCommand); | 1743 visitor->trace(m_lastEditCommand); |
1739 visitor->trace(m_undoStack); | 1744 visitor->trace(m_undoStack); |
1740 visitor->trace(m_mark); | 1745 visitor->trace(m_mark); |
1741 visitor->trace(m_typingStyle); | 1746 visitor->trace(m_typingStyle); |
1742 } | 1747 } |
1743 | 1748 |
1744 } // namespace blink | 1749 } // namespace blink |
OLD | NEW |