[SCM] WebKit Debian packaging branch, debian/unstable, updated. debian/1.1.15-1-40151-g37bb677

cblu cblu at 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Sat Sep 26 08:26:52 UTC 2009


The following commit has been merged in the debian/unstable branch:
commit c7e1063cf85d524098dd91db1cab210a33fe947a
Author: cblu <cblu at 268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Mon Feb 16 19:18:41 2004 +0000

    	WebCore side of pasting image data.
    
            Reviewed by kocienda.
    
            * khtml/editing/htmlediting.cpp:
            (PasteImageCommand::PasteImageCommand): new
            (PasteImageCommand::~PasteImageCommand): new
            (PasteImageCommand::impl): new
            * khtml/editing/htmlediting.h:
            (khtml::):
            * khtml/editing/htmlediting_impl.cpp:
            (EditCommandImpl::name): added support for PasteImageCommandID
            (CompositeEditCommandImpl::insertNodeAt): new, factored out from PasteHTMLCommandImpl::apply
            (PasteHTMLCommandImpl::apply): call insertNodeAt
            (PasteImageCommandImpl::PasteImageCommandImpl): new
            (PasteImageCommandImpl::~PasteImageCommandImpl): new
            (PasteImageCommandImpl::apply): new
            * khtml/editing/htmlediting_impl.h:
            * khtml/khtml_part.cpp:
            (KHTMLPart::pasteHTMLString): unchanged
            (KHTMLPart::pasteImage): new
            * khtml/khtml_part.h:
            * kwq/WebCoreBridge.h:
            * kwq/WebCoreBridge.mm:
            (-[WebCoreBridge pasteImageWithURL:]): new
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@6094 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebCore/ChangeLog-2005-08-23 b/WebCore/ChangeLog-2005-08-23
index f788a73..5dec03a 100644
--- a/WebCore/ChangeLog-2005-08-23
+++ b/WebCore/ChangeLog-2005-08-23
@@ -1,3 +1,31 @@
+2004-02-16  Chris Blumenberg  <cblu at apple.com>
+
+	WebCore side of pasting image data.
+
+        Reviewed by kocienda.
+
+        * khtml/editing/htmlediting.cpp:
+        (PasteImageCommand::PasteImageCommand): new
+        (PasteImageCommand::~PasteImageCommand): new
+        (PasteImageCommand::impl): new
+        * khtml/editing/htmlediting.h:
+        (khtml::):
+        * khtml/editing/htmlediting_impl.cpp:
+        (EditCommandImpl::name): added support for PasteImageCommandID
+        (CompositeEditCommandImpl::insertNodeAt): new, factored out from PasteHTMLCommandImpl::apply
+        (PasteHTMLCommandImpl::apply): call insertNodeAt
+        (PasteImageCommandImpl::PasteImageCommandImpl): new
+        (PasteImageCommandImpl::~PasteImageCommandImpl): new
+        (PasteImageCommandImpl::apply): new
+        * khtml/editing/htmlediting_impl.h:
+        * khtml/khtml_part.cpp:
+        (KHTMLPart::pasteHTMLString): unchanged
+        (KHTMLPart::pasteImage): new
+        * khtml/khtml_part.h:
+        * kwq/WebCoreBridge.h:
+        * kwq/WebCoreBridge.mm:
+        (-[WebCoreBridge pasteImageWithURL:]): new
+
 2004-02-16  Darin Adler  <darin at apple.com>
 
         Reviewed by Ken.
diff --git a/WebCore/khtml/editing/htmlediting.cpp b/WebCore/khtml/editing/htmlediting.cpp
index 050c2c8..3141f24 100644
--- a/WebCore/khtml/editing/htmlediting.cpp
+++ b/WebCore/khtml/editing/htmlediting.cpp
@@ -72,6 +72,8 @@ using khtml::MoveSelectionToCommand;
 using khtml::MoveSelectionToCommandImpl;
 using khtml::PasteHTMLCommand;
 using khtml::PasteHTMLCommandImpl;
+using khtml::PasteImageCommand;
+using khtml::PasteImageCommandImpl;
 using khtml::SplitTextNodeCommand;
 using khtml::SplitTextNodeCommandImpl;
 
@@ -543,3 +545,21 @@ DOMString PasteHTMLCommand::HTMLString() const
     return impl()->HTMLString();
 }
 
+//------------------------------------------------------------------------------------------
+// PasteImageCommand
+
+PasteImageCommand::PasteImageCommand(DocumentImpl *document, const DOMString &src) 
+    : CompositeEditCommand(new PasteImageCommandImpl(document, src))
+{
+}
+
+PasteImageCommand::~PasteImageCommand() 
+{
+}
+
+PasteImageCommandImpl *PasteImageCommand::impl() const
+{
+    return static_cast<PasteImageCommandImpl *>(get());
+}
+
+
diff --git a/WebCore/khtml/editing/htmlediting.h b/WebCore/khtml/editing/htmlediting.h
index 82948a9..997e6c1 100644
--- a/WebCore/khtml/editing/htmlediting.h
+++ b/WebCore/khtml/editing/htmlediting.h
@@ -58,6 +58,7 @@ class ModifyTextNodeCommandImpl;
 class RemoveNodeCommandImpl;
 class MoveSelectionToCommandImpl;
 class PasteHTMLCommandImpl;
+class PasteImageCommandImpl;
 class SplitTextNodeCommandImpl;
 
 //------------------------------------------------------------------------------------------
@@ -78,6 +79,7 @@ enum ECommandID {
     RemoveNodeCommandID,
     MoveSelectionToCommandID,
     PasteHTMLCommandID,
+    PasteImageCommandID,
     SplitTextNodeCommandID,
 };
 
@@ -304,6 +306,16 @@ private:
     inline PasteHTMLCommandImpl *impl() const;
 };
 
+class PasteImageCommand : public CompositeEditCommand
+{
+public:
+    PasteImageCommand(DOM::DocumentImpl *document, const DOM::DOMString &src);
+    virtual ~PasteImageCommand();
+        
+private:
+    inline PasteImageCommandImpl *impl() const;
+};
+
 }; // end namespace khtml
 
 #endif
diff --git a/WebCore/khtml/editing/htmlediting_impl.cpp b/WebCore/khtml/editing/htmlediting_impl.cpp
index 0aaf73c..3380e1f 100644
--- a/WebCore/khtml/editing/htmlediting_impl.cpp
+++ b/WebCore/khtml/editing/htmlediting_impl.cpp
@@ -35,6 +35,8 @@
 #include "khtml_selection.h"
 #include "dom/dom_position.h"
 #include "html/html_elementimpl.h"
+#include "html/html_imageimpl.h"
+#include "htmlattrs.h"
 #include "rendering/render_object.h"
 #include "xml/dom_docimpl.h"
 #include "xml/dom_elementimpl.h"
@@ -48,6 +50,7 @@ using DOM::DOMPosition;
 using DOM::DOMString;
 using DOM::ElementImpl;
 using DOM::HTMLElementImpl;
+using DOM::HTMLImageElementImpl;
 using DOM::Node;
 using DOM::NodeImpl;
 using DOM::NodeListImpl;
@@ -83,6 +86,8 @@ using khtml::MoveSelectionToCommand;
 using khtml::MoveSelectionToCommandImpl;
 using khtml::PasteHTMLCommand;
 using khtml::PasteHTMLCommandImpl;
+using khtml::PasteImageCommand;
+using khtml::PasteImageCommandImpl;
 using khtml::SplitTextNodeCommand;
 using khtml::SplitTextNodeCommandImpl;
 
@@ -240,6 +245,9 @@ QString EditCommandImpl::name() const
         case PasteHTMLCommandID:
             return "PasteHTMLCommandImpl";
             break;
+        case PasteImageCommandID:
+            return "PasteImageCommandImpl";
+            break;
         case SplitTextNodeCommandID:
             return "SplitTextNodeCommandImpl";
             break;
@@ -315,6 +323,20 @@ void CompositeEditCommandImpl::insertNodeAfter(DOM::NodeImpl *insertChild, DOM::
     }
 }
 
+void CompositeEditCommandImpl::insertNodeAt(DOM::NodeImpl *insertChild, DOM::NodeImpl *refChild, long offset)
+{
+    if (refChild->caretMinOffset() >= offset) {
+        insertNodeBefore(insertChild, refChild);
+    } 
+    else if (refChild->isTextNode() && refChild->caretMaxOffset() > offset) {
+        splitTextNode(static_cast<TextImpl *>(refChild), offset);
+        insertNodeBefore(insertChild, refChild);
+    } 
+    else {
+        insertNodeAfter(insertChild, refChild);
+    }
+}
+
 void CompositeEditCommandImpl::appendNode(DOM::NodeImpl *parent, DOM::NodeImpl *appendChild)
 {
     AppendNodeCommand cmd(document(), parent, appendChild);
@@ -1198,26 +1220,10 @@ void PasteHTMLCommandImpl::apply()
     } 
     else {
         // HTML tree paste.
-        DOM::NodeImpl *child = firstChild;
-        DOM::NodeImpl *beforeNode = NULL;
-        if (startNode->caretMinOffset() == startOffset) {
-            // Caret is at the beginning of the node. Insert before it.
-            DOM::NodeImpl *nextSibling = child->nextSibling();
-            insertNodeBefore(child, startNode);
-            beforeNode = child;
-            child = nextSibling;
-        } 
-        else if (textNode && textNode->caretMaxOffset() != startOffset) {
-            // Caret is in middle of a text node. Split the text node and insert in between.
-            splitTextNode(textNode, startOffset);
-            beforeNode = textNode->previousSibling();
-        } 
-        else {
-            // Caret is at the end of the node. Insert after it.
-            beforeNode = startNode;
-        }
+        insertNodeAt(firstChild, startNode, startOffset);
         
-        ASSERT(beforeNode);
+        DOM::NodeImpl *child = startNode->nextSibling();
+        DOM::NodeImpl *beforeNode = startNode;
 		
         // Insert the nodes from the clipping.
         while (child) {
@@ -1242,3 +1248,37 @@ void PasteHTMLCommandImpl::apply()
 
     endApply();
 }
+
+PasteImageCommandImpl::PasteImageCommandImpl(DocumentImpl *document, const DOMString &src) 
+: CompositeEditCommandImpl(document)
+{
+    ASSERT(!src.isEmpty());
+    m_src = src; 
+}
+
+PasteImageCommandImpl::~PasteImageCommandImpl()
+{
+}
+
+void PasteImageCommandImpl::apply()
+{
+    beginApply();
+    
+    deleteSelection();
+    
+    KHTMLPart *part = document()->part();
+    ASSERT(part);
+    
+    KHTMLSelection selection = part->selection();
+    ASSERT(!selection.isEmpty());
+    
+    DOM::NodeImpl *startNode = selection.startNode();
+    HTMLImageElementImpl *imageNode = new HTMLImageElementImpl(startNode->docPtr());
+    imageNode->setAttribute(ATTR_SRC, m_src);
+    
+    insertNodeAt(imageNode, startNode, selection.startOffset());
+    selection = KHTMLSelection(imageNode, imageNode->caretMaxOffset());
+    setEndingSelection(selection);
+    
+    endApply();
+}
diff --git a/WebCore/khtml/editing/htmlediting_impl.h b/WebCore/khtml/editing/htmlediting_impl.h
index 67f3322..b236955 100644
--- a/WebCore/khtml/editing/htmlediting_impl.h
+++ b/WebCore/khtml/editing/htmlediting_impl.h
@@ -117,6 +117,7 @@ protected:
     void applyCommand(EditCommand &);
     void insertNodeBefore(DOM::NodeImpl *insertChild, DOM::NodeImpl *refChild);
     void insertNodeAfter(DOM::NodeImpl *insertChild, DOM::NodeImpl *refChild);
+    void insertNodeAt(DOM::NodeImpl *insertChild, DOM::NodeImpl *refChild, long offset);
     void appendNode(DOM::NodeImpl *parent, DOM::NodeImpl *appendChild);
     void removeNode(DOM::NodeImpl *removeChild);
     void splitTextNode(DOM::TextImpl *text, long offset);
@@ -348,6 +349,19 @@ private:
     DOM::DOMString m_HTMLString;
 };
 
+class PasteImageCommandImpl : public CompositeEditCommandImpl
+{
+public:
+    PasteImageCommandImpl(DOM::DocumentImpl *document, const DOM::DOMString &src);
+    virtual ~PasteImageCommandImpl();
+    
+    virtual void apply();
+    
+private:
+    DOM::DOMString m_src;
+};
+
+
 }; // end namespace khtml
 
 #endif
diff --git a/WebCore/khtml/khtml_part.cpp b/WebCore/khtml/khtml_part.cpp
index 57a181a..8f0568c 100644
--- a/WebCore/khtml/khtml_part.cpp
+++ b/WebCore/khtml/khtml_part.cpp
@@ -105,6 +105,7 @@ using khtml::EditCommand;
 using khtml::EditCommand;
 using khtml::InlineTextBox;
 using khtml::PasteHTMLCommand;
+using khtml::PasteImageCommand;
 using khtml::RenderObject;
 using khtml::RenderText;
 using khtml::Tokenizer;
@@ -5152,6 +5153,12 @@ void KHTMLPart::pasteHTMLString(const QString &HTMLString)
     applyCommand(cmd);
 }
 
+void KHTMLPart::pasteImage(const QString &src)
+{
+    EditCommand cmd(PasteImageCommand(d->m_doc, DOMString(src)));
+    applyCommand(cmd);
+}
+
 #if !APPLE_CHANGES
 
 bool KHTMLPart::checkLinkSecurity(const KURL &linkURL,const QString &message, const QString &button)
diff --git a/WebCore/khtml/khtml_part.h b/WebCore/khtml/khtml_part.h
index 1d13d9e..f34a1e0 100644
--- a/WebCore/khtml/khtml_part.h
+++ b/WebCore/khtml/khtml_part.h
@@ -644,6 +644,11 @@ public:
    * Pastes an HTML string at the current caret position.
    */
   void pasteHTMLString(const QString &HTMLString);
+  
+  /**
+   * Pastes a new image node at the current caret position.
+   */
+  void pasteImage(const QString &src);
 
   /**
    * Convenience method to show the document's view.
diff --git a/WebCore/kwq/WebCoreBridge.h b/WebCore/kwq/WebCoreBridge.h
index 4263ef6..738a68e 100644
--- a/WebCore/kwq/WebCoreBridge.h
+++ b/WebCore/kwq/WebCoreBridge.h
@@ -206,6 +206,8 @@ typedef enum {
 - (BOOL)moveCaretToPoint:(NSPoint)point;
 
 - (void)pasteHTMLString:(NSString *)HTMLString;
+- (void)pasteImageWithURL:(NSURL *)URL;
+
 - (void)deleteSelection;
 
 - (BOOL)haveSelection;
diff --git a/WebCore/kwq/WebCoreBridge.mm b/WebCore/kwq/WebCoreBridge.mm
index e18d760..5b2e3cb 100644
--- a/WebCore/kwq/WebCoreBridge.mm
+++ b/WebCore/kwq/WebCoreBridge.mm
@@ -400,6 +400,11 @@ static bool initializedKJS = FALSE;
     _part->pasteHTMLString(QString::fromNSString(HTMLString));
 }
 
+- (void)pasteImageWithURL:(NSURL *)URL
+{
+    _part->pasteImage(QString::fromNSString([URL absoluteString]));
+}
+
 - (void)deleteSelection
 {
     _part->deleteSelection();

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list