Skip to content
This repository has been archived by the owner on Apr 3, 2020. It is now read-only.

Commit

Permalink
Fix for MIME handler bug. The bug resulted from a previous bugfix (ht…
Browse files Browse the repository at this point in the history
…tps://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

(cherry picked from commit 18f5a13)

Cr-Original-Commit-Position: refs/heads/master@{#318948}
Cr-Commit-Position: refs/branch-heads/2311@{#185}
Cr-Branched-From: 09b7de5-refs/heads/master@{#317474}
  • Loading branch information
Alex Mineer committed Mar 9, 2015
1 parent 390e6e7 commit 8bba07c
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 3 deletions.
4 changes: 4 additions & 0 deletions extensions/browser/api/guest_view/guest_view_internal_api.cc
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ bool GuestViewInternalCreateGuestFunction::RunAsync() {
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,
owner_web_contents,
*create_params,
Expand Down
18 changes: 15 additions & 3 deletions extensions/browser/guest_view/guest_view_base.cc
Original file line number Diff line number Diff line change
Expand Up @@ -764,9 +764,21 @@ void GuestViewBase::SetUpSizing(const base::DictionaryValue& params) {
double element_width = 0.0;
params.GetDouble(guestview::kElementHeight, &element_height);
params.GetDouble(guestview::kElementWidth, &element_width);
// Convert the element size from logical pixels to physical pixels.
int normal_height = LogicalPixelsToPhysicalPixels(element_height);
int normal_width = LogicalPixelsToPhysicalPixels(element_width);

// If the element size was provided in logical units (versus physical), then
// 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;
set_size_params.enable_auto_size.reset(new bool(auto_size_enabled));
Expand Down
1 change: 1 addition & 0 deletions extensions/common/guest_view/guest_view_constants.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const char kAttributeMinHeight[] = "minheight";
const char kAttributeMinWidth[] = "minwidth";
const char kElementWidth[] = "elementWidth";
const char kElementHeight[] = "elementHeight";
const char kElementSizeIsLogical[] = "elementSizeIsLogical";

// Events.
const char kEventResize[] = "guestViewInternal.onResize";
Expand Down
1 change: 1 addition & 0 deletions extensions/common/guest_view/guest_view_constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ extern const char kAttributeMinHeight[];
extern const char kAttributeMinWidth[];
extern const char kElementWidth[];
extern const char kElementHeight[];
extern const char kElementSizeIsLogical[];

// Events.
extern const char kEventResize[];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include "content/public/renderer/render_view.h"
#include "extensions/common/extension.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/script_context.h"
#include "v8/include/v8.h"
Expand Down Expand Up @@ -74,6 +75,10 @@ void GuestViewInternalCustomBindings::AttachGuest(
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(
new ExtensionsGuestViewContainer::AttachRequest(
guest_view_container,
Expand Down

0 comments on commit 8bba07c

Please sign in to comment.