| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2006 Apple Computer, Inc. All rights reserved. | 2 * Copyright (C) 2006 Apple Computer, Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 24 */ | 24 */ |
| 25 | 25 |
| 26 #include "core/editing/commands/CreateLinkCommand.h" | 26 #include "core/editing/commands/CreateLinkCommand.h" |
| 27 | 27 |
| 28 #include "core/dom/Text.h" | 28 #include "core/dom/Text.h" |
| 29 #include "core/html/HTMLAnchorElement.h" | 29 #include "core/html/HTMLAnchorElement.h" |
| 30 | 30 |
| 31 namespace blink { | 31 namespace blink { |
| 32 | 32 |
| 33 CreateLinkCommand::CreateLinkCommand(Document& document, const String& url) | 33 CreateLinkCommand::CreateLinkCommand(Document& document, |
| 34 : CompositeEditCommand(document) { | 34 EditCommandSource source, |
| 35 const String& url) |
| 36 : CompositeEditCommand(document, source) { |
| 35 m_url = url; | 37 m_url = url; |
| 36 } | 38 } |
| 37 | 39 |
| 38 void CreateLinkCommand::doApply(EditingState* editingState) { | 40 void CreateLinkCommand::doApply(EditingState* editingState) { |
| 39 if (endingSelection().isNone()) | 41 if (endingSelection().isNone()) |
| 40 return; | 42 return; |
| 41 | 43 |
| 42 HTMLAnchorElement* anchorElement = HTMLAnchorElement::create(document()); | 44 HTMLAnchorElement* anchorElement = HTMLAnchorElement::create(document()); |
| 43 anchorElement->setHref(AtomicString(m_url)); | 45 anchorElement->setHref(AtomicString(m_url)); |
| 44 | 46 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 57 setEndingSelection( | 59 setEndingSelection( |
| 58 SelectionInDOMTree::Builder() | 60 SelectionInDOMTree::Builder() |
| 59 .collapse(Position::inParentBeforeNode(*anchorElement)) | 61 .collapse(Position::inParentBeforeNode(*anchorElement)) |
| 60 .extend(Position::inParentAfterNode(*anchorElement)) | 62 .extend(Position::inParentAfterNode(*anchorElement)) |
| 61 .setIsDirectional(endingSelection().isDirectional()) | 63 .setIsDirectional(endingSelection().isDirectional()) |
| 62 .build()); | 64 .build()); |
| 63 } | 65 } |
| 64 } | 66 } |
| 65 | 67 |
| 66 } // namespace blink | 68 } // namespace blink |
| OLD | NEW |