| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2007 Apple Computer, Inc. All rights reserved. | 2 * Copyright (C) 2007 Apple Computer, Inc. All rights reserved. |
| 3 * Copyright (C) 2010 Google Inc. All rights reserved. | 3 * Copyright (C) 2010 Google Inc. All rights reserved. |
| 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 22 matching lines...) Expand all Loading... |
| 33 #include "core/dom/Element.h" | 33 #include "core/dom/Element.h" |
| 34 #include "core/editing/ApplyStyleCommand.h" | 34 #include "core/editing/ApplyStyleCommand.h" |
| 35 #include "core/editing/EditingStyle.h" | 35 #include "core/editing/EditingStyle.h" |
| 36 #include "core/editing/FrameSelection.h" | 36 #include "core/editing/FrameSelection.h" |
| 37 #include "core/page/Frame.h" | 37 #include "core/page/Frame.h" |
| 38 | 38 |
| 39 namespace WebCore { | 39 namespace WebCore { |
| 40 | 40 |
| 41 using namespace HTMLNames; | 41 using namespace HTMLNames; |
| 42 | 42 |
| 43 RemoveFormatCommand::RemoveFormatCommand(Document* document) | 43 RemoveFormatCommand::RemoveFormatCommand(Document& document) |
| 44 : CompositeEditCommand(document) | 44 : CompositeEditCommand(document) |
| 45 { | 45 { |
| 46 } | 46 } |
| 47 | 47 |
| 48 static bool isElementForRemoveFormatCommand(const Element* element) | 48 static bool isElementForRemoveFormatCommand(const Element* element) |
| 49 { | 49 { |
| 50 DEFINE_STATIC_LOCAL(HashSet<QualifiedName>, elements, ()); | 50 DEFINE_STATIC_LOCAL(HashSet<QualifiedName>, elements, ()); |
| 51 if (elements.isEmpty()) { | 51 if (elements.isEmpty()) { |
| 52 elements.add(acronymTag); | 52 elements.add(acronymTag); |
| 53 elements.add(bTag); | 53 elements.add(bTag); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 72 elements.add(supTag); | 72 elements.add(supTag); |
| 73 elements.add(ttTag); | 73 elements.add(ttTag); |
| 74 elements.add(uTag); | 74 elements.add(uTag); |
| 75 elements.add(varTag); | 75 elements.add(varTag); |
| 76 } | 76 } |
| 77 return elements.contains(element->tagQName()); | 77 return elements.contains(element->tagQName()); |
| 78 } | 78 } |
| 79 | 79 |
| 80 void RemoveFormatCommand::doApply() | 80 void RemoveFormatCommand::doApply() |
| 81 { | 81 { |
| 82 Frame* frame = document()->frame(); | 82 Frame* frame = document().frame(); |
| 83 | 83 |
| 84 if (!frame->selection()->selection().isNonOrphanedCaretOrRange()) | 84 if (!frame->selection()->selection().isNonOrphanedCaretOrRange()) |
| 85 return; | 85 return; |
| 86 | 86 |
| 87 // Get the default style for this editable root, it's the style that we'll g
ive the | 87 // Get the default style for this editable root, it's the style that we'll g
ive the |
| 88 // content that we're operating on. | 88 // content that we're operating on. |
| 89 Node* root = frame->selection()->rootEditableElement(); | 89 Node* root = frame->selection()->rootEditableElement(); |
| 90 RefPtr<EditingStyle> defaultStyle = EditingStyle::create(root); | 90 RefPtr<EditingStyle> defaultStyle = EditingStyle::create(root); |
| 91 | 91 |
| 92 // We want to remove everything but transparent background. | 92 // We want to remove everything but transparent background. |
| 93 // FIXME: We shouldn't access style(). | 93 // FIXME: We shouldn't access style(). |
| 94 defaultStyle->style()->setProperty(CSSPropertyBackgroundColor, CSSValueTrans
parent); | 94 defaultStyle->style()->setProperty(CSSPropertyBackgroundColor, CSSValueTrans
parent); |
| 95 | 95 |
| 96 applyCommandToComposite(ApplyStyleCommand::create(document(), defaultStyle.g
et(), isElementForRemoveFormatCommand, editingAction())); | 96 applyCommandToComposite(ApplyStyleCommand::create(document(), defaultStyle.g
et(), isElementForRemoveFormatCommand, editingAction())); |
| 97 } | 97 } |
| 98 | 98 |
| 99 } | 99 } |
| OLD | NEW |