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 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
343 } | 343 } |
344 | 344 |
345 void Editor::pasteAsPlainText(const String& pastingText, bool smartReplace) | 345 void Editor::pasteAsPlainText(const String& pastingText, bool smartReplace) |
346 { | 346 { |
347 Node* target = findEventTargetFromSelection(); | 347 Node* target = findEventTargetFromSelection(); |
348 if (!target) | 348 if (!target) |
349 return; | 349 return; |
350 target->dispatchEvent(TextEvent::createForPlainTextPaste(m_frame.domWindow()
, pastingText, smartReplace), IGNORE_EXCEPTION); | 350 target->dispatchEvent(TextEvent::createForPlainTextPaste(m_frame.domWindow()
, pastingText, smartReplace), IGNORE_EXCEPTION); |
351 } | 351 } |
352 | 352 |
353 void Editor::pasteAsFragment(PassRefPtr<DocumentFragment> pastingFragment, bool
smartReplace, bool matchStyle) | 353 void Editor::pasteAsFragment(PassRefPtrWillBeRawPtr<DocumentFragment> pastingFra
gment, bool smartReplace, bool matchStyle) |
354 { | 354 { |
355 Node* target = findEventTargetFromSelection(); | 355 Node* target = findEventTargetFromSelection(); |
356 if (!target) | 356 if (!target) |
357 return; | 357 return; |
358 target->dispatchEvent(TextEvent::createForFragmentPaste(m_frame.domWindow(),
pastingFragment, smartReplace, matchStyle), IGNORE_EXCEPTION); | 358 target->dispatchEvent(TextEvent::createForFragmentPaste(m_frame.domWindow(),
pastingFragment, smartReplace, matchStyle), IGNORE_EXCEPTION); |
359 } | 359 } |
360 | 360 |
361 bool Editor::tryDHTMLCopy() | 361 bool Editor::tryDHTMLCopy() |
362 { | 362 { |
363 if (m_frame.selection().isInPasswordField()) | 363 if (m_frame.selection().isInPasswordField()) |
(...skipping 17 matching lines...) Expand all Loading... |
381 | 381 |
382 void Editor::pasteAsPlainTextWithPasteboard(Pasteboard* pasteboard) | 382 void Editor::pasteAsPlainTextWithPasteboard(Pasteboard* pasteboard) |
383 { | 383 { |
384 String text = pasteboard->plainText(); | 384 String text = pasteboard->plainText(); |
385 pasteAsPlainText(text, canSmartReplaceWithPasteboard(pasteboard)); | 385 pasteAsPlainText(text, canSmartReplaceWithPasteboard(pasteboard)); |
386 } | 386 } |
387 | 387 |
388 void Editor::pasteWithPasteboard(Pasteboard* pasteboard) | 388 void Editor::pasteWithPasteboard(Pasteboard* pasteboard) |
389 { | 389 { |
390 RefPtrWillBeRawPtr<Range> range = selectedRange(); | 390 RefPtrWillBeRawPtr<Range> range = selectedRange(); |
391 RefPtr<DocumentFragment> fragment; | 391 RefPtrWillBeRawPtr<DocumentFragment> fragment = nullptr; |
392 bool chosePlainText = false; | 392 bool chosePlainText = false; |
393 | 393 |
394 if (pasteboard->isHTMLAvailable()) { | 394 if (pasteboard->isHTMLAvailable()) { |
395 unsigned fragmentStart = 0; | 395 unsigned fragmentStart = 0; |
396 unsigned fragmentEnd = 0; | 396 unsigned fragmentEnd = 0; |
397 KURL url; | 397 KURL url; |
398 String markup = pasteboard->readHTML(url, fragmentStart, fragmentEnd); | 398 String markup = pasteboard->readHTML(url, fragmentStart, fragmentEnd); |
399 if (!markup.isEmpty()) { | 399 if (!markup.isEmpty()) { |
400 ASSERT(m_frame.document()); | 400 ASSERT(m_frame.document()); |
401 fragment = createFragmentFromMarkupWithContext(*m_frame.document(),
markup, fragmentStart, fragmentEnd, url, DisallowScriptingAndPluginContent); | 401 fragment = createFragmentFromMarkupWithContext(*m_frame.document(),
markup, fragmentStart, fragmentEnd, url, DisallowScriptingAndPluginContent); |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
476 clipboard->setAccessPolicy(ClipboardNumb); | 476 clipboard->setAccessPolicy(ClipboardNumb); |
477 | 477 |
478 return !noDefaultProcessing; | 478 return !noDefaultProcessing; |
479 } | 479 } |
480 | 480 |
481 bool Editor::canSmartReplaceWithPasteboard(Pasteboard* pasteboard) | 481 bool Editor::canSmartReplaceWithPasteboard(Pasteboard* pasteboard) |
482 { | 482 { |
483 return smartInsertDeleteEnabled() && pasteboard->canSmartReplace(); | 483 return smartInsertDeleteEnabled() && pasteboard->canSmartReplace(); |
484 } | 484 } |
485 | 485 |
486 void Editor::replaceSelectionWithFragment(PassRefPtr<DocumentFragment> fragment,
bool selectReplacement, bool smartReplace, bool matchStyle) | 486 void Editor::replaceSelectionWithFragment(PassRefPtrWillBeRawPtr<DocumentFragmen
t> fragment, bool selectReplacement, bool smartReplace, bool matchStyle) |
487 { | 487 { |
488 if (m_frame.selection().isNone() || !m_frame.selection().isContentEditable()
|| !fragment) | 488 if (m_frame.selection().isNone() || !m_frame.selection().isContentEditable()
|| !fragment) |
489 return; | 489 return; |
490 | 490 |
491 ReplaceSelectionCommand::CommandOptions options = ReplaceSelectionCommand::P
reventNesting | ReplaceSelectionCommand::SanitizeFragment; | 491 ReplaceSelectionCommand::CommandOptions options = ReplaceSelectionCommand::P
reventNesting | ReplaceSelectionCommand::SanitizeFragment; |
492 if (selectReplacement) | 492 if (selectReplacement) |
493 options |= ReplaceSelectionCommand::SelectReplacement; | 493 options |= ReplaceSelectionCommand::SelectReplacement; |
494 if (smartReplace) | 494 if (smartReplace) |
495 options |= ReplaceSelectionCommand::SmartReplace; | 495 options |= ReplaceSelectionCommand::SmartReplace; |
496 if (matchStyle) | 496 if (matchStyle) |
(...skipping 732 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1229 return m_frame.spellChecker(); | 1229 return m_frame.spellChecker(); |
1230 } | 1230 } |
1231 | 1231 |
1232 void Editor::toggleOverwriteModeEnabled() | 1232 void Editor::toggleOverwriteModeEnabled() |
1233 { | 1233 { |
1234 m_overwriteModeEnabled = !m_overwriteModeEnabled; | 1234 m_overwriteModeEnabled = !m_overwriteModeEnabled; |
1235 frame().selection().setShouldShowBlockCursor(m_overwriteModeEnabled); | 1235 frame().selection().setShouldShowBlockCursor(m_overwriteModeEnabled); |
1236 } | 1236 } |
1237 | 1237 |
1238 } // namespace WebCore | 1238 } // namespace WebCore |
OLD | NEW |