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

Side by Side Diff: third_party/WebKit/Source/core/testing/Internals.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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2012 Google Inc. All rights reserved.
3 * Copyright (C) 2013 Apple Inc. All rights reserved. 3 * Copyright (C) 2013 Apple Inc. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 8 *
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 2583 matching lines...) Expand 10 before | Expand all | Expand 10 after
2594 int Internals::selectPopupItemStyleFontHeight(Node* node, int itemIndex) { 2594 int Internals::selectPopupItemStyleFontHeight(Node* node, int itemIndex) {
2595 if (!node || !isHTMLSelectElement(*node)) 2595 if (!node || !isHTMLSelectElement(*node))
2596 return false; 2596 return false;
2597 2597
2598 HTMLSelectElement& select = toHTMLSelectElement(*node); 2598 HTMLSelectElement& select = toHTMLSelectElement(*node);
2599 if (itemIndex < 0 || 2599 if (itemIndex < 0 ||
2600 static_cast<size_t>(itemIndex) >= select.listItems().size()) 2600 static_cast<size_t>(itemIndex) >= select.listItems().size())
2601 return false; 2601 return false;
2602 const ComputedStyle* itemStyle = 2602 const ComputedStyle* itemStyle =
2603 select.itemComputedStyle(*select.listItems()[itemIndex]); 2603 select.itemComputedStyle(*select.listItems()[itemIndex]);
2604 return itemStyle ? itemStyle->font().getFontMetrics().height() : 0; 2604
2605 if (itemStyle) {
2606 const SimpleFontData* fontData = itemStyle->font().primaryFont();
2607 DCHECK(fontData);
2608 return fontData ? fontData->getFontMetrics().height() : 0;
2609 }
2610 return 0;
2605 } 2611 }
2606 2612
2607 void Internals::resetTypeAheadSession(HTMLSelectElement* select) { 2613 void Internals::resetTypeAheadSession(HTMLSelectElement* select) {
2608 ASSERT(select); 2614 ASSERT(select);
2609 select->resetTypeAheadSessionForTesting(); 2615 select->resetTypeAheadSessionForTesting();
2610 } 2616 }
2611 2617
2612 bool Internals::loseSharedGraphicsContext3D() { 2618 bool Internals::loseSharedGraphicsContext3D() {
2613 std::unique_ptr<WebGraphicsContext3DProvider> sharedProvider = wrapUnique( 2619 std::unique_ptr<WebGraphicsContext3DProvider> sharedProvider = wrapUnique(
2614 Platform::current()->createSharedOffscreenGraphicsContext3DProvider()); 2620 Platform::current()->createSharedOffscreenGraphicsContext3DProvider());
(...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after
3025 return ClientRect::create(); 3031 return ClientRect::create();
3026 3032
3027 return ClientRect::create(FloatRect(node->layoutObject()->visualRect())); 3033 return ClientRect::create(FloatRect(node->layoutObject()->visualRect()));
3028 } 3034 }
3029 3035
3030 void Internals::crash() { 3036 void Internals::crash() {
3031 CHECK(false) << "Intentional crash"; 3037 CHECK(false) << "Intentional crash";
3032 } 3038 }
3033 3039
3034 } // namespace blink 3040 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698