WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
NEW
105106
Add SPI to WebKit1 WebFrame for hit testing
https://bugs.webkit.org/show_bug.cgi?id=105106
Summary
Add SPI to WebKit1 WebFrame for hit testing
Alice Liu
Reported
2012-12-15 13:40:17 PST
WebFrame doesn't have any hit testing-related API. And it doesn't have way to convert that DOMNode to a JSValueRef. This patch adds that functionality to WebFrame, as SPI in WebFramePrivate. I'm not sure if it should be SPI or API. i could use some feedback on that, especially. <
rdar://problem/12880594
>
Attachments
patch
(3.04 KB, patch)
2012-12-15 13:46 PST
,
Alice Liu
no flags
Details
Formatted Diff
Diff
patch created from correct directory level
(3.10 KB, patch)
2012-12-15 14:18 PST
,
Alice Liu
sam
: review-
buildbot
: commit-queue-
Details
Formatted Diff
Diff
patch fixed name
(3.12 KB, patch)
2012-12-15 22:57 PST
,
Alice Liu
no flags
Details
Formatted Diff
Diff
patch, just elementAtPoint
(10.24 KB, patch)
2012-12-18 01:14 PST
,
Alice Liu
no flags
Details
Formatted Diff
Diff
patch
(10.24 KB, patch)
2012-12-18 01:26 PST
,
Alice Liu
mitz: review+
Details
Formatted Diff
Diff
Show Obsolete
(4)
View All
Add attachment
proposed patch, testcase, etc.
Alice Liu
Comment 1
2012-12-15 13:46:49 PST
Created
attachment 179613
[details]
patch
Alice Liu
Comment 2
2012-12-15 14:18:53 PST
Created
attachment 179616
[details]
patch created from correct directory level
mitz
Comment 3
2012-12-15 14:29:51 PST
Comment on
attachment 179616
[details]
patch created from correct directory level View in context:
https://bugs.webkit.org/attachment.cgi?id=179616&action=review
> Source/WebKit/mac/ChangeLog:3 > + Add API or SPI to WebFrame for hit testing and node conversion to JSValueRef
It’s odd to have these two APIs lumped together into one bug and one patch, even if your intentions are to use them together. Please file a separate bug for one of these.
> Source/WebKit/mac/WebView/WebFrame.mm:1505 > + Frame* coreFrame = _private->coreFrame; > + if (!coreFrame) > + return nil; > + return [[[WebElementDictionary alloc] initWithHitTestResult:coreFrame->eventHandler()->hitTestResultAtPoint(IntPoint(point), false, true)] autorelease];
This does a poor job for non-WebHTMLView frames (the only built-in example of which that is left is WebPDFView). You can see how -[WebView _elementAtWindowPoint:] handles this more gracefully and generally. I’d say it’s OK to go with this simplified version, but a generic version would be fine, too.
> Source/WebKit/mac/WebView/WebFrame.mm:1508 > +- (JSValueRef)jsWrapper:(DOMNode *)node forWorld:(WebScriptWorld *)world
I think a name like -jsWrapperForNode:inWorld: would be more Cocoa-y and accurate.
Build Bot
Comment 4
2012-12-15 15:26:39 PST
Comment on
attachment 179616
[details]
patch created from correct directory level
Attachment 179616
[details]
did not pass mac-ews (mac): Output:
http://queues.webkit.org/results/15366188
Sam Weinig
Comment 5
2012-12-15 18:29:21 PST
Comment on
attachment 179616
[details]
patch created from correct directory level I agree with mitz.
Alice Liu
Comment 6
2012-12-15 22:57:42 PST
Created
attachment 179641
[details]
patch fixed name
Alice Liu
Comment 7
2012-12-18 01:07:08 PST
(In reply to
comment #3
)
> (From update of
attachment 179616
[details]
) > View in context:
https://bugs.webkit.org/attachment.cgi?id=179616&action=review
> > > Source/WebKit/mac/ChangeLog:3 > > + Add API or SPI to WebFrame for hit testing and node conversion to JSValueRef > > It’s odd to have these two APIs lumped together into one bug and one patch, even if your intentions are to use them together. Please file a separate bug for one of these. >
filed
bug 105262
for node conversion. re-designating this bug as hit-testing-related only.
> > Source/WebKit/mac/WebView/WebFrame.mm:1505 > > + Frame* coreFrame = _private->coreFrame; > > + if (!coreFrame) > > + return nil; > > + return [[[WebElementDictionary alloc] initWithHitTestResult:coreFrame->eventHandler()->hitTestResultAtPoint(IntPoint(point), false, true)] autorelease]; > > This does a poor job for non-WebHTMLView frames (the only built-in example of which that is left is WebPDFView). You can see how -[WebView _elementAtWindowPoint:] handles this more gracefully and generally. I’d say it’s OK to go with this simplified version, but a generic version would be fine, too. >
Thanks for pointing that out. The key thing i heard there was that you are OK with this simplified version.
> > Source/WebKit/mac/WebView/WebFrame.mm:1508 > > +- (JSValueRef)jsWrapper:(DOMNode *)node forWorld:(WebScriptWorld *)world > > I think a name like > -jsWrapperForNode:inWorld: > would be more Cocoa-y and accurate.
addressed in patch for
bug 105262
. thank you. -alice
Alice Liu
Comment 8
2012-12-18 01:14:23 PST
Created
attachment 179897
[details]
patch, just elementAtPoint
Alice Liu
Comment 9
2012-12-18 01:26:48 PST
Created
attachment 179900
[details]
patch
Alice Liu
Comment 10
2012-12-18 01:49:55 PST
Are the failures on the chromium-ews and mac-ews bots expected? they have nothing to do with applied patch.
mitz
Comment 11
2012-12-18 10:01:06 PST
Comment on
attachment 179900
[details]
patch Thanks for splitting this up and adding an API test! A few suggestions below.
mitz
Comment 12
2012-12-18 10:02:15 PST
(In reply to
comment #11
)
> (From update of
attachment 179900
[details]
) > Thanks for splitting this up and adding an API test! A few suggestions below.
The review form ate my suggestions. I’m going to try again.
mitz
Comment 13
2012-12-18 10:02:48 PST
Comment on
attachment 179900
[details]
patch View in context:
https://bugs.webkit.org/attachment.cgi?id=179900&action=review
> Source/WebKit/mac/WebView/WebFramePrivate.h:141 > +- (NSDictionary *)elementAtPoint:(NSPoint)point;
Though we’re not terribly consistent about this, many of our SPI methods are prefixed with an underscore. I would prefer that.
mitz
Comment 14
2012-12-18 10:07:38 PST
Comment on
attachment 179900
[details]
patch View in context:
https://bugs.webkit.org/attachment.cgi?id=179900&action=review
> Tools/TestWebKitAPI/Tests/mac/ElementAtPointInWebFrame.mm:32 > +@interface ElementAtPointFrameLoadDelegate : NSObject { > +}
I think you can leave off the braces when there are no ivars.
> Tools/TestWebKitAPI/Tests/mac/ElementAtPointInWebFrame.mm:50 > + RetainPtr<WebView> webView(AdoptNS, [[WebView alloc] initWithFrame:NSMakeRect(0, 0, 120, 200) frameName:nil groupName:nil]);
One of the features of this SPI (which separates it from the elementFromPoint DOM API) is that it can hit test outside the frame bounds. It would be neat if you e.g. made the frame narrower and then hit tested a point whose x coordinate was beyond the frame’s width.
> Tools/TestWebKitAPI/Tests/mac/ElementAtPointInWebFrame.mm:63 > + EXPECT_TRUE([[domElement getAttribute:@"name"] isEqualToString:@"first"]);
Rather than EXPECT_TRUE, you should use the macro that compares NSStrings, EXPECT_WK_STREQ.
> Tools/TestWebKitAPI/Tests/mac/ElementAtPointInWebFrame.mm:67 > + EXPECT_TRUE([[domElement getAttribute:@"name"] isEqualToString:@"second"]);
Ditto.
> Tools/TestWebKitAPI/Tests/mac/ElementAtPointInWebFrame.mm:71 > + EXPECT_TRUE([[domElement tagName] isEqualToString:@"BODY"]);
Ditto.
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug