This source file includes following definitions.
- isElementForRemoveFormatCommand
- doApply
#include "config.h"
#include "core/editing/RemoveFormatCommand.h"
#include "CSSValueKeywords.h"
#include "HTMLNames.h"
#include "core/css/StylePropertySet.h"
#include "core/dom/Element.h"
#include "core/editing/ApplyStyleCommand.h"
#include "core/editing/EditingStyle.h"
#include "core/editing/FrameSelection.h"
#include "core/frame/LocalFrame.h"
namespace WebCore {
using namespace HTMLNames;
RemoveFormatCommand::RemoveFormatCommand(Document& document)
: CompositeEditCommand(document)
{
}
static bool isElementForRemoveFormatCommand(const Element* element)
{
DEFINE_STATIC_LOCAL(HashSet<QualifiedName>, elements, ());
if (elements.isEmpty()) {
elements.add(acronymTag);
elements.add(bTag);
elements.add(bdoTag);
elements.add(bigTag);
elements.add(citeTag);
elements.add(codeTag);
elements.add(dfnTag);
elements.add(emTag);
elements.add(fontTag);
elements.add(iTag);
elements.add(insTag);
elements.add(kbdTag);
elements.add(nobrTag);
elements.add(qTag);
elements.add(sTag);
elements.add(sampTag);
elements.add(smallTag);
elements.add(strikeTag);
elements.add(strongTag);
elements.add(subTag);
elements.add(supTag);
elements.add(ttTag);
elements.add(uTag);
elements.add(varTag);
}
return elements.contains(element->tagQName());
}
void RemoveFormatCommand::doApply()
{
LocalFrame* frame = document().frame();
if (!frame->selection().selection().isNonOrphanedCaretOrRange())
return;
Node* root = frame->selection().rootEditableElement();
RefPtr<EditingStyle> defaultStyle = EditingStyle::create(root);
defaultStyle->style()->setProperty(CSSPropertyBackgroundColor, CSSValueTransparent);
applyCommandToComposite(ApplyStyleCommand::create(document(), defaultStyle.get(), isElementForRemoveFormatCommand, editingAction()));
}
}