Hi: I'm trying to figure out the DOM element at a certain (x,y) point. To do this I'm using Document::prepareMouseEvent() which seems to return what I expect - most of the time. Specifically <input type="text"> nodes are returned as <div>#text</div>. It appears to me as though I'm getting the internal representation of the text input element. How can I get the "real" element at a given location? Thanks.
webkit-help is the list you want, not webkit-dev. But to answer your question, see Document::elementAtPoint(x, y). -eric On Wed, Aug 12, 2009 at 12:32 AM, Chris Mumford <cmumford@cmumford.com>wrote:
Hi:
I'm trying to figure out the DOM element at a certain (x,y) point. To do this I'm using Document::prepareMouseEvent() which seems to return what I expect - most of the time. Specifically <input type="text"> nodes are returned as <div>#text</div>. It appears to me as though I'm getting the internal representation of the text input element. How can I get the "real" element at a given location?
Thanks.
_______________________________________________ webkit-dev mailing list webkit-dev@lists.webkit.org http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev
HitTest can also help here, probably. APIs for it are port dependent, iirc. On Wed, Aug 12, 2009 at 3:41 AM, Eric Seidel<eric@webkit.org> wrote:
webkit-help is the list you want, not webkit-dev. But to answer your question, see Document::elementAtPoint(x, y). -eric On Wed, Aug 12, 2009 at 12:32 AM, Chris Mumford <cmumford@cmumford.com> wrote:
Hi:
I'm trying to figure out the DOM element at a certain (x,y) point. To do this I'm using Document::prepareMouseEvent() which seems to return what I expect - most of the time. Specifically <input type="text"> nodes are returned as <div>#text</div>. It appears to me as though I'm getting the internal representation of the text input element. How can I get the "real" element at a given location?
Thanks.
_______________________________________________ webkit-dev mailing list webkit-dev@lists.webkit.org http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev
_______________________________________________ webkit-dev mailing list webkit-dev@lists.webkit.org http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev
-- --Antonio Gomes
How can i get the background-image url of an element node? Usually, I can read the "background-image" attribute of the node. But if it is written in the style sheet, there is no explicit "background-image" attribute in the element's attributes list. Instead, there is a "class" attribute. I have also tried to get some information from RenderStyle. But it can only provide an interface hasBackgroundImage() . How can I get it? It seems not to be an elegant way that we firstly read the style class abtribute and then parse the style sheet file. Could WebKit provides an expandedAttributes() interface which can return all the attributes by simply expanding the class attribute with those written in the style sheet? Thanks! _________________________________________________________________ 您可以借助 Windows Live 整理、编辑和共享您的照片。 http://www.microsoft.com/china/windows/windowslive/products/photo-gallery-ed...
This is really a question for the webkit-help list. The solution is to call getComputedStyle(). Simon On Aug 12, 2009, at 8:52 AM, TianShijun wrote:
How can i get the background-image url of an element node?
Usually, I can read the "background-image" attribute of the node. But if it is written in the style sheet, there is no explicit "background-image" attribute in the element's attributes list. Instead, there is a "class" attribute.
I have also tried to get some information from RenderStyle. But it can only provide an interface hasBackgroundImage() .
How can I get it? It seems not to be an elegant way that we firstly read the style class abtribute and then parse the style sheet file. Could WebKit provides an expandedAttributes() interface which can return all the attributes by simply expanding the class attribute with those written in the style sheet?
Hi Simon, I cannot find this method in either Node.h or RenderStyle.h. I wonder that why we cannot get the attribute of an element node just by invoking some member function of the node? CC: webkit-dev@lists.webkit.org From: simon.fraser@apple.com To: tiansjun@hotmail.com Subject: Re: [webkit-dev] How to get the background image of a node? Date: Wed, 12 Aug 2009 08:55:53 -0700 This is really a question for the webkit-help list. The solution is to call getComputedStyle(). Simon On Aug 12, 2009, at 8:52 AM, TianShijun wrote:How can i get the background-image url of an element node? Usually, I can read the "background-image" attribute of the node. But if it is written in the style sheet, there is no explicit "background-image" attribute in the element's attributes list. Instead, there is a "class" attribute. I have also tried to get some information from RenderStyle. But it can only provide an interface hasBackgroundImage() . How can I get it? It seems not to be an elegant way that we firstly read the style class abtribute and then parse the style sheet file. Could WebKit provides an expandedAttributes() interface which can return all the attributes by simply expanding the class attribute with those written in the style sheet? _________________________________________________________________ 您可以借助 Windows Live 整理、编辑和共享您的照片。 http://www.microsoft.com/china/windows/windowslive/products/photo-gallery-ed...
2009/8/12 TianShijun <tiansjun@hotmail.com>
Hi Simon, I cannot find this method in either Node.h or RenderStyle.h. I wonder that why we cannot get the attribute of an element node just by invoking some member function of the node?
Line 440 of Node.h virtual RenderStyle* computedStyle(); This gives you renderStyle. If you do position.computedStyle(), you'll obtain CSSComputedStyleDeclaration. A node could be anything, so you need to first check whether it's an HTML element or not. You can do so by calling node->isElementNode(). Once node->isElementNode() returned, true, you cast the node into Element and call getAttribute there as in: static_cast<Element*>(node)->getAttribute(qualifiedName) *Please post the questions like this on webkit-help.* Ryosuke
participants (6)
-
Chris Mumford
-
Eric Seidel
-
Ryosuke Niwa
-
Simon Fraser
-
TianShijun
-
tonikitoo (Antonio Gomes)