From 65f03d4f644ce73618e5f4f50dd694b26f55ae12 Mon Sep 17 00:00:00 2001 From: Ben Murdoch Date: Fri, 13 May 2011 16:23:25 +0100 Subject: Merge WebKit at r75993: Initial merge by git. Change-Id: I602bbdc3974787a3b0450456a30a7868286921c3 --- Source/WebKit/wx/WebEdit.cpp | 80 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100644 Source/WebKit/wx/WebEdit.cpp (limited to 'Source/WebKit/wx/WebEdit.cpp') diff --git a/Source/WebKit/wx/WebEdit.cpp b/Source/WebKit/wx/WebEdit.cpp new file mode 100644 index 0000000..33b4c86 --- /dev/null +++ b/Source/WebKit/wx/WebEdit.cpp @@ -0,0 +1,80 @@ + + +#include "config.h" +#include "WebEdit.h" + +#include "CompositeEditCommand.h" +#include "Document.h" +#include "Frame.h" +#include "HTMLNames.h" +#include "QualifiedName.h" +#include "StringImpl.h" + +#include "WebFrame.h" +#include "WebDOMElement.h" +#include + +namespace WebCore { + +class WebCoreEditCommand: public CompositeEditCommand +{ +public: + WebCoreEditCommand(WebCore::Document* document) + : CompositeEditCommand(document) + { } + + void setElementAttribute(PassRefPtr element, const QualifiedName& attribute, const AtomicString& value) + { + setNodeAttribute(element, attribute, value); + } + // composite commands are applied as they are added, so we don't + // need doApply to do anything. + virtual void doApply() {} +}; + +} + +class WebCoreEditCommandPrivate { +public: + WebCoreEditCommandPrivate() + : m_ptr(0) + { } + + WebCoreEditCommandPrivate(WebCore::WebCoreEditCommand* ptr) + : m_ptr(adoptRef(ptr)) + { } + + ~WebCoreEditCommandPrivate() { } + + WebCore::WebCoreEditCommand* command() { return m_ptr.get(); } + + RefPtr m_ptr; +}; + +wxWebEditCommand::wxWebEditCommand(wxWebFrame* webframe) +{ + if (webframe) { + WebCore::Frame* frame = webframe->GetFrame(); + if (frame && frame->document()) + m_impl = new WebCoreEditCommandPrivate(new WebCore::WebCoreEditCommand(frame->document())); + } +} + +wxWebEditCommand::~wxWebEditCommand() +{ + // the impl. is ref-counted, so don't delete it as it may be in an undo/redo stack + delete m_impl; + m_impl = 0; +} + +void wxWebEditCommand::SetNodeAttribute(WebDOMElement* element, const wxString& name, const wxString& value) +{ + if (m_impl && m_impl->command()) + m_impl->command()->setElementAttribute(element->impl(), WebCore::QualifiedName(WTF::nullAtom, WTF::String(name), WTF::nullAtom), WTF::String(value)); +} + +void wxWebEditCommand::Apply() +{ + if (m_impl && m_impl->command()) + m_impl->command()->apply(); +} -- cgit v1.1