hello
I want to know how to retrieve the properties (the source, height, width ...) an image loaded with gecko (gecko sdk delphi). xpcom help. Here's the function Add:
procedure inserer_image()
var
ss,src,dest,dest1:string;
img,br: nsIDOMElement;
s1,s2: IInterfacedString;
EditorDocument: nsIDOMNSHTMLDocument;
begin
//Insérer un Elèment image
s1:=NewString('img');
img:=mDocument.CreateElement(s1.AString);
//border
s1:=NewString('border');
s2:=NewString(FormValideEditionImage.Edit_LargeurBordure.text);
img.SetAttribute(s1.AString,s2.AString);
//
s1:=NewString('src');
s2:=NewString('file:///'+c:/image.png);
img.SetAttribute(s1.AString,s2.AString);
......
InsertNode(img);
end;
procedure TForm6.InsertNode(const aInsertNode: nsIDOMElement);
var
mDocument: nsIDOMDocument;
Sel: nsISelection;
Range: nsIDOMRange;
Container: nsIDOMNode;
DocR: nsIDOMDocumentRange;
iPos: PRUint32;
NodeValue: IInterfacedString;
AfterNode: nsIDOMNode;
BeforeNode: nsIDOMNode;
TextNode: nsIDOMNode;
TextBefore,TextAfter: WideString;
begin
// récupèrer la l'objet sélectioné
Sel:=GeckoBrowser1.ContentWindow.GetSelection;
Range:=Sel.GetRangeAt(0); // le premier élément selectioné
// tout déselectionner
sel.RemoveAllRanges();
// supprimer le contenu de la sélection en cours du document
range.deleteContents();
// obtenir l'alocation de la sélection courante
Container:=Range.StartContainer;
ipos:=Range.startOffset;
// faire une nouvelle Range pour la nouvelle sélection
DocR:=mDocument as nsIDOMDocumentRange;
Range:=DocR.CreateRange;
if (Container.NodeType=3) and (aInsertNode.NodeType=3) then
begin
// if we insert text in a textnode, do optimized insertion
NodeValue:=NewString;
aInsertNode.GetNodeValue(NodeValue.AString);
(Container as nsIDOMCharacterData).InsertData(iPos, NodeValue.AString);
// put cursor after inserted text
Range.SetEnd(Container, iPos+(aInsertNode as nsIDOMCharacterData).Length);
Range.SetStart(Container, iPos+(aInsertNode as nsIDOMCharacterData).Length);
....
....
// insert the 3 new nodes before the old one
Container.InsertBefore(AfterNode, TextNode);
Container.InsertBefore(aInsertNode, AfterNode);
Container.InsertBefore(BeforeNode, aInsertNode);
// remove the old node
Container.RemoveChild(TextNode);
end
else
begin
// else simply insert the node
AfterNode:=Container.ChildNodes.Item(ipos);
Container.InsertBefore(aInsertNode, AfterNode);
end;
Range.SetEnd(AfterNode, 0);
Range.SetStart(AfterNode, 0);
end;
Sel.AddRange(Range);
end;
I want to retrieve the html code of the image selected when I double click on the image.
Have you a track to solve this problem (in Delphi or other programming language)
Thank you