summaryrefslogtreecommitdiffstats
path: root/Source/WebKit/wx/WebEdit.cpp
diff options
context:
space:
mode:
authorBen Murdoch <benm@google.com>2011-05-13 16:23:25 +0100
committerBen Murdoch <benm@google.com>2011-05-16 11:35:02 +0100
commit65f03d4f644ce73618e5f4f50dd694b26f55ae12 (patch)
treef478babb801e720de7bfaee23443ffe029f58731 /Source/WebKit/wx/WebEdit.cpp
parent47de4a2fb7262c7ebdb9cd133ad2c54c187454d0 (diff)
downloadexternal_webkit-65f03d4f644ce73618e5f4f50dd694b26f55ae12.zip
external_webkit-65f03d4f644ce73618e5f4f50dd694b26f55ae12.tar.gz
external_webkit-65f03d4f644ce73618e5f4f50dd694b26f55ae12.tar.bz2
Merge WebKit at r75993: Initial merge by git.
Change-Id: I602bbdc3974787a3b0450456a30a7868286921c3
Diffstat (limited to 'Source/WebKit/wx/WebEdit.cpp')
-rw-r--r--Source/WebKit/wx/WebEdit.cpp80
1 files changed, 80 insertions, 0 deletions
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 <wtf/text/AtomicString.h>
+
+namespace WebCore {
+
+class WebCoreEditCommand: public CompositeEditCommand
+{
+public:
+ WebCoreEditCommand(WebCore::Document* document)
+ : CompositeEditCommand(document)
+ { }
+
+ void setElementAttribute(PassRefPtr<Element> 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<WebCore::WebCoreEditCommand> 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();
+}