OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved. | 2 * Copyright (C) 2006, 2007, 2008 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 * Copyright (C) 2009 Igalia S.L. | 4 * Copyright (C) 2009 Igalia S.L. |
5 * | 5 * |
6 * Redistribution and use in source and binary forms, with or without | 6 * Redistribution and use in source and binary forms, with or without |
7 * modification, are permitted provided that the following conditions | 7 * modification, are permitted provided that the following conditions |
8 * are met: | 8 * are met: |
9 * 1. Redistributions of source code must retain the above copyright | 9 * 1. Redistributions of source code must retain the above copyright |
10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
192 | 192 |
193 static bool executeInsertFragment(Frame& frame, PassRefPtr<DocumentFragment> fra
gment) | 193 static bool executeInsertFragment(Frame& frame, PassRefPtr<DocumentFragment> fra
gment) |
194 { | 194 { |
195 ASSERT(frame.document()); | 195 ASSERT(frame.document()); |
196 applyCommand(ReplaceSelectionCommand::create(*frame.document(), fragment, Re
placeSelectionCommand::PreventNesting, EditActionUnspecified)); | 196 applyCommand(ReplaceSelectionCommand::create(*frame.document(), fragment, Re
placeSelectionCommand::PreventNesting, EditActionUnspecified)); |
197 return true; | 197 return true; |
198 } | 198 } |
199 | 199 |
200 static bool executeInsertNode(Frame& frame, PassRefPtr<Node> content) | 200 static bool executeInsertNode(Frame& frame, PassRefPtr<Node> content) |
201 { | 201 { |
202 RefPtr<DocumentFragment> fragment = DocumentFragment::create(frame.document(
)); | 202 ASSERT(frame.document()); |
| 203 RefPtr<DocumentFragment> fragment = DocumentFragment::create(*frame.document
()); |
203 TrackExceptionState es; | 204 TrackExceptionState es; |
204 fragment->appendChild(content, es); | 205 fragment->appendChild(content, es); |
205 if (es.hadException()) | 206 if (es.hadException()) |
206 return false; | 207 return false; |
207 return executeInsertFragment(frame, fragment.release()); | 208 return executeInsertFragment(frame, fragment.release()); |
208 } | 209 } |
209 | 210 |
210 static bool expandSelectionToGranularity(Frame& frame, TextGranularity granulari
ty) | 211 static bool expandSelectionToGranularity(Frame& frame, TextGranularity granulari
ty) |
211 { | 212 { |
212 VisibleSelection selection = frame.selection().selection(); | 213 VisibleSelection selection = frame.selection().selection(); |
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
496 { | 497 { |
497 ASSERT(frame.document()); | 498 ASSERT(frame.document()); |
498 RefPtr<HTMLHRElement> rule = HTMLHRElement::create(*frame.document()); | 499 RefPtr<HTMLHRElement> rule = HTMLHRElement::create(*frame.document()); |
499 if (!value.isEmpty()) | 500 if (!value.isEmpty()) |
500 rule->setIdAttribute(value); | 501 rule->setIdAttribute(value); |
501 return executeInsertNode(frame, rule.release()); | 502 return executeInsertNode(frame, rule.release()); |
502 } | 503 } |
503 | 504 |
504 static bool executeInsertHTML(Frame& frame, Event*, EditorCommandSource, const S
tring& value) | 505 static bool executeInsertHTML(Frame& frame, Event*, EditorCommandSource, const S
tring& value) |
505 { | 506 { |
506 return executeInsertFragment(frame, createFragmentFromMarkup(frame.document(
), value, "")); | 507 ASSERT(frame.document()); |
| 508 return executeInsertFragment(frame, createFragmentFromMarkup(*frame.document
(), value, "")); |
507 } | 509 } |
508 | 510 |
509 static bool executeInsertImage(Frame& frame, Event*, EditorCommandSource, const
String& value) | 511 static bool executeInsertImage(Frame& frame, Event*, EditorCommandSource, const
String& value) |
510 { | 512 { |
511 // FIXME: If userInterface is true, we should display a dialog box and let t
he user choose a local image. | 513 // FIXME: If userInterface is true, we should display a dialog box and let t
he user choose a local image. |
512 ASSERT(frame.document()); | 514 ASSERT(frame.document()); |
513 RefPtr<HTMLImageElement> image = HTMLImageElement::create(*frame.document())
; | 515 RefPtr<HTMLImageElement> image = HTMLImageElement::create(*frame.document())
; |
514 image->setSrc(value); | 516 image->setSrc(value); |
515 return executeInsertNode(frame, image.release()); | 517 return executeInsertNode(frame, image.release()); |
516 } | 518 } |
(...skipping 1240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1757 return m_command->state(*m_frame, triggeringEvent) == TrueTriState ? "tr
ue" : "false"; | 1759 return m_command->state(*m_frame, triggeringEvent) == TrueTriState ? "tr
ue" : "false"; |
1758 return m_command->value(*m_frame, triggeringEvent); | 1760 return m_command->value(*m_frame, triggeringEvent); |
1759 } | 1761 } |
1760 | 1762 |
1761 bool Editor::Command::isTextInsertion() const | 1763 bool Editor::Command::isTextInsertion() const |
1762 { | 1764 { |
1763 return m_command && m_command->isTextInsertion; | 1765 return m_command && m_command->isTextInsertion; |
1764 } | 1766 } |
1765 | 1767 |
1766 } // namespace WebCore | 1768 } // namespace WebCore |
OLD | NEW |