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

Side by Side Diff: third_party/WebKit/Source/core/paint/ScrollableAreaPainter.cpp

Issue 2698543002: Resizes corner rect to match device scale factor (Closed)
Patch Set: Resizes corner rect to match device scale factor Created 3 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 "core/paint/ScrollableAreaPainter.h" 5 #include "core/paint/ScrollableAreaPainter.h"
6 6
7 #include "core/layout/LayoutView.h" 7 #include "core/layout/LayoutView.h"
8 #include "core/page/Page.h" 8 #include "core/page/Page.h"
9 #include "core/paint/LayoutObjectDrawingRecorder.h" 9 #include "core/paint/LayoutObjectDrawingRecorder.h"
10 #include "core/paint/ObjectPaintProperties.h" 10 #include "core/paint/ObjectPaintProperties.h"
11 #include "core/paint/PaintInfo.h" 11 #include "core/paint/PaintInfo.h"
12 #include "core/paint/PaintLayer.h" 12 #include "core/paint/PaintLayer.h"
13 #include "core/paint/PaintLayerScrollableArea.h" 13 #include "core/paint/PaintLayerScrollableArea.h"
14 #include "core/paint/ScrollbarPainter.h" 14 #include "core/paint/ScrollbarPainter.h"
15 #include "core/paint/TransformRecorder.h" 15 #include "core/paint/TransformRecorder.h"
16 #include "platform/HostWindow.h"
16 #include "platform/graphics/GraphicsContext.h" 17 #include "platform/graphics/GraphicsContext.h"
17 #include "platform/graphics/GraphicsContextStateSaver.h" 18 #include "platform/graphics/GraphicsContextStateSaver.h"
18 #include "platform/graphics/paint/ClipRecorder.h" 19 #include "platform/graphics/paint/ClipRecorder.h"
19 #include "platform/graphics/paint/ScopedPaintChunkProperties.h" 20 #include "platform/graphics/paint/ScopedPaintChunkProperties.h"
20 21
21 namespace blink { 22 namespace blink {
22 23
23 void ScrollableAreaPainter::paintResizer(GraphicsContext& context, 24 void ScrollableAreaPainter::paintResizer(GraphicsContext& context,
24 const IntPoint& paintOffset, 25 const IntPoint& paintOffset,
25 const CullRect& cullRect) { 26 const CullRect& cullRect) {
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 context.setStrokeColor(Color(217, 217, 217)); 62 context.setStrokeColor(Color(217, 217, 217));
62 context.setStrokeThickness(1.0f); 63 context.setStrokeThickness(1.0f);
63 context.setFillColor(Color::transparent); 64 context.setFillColor(Color::transparent);
64 context.drawRect(largerCorner); 65 context.drawRect(largerCorner);
65 } 66 }
66 } 67 }
67 68
68 void ScrollableAreaPainter::drawPlatformResizerImage( 69 void ScrollableAreaPainter::drawPlatformResizerImage(
69 GraphicsContext& context, 70 GraphicsContext& context,
70 IntRect resizerCornerRect) { 71 IntRect resizerCornerRect) {
72 float oldDeviceScaleFactor =
73 blink::deviceScaleFactor(getScrollableArea().box().frame());
74 // |blink::deviceScaleFactor| returns different values between MAC (2 or 1)
75 // and other platforms (always 1). For this reason we cannot hardcode the
76 // value of 1 in the call for |windowToViewportScalar|. Since zoom-for-dsf is
77 // disabled on MAC, |windowToViewportScalar| will be a no-op on it.
71 float deviceScaleFactor = 78 float deviceScaleFactor =
72 blink::deviceScaleFactor(getScrollableArea().box().frame()); 79 getScrollableArea().getHostWindow()->windowToViewportScalar(
80 oldDeviceScaleFactor);
73 81
74 RefPtr<Image> resizeCornerImage; 82 RefPtr<Image> resizeCornerImage;
75 IntSize cornerResizerSize; 83 IntSize cornerResizerSize;
76 if (deviceScaleFactor >= 2) { 84 if (deviceScaleFactor >= 2) {
77 DEFINE_STATIC_REF(Image, resizeCornerImageHiRes, 85 DEFINE_STATIC_REF(Image, resizeCornerImageHiRes,
78 (Image::loadPlatformResource("textAreaResizeCorner@2x"))); 86 (Image::loadPlatformResource("textAreaResizeCorner@2x")));
79 resizeCornerImage = resizeCornerImageHiRes; 87 resizeCornerImage = resizeCornerImageHiRes;
80 cornerResizerSize = resizeCornerImage->size(); 88 cornerResizerSize = resizeCornerImage->size();
81 cornerResizerSize.scale(0.5f); 89 if (oldDeviceScaleFactor >= 2)
90 cornerResizerSize.scale(0.5f);
82 } else { 91 } else {
83 DEFINE_STATIC_REF(Image, resizeCornerImageLoRes, 92 DEFINE_STATIC_REF(Image, resizeCornerImageLoRes,
84 (Image::loadPlatformResource("textAreaResizeCorner"))); 93 (Image::loadPlatformResource("textAreaResizeCorner")));
85 resizeCornerImage = resizeCornerImageLoRes; 94 resizeCornerImage = resizeCornerImageLoRes;
86 cornerResizerSize = resizeCornerImage->size(); 95 cornerResizerSize = resizeCornerImage->size();
87 } 96 }
88 97
89 if (getScrollableArea() 98 if (getScrollableArea()
90 .box() 99 .box()
91 .shouldPlaceBlockDirectionScrollbarOnLogicalLeft()) { 100 .shouldPlaceBlockDirectionScrollbarOnLogicalLeft()) {
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
255 LayoutObjectDrawingRecorder recorder(context, getScrollableArea().box(), 264 LayoutObjectDrawingRecorder recorder(context, getScrollableArea().box(),
256 DisplayItem::kScrollbarCorner, absRect); 265 DisplayItem::kScrollbarCorner, absRect);
257 context.fillRect(absRect, Color::white); 266 context.fillRect(absRect, Color::white);
258 } 267 }
259 268
260 PaintLayerScrollableArea& ScrollableAreaPainter::getScrollableArea() const { 269 PaintLayerScrollableArea& ScrollableAreaPainter::getScrollableArea() const {
261 return *m_scrollableArea; 270 return *m_scrollableArea;
262 } 271 }
263 272
264 } // namespace blink 273 } // 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