Merge pull request #9440 from brenca/osr-fixes
Additional small OSR fixes
This commit is contained in:
commit
9bed0ffdbf
4 changed files with 28 additions and 8 deletions
|
@ -1660,6 +1660,18 @@ void WebContents::Invalidate() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gfx::Size WebContents::GetSizeForNewRenderView(
|
||||||
|
content::WebContents* wc) const {
|
||||||
|
if (IsOffScreen() && wc == web_contents()) {
|
||||||
|
auto relay = NativeWindowRelay::FromWebContents(web_contents());
|
||||||
|
if (relay) {
|
||||||
|
return relay->window->GetSize();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return gfx::Size();
|
||||||
|
}
|
||||||
|
|
||||||
void WebContents::SetZoomLevel(double level) {
|
void WebContents::SetZoomLevel(double level) {
|
||||||
zoom_controller_->SetZoomLevel(level);
|
zoom_controller_->SetZoomLevel(level);
|
||||||
}
|
}
|
||||||
|
|
|
@ -185,6 +185,7 @@ class WebContents : public mate::TrackableObject<WebContents>,
|
||||||
void SetFrameRate(int frame_rate);
|
void SetFrameRate(int frame_rate);
|
||||||
int GetFrameRate() const;
|
int GetFrameRate() const;
|
||||||
void Invalidate();
|
void Invalidate();
|
||||||
|
gfx::Size GetSizeForNewRenderView(content::WebContents*) const override;
|
||||||
|
|
||||||
// Methods for zoom handling.
|
// Methods for zoom handling.
|
||||||
void SetZoomLevel(double level);
|
void SetZoomLevel(double level);
|
||||||
|
|
|
@ -858,6 +858,8 @@ std::unique_ptr<cc::SoftwareOutputDevice>
|
||||||
DCHECK(!copy_frame_generator_);
|
DCHECK(!copy_frame_generator_);
|
||||||
DCHECK(!software_output_device_);
|
DCHECK(!software_output_device_);
|
||||||
|
|
||||||
|
ResizeRootLayer();
|
||||||
|
|
||||||
software_output_device_ = new OffScreenOutputDevice(
|
software_output_device_ = new OffScreenOutputDevice(
|
||||||
transparent_,
|
transparent_,
|
||||||
base::Bind(&OffScreenRenderWidgetHostView::OnPaint,
|
base::Bind(&OffScreenRenderWidgetHostView::OnPaint,
|
||||||
|
@ -1127,8 +1129,8 @@ void OffScreenRenderWidgetHostView::InvalidateBounds(const gfx::Rect& bounds) {
|
||||||
void OffScreenRenderWidgetHostView::ResizeRootLayer() {
|
void OffScreenRenderWidgetHostView::ResizeRootLayer() {
|
||||||
SetupFrameRate(false);
|
SetupFrameRate(false);
|
||||||
|
|
||||||
const float orgScaleFactor = scale_factor_;
|
const float compositorScaleFactor = GetCompositor()->device_scale_factor();
|
||||||
const bool scaleFactorDidChange = (orgScaleFactor != scale_factor_);
|
const bool scaleFactorDidChange = (compositorScaleFactor != scale_factor_);
|
||||||
|
|
||||||
gfx::Size size;
|
gfx::Size size;
|
||||||
if (!IsPopupWidget())
|
if (!IsPopupWidget())
|
||||||
|
|
|
@ -2338,6 +2338,8 @@ describe('BrowserWindow module', function () {
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
if (w != null) w.destroy()
|
if (w != null) w.destroy()
|
||||||
w = new BrowserWindow({
|
w = new BrowserWindow({
|
||||||
|
width: 100,
|
||||||
|
height: 100,
|
||||||
show: false,
|
show: false,
|
||||||
webPreferences: {
|
webPreferences: {
|
||||||
backgroundThrottling: false,
|
backgroundThrottling: false,
|
||||||
|
@ -2346,9 +2348,12 @@ describe('BrowserWindow module', function () {
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
it('creates offscreen window', function (done) {
|
it('creates offscreen window with correct size', function (done) {
|
||||||
w.webContents.once('paint', function (event, rect, data, size) {
|
w.webContents.once('paint', function (event, rect, data) {
|
||||||
assert.notEqual(data.length, 0)
|
assert.notEqual(data.length, 0)
|
||||||
|
let size = data.getSize()
|
||||||
|
assertWithinDelta(size.width, 100, 2, 'width')
|
||||||
|
assertWithinDelta(size.height, 100, 2, 'height')
|
||||||
done()
|
done()
|
||||||
})
|
})
|
||||||
w.loadURL('file://' + fixtures + '/api/offscreen-rendering.html')
|
w.loadURL('file://' + fixtures + '/api/offscreen-rendering.html')
|
||||||
|
@ -2369,7 +2374,7 @@ describe('BrowserWindow module', function () {
|
||||||
|
|
||||||
describe('window.webContents.isPainting()', function () {
|
describe('window.webContents.isPainting()', function () {
|
||||||
it('returns whether is currently painting', function (done) {
|
it('returns whether is currently painting', function (done) {
|
||||||
w.webContents.once('paint', function (event, rect, data, size) {
|
w.webContents.once('paint', function (event, rect, data) {
|
||||||
assert.equal(w.webContents.isPainting(), true)
|
assert.equal(w.webContents.isPainting(), true)
|
||||||
done()
|
done()
|
||||||
})
|
})
|
||||||
|
@ -2393,7 +2398,7 @@ describe('BrowserWindow module', function () {
|
||||||
w.webContents.on('dom-ready', function () {
|
w.webContents.on('dom-ready', function () {
|
||||||
w.webContents.stopPainting()
|
w.webContents.stopPainting()
|
||||||
w.webContents.startPainting()
|
w.webContents.startPainting()
|
||||||
w.webContents.once('paint', function (event, rect, data, size) {
|
w.webContents.once('paint', function (event, rect, data) {
|
||||||
assert.equal(w.webContents.isPainting(), true)
|
assert.equal(w.webContents.isPainting(), true)
|
||||||
done()
|
done()
|
||||||
})
|
})
|
||||||
|
@ -2404,7 +2409,7 @@ describe('BrowserWindow module', function () {
|
||||||
|
|
||||||
describe('window.webContents.getFrameRate()', function () {
|
describe('window.webContents.getFrameRate()', function () {
|
||||||
it('has default frame rate', function (done) {
|
it('has default frame rate', function (done) {
|
||||||
w.webContents.once('paint', function (event, rect, data, size) {
|
w.webContents.once('paint', function (event, rect, data) {
|
||||||
assert.equal(w.webContents.getFrameRate(), 60)
|
assert.equal(w.webContents.getFrameRate(), 60)
|
||||||
done()
|
done()
|
||||||
})
|
})
|
||||||
|
@ -2416,7 +2421,7 @@ describe('BrowserWindow module', function () {
|
||||||
it('sets custom frame rate', function (done) {
|
it('sets custom frame rate', function (done) {
|
||||||
w.webContents.on('dom-ready', function () {
|
w.webContents.on('dom-ready', function () {
|
||||||
w.webContents.setFrameRate(30)
|
w.webContents.setFrameRate(30)
|
||||||
w.webContents.once('paint', function (event, rect, data, size) {
|
w.webContents.once('paint', function (event, rect, data) {
|
||||||
assert.equal(w.webContents.getFrameRate(), 30)
|
assert.equal(w.webContents.getFrameRate(), 30)
|
||||||
done()
|
done()
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in a new issue