Bug 129441 - Web Inspector: highlight data for overlay should use protocol type builders
Summary: Web Inspector: highlight data for overlay should use protocol type builders
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Web Inspector (show other bugs)
Version: 528+ (Nightly build)
Hardware: All All
: P2 Normal
Assignee: Brian Burg
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2014-02-27 11:25 PST by BJ Burg
Modified: 2015-01-18 16:05 PST (History)
7 users (show)

See Also:


Attachments
Patch (52.62 KB, patch)
2015-01-17 12:05 PST, Brian Burg
no flags Details | Formatted Diff | Diff
Patch (54.95 KB, patch)
2015-01-17 17:02 PST, Brian Burg
no flags Details | Formatted Diff | Diff
EWS Round 2 (55.52 KB, patch)
2015-01-17 17:52 PST, Brian Burg
no flags Details | Formatted Diff | Diff
EWS Round 3 (56.05 KB, patch)
2015-01-17 20:32 PST, Brian Burg
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description BJ Burg 2014-02-27 11:25:17 PST
Right now, InspectorOverlay::buildObjectForHighlightedNode and its helper methods manually build up InspectorObjects. This makes it really hard to tell what the shape of the data is without looking at the code that builds it. It also is a very thin abstraction between the code on the overlay page and its backend.

I suggest we add a new Overlay domain that contains these types. This will give us type builders for free. At a later time, we could easily convert the InspectorOverlay::evaluateInOverlay calls into protocol commands.
Comment 1 Radar WebKit Bug Importer 2014-02-27 11:26:02 PST
<rdar://problem/16186822>
Comment 2 Brian Burg 2015-01-17 12:05:58 PST
Created attachment 244843 [details]
Patch
Comment 3 Timothy Hatcher 2015-01-17 13:09:27 PST
Comment on attachment 244843 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=244843&action=review

Looks good! There might be one issue with the ElementData change.

> Source/WebCore/inspector/InspectorController.h:55
> +namespace Protocol { namespace OverlayTypes {
> +class NodeHighlightData;
> +} }
>  }

Some newlines would help. (Unless this is the common style now.)

> Source/WebCore/inspector/InspectorOverlay.cpp:719
> -    elementInfo->setString("nodeWidth", String::number(modelObject ? adjustForAbsoluteZoom(modelObject->pixelSnappedOffsetWidth(), *modelObject) : boundingBox.width()));
> -    elementInfo->setString("nodeHeight", String::number(modelObject ? adjustForAbsoluteZoom(modelObject->pixelSnappedOffsetHeight(), *modelObject) : boundingBox.height()));
> -    
> +    auto sizeObject = Inspector::Protocol::OverlayTypes::Size::create()
> +        .setWidth(modelObject ? adjustForAbsoluteZoom(modelObject->pixelSnappedOffsetWidth(), *modelObject) : boundingBox.width())
> +        .setHeight(modelObject ? adjustForAbsoluteZoom(modelObject->pixelSnappedOffsetHeight(), *modelObject) : boundingBox.height())
> +        .release();
> +    elementData->setSize(WTF::move(sizeObject));

Doesn't this require a change in the OverlayPage script? nodeWidth and nodeHeight is now size.width and size.height, right?

> Source/WebCore/inspector/InspectorOverlay.cpp:870
> +        .setDeviceScaleFactor(m_page.deviceScaleFactor())

I'm surprised we need to pass this along.

> Source/WebCore/inspector/InspectorOverlay.h:49
> +namespace Protocol {
> +namespace OverlayTypes {
> +class NodeHighlightData;
> +}
> +}

Like this.
Comment 4 Timothy Hatcher 2015-01-17 13:10:28 PST
Comment on attachment 244843 [details]
Patch

Never mind, I didn't see the InspectorOverlayPage.js changes on the first pass.
Comment 5 Brian Burg 2015-01-17 17:02:27 PST
Created attachment 244846 [details]
Patch
Comment 6 Brian Burg 2015-01-17 17:52:10 PST
Created attachment 244847 [details]
EWS Round 2
Comment 7 Brian Burg 2015-01-17 20:32:13 PST
Created attachment 244851 [details]
EWS Round 3
Comment 8 Brian Burg 2015-01-18 09:07:03 PST
Committed r178631: <http://trac.webkit.org/changeset/178631>
Comment 9 Brian Burg 2015-01-18 09:07:34 PST
(In reply to comment #8)
> Committed r178631: <http://trac.webkit.org/changeset/178631>

Includes windows and GTK build fixes.
Comment 10 Daniel Bates 2015-01-18 16:05:21 PST
(In reply to comment #8)
> Committed r178631: <http://trac.webkit.org/changeset/178631>

This broke the iOS build.

Committed build fix in <http://trac.webkit.org/changeset/178636>.