| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 1999 Antti Koivisto (koivisto@kde.org) | 2 * Copyright (C) 1999 Antti Koivisto (koivisto@kde.org) |
| 3 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights
reserved. | 3 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights
reserved. |
| 4 * Copyright (C) 2011 Adobe Systems Incorporated. All rights reserved. | 4 * Copyright (C) 2011 Adobe Systems Incorporated. All rights reserved. |
| 5 * | 5 * |
| 6 * This library is free software; you can redistribute it and/or | 6 * This library is free software; you can redistribute it and/or |
| 7 * modify it under the terms of the GNU Library General Public | 7 * modify it under the terms of the GNU Library General Public |
| 8 * License as published by the Free Software Foundation; either | 8 * License as published by the Free Software Foundation; either |
| 9 * version 2 of the License, or (at your option) any later version. | 9 * version 2 of the License, or (at your option) any later version. |
| 10 * | 10 * |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 #include "core/rendering/style/ShadowList.h" | 33 #include "core/rendering/style/ShadowList.h" |
| 34 #include "core/rendering/style/StyleImage.h" | 34 #include "core/rendering/style/StyleImage.h" |
| 35 #include "core/rendering/style/StyleInheritedData.h" | 35 #include "core/rendering/style/StyleInheritedData.h" |
| 36 #include "platform/LengthFunctions.h" | 36 #include "platform/LengthFunctions.h" |
| 37 #include "platform/RuntimeEnabledFeatures.h" | 37 #include "platform/RuntimeEnabledFeatures.h" |
| 38 #include "platform/fonts/Font.h" | 38 #include "platform/fonts/Font.h" |
| 39 #include "platform/fonts/FontSelector.h" | 39 #include "platform/fonts/FontSelector.h" |
| 40 #include "platform/geometry/FloatRoundedRect.h" | 40 #include "platform/geometry/FloatRoundedRect.h" |
| 41 #include "wtf/MathExtras.h" | 41 #include "wtf/MathExtras.h" |
| 42 | 42 |
| 43 using namespace std; | |
| 44 | |
| 45 namespace WebCore { | 43 namespace WebCore { |
| 46 | 44 |
| 47 struct SameSizeAsBorderValue { | 45 struct SameSizeAsBorderValue { |
| 48 RGBA32 m_color; | 46 RGBA32 m_color; |
| 49 unsigned m_width; | 47 unsigned m_width; |
| 50 }; | 48 }; |
| 51 | 49 |
| 52 COMPILE_ASSERT(sizeof(BorderValue) == sizeof(SameSizeAsBorderValue), BorderValue
_should_not_grow); | 50 COMPILE_ASSERT(sizeof(BorderValue) == sizeof(SameSizeAsBorderValue), BorderValue
_should_not_grow); |
| 53 | 51 |
| 54 struct SameSizeAsRenderStyle : public RefCounted<SameSizeAsRenderStyle> { | 52 struct SameSizeAsRenderStyle : public RefCounted<SameSizeAsRenderStyle> { |
| (...skipping 1176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1231 | 1229 |
| 1232 void RenderStyle::setFontSize(float size) | 1230 void RenderStyle::setFontSize(float size) |
| 1233 { | 1231 { |
| 1234 // size must be specifiedSize if Text Autosizing is enabled, but computedSiz
e if text | 1232 // size must be specifiedSize if Text Autosizing is enabled, but computedSiz
e if text |
| 1235 // zoom is enabled (if neither is enabled it's irrelevant as they're probabl
y the same). | 1233 // zoom is enabled (if neither is enabled it's irrelevant as they're probabl
y the same). |
| 1236 | 1234 |
| 1237 ASSERT(std::isfinite(size)); | 1235 ASSERT(std::isfinite(size)); |
| 1238 if (!std::isfinite(size) || size < 0) | 1236 if (!std::isfinite(size) || size < 0) |
| 1239 size = 0; | 1237 size = 0; |
| 1240 else | 1238 else |
| 1241 size = min(maximumAllowedFontSize, size); | 1239 size = std::min(maximumAllowedFontSize, size); |
| 1242 | 1240 |
| 1243 FontSelector* currentFontSelector = font().fontSelector(); | 1241 FontSelector* currentFontSelector = font().fontSelector(); |
| 1244 FontDescription desc(fontDescription()); | 1242 FontDescription desc(fontDescription()); |
| 1245 desc.setSpecifiedSize(size); | 1243 desc.setSpecifiedSize(size); |
| 1246 desc.setComputedSize(size); | 1244 desc.setComputedSize(size); |
| 1247 | 1245 |
| 1248 float multiplier = textAutosizingMultiplier(); | 1246 float multiplier = textAutosizingMultiplier(); |
| 1249 if (multiplier > 1) { | 1247 if (multiplier > 1) { |
| 1250 float autosizedFontSize = TextAutosizer::computeAutosizedFontSize(size,
multiplier); | 1248 float autosizedFontSize = TextAutosizer::computeAutosizedFontSize(size,
multiplier); |
| 1251 desc.setComputedSize(min(maximumAllowedFontSize, autosizedFontSize)); | 1249 desc.setComputedSize(std::min(maximumAllowedFontSize, autosizedFontSize)
); |
| 1252 } | 1250 } |
| 1253 | 1251 |
| 1254 setFontDescription(desc); | 1252 setFontDescription(desc); |
| 1255 font().update(currentFontSelector); | 1253 font().update(currentFontSelector); |
| 1256 } | 1254 } |
| 1257 | 1255 |
| 1258 void RenderStyle::setFontWeight(FontWeight weight) | 1256 void RenderStyle::setFontWeight(FontWeight weight) |
| 1259 { | 1257 { |
| 1260 FontSelector* currentFontSelector = font().fontSelector(); | 1258 FontSelector* currentFontSelector = font().fontSelector(); |
| 1261 FontDescription desc(fontDescription()); | 1259 FontDescription desc(fontDescription()); |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1322 bottom = 0; | 1320 bottom = 0; |
| 1323 left = 0; | 1321 left = 0; |
| 1324 | 1322 |
| 1325 size_t shadowCount = shadowList ? shadowList->shadows().size() : 0; | 1323 size_t shadowCount = shadowList ? shadowList->shadows().size() : 0; |
| 1326 for (size_t i = 0; i < shadowCount; ++i) { | 1324 for (size_t i = 0; i < shadowCount; ++i) { |
| 1327 const ShadowData& shadow = shadowList->shadows()[i]; | 1325 const ShadowData& shadow = shadowList->shadows()[i]; |
| 1328 if (shadow.style() == Inset) | 1326 if (shadow.style() == Inset) |
| 1329 continue; | 1327 continue; |
| 1330 float blurAndSpread = shadow.blur() + shadow.spread(); | 1328 float blurAndSpread = shadow.blur() + shadow.spread(); |
| 1331 | 1329 |
| 1332 top = min<LayoutUnit>(top, shadow.y() - blurAndSpread); | 1330 top = std::min<LayoutUnit>(top, shadow.y() - blurAndSpread); |
| 1333 right = max<LayoutUnit>(right, shadow.x() + blurAndSpread); | 1331 right = std::max<LayoutUnit>(right, shadow.x() + blurAndSpread); |
| 1334 bottom = max<LayoutUnit>(bottom, shadow.y() + blurAndSpread); | 1332 bottom = std::max<LayoutUnit>(bottom, shadow.y() + blurAndSpread); |
| 1335 left = min<LayoutUnit>(left, shadow.x() - blurAndSpread); | 1333 left = std::min<LayoutUnit>(left, shadow.x() - blurAndSpread); |
| 1336 } | 1334 } |
| 1337 } | 1335 } |
| 1338 | 1336 |
| 1339 LayoutBoxExtent RenderStyle::getShadowInsetExtent(const ShadowList* shadowList)
const | 1337 LayoutBoxExtent RenderStyle::getShadowInsetExtent(const ShadowList* shadowList)
const |
| 1340 { | 1338 { |
| 1341 LayoutUnit top = 0; | 1339 LayoutUnit top = 0; |
| 1342 LayoutUnit right = 0; | 1340 LayoutUnit right = 0; |
| 1343 LayoutUnit bottom = 0; | 1341 LayoutUnit bottom = 0; |
| 1344 LayoutUnit left = 0; | 1342 LayoutUnit left = 0; |
| 1345 | 1343 |
| 1346 size_t shadowCount = shadowList ? shadowList->shadows().size() : 0; | 1344 size_t shadowCount = shadowList ? shadowList->shadows().size() : 0; |
| 1347 for (size_t i = 0; i < shadowCount; ++i) { | 1345 for (size_t i = 0; i < shadowCount; ++i) { |
| 1348 const ShadowData& shadow = shadowList->shadows()[i]; | 1346 const ShadowData& shadow = shadowList->shadows()[i]; |
| 1349 if (shadow.style() == Normal) | 1347 if (shadow.style() == Normal) |
| 1350 continue; | 1348 continue; |
| 1351 float blurAndSpread = shadow.blur() + shadow.spread(); | 1349 float blurAndSpread = shadow.blur() + shadow.spread(); |
| 1352 top = max<LayoutUnit>(top, shadow.y() + blurAndSpread); | 1350 top = std::max<LayoutUnit>(top, shadow.y() + blurAndSpread); |
| 1353 right = min<LayoutUnit>(right, shadow.x() - blurAndSpread); | 1351 right = std::min<LayoutUnit>(right, shadow.x() - blurAndSpread); |
| 1354 bottom = min<LayoutUnit>(bottom, shadow.y() - blurAndSpread); | 1352 bottom = std::min<LayoutUnit>(bottom, shadow.y() - blurAndSpread); |
| 1355 left = max<LayoutUnit>(left, shadow.x() + blurAndSpread); | 1353 left = std::max<LayoutUnit>(left, shadow.x() + blurAndSpread); |
| 1356 } | 1354 } |
| 1357 | 1355 |
| 1358 return LayoutBoxExtent(top, right, bottom, left); | 1356 return LayoutBoxExtent(top, right, bottom, left); |
| 1359 } | 1357 } |
| 1360 | 1358 |
| 1361 void RenderStyle::getShadowHorizontalExtent(const ShadowList* shadowList, Layout
Unit &left, LayoutUnit &right) const | 1359 void RenderStyle::getShadowHorizontalExtent(const ShadowList* shadowList, Layout
Unit &left, LayoutUnit &right) const |
| 1362 { | 1360 { |
| 1363 left = 0; | 1361 left = 0; |
| 1364 right = 0; | 1362 right = 0; |
| 1365 | 1363 |
| 1366 size_t shadowCount = shadowList ? shadowList->shadows().size() : 0; | 1364 size_t shadowCount = shadowList ? shadowList->shadows().size() : 0; |
| 1367 for (size_t i = 0; i < shadowCount; ++i) { | 1365 for (size_t i = 0; i < shadowCount; ++i) { |
| 1368 const ShadowData& shadow = shadowList->shadows()[i]; | 1366 const ShadowData& shadow = shadowList->shadows()[i]; |
| 1369 if (shadow.style() == Inset) | 1367 if (shadow.style() == Inset) |
| 1370 continue; | 1368 continue; |
| 1371 float blurAndSpread = shadow.blur() + shadow.spread(); | 1369 float blurAndSpread = shadow.blur() + shadow.spread(); |
| 1372 | 1370 |
| 1373 left = min<LayoutUnit>(left, shadow.x() - blurAndSpread); | 1371 left = std::min<LayoutUnit>(left, shadow.x() - blurAndSpread); |
| 1374 right = max<LayoutUnit>(right, shadow.x() + blurAndSpread); | 1372 right = std::max<LayoutUnit>(right, shadow.x() + blurAndSpread); |
| 1375 } | 1373 } |
| 1376 } | 1374 } |
| 1377 | 1375 |
| 1378 void RenderStyle::getShadowVerticalExtent(const ShadowList* shadowList, LayoutUn
it &top, LayoutUnit &bottom) const | 1376 void RenderStyle::getShadowVerticalExtent(const ShadowList* shadowList, LayoutUn
it &top, LayoutUnit &bottom) const |
| 1379 { | 1377 { |
| 1380 top = 0; | 1378 top = 0; |
| 1381 bottom = 0; | 1379 bottom = 0; |
| 1382 | 1380 |
| 1383 size_t shadowCount = shadowList ? shadowList->shadows().size() : 0; | 1381 size_t shadowCount = shadowList ? shadowList->shadows().size() : 0; |
| 1384 for (size_t i = 0; i < shadowCount; ++i) { | 1382 for (size_t i = 0; i < shadowCount; ++i) { |
| 1385 const ShadowData& shadow = shadowList->shadows()[i]; | 1383 const ShadowData& shadow = shadowList->shadows()[i]; |
| 1386 if (shadow.style() == Inset) | 1384 if (shadow.style() == Inset) |
| 1387 continue; | 1385 continue; |
| 1388 float blurAndSpread = shadow.blur() + shadow.spread(); | 1386 float blurAndSpread = shadow.blur() + shadow.spread(); |
| 1389 | 1387 |
| 1390 top = min<LayoutUnit>(top, shadow.y() - blurAndSpread); | 1388 top = std::min<LayoutUnit>(top, shadow.y() - blurAndSpread); |
| 1391 bottom = max<LayoutUnit>(bottom, shadow.y() + blurAndSpread); | 1389 bottom = std::max<LayoutUnit>(bottom, shadow.y() + blurAndSpread); |
| 1392 } | 1390 } |
| 1393 } | 1391 } |
| 1394 | 1392 |
| 1395 StyleColor RenderStyle::visitedDependentDecorationStyleColor() const | 1393 StyleColor RenderStyle::visitedDependentDecorationStyleColor() const |
| 1396 { | 1394 { |
| 1397 bool isVisited = insideLink() == InsideVisitedLink; | 1395 bool isVisited = insideLink() == InsideVisitedLink; |
| 1398 | 1396 |
| 1399 StyleColor styleColor = isVisited ? visitedLinkTextDecorationColor() : textD
ecorationColor(); | 1397 StyleColor styleColor = isVisited ? visitedLinkTextDecorationColor() : textD
ecorationColor(); |
| 1400 | 1398 |
| 1401 if (!styleColor.isCurrentColor()) | 1399 if (!styleColor.isCurrentColor()) |
| (...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1707 // right | 1705 // right |
| 1708 radiiSum = radii.topRight().height() + radii.bottomRight().height(); | 1706 radiiSum = radii.topRight().height() + radii.bottomRight().height(); |
| 1709 if (radiiSum > rect.height()) | 1707 if (radiiSum > rect.height()) |
| 1710 factor = std::min(rect.height() / radiiSum, factor); | 1708 factor = std::min(rect.height() / radiiSum, factor); |
| 1711 | 1709 |
| 1712 ASSERT(factor <= 1); | 1710 ASSERT(factor <= 1); |
| 1713 return factor; | 1711 return factor; |
| 1714 } | 1712 } |
| 1715 | 1713 |
| 1716 } // namespace WebCore | 1714 } // namespace WebCore |
| OLD | NEW |