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 326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
337 { | 337 { |
338 if (m_frame.selection().isNone()) | 338 if (m_frame.selection().isNone()) |
339 return; | 339 return; |
340 | 340 |
341 ASSERT(m_frame.document()); | 341 ASSERT(m_frame.document()); |
342 DeleteSelectionCommand::create(*m_frame.document(), smartDelete)->apply(); | 342 DeleteSelectionCommand::create(*m_frame.document(), smartDelete)->apply(); |
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 Element* 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(PassRefPtrWillBeRawPtr<DocumentFragment> pastingFra
gment, bool smartReplace, bool matchStyle) | 353 void Editor::pasteAsFragment(PassRefPtrWillBeRawPtr<DocumentFragment> pastingFra
gment, bool smartReplace, bool matchStyle) |
354 { | 354 { |
355 Node* target = findEventTargetFromSelection(); | 355 Element* 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()) |
364 return false; | 364 return false; |
365 | 365 |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
450 ASSERT(pasteboard); | 450 ASSERT(pasteboard); |
451 ASSERT(node); | 451 ASSERT(node); |
452 | 452 |
453 RefPtr<Image> image = imageFromNode(*node); | 453 RefPtr<Image> image = imageFromNode(*node); |
454 if (!image.get()) | 454 if (!image.get()) |
455 return; | 455 return; |
456 | 456 |
457 // FIXME: This should probably be reconciled with HitTestResult::absoluteIma
geURL. | 457 // FIXME: This should probably be reconciled with HitTestResult::absoluteIma
geURL. |
458 AtomicString urlString; | 458 AtomicString urlString; |
459 if (isHTMLImageElement(*node) || isHTMLInputElement(*node)) | 459 if (isHTMLImageElement(*node) || isHTMLInputElement(*node)) |
460 urlString = toElement(node)->getAttribute(srcAttr); | 460 urlString = toHTMLElement(node)->getAttribute(srcAttr); |
461 else if (isSVGImageElement(*node)) | 461 else if (isSVGImageElement(*node)) |
462 urlString = toElement(node)->getAttribute(XLinkNames::hrefAttr); | 462 urlString = toSVGElement(node)->getAttribute(XLinkNames::hrefAttr); |
463 else if (isHTMLEmbedElement(*node) || isHTMLObjectElement(*node) || isHTMLCa
nvasElement(*node)) | 463 else if (isHTMLEmbedElement(*node) || isHTMLObjectElement(*node) || isHTMLCa
nvasElement(*node)) |
464 urlString = toElement(node)->imageSourceURL(); | 464 urlString = toHTMLElement(node)->imageSourceURL(); |
465 KURL url = urlString.isEmpty() ? KURL() : node->document().completeURL(strip
LeadingAndTrailingHTMLSpaces(urlString)); | 465 KURL url = urlString.isEmpty() ? KURL() : node->document().completeURL(strip
LeadingAndTrailingHTMLSpaces(urlString)); |
466 | 466 |
467 pasteboard->writeImage(image.get(), url, title); | 467 pasteboard->writeImage(image.get(), url, title); |
468 } | 468 } |
469 | 469 |
470 // Returns whether caller should continue with "the default processing", which i
s the same as | 470 // Returns whether caller should continue with "the default processing", which i
s the same as |
471 // the event handler NOT setting the return value to false | 471 // the event handler NOT setting the return value to false |
472 bool Editor::dispatchCPPEvent(const AtomicString &eventType, DataTransferAccessP
olicy policy, PasteMode pasteMode) | 472 bool Editor::dispatchCPPEvent(const AtomicString& eventType, DataTransferAccessP
olicy policy, PasteMode pasteMode) |
473 { | 473 { |
474 Node* target = findEventTargetFromSelection(); | 474 Element* target = findEventTargetFromSelection(); |
475 if (!target) | 475 if (!target) |
476 return true; | 476 return true; |
477 | 477 |
478 RefPtrWillBeRawPtr<DataTransfer> dataTransfer = DataTransfer::create( | 478 RefPtrWillBeRawPtr<DataTransfer> dataTransfer = DataTransfer::create( |
479 DataTransfer::CopyAndPaste, | 479 DataTransfer::CopyAndPaste, |
480 policy, | 480 policy, |
481 policy == DataTransferWritable | 481 policy == DataTransferWritable |
482 ? DataObject::create() | 482 ? DataObject::create() |
483 : DataObject::createFromPasteboard(pasteMode)); | 483 : DataObject::createFromPasteboard(pasteMode)); |
484 | 484 |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
562 { | 562 { |
563 ASSERT(m_frame.document()); | 563 ASSERT(m_frame.document()); |
564 RemoveFormatCommand::create(*m_frame.document())->apply(); | 564 RemoveFormatCommand::create(*m_frame.document())->apply(); |
565 } | 565 } |
566 | 566 |
567 void Editor::clearLastEditCommand() | 567 void Editor::clearLastEditCommand() |
568 { | 568 { |
569 m_lastEditCommand.clear(); | 569 m_lastEditCommand.clear(); |
570 } | 570 } |
571 | 571 |
572 Node* Editor::findEventTargetFrom(const VisibleSelection& selection) const | 572 Element* Editor::findEventTargetFrom(const VisibleSelection& selection) const |
573 { | 573 { |
574 Node* target = selection.start().element(); | 574 Element* target = selection.start().element(); |
575 if (!target) | 575 if (!target) |
576 target = m_frame.document()->body(); | 576 target = m_frame.document()->body(); |
577 | 577 |
578 return target; | 578 return target; |
579 } | 579 } |
580 | 580 |
581 Node* Editor::findEventTargetFromSelection() const | 581 Element* Editor::findEventTargetFromSelection() const |
582 { | 582 { |
583 return findEventTargetFrom(m_frame.selection().selection()); | 583 return findEventTargetFrom(m_frame.selection().selection()); |
584 } | 584 } |
585 | 585 |
586 void Editor::applyStyle(StylePropertySet* style, EditAction editingAction) | 586 void Editor::applyStyle(StylePropertySet* style, EditAction editingAction) |
587 { | 587 { |
588 switch (m_frame.selection().selectionType()) { | 588 switch (m_frame.selection().selectionType()) { |
589 case NoSelection: | 589 case NoSelection: |
590 // do nothing | 590 // do nothing |
591 break; | 591 break; |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
742 { | 742 { |
743 } | 743 } |
744 | 744 |
745 void Editor::clear() | 745 void Editor::clear() |
746 { | 746 { |
747 m_frame.inputMethodController().clear(); | 747 m_frame.inputMethodController().clear(); |
748 m_shouldStyleWithCSS = false; | 748 m_shouldStyleWithCSS = false; |
749 m_defaultParagraphSeparator = EditorParagraphSeparatorIsDiv; | 749 m_defaultParagraphSeparator = EditorParagraphSeparatorIsDiv; |
750 } | 750 } |
751 | 751 |
752 bool Editor::insertText(const String& text, Event* triggeringEvent) | 752 bool Editor::insertText(const String& text, KeyboardEvent* triggeringEvent) |
753 { | 753 { |
754 return m_frame.eventHandler().handleTextInputEvent(text, triggeringEvent); | 754 return m_frame.eventHandler().handleTextInputEvent(text, triggeringEvent); |
755 } | 755 } |
756 | 756 |
757 bool Editor::insertTextWithoutSendingTextEvent(const String& text, bool selectIn
sertedText, TextEvent* triggeringEvent) | 757 bool Editor::insertTextWithoutSendingTextEvent(const String& text, bool selectIn
sertedText, TextEvent* triggeringEvent) |
758 { | 758 { |
759 if (text.isEmpty()) | 759 if (text.isEmpty()) |
760 return false; | 760 return false; |
761 | 761 |
762 VisibleSelection selection = selectionForCommand(triggeringEvent); | 762 VisibleSelection selection = selectionForCommand(triggeringEvent); |
(...skipping 515 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1278 frame().selection().setShouldShowBlockCursor(m_overwriteModeEnabled); | 1278 frame().selection().setShouldShowBlockCursor(m_overwriteModeEnabled); |
1279 } | 1279 } |
1280 | 1280 |
1281 void Editor::trace(Visitor* visitor) | 1281 void Editor::trace(Visitor* visitor) |
1282 { | 1282 { |
1283 visitor->trace(m_lastEditCommand); | 1283 visitor->trace(m_lastEditCommand); |
1284 visitor->trace(m_mark); | 1284 visitor->trace(m_mark); |
1285 } | 1285 } |
1286 | 1286 |
1287 } // namespace blink | 1287 } // namespace blink |
OLD | NEW |