Skip to content

Commit

Permalink
Merge version 53.0.2785.157_bb1501
Browse files Browse the repository at this point in the history
This update contains the following changes:
- Implementation of the Widget Inspector
- Support for printToPDF in 'renderer in main-thread' mode
  • Loading branch information
imran1008 committed Feb 16, 2018
2 parents d9feb9d + 838d460 commit c3999f2
Show file tree
Hide file tree
Showing 24 changed files with 7,209 additions and 46 deletions.
34 changes: 33 additions & 1 deletion src/blpwtk2/private/blpwtk2_rendererutil.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
* IN THE SOFTWARE.
*/
#include <vector>

#include <blpwtk2_rendererutil.h>
#include <blpwtk2_blob.h>
Expand All @@ -32,14 +33,16 @@
#include <third_party/WebKit/public/web/WebInputEvent.h>
#include <ui/events/event.h>

#include <content/public/renderer/render_view.h>
#include <third_party/WebKit/public/web/WebView.h>
#include <third_party/WebKit/public/web/WebFrame.h>
#include <skia/ext/platform_canvas.h>
#include <third_party/skia/include/core/SkDocument.h>
#include <third_party/skia/include/core/SkStream.h>
#include <pdf/pdf.h>
#include <ui/gfx/geometry/size.h>
#include <components/printing/renderer/print_web_view_helper.h>

#include <v8.h>

namespace blpwtk2 {

Expand Down Expand Up @@ -185,4 +188,33 @@ void RendererUtil::setLCDTextShouldBlendWithCSSBackgroundColor(int renderViewRou
rv->GetWebView()->setLCDTextShouldBlendWithCSSBackgroundColor(enable);
}


String RendererUtil::printToPDF(
content::RenderView* renderView, const char* propOnIFrame)
{
blpwtk2::String returnVal;
v8::Isolate* isolate = v8::Isolate::GetCurrent();
v8::HandleScope handleScope(isolate);

for (auto* frame = renderView->GetWebView()->mainFrame();
frame;
frame = frame->traverseNext(false)) {

v8::Local<v8::Context> jsContext = frame->mainWorldScriptContext();
v8::Local<v8::Object> winObject = jsContext->Global();

if (winObject->Has(v8::String::NewFromUtf8(isolate, propOnIFrame))) {
std::vector<char> buffer =
printing::PrintWebViewHelper::Get(renderView)->PrintToPDF(
frame->toWebLocalFrame());

returnVal.assign(buffer.data(), buffer.size());
break;
}
}

return returnVal;
}


} // close namespace blpwtk2
4 changes: 4 additions & 0 deletions src/blpwtk2/private/blpwtk2_rendererutil.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include <blpwtk2_config.h>
#include <blpwtk2_webview.h>
#include <blpwtk2_string.h>
#include <content/public/renderer/render_view.h>

namespace content {

Expand All @@ -48,6 +49,9 @@ struct RendererUtil

static void setLCDTextShouldBlendWithCSSBackgroundColor(int renderViewRoutingId,
bool enable);

static String printToPDF(
content::RenderView* renderView, const char* propOnIFrame);
};

} // close namespace blpwtk2
Expand Down
27 changes: 3 additions & 24 deletions src/blpwtk2/private/blpwtk2_webviewimpl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -388,30 +388,9 @@ void WebViewImpl::print()
}

String WebViewImpl::printToPDF(const char *propertyNameOnIframeToPrint)
{
String returnVal;
content::RenderView* rv = content::RenderView::FromRoutingID(d_renderViewRoutingId);
v8::Isolate* isolate = v8::Isolate::GetCurrent();
v8::HandleScope handleScope(isolate);

for (auto *frame = rv->GetWebView()->mainFrame();
frame;
frame = frame->traverseNext(false)) {

v8::Local<v8::Context> jsContext = frame->mainWorldScriptContext();
v8::Local<v8::Object> winObject = jsContext->Global();

if (winObject->Has(v8::String::NewFromUtf8(isolate, propertyNameOnIframeToPrint))) {
std::vector<char> buffer =
printing::PrintWebViewHelper::Get(rv)->PrintToPDF(
frame->toWebLocalFrame());

returnVal.assign(buffer.data(), buffer.size());
break;
}
}

return returnVal;
{
auto* renderView = content::RenderView::FromRoutingID(d_renderViewRoutingId);
return RendererUtil::printToPDF(renderView, propertyNameOnIframeToPrint);
}

void WebViewImpl::drawContentsToBlob(Blob *blob, const DrawParams& params)
Expand Down
14 changes: 3 additions & 11 deletions src/blpwtk2/private/blpwtk2_webviewproxy.cc
Original file line number Diff line number Diff line change
Expand Up @@ -38,19 +38,11 @@
#include <base/bind.h>
#include <base/message_loop/message_loop.h>
#include <cc/trees/proxy_main.h>
#include <content/browser/renderer_host/web_input_event_aura.h>
#include <content/public/browser/native_web_keyboard_event.h>
#include <content/public/renderer/render_view.h>
#include <content/renderer/render_view_impl.h>
#include <third_party/WebKit/public/web/WebView.h>
#include <third_party/WebKit/public/web/WebFrame.h>
#include <third_party/WebKit/public/web/WebInputEvent.h>
#include <skia/ext/platform_canvas.h>
#include <third_party/skia/include/core/SkDocument.h>
#include <third_party/skia/include/core/SkStream.h>
#include <pdf/pdf.h>
#include <ui/events/event.h>
#include <ui/gfx/geometry/size.h>

#include <dwmapi.h>
#include <windows.h>
Expand Down Expand Up @@ -370,9 +362,9 @@ void WebViewProxy::print()
}

String WebViewProxy::printToPDF(const char *propertyNameOnIframeToPrint)
{
// NOT YET IMPLEMENTED
return String();
{
auto* renderView = content::RenderView::FromRoutingID(d_renderViewRoutingId);
return RendererUtil::printToPDF(renderView, propertyNameOnIframeToPrint);
}

static inline SkScalar distance(SkScalar x, SkScalar y)
Expand Down
2 changes: 1 addition & 1 deletion src/build/make_devkit
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ def addGenFiles(doGnBuild):


def main(args):
version = "bb1402" # SET BB VERSION NUMBER HERE
version = "bb1501" # SET BB VERSION NUMBER HERE

outDir = None
doClean = True
Expand Down
5 changes: 4 additions & 1 deletion src/third_party/WebKit/Source/devtools/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ devtools_modules_js_files =
gypi_values.devtools_temp_storage_shared_worker_js_files +
gypi_values.devtools_timeline_model_js_files +
gypi_values.devtools_timeline_js_files +
gypi_values.devtools_ui_lazy_js_files
gypi_values.devtools_ui_lazy_js_files +
gypi_values.devtools_widgetinspector_js_files

all_devtools_files =
gypi_values.devtools_cm_css_files + gypi_values.devtools_cm_js_files +
Expand Down Expand Up @@ -165,6 +166,7 @@ action("generate_devtools_grd") {
resources_out_dir + "timeline_module.js",
resources_out_dir + "ui_lazy_module.js",
resources_out_dir + "devtools_extension_api.js",
resources_out_dir + "widget_inspector_module.js"
]
static_files_args = [] # Nothing needed for this
}
Expand Down Expand Up @@ -300,6 +302,7 @@ action("build_applications") {
resources_out_dir + "timeline_model_module.js",
resources_out_dir + "timeline_module.js",
resources_out_dir + "ui_lazy_module.js",
resources_out_dir + "widget_inspector_module.js"
]

debug_mode = "0"
Expand Down
11 changes: 11 additions & 0 deletions src/third_party/WebKit/Source/devtools/devtools.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -405,6 +405,16 @@
'front_end/audits/AuditRules.js',
'front_end/audits/AuditsPanel.js',
],
'devtools_widgetinspector_js_files':[
'front_end/widget_inspector/WidgetInspectorPanel.js',
'front_end/widget_inspector/mainViewWidgetInspector.css',
'front_end/widget_inspector/widgetTreeOutline.css',
'front_end/widget_inspector/WidgetTreeElement.js',
'front_end/widget_inspector/WidgetTreeOutline.js',
'front_end/widget_inspector/WidgetTreeElementHighlighter.js',
'front_end/widget_inspector/WidgetPropertiesWidget.js',
'front_end/widget_inspector/WidgetMethodsWidget.js'
],
'devtools_cm_modes_js_files': [
'front_end/cm_modes/clike.js',
'front_end/cm_modes/coffeescript.js',
Expand Down Expand Up @@ -796,6 +806,7 @@
'<@(devtools_accessibility_js_files)',
'<@(devtools_animation_js_files)',
'<@(devtools_audits_js_files)',
'<@(devtools_widgetinspector_js_files)',
'<@(devtools_cm_modes_js_files)',
'<@(devtools_components_lazy_js_files)',
'<@(devtools_console_js_files)',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,14 @@
* @param {boolean=} ignoreHasOwnProperty
* @param {!Array.<!WebInspector.RemoteObjectProperty>=} extraProperties
*/
WebInspector.ObjectPropertiesSection = function(object, title, emptyPlaceholder, ignoreHasOwnProperty, extraProperties)
WebInspector.ObjectPropertiesSection = function(object, title, emptyPlaceholder, ignoreHasOwnProperty, extraProperties, hideOriginalProperties)
{
this._object = object;
this._editable = true;
TreeOutlineInShadow.call(this);
this.hideOverflow();
this.setFocusable(false);
this._objectTreeElement = new WebInspector.ObjectPropertiesSection.RootElement(object, emptyPlaceholder, ignoreHasOwnProperty, extraProperties);
this._objectTreeElement = new WebInspector.ObjectPropertiesSection.RootElement(object, emptyPlaceholder, ignoreHasOwnProperty, extraProperties, hideOriginalProperties);
this.appendChild(this._objectTreeElement);
if (typeof title === "string" || !title)
this.element.createChild("span").textContent = title || "";
Expand All @@ -51,6 +51,13 @@ WebInspector.ObjectPropertiesSection = function(object, title, emptyPlaceholder,
this.registerRequiredCSS("components/objectValue.css");
this.registerRequiredCSS("components/objectPropertiesSection.css");
this.rootElement().childrenListElement.classList.add("source-code", "object-properties-section");

//WidgetInspector-specific
if(hideOriginalProperties === true){
this.rootElement().childrenListElement.classList.add("hide-children");
this.rootElement().treeOutline.element.classList.add("hide-children");
}

}

/** @const */
Expand Down Expand Up @@ -311,6 +318,17 @@ WebInspector.ObjectPropertyTreeElement.prototype = {
if (this.property.value) {
this.valueElement = WebInspector.ObjectPropertiesSection.createValueElementWithCustomSupport(this.property.value, this.property.wasThrown, this.listItemElement);
this.valueElement.addEventListener("contextmenu", this._contextMenuFired.bind(this, this.property), false);

//WidgetInspector-specific
// Check for WidgetInspector's EditProperties tab
// property.newProp set in WidgetPropertiesWidget.js
if(this.property.newProp){
this.listItemElement.classList.add("show-child");
if (this.property.value.type.toLowerCase() !== "object") {
this.listItemElement.classList.add("widget-prop-not-obj");
}
}

} else if (this.property.getter) {
this.valueElement = WebInspector.ObjectPropertyTreeElement.createRemoteObjectAccessorPropertySpan(this.property.parentObject, [this.property.name], this._onInvokeGetterClick.bind(this));
} else {
Expand Down Expand Up @@ -439,10 +457,28 @@ WebInspector.ObjectPropertyTreeElement.prototype = {
{
var property = WebInspector.RemoteObject.toCallArgument(this.property.symbol || this.property.name);
expression = expression.trim();
if (expression)
this.property.parentObject.setPropertyValue(property, expression, callback.bind(this));
else
if (expression) {
//WidgetInspector-specific
// checks if this is a property in the WidgetInspector's EditProperties tab, and if so, use a different function
var inspectorMap = WebInspector.WidgetInspectorPanel.instance()._widgetInspectorMap;
var editableLayoutProp = false;
inspectorMap.callFunction("function() { return this.editableLayoutProp('" + property.value.split(" ")[0] + "'); }", [{}],
function (result, wasThrown) {
var isEditable = (result.description !== "null");
if (this.property.newProp && this.property.widgetElement) {
WebInspector.WidgetPropertiesWidget.setPropertyValue(this.property.widgetElement, property, expression, callback.bind(this));
}
else if (isEditable) {
WebInspector.WidgetPropertiesWidget.setPropertyValue(this.property.widgetElement, property, expression, callback.bind(this));
}
else {
this.property.parentObject.setPropertyValue(property, expression, callback.bind(this));
}
}.bind(this));
}
else {
this.property.parentObject.deleteProperty(property, callback.bind(this));
}

/**
* @param {?Protocol.Error} error
Expand All @@ -454,7 +490,6 @@ WebInspector.ObjectPropertyTreeElement.prototype = {
this.update();
return;
}

if (!expression) {
// The property was deleted, so remove this tree element.
this.parent.removeChild(this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,19 @@
.object-properties-section-root-element.expanded::before {
-webkit-mask-position: -20px -97px !important;
}

.hide-children > .object-properties-section-root-element {
display:none !important;
}

.hide-children > .children.expanded {
display: inline-table;
}

.hide-children > .children.expanded > .parent:not(.show-child) {
display:none;
}

.widget-prop-not-obj::before {
display:none;
}
Original file line number Diff line number Diff line change
Expand Up @@ -1120,6 +1120,10 @@ WebInspector.ElementsPanel.DOMNodeRevealer.prototype = {
*/
reveal: function(node)
{
var widgetInspectorPanel = WebInspector.WidgetInspectorPanel.instance();
if (WebInspector.inspectorView.currentPanel() === widgetInspectorPanel) {
return; // do not switch to Elements panel if revealing from WidgetInspector panel
}
var panel = WebInspector.ElementsPanel.instance();
panel._pendingNodeReveal = true;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,9 @@ WebInspector.InspectElementModeController.prototype = {
_setMode: function(mode)
{
this._mode = mode;
for (var domModel of WebInspector.DOMModel.instances())
for (var domModel of WebInspector.DOMModel.instances()) {
domModel.setInspectMode(mode);
}

if (this._layoutEditorButton) {
this._layoutEditorButton.setEnabled(!this.isInInspectElementMode());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
{ "name": "profiler" },
{ "name": "resources", "condition": "!v8only" },
{ "name": "audits", "condition": "!v8only" },
{ "name": "widget_inspector", "condition": "!v8only" },
{ "name": "devices", "condition": "!v8only" },
{ "name": "security", "condition": "!v8only" },
{ "name": "console" },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1077,8 +1077,9 @@ WebInspector.ScopeRef = function(number, callFrameId)
* @param {boolean=} wasThrown
* @param {boolean=} synthetic
* @param {?WebInspector.RemoteObject=} symbol
* @param {boolean=} hidden
*/
WebInspector.RemoteObjectProperty = function(name, value, enumerable, writable, isOwn, wasThrown, symbol, synthetic)
WebInspector.RemoteObjectProperty = function(name, value, enumerable, writable, isOwn, wasThrown, symbol, synthetic, hidden)
{
this.name = name;
if (value !== null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,3 +125,11 @@ ol.tree-outline:focus li.selected * {
.tree-outline ol.children.expanded {
display: block;
}

.tree-outline.hide-children ol.children.expanded {
display: list-item;
}

.tree-outline.hide-children li {
display: list-item;
}
12 changes: 12 additions & 0 deletions src/third_party/WebKit/Source/devtools/front_end/ui/treeoutline.js
Original file line number Diff line number Diff line change
Expand Up @@ -511,6 +511,18 @@ TreeElement.prototype = {
this.setExpandable(true);
child.parent = this;

// update child layout properties for editing
var propsFound = {};
if (this.property && this.property.widgetElement && child.property && !propsFound[child.property.name]) {
child.property.widgetElement = this.property.widgetElement; // propogate the widgetElement to properties
propsFound[child.property.name] = true;
var inspectorMap = WebInspector.WidgetInspectorPanel.instance()._widgetInspectorMap;
inspectorMap.callFunction("function() { return this.clientPropertyToServerProperty('', " + child.property.name + "); }", [{}],
function (result, wasThrown) {
child.property.name = child.property.name + " (" + result.description + ")";
});
}

if (this.treeOutline)
this.treeOutline._bindTreeElement(child);
for (var current = child.firstChild(); this.treeOutline && current; current = current.traverseNextTreeElement(false, child, true))
Expand Down
Loading

0 comments on commit c3999f2

Please sign in to comment.