Commit 18f5a136 authored by paulmeyer's avatar paulmeyer Committed by Commit bot

Fix for MIME handler bug. The bug resulted from a previous bugfix...

Fix for MIME handler bug. The bug resulted from a previous bugfix (https://codereview.chromium.org/939443002/) that added a conversion from logical to physical units to fix a similar sizing bug with other guestviews. However, MIME handler guests never use logical pixels, so this conversion broke their sizing when they are created in a zoomed embedder.

This patch adds a more robust method of checking whether sizes are provided in logical or physical units, and all cases are handled appropriately.

BUG=462194

Review URL: https://codereview.chromium.org/972193003

Cr-Commit-Position: refs/heads/master@{#318948}
parent 2b35c8e3
...@@ -39,6 +39,10 @@ bool GuestViewInternalCreateGuestFunction::RunAsync() { ...@@ -39,6 +39,10 @@ bool GuestViewInternalCreateGuestFunction::RunAsync() {
return false; return false;
} }
// Add flag to |create_params| to indicate that the element size is specified
// in logical units.
create_params->SetBoolean(guestview::kElementSizeIsLogical, true);
guest_view_manager->CreateGuest(view_type, guest_view_manager->CreateGuest(view_type,
sender_web_contents, sender_web_contents,
*create_params, *create_params,
......
...@@ -754,9 +754,21 @@ void GuestViewBase::SetUpSizing(const base::DictionaryValue& params) { ...@@ -754,9 +754,21 @@ void GuestViewBase::SetUpSizing(const base::DictionaryValue& params) {
double element_width = 0.0; double element_width = 0.0;
params.GetDouble(guestview::kElementHeight, &element_height); params.GetDouble(guestview::kElementHeight, &element_height);
params.GetDouble(guestview::kElementWidth, &element_width); params.GetDouble(guestview::kElementWidth, &element_width);
// Convert the element size from logical pixels to physical pixels.
int normal_height = LogicalPixelsToPhysicalPixels(element_height); // If the element size was provided in logical units (versus physical), then
int normal_width = LogicalPixelsToPhysicalPixels(element_width); // it will be converted to physical units.
bool element_size_is_logical = false;
params.GetBoolean(guestview::kElementSizeIsLogical, &element_size_is_logical);
int normal_height = 0;
int normal_width = 0;
if (element_size_is_logical) {
// Convert the element size from logical pixels to physical pixels.
normal_height = LogicalPixelsToPhysicalPixels(element_height);
normal_width = LogicalPixelsToPhysicalPixels(element_width);
} else {
normal_height = lround(element_height);
normal_width = lround(element_width);
}
SetSizeParams set_size_params; SetSizeParams set_size_params;
set_size_params.enable_auto_size.reset(new bool(auto_size_enabled)); set_size_params.enable_auto_size.reset(new bool(auto_size_enabled));
......
...@@ -14,6 +14,7 @@ const char kAttributeMinHeight[] = "minheight"; ...@@ -14,6 +14,7 @@ const char kAttributeMinHeight[] = "minheight";
const char kAttributeMinWidth[] = "minwidth"; const char kAttributeMinWidth[] = "minwidth";
const char kElementWidth[] = "elementWidth"; const char kElementWidth[] = "elementWidth";
const char kElementHeight[] = "elementHeight"; const char kElementHeight[] = "elementHeight";
const char kElementSizeIsLogical[] = "elementSizeIsLogical";
// Events. // Events.
const char kEventResize[] = "guestViewInternal.onResize"; const char kEventResize[] = "guestViewInternal.onResize";
......
...@@ -17,6 +17,7 @@ extern const char kAttributeMinHeight[]; ...@@ -17,6 +17,7 @@ extern const char kAttributeMinHeight[];
extern const char kAttributeMinWidth[]; extern const char kAttributeMinWidth[];
extern const char kElementWidth[]; extern const char kElementWidth[];
extern const char kElementHeight[]; extern const char kElementHeight[];
extern const char kElementSizeIsLogical[];
// Events. // Events.
extern const char kEventResize[]; extern const char kEventResize[];
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#include "content/public/renderer/render_view.h" #include "content/public/renderer/render_view.h"
#include "extensions/common/extension.h" #include "extensions/common/extension.h"
#include "extensions/common/extension_messages.h" #include "extensions/common/extension_messages.h"
#include "extensions/common/guest_view/guest_view_constants.h"
#include "extensions/renderer/guest_view/extensions_guest_view_container.h" #include "extensions/renderer/guest_view/extensions_guest_view_container.h"
#include "extensions/renderer/script_context.h" #include "extensions/renderer/script_context.h"
#include "v8/include/v8.h" #include "v8/include/v8.h"
...@@ -74,6 +75,10 @@ void GuestViewInternalCustomBindings::AttachGuest( ...@@ -74,6 +75,10 @@ void GuestViewInternalCustomBindings::AttachGuest(
static_cast<base::DictionaryValue*>(params_as_value.release())); static_cast<base::DictionaryValue*>(params_as_value.release()));
} }
// Add flag to |params| to indicate that the element size is specified in
// logical units.
params->SetBoolean(guestview::kElementSizeIsLogical, true);
linked_ptr<ExtensionsGuestViewContainer::Request> request( linked_ptr<ExtensionsGuestViewContainer::Request> request(
new ExtensionsGuestViewContainer::AttachRequest( new ExtensionsGuestViewContainer::AttachRequest(
guest_view_container, guest_view_container,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment