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

Side by Side Diff: third_party/WebKit/Source/web/ExternalPopupMenu.cpp

Issue 2416033003: Remove unsafe getFontMetrics methods (Closed)
Patch Set: Address wkroman suggestions Created 4 years, 2 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/Source/platform/fonts/Font.h ('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) 2010 Google Inc. All rights reserved. 2 * Copyright (C) 2010 Google 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 are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after
251 } 251 }
252 popupItem.enabled = !itemElement.isDisabledFormControl(); 252 popupItem.enabled = !itemElement.isDisabledFormControl();
253 const ComputedStyle& style = *ownerElement.itemComputedStyle(itemElement); 253 const ComputedStyle& style = *ownerElement.itemComputedStyle(itemElement);
254 popupItem.textDirection = toWebTextDirection(style.direction()); 254 popupItem.textDirection = toWebTextDirection(style.direction());
255 popupItem.hasTextDirectionOverride = isOverride(style.unicodeBidi()); 255 popupItem.hasTextDirectionOverride = isOverride(style.unicodeBidi());
256 } 256 }
257 257
258 const ComputedStyle& menuStyle = ownerElement.computedStyle() 258 const ComputedStyle& menuStyle = ownerElement.computedStyle()
259 ? *ownerElement.computedStyle() 259 ? *ownerElement.computedStyle()
260 : *ownerElement.ensureComputedStyle(); 260 : *ownerElement.ensureComputedStyle();
261 info.itemHeight = menuStyle.font().getFontMetrics().height(); 261 const SimpleFontData* fontData = menuStyle.font().primaryFont();
262 DCHECK(fontData);
263 info.itemHeight = fontData ? fontData->getFontMetrics().height() : 0;
262 info.itemFontSize = 264 info.itemFontSize =
263 static_cast<int>(menuStyle.font().getFontDescription().computedSize()); 265 static_cast<int>(menuStyle.font().getFontDescription().computedSize());
264 info.selectedIndex = toExternalPopupMenuItemIndex( 266 info.selectedIndex = toExternalPopupMenuItemIndex(
265 ownerElement.selectedListIndex(), ownerElement); 267 ownerElement.selectedListIndex(), ownerElement);
266 info.rightAligned = menuStyle.direction() == RTL; 268 info.rightAligned = menuStyle.direction() == RTL;
267 info.allowMultipleSelection = ownerElement.isMultiple(); 269 info.allowMultipleSelection = ownerElement.isMultiple();
268 if (count < itemCount) 270 if (count < itemCount)
269 items.shrink(count); 271 items.shrink(count);
270 info.items = items; 272 info.items = items;
271 } 273 }
(...skipping 26 matching lines...) Expand all
298 if (ownerElement.itemIsDisplayNone(*items[i])) 300 if (ownerElement.itemIsDisplayNone(*items[i]))
299 continue; 301 continue;
300 if (popupMenuItemIndex == i) 302 if (popupMenuItemIndex == i)
301 return indexTracker; 303 return indexTracker;
302 ++indexTracker; 304 ++indexTracker;
303 } 305 }
304 return -1; 306 return -1;
305 } 307 }
306 308
307 } // namespace blink 309 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/platform/fonts/Font.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698