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

Side by Side Diff: third_party/WebKit/Source/core/paint/ThemePainterMac.mm

Issue 2125533002: [Mac] Draw the caps lock indicator on the left side for RTL direction. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add a layout test Created 4 years, 5 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 | « third_party/WebKit/LayoutTests/fast/text/caps-lock-indicator-enabled-rtl.html ('k') | 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 /* 1 /*
2 * Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. 2 * Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
3 * Copyright (C) 2008, 2009 Google, Inc. 3 * Copyright (C) 2008, 2009 Google, Inc.
4 * 4 *
5 * This library is free software; you can redistribute it and/or 5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public 6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either 7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version. 8 * version 2 of the License, or (at your option) any later version.
9 * 9 *
10 * This library is distributed in the hope that it will be useful, 10 * This library is distributed in the hope that it will be useful,
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 GraphicsContextStateSaver stateSaver(paintInfo.context); 80 GraphicsContextStateSaver stateSaver(paintInfo.context);
81 81
82 [textField setEnabled:(LayoutTheme::isEnabled(o) && !LayoutTheme::isReadOnly Control(o))]; 82 [textField setEnabled:(LayoutTheme::isEnabled(o) && !LayoutTheme::isReadOnly Control(o))];
83 [textField drawWithFrame:NSRect(r) inView:m_layoutTheme.documentViewFor(o)]; 83 [textField drawWithFrame:NSRect(r) inView:m_layoutTheme.documentViewFor(o)];
84 84
85 [textField setControlView:nil]; 85 [textField setControlView:nil];
86 86
87 return false; 87 return false;
88 } 88 }
89 89
90 bool ThemePainterMac::paintCapsLockIndicator(const LayoutObject&, const PaintInf o& paintInfo, const IntRect& r) 90 bool ThemePainterMac::paintCapsLockIndicator(const LayoutObject& o, const PaintI nfo& paintInfo, const IntRect& r)
91 { 91 {
92 // This draws the caps lock indicator as it was done by 92 // This draws the caps lock indicator as it was done by
93 // WKDrawCapsLockIndicator. 93 // WKDrawCapsLockIndicator.
94 LocalCurrentGraphicsContext localContext(paintInfo.context, r); 94 LocalCurrentGraphicsContext localContext(paintInfo.context, r);
95 CGContextRef c = localContext.cgContext(); 95 CGContextRef c = localContext.cgContext();
96 CGMutablePathRef shape = CGPathCreateMutable(); 96 CGMutablePathRef shape = CGPathCreateMutable();
97 97
98 // To draw the caps lock indicator, draw the shape into a small 98 // To draw the caps lock indicator, draw the shape into a small
99 // square that is then scaled to the size of r. 99 // square that is then scaled to the size of r.
100 const CGFloat kSquareSize = 17; 100 const CGFloat kSquareSize = 17;
(...skipping 20 matching lines...) Expand all
121 // arrow. 121 // arrow.
122 CGPathAddLineToPoint(shape, NULL, 10.75, 12); 122 CGPathAddLineToPoint(shape, NULL, 10.75, 12);
123 CGPathAddLineToPoint(shape, NULL, 6.25, 12); 123 CGPathAddLineToPoint(shape, NULL, 6.25, 12);
124 CGPathAddLineToPoint(shape, NULL, 6.25, 14.25); 124 CGPathAddLineToPoint(shape, NULL, 6.25, 14.25);
125 CGPathAddLineToPoint(shape, NULL, 10.75, 14.25); 125 CGPathAddLineToPoint(shape, NULL, 10.75, 14.25);
126 CGPathAddLineToPoint(shape, NULL, 10.75, 12); 126 CGPathAddLineToPoint(shape, NULL, 10.75, 12);
127 127
128 // Scale and translate the shape. 128 // Scale and translate the shape.
129 CGRect cgr = r; 129 CGRect cgr = r;
130 CGFloat maxX = CGRectGetMaxX(cgr); 130 CGFloat maxX = CGRectGetMaxX(cgr);
131 CGFloat minX = CGRectGetMinX(cgr);
131 CGFloat minY = CGRectGetMinY(cgr); 132 CGFloat minY = CGRectGetMinY(cgr);
132 CGFloat heightScale = r.height() / kSquareSize; 133 CGFloat heightScale = r.height() / kSquareSize;
134 bool isRTL = o.styleRef().direction() == RTL;
133 CGAffineTransform transform = CGAffineTransformMake( 135 CGAffineTransform transform = CGAffineTransformMake(
134 heightScale, 0, // A B 136 heightScale, 0, // A B
135 0, heightScale, // C D 137 0, heightScale, // C D
136 maxX - r.height(), minY); // Tx Ty 138 isRTL ? minX : maxX - r.height(), minY); // Tx Ty
137 139
138 CGMutablePathRef paintPath = CGPathCreateMutable(); 140 CGMutablePathRef paintPath = CGPathCreateMutable();
139 CGPathAddPath(paintPath, &transform, shape); 141 CGPathAddPath(paintPath, &transform, shape);
140 CGPathRelease(shape); 142 CGPathRelease(shape);
141 143
142 CGContextSetRGBFillColor(c, 0, 0, 0, 0.4); 144 CGContextSetRGBFillColor(c, 0, 0, 0, 0.4);
143 CGContextBeginPath(c); 145 CGContextBeginPath(c);
144 CGContextAddPath(c, paintPath); 146 CGContextAddPath(c, paintPath);
145 CGContextFillPath(c); 147 CGContextFillPath(c);
146 CGPathRelease(paintPath); 148 CGPathRelease(paintPath);
(...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after
541 paintInfo.context.rotate(deg2rad(-45.0)); 543 paintInfo.context.rotate(deg2rad(-45.0));
542 paintInfo.context.translate(-centerX, -centerY); 544 paintInfo.context.translate(-centerX, -centerY);
543 545
544 paintInfo.context.setFillColor(fillColor); 546 paintInfo.context.setFillColor(fillColor);
545 paintInfo.context.fillEllipse(unzoomedRect); 547 paintInfo.context.fillEllipse(unzoomedRect);
546 548
547 return false; 549 return false;
548 } 550 }
549 551
550 } // namespace blink 552 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/LayoutTests/fast/text/caps-lock-indicator-enabled-rtl.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698