Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4)

Side by Side Diff: sky/engine/core/rendering/RenderIFrame.cpp

Issue 896233002: Fix render bounds of iframes on devices with a pixel ratio != 1. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Address comments Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "sky/engine/config.h" 5 #include "sky/engine/config.h"
6 6
7 #include "sky/engine/core/rendering/RenderIFrame.h" 7 #include "sky/engine/core/rendering/RenderIFrame.h"
8 8
9 #include "sky/engine/core/editing/FrameSelection.h" 9 #include "sky/engine/core/editing/FrameSelection.h"
10 #include "sky/engine/core/html/HTMLIFrameElement.h" 10 #include "sky/engine/core/html/HTMLIFrameElement.h"
(...skipping 15 matching lines...) Expand all
26 if (view()) 26 if (view())
27 view()->removeIFrame(this); 27 view()->removeIFrame(this);
28 } 28 }
29 29
30 void RenderIFrame::updateWidgetBounds() 30 void RenderIFrame::updateWidgetBounds()
31 { 31 {
32 mojo::View* contentView = toHTMLIFrameElement(node())->contentView(); 32 mojo::View* contentView = toHTMLIFrameElement(node())->contentView();
33 if (!contentView) 33 if (!contentView)
34 return; 34 return;
35 35
36 // FIXME: Once viewport_metrics are initialized properly on child views,
37 // The GetRoot() call should be removed.
38 const float devicePixelRatio =
39 contentView->GetRoot()->viewport_metrics().device_pixel_ratio;
40
36 IntRect bounds = absoluteContentBox(); 41 IntRect bounds = absoluteContentBox();
37 mojo::Rect mojoBounds; 42 mojo::Rect mojoBounds;
38 mojoBounds.x = bounds.x(); 43 mojoBounds.x = bounds.x() * devicePixelRatio;
39 mojoBounds.y = bounds.y(); 44 mojoBounds.y = bounds.y() * devicePixelRatio;
40 mojoBounds.width = bounds.width(); 45 mojoBounds.width = bounds.width() * devicePixelRatio;
41 mojoBounds.height = bounds.height(); 46 mojoBounds.height = bounds.height() * devicePixelRatio;
42 contentView->SetBounds(mojoBounds); 47 contentView->SetBounds(mojoBounds);
43 } 48 }
44 49
45 void RenderIFrame::paintReplaced(PaintInfo& paintInfo, 50 void RenderIFrame::paintReplaced(PaintInfo& paintInfo,
46 const LayoutPoint& paintOffset) 51 const LayoutPoint& paintOffset)
47 { 52 {
48 // Draw a gray background. This should be painted over by the actual 53 // Draw a gray background. This should be painted over by the actual
49 // content. 54 // content.
50 // TODO(mpcomplete): figure out what we should actually do here. 55 // TODO(mpcomplete): figure out what we should actually do here.
51 GraphicsContext* context = paintInfo.context; 56 GraphicsContext* context = paintInfo.context;
52 57
53 IntRect paintRect = pixelSnappedIntRect(LayoutRect( 58 IntRect paintRect = pixelSnappedIntRect(LayoutRect(
54 paintOffset.x(), paintOffset.y(), contentWidth(), contentHeight())); 59 paintOffset.x(), paintOffset.y(), contentWidth(), contentHeight()));
55 context->setStrokeStyle(SolidStroke); 60 context->setStrokeStyle(SolidStroke);
56 context->setStrokeColor(Color::lightGray); 61 context->setStrokeColor(Color::lightGray);
57 context->setFillColor(Color::darkGray); 62 context->setFillColor(Color::darkGray);
58 context->drawRect(paintRect); 63 context->drawRect(paintRect);
59 } 64 }
60 65
61 } // namespace blink 66 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698