Commit 5f02ed92 authored by Becca Hughes's avatar Becca Hughes Committed by Commit Bot

Media Controls: Only update slider positions when needed

The slider positions are constantly updated even when they have
not changed. This changes them to only be updated when changed.

BUG=821961,821414

Change-Id: Ia978e130d51915bce121913db7f66caccbd9e636
Reviewed-on: https://chromium-review.googlesource.com/991075Reviewed-by: default avatarMounir Lamouri <mlamouri@chromium.org>
Commit-Queue: Becca Hughes <beccahughes@chromium.org>
Cr-Commit-Position: refs/heads/master@{#547727}
parent 87c0b543
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#include "core/html/HTMLDivElement.h" #include "core/html/HTMLDivElement.h"
#include "core/input_type_names.h" #include "core/input_type_names.h"
#include "core/layout/LayoutBox.h"
#include "core/layout/LayoutBoxModelObject.h" #include "core/layout/LayoutBoxModelObject.h"
#include "core/layout/LayoutView.h" #include "core/layout/LayoutView.h"
#include "core/resize_observer/ResizeObserver.h" #include "core/resize_observer/ResizeObserver.h"
...@@ -22,6 +23,20 @@ void SetSegmentDivPosition(blink::HTMLDivElement* segment, ...@@ -22,6 +23,20 @@ void SetSegmentDivPosition(blink::HTMLDivElement* segment,
float zoom_factor) { float zoom_factor) {
int segment_width = int((position.width * width) / zoom_factor); int segment_width = int((position.width * width) / zoom_factor);
int segment_left = int((position.left * width) / zoom_factor); int segment_left = int((position.left * width) / zoom_factor);
int current_width = 0;
int current_left = 0;
// Get the current width and left for the segment. If the box is not present
// then it will be a nullptr so we should assume zero.
blink::LayoutBox* box = segment->GetLayoutBox();
if (box) {
current_width = box->PixelSnappedWidth();
current_left = box->LogicalLeft().ToInt();
}
// If the width and left has not changed then do not update the segment.
if (segment_width == current_width && segment_left == current_left)
return;
StringBuilder builder; StringBuilder builder;
builder.Append("width: "); builder.Append("width: ");
......
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