OLD | NEW |
---|---|
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 Loading... | |
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 // |blink::deviceScaleFactor| returns different values between MAC (2 or 1) | |
73 // and other platforms (always 1). For this reason we cannot hardcode the | |
74 // value of 1 in the call for |windowToViewportScalar|. Since zoom-for-dsf is | |
75 // disabled on MAC, |windowToViewportScalar| will be a no-op on it. | |
71 float deviceScaleFactor = | 76 float deviceScaleFactor = |
72 blink::deviceScaleFactor(getScrollableArea().box().frame()); | 77 getScrollableArea().getHostWindow()->windowToViewportScalar( |
78 blink::deviceScaleFactor(getScrollableArea().box().frame())); | |
73 | 79 |
74 RefPtr<Image> resizeCornerImage; | 80 RefPtr<Image> resizeCornerImage; |
75 IntSize cornerResizerSize; | 81 IntSize cornerResizerSize; |
76 if (deviceScaleFactor >= 2) { | 82 if (deviceScaleFactor >= 2) { |
77 DEFINE_STATIC_REF(Image, resizeCornerImageHiRes, | 83 DEFINE_STATIC_REF(Image, resizeCornerImageHiRes, |
78 (Image::loadPlatformResource("textAreaResizeCorner@2x"))); | 84 (Image::loadPlatformResource("textAreaResizeCorner@2x"))); |
79 resizeCornerImage = resizeCornerImageHiRes; | 85 resizeCornerImage = resizeCornerImageHiRes; |
80 cornerResizerSize = resizeCornerImage->size(); | 86 cornerResizerSize = resizeCornerImage->size(); |
81 cornerResizerSize.scale(0.5f); | 87 if (blink::deviceScaleFactor(getScrollableArea().box().frame()) >= 2) |
oshima
2017/02/17 16:59:59
nit: cache this value first, like
float oldBlinkD
| |
88 cornerResizerSize.scale(0.5f); | |
82 } else { | 89 } else { |
83 DEFINE_STATIC_REF(Image, resizeCornerImageLoRes, | 90 DEFINE_STATIC_REF(Image, resizeCornerImageLoRes, |
84 (Image::loadPlatformResource("textAreaResizeCorner"))); | 91 (Image::loadPlatformResource("textAreaResizeCorner"))); |
85 resizeCornerImage = resizeCornerImageLoRes; | 92 resizeCornerImage = resizeCornerImageLoRes; |
86 cornerResizerSize = resizeCornerImage->size(); | 93 cornerResizerSize = resizeCornerImage->size(); |
87 } | 94 } |
88 | 95 |
89 if (getScrollableArea() | 96 if (getScrollableArea() |
90 .box() | 97 .box() |
91 .shouldPlaceBlockDirectionScrollbarOnLogicalLeft()) { | 98 .shouldPlaceBlockDirectionScrollbarOnLogicalLeft()) { |
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
255 LayoutObjectDrawingRecorder recorder(context, getScrollableArea().box(), | 262 LayoutObjectDrawingRecorder recorder(context, getScrollableArea().box(), |
256 DisplayItem::kScrollbarCorner, absRect); | 263 DisplayItem::kScrollbarCorner, absRect); |
257 context.fillRect(absRect, Color::white); | 264 context.fillRect(absRect, Color::white); |
258 } | 265 } |
259 | 266 |
260 PaintLayerScrollableArea& ScrollableAreaPainter::getScrollableArea() const { | 267 PaintLayerScrollableArea& ScrollableAreaPainter::getScrollableArea() const { |
261 return *m_scrollableArea; | 268 return *m_scrollableArea; |
262 } | 269 } |
263 | 270 |
264 } // namespace blink | 271 } // namespace blink |
OLD | NEW |