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

Side by Side Diff: third_party/WebKit/Source/platform/DragImage.cpp

Issue 1774943003: blink: Rename platform/ methods to prefix with get when they collide. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: clash-platform: rebase-yayyyyyyyy Created 4 years, 9 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2007 Apple Inc. All rights reserved. 2 * Copyright (C) 2007 Apple Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 String urlString = url.getString(); 181 String urlString = url.getString();
182 String label = inLabel.stripWhiteSpace(); 182 String label = inLabel.stripWhiteSpace();
183 if (label.isEmpty()) { 183 if (label.isEmpty()) {
184 drawURLString = false; 184 drawURLString = false;
185 label = urlString; 185 label = urlString;
186 } 186 }
187 187
188 // First step is drawing the link drag image width. 188 // First step is drawing the link drag image width.
189 TextRun labelRun(label.impl()); 189 TextRun labelRun(label.impl());
190 TextRun urlRun(urlString.impl()); 190 TextRun urlRun(urlString.impl());
191 IntSize labelSize(labelFont.width(labelRun), labelFont.fontMetrics().ascent( ) + labelFont.fontMetrics().descent()); 191 IntSize labelSize(labelFont.width(labelRun), labelFont.getFontMetrics().asce nt() + labelFont.getFontMetrics().descent());
192 192
193 if (labelSize.width() > maxDragLabelStringWidthDIP) { 193 if (labelSize.width() > maxDragLabelStringWidthDIP) {
194 labelSize.setWidth(maxDragLabelStringWidthDIP); 194 labelSize.setWidth(maxDragLabelStringWidthDIP);
195 clipLabelString = true; 195 clipLabelString = true;
196 } 196 }
197 197
198 IntSize urlStringSize; 198 IntSize urlStringSize;
199 IntSize imageSize(labelSize.width() + kDragLabelBorderX * 2, labelSize.heigh t() + kDragLabelBorderY * 2); 199 IntSize imageSize(labelSize.width() + kDragLabelBorderX * 2, labelSize.heigh t() + kDragLabelBorderY * 2);
200 200
201 if (drawURLString) { 201 if (drawURLString) {
202 urlStringSize.setWidth(urlFont.width(urlRun)); 202 urlStringSize.setWidth(urlFont.width(urlRun));
203 urlStringSize.setHeight(urlFont.fontMetrics().ascent() + urlFont.fontMet rics().descent()); 203 urlStringSize.setHeight(urlFont.getFontMetrics().ascent() + urlFont.getF ontMetrics().descent());
204 imageSize.setHeight(imageSize.height() + urlStringSize.height()); 204 imageSize.setHeight(imageSize.height() + urlStringSize.height());
205 if (urlStringSize.width() > maxDragLabelStringWidthDIP) { 205 if (urlStringSize.width() > maxDragLabelStringWidthDIP) {
206 imageSize.setWidth(maxDragLabelStringWidthDIP); 206 imageSize.setWidth(maxDragLabelStringWidthDIP);
207 clipURLString = true; 207 clipURLString = true;
208 } else 208 } else
209 imageSize.setWidth(std::max(labelSize.width(), urlStringSize.width() ) + kDragLabelBorderX * 2); 209 imageSize.setWidth(std::max(labelSize.width(), urlStringSize.width() ) + kDragLabelBorderX * 2);
210 } 210 }
211 211
212 // We now know how big the image needs to be, so we create and 212 // We now know how big the image needs to be, so we create and
213 // fill the background 213 // fill the background
(...skipping 12 matching lines...) Expand all
226 backgroundPaint.setColor(SkColorSetRGB(140, 140, 140)); 226 backgroundPaint.setColor(SkColorSetRGB(140, 140, 140));
227 SkRRect rrect; 227 SkRRect rrect;
228 rrect.setRectXY(SkRect::MakeWH(imageSize.width(), imageSize.height()), DragL abelRadius, DragLabelRadius); 228 rrect.setRectXY(SkRect::MakeWH(imageSize.width(), imageSize.height()), DragL abelRadius, DragLabelRadius);
229 buffer->canvas()->drawRRect(rrect, backgroundPaint); 229 buffer->canvas()->drawRRect(rrect, backgroundPaint);
230 230
231 // Draw the text 231 // Draw the text
232 SkPaint textPaint; 232 SkPaint textPaint;
233 if (drawURLString) { 233 if (drawURLString) {
234 if (clipURLString) 234 if (clipURLString)
235 urlString = StringTruncator::centerTruncate(urlString, imageSize.wid th() - (kDragLabelBorderX * 2.0f), urlFont); 235 urlString = StringTruncator::centerTruncate(urlString, imageSize.wid th() - (kDragLabelBorderX * 2.0f), urlFont);
236 IntPoint textPos(kDragLabelBorderX, imageSize.height() - (kLabelBorderYO ffset + urlFont.fontMetrics().descent())); 236 IntPoint textPos(kDragLabelBorderX, imageSize.height() - (kLabelBorderYO ffset + urlFont.getFontMetrics().descent()));
237 TextRun textRun(urlString); 237 TextRun textRun(urlString);
238 urlFont.drawText(buffer->canvas(), TextRunPaintInfo(textRun), textPos, d eviceScaleFactor, textPaint); 238 urlFont.drawText(buffer->canvas(), TextRunPaintInfo(textRun), textPos, d eviceScaleFactor, textPaint);
239 } 239 }
240 240
241 if (clipLabelString) 241 if (clipLabelString)
242 label = StringTruncator::rightTruncate(label, imageSize.width() - (kDrag LabelBorderX * 2.0f), labelFont); 242 label = StringTruncator::rightTruncate(label, imageSize.width() - (kDrag LabelBorderX * 2.0f), labelFont);
243 243
244 bool hasStrongDirectionality; 244 bool hasStrongDirectionality;
245 TextRun textRun = textRunWithDirectionality(label, &hasStrongDirectionality) ; 245 TextRun textRun = textRunWithDirectionality(label, &hasStrongDirectionality) ;
246 IntPoint textPos(kDragLabelBorderX, kDragLabelBorderY + labelFont.fontDescri ption().computedPixelSize()); 246 IntPoint textPos(kDragLabelBorderX, kDragLabelBorderY + labelFont.getFontDes cription().computedPixelSize());
247 if (hasStrongDirectionality && textRun.direction() == RTL) { 247 if (hasStrongDirectionality && textRun.direction() == RTL) {
248 float textWidth = labelFont.width(textRun); 248 float textWidth = labelFont.width(textRun);
249 int availableWidth = imageSize.width() - kDragLabelBorderX * 2; 249 int availableWidth = imageSize.width() - kDragLabelBorderX * 2;
250 textPos.setX(availableWidth - ceilf(textWidth)); 250 textPos.setX(availableWidth - ceilf(textWidth));
251 } 251 }
252 labelFont.drawBidiText(buffer->canvas(), TextRunPaintInfo(textRun), FloatPoi nt(textPos), Font::DoNotPaintIfFontNotReady, deviceScaleFactor, textPaint); 252 labelFont.drawBidiText(buffer->canvas(), TextRunPaintInfo(textRun), FloatPoi nt(textPos), Font::DoNotPaintIfFontNotReady, deviceScaleFactor, textPaint);
253 253
254 RefPtr<Image> image = buffer->newImageSnapshot(); 254 RefPtr<Image> image = buffer->newImageSnapshot();
255 return DragImage::create(image.get(), DoNotRespectImageOrientation, deviceSc aleFactor); 255 return DragImage::create(image.get(), DoNotRespectImageOrientation, deviceSc aleFactor);
256 } 256 }
(...skipping 11 matching lines...) Expand all
268 268
269 void DragImage::scale(float scaleX, float scaleY) 269 void DragImage::scale(float scaleX, float scaleY)
270 { 270 {
271 skia::ImageOperations::ResizeMethod resizeMethod = m_interpolationQuality == InterpolationNone ? skia::ImageOperations::RESIZE_BOX : skia::ImageOperations:: RESIZE_LANCZOS3; 271 skia::ImageOperations::ResizeMethod resizeMethod = m_interpolationQuality == InterpolationNone ? skia::ImageOperations::RESIZE_BOX : skia::ImageOperations:: RESIZE_LANCZOS3;
272 int imageWidth = scaleX * m_bitmap.width(); 272 int imageWidth = scaleX * m_bitmap.width();
273 int imageHeight = scaleY * m_bitmap.height(); 273 int imageHeight = scaleY * m_bitmap.height();
274 m_bitmap = skia::ImageOperations::Resize(m_bitmap, resizeMethod, imageWidth, imageHeight); 274 m_bitmap = skia::ImageOperations::Resize(m_bitmap, resizeMethod, imageWidth, imageHeight);
275 } 275 }
276 276
277 } // namespace blink 277 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/platform/Cursor.h ('k') | third_party/WebKit/Source/platform/Prerender.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698