OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
3 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc.
All rights reserved. | 3 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc.
All rights reserved. |
4 * Copyright (C) 2013 Google Inc. All rights reserved. | 4 * Copyright (C) 2013 Google Inc. 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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 } | 55 } |
56 | 56 |
57 private: | 57 private: |
58 FontBuilder* m_fontBuilder; | 58 FontBuilder* m_fontBuilder; |
59 FontDescription m_fontDescription; | 59 FontDescription m_fontDescription; |
60 }; | 60 }; |
61 | 61 |
62 FontBuilder::FontBuilder() | 62 FontBuilder::FontBuilder() |
63 : m_document(0) | 63 : m_document(0) |
64 , m_useSVGZoomRules(false) | 64 , m_useSVGZoomRules(false) |
| 65 , m_fontSizehasViewportUnits(false) |
65 , m_fontDirty(false) | 66 , m_fontDirty(false) |
66 { | 67 { |
67 } | 68 } |
68 | 69 |
69 void FontBuilder::initForStyleResolve(const Document& document, RenderStyle* sty
le, bool useSVGZoomRules) | 70 void FontBuilder::initForStyleResolve(const Document& document, RenderStyle* sty
le, bool useSVGZoomRules) |
70 { | 71 { |
71 // All documents need to be in a frame (and thus have access to Settings) | 72 // All documents need to be in a frame (and thus have access to Settings) |
72 // for style-resolution to make sense. | 73 // for style-resolution to make sense. |
73 // Unfortunately SVG Animations currently violate this: crbug.com/260966 | 74 // Unfortunately SVG Animations currently violate this: crbug.com/260966 |
74 // ASSERT(m_document->frame()); | 75 // ASSERT(m_document->frame()); |
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
317 case CSSValueSmaller: | 318 case CSSValueSmaller: |
318 size = smallerFontSize(parentSize); | 319 size = smallerFontSize(parentSize); |
319 break; | 320 break; |
320 default: | 321 default: |
321 return; | 322 return; |
322 } | 323 } |
323 | 324 |
324 scope.fontDescription().setIsAbsoluteSize(parentIsAbsoluteSize && (value
ID == CSSValueLarger || valueID == CSSValueSmaller)); | 325 scope.fontDescription().setIsAbsoluteSize(parentIsAbsoluteSize && (value
ID == CSSValueLarger || valueID == CSSValueSmaller)); |
325 } else { | 326 } else { |
326 scope.fontDescription().setIsAbsoluteSize(parentIsAbsoluteSize || !(prim
itiveValue->isPercentage() || primitiveValue->isFontRelativeLength())); | 327 scope.fontDescription().setIsAbsoluteSize(parentIsAbsoluteSize || !(prim
itiveValue->isPercentage() || primitiveValue->isFontRelativeLength())); |
327 if (primitiveValue->isLength()) | 328 if (primitiveValue->isPercentage()) { |
328 size = primitiveValue->computeLength<float>(CSSToLengthConversionDat
a(parentStyle, rootElementStyle, 1.0, true)); | |
329 else if (primitiveValue->isPercentage()) | |
330 size = (primitiveValue->getFloatValue() * parentSize) / 100.0f; | 329 size = (primitiveValue->getFloatValue() * parentSize) / 100.0f; |
331 else if (primitiveValue->isCalculatedPercentageWithLength()) | 330 } else { |
332 size = primitiveValue->cssCalcValue()->toCalcValue(CSSToLengthConver
sionData(parentStyle, rootElementStyle, 1.0f))->evaluate(parentSize); | 331 // If we have viewport units the conversion will mark the parent sty
le as having viewport units. |
333 else if (primitiveValue->isViewportPercentageLength()) | 332 bool parentHasViewportUnits = parentStyle->hasViewportUnits(); |
334 size = valueForLength(primitiveValue->viewportPercentageLength(), 0,
m_document->renderView()); | 333 parentStyle->setHasViewportUnits(false); |
335 else | 334 CSSToLengthConversionData conversionData(parentStyle, rootElementSty
le, m_document->renderView(), 1.0f, true); |
336 return; | 335 if (primitiveValue->isLength()) |
| 336 size = primitiveValue->computeLength<float>(conversionData); |
| 337 else if (primitiveValue->isCalculatedPercentageWithLength()) |
| 338 size = primitiveValue->cssCalcValue()->toCalcValue(conversionDat
a)->evaluate(parentSize); |
| 339 else |
| 340 ASSERT_NOT_REACHED(); |
| 341 m_fontSizehasViewportUnits = parentStyle->hasViewportUnits(); |
| 342 parentStyle->setHasViewportUnits(parentHasViewportUnits); |
| 343 } |
337 } | 344 } |
338 | 345 |
339 if (size < 0) | 346 if (size < 0) |
340 return; | 347 return; |
341 | 348 |
342 // Overly large font sizes will cause crashes on some platforms (such as Win
dows). | 349 // Overly large font sizes will cause crashes on some platforms (such as Win
dows). |
343 // Cap font size here to make sure that doesn't happen. | 350 // Cap font size here to make sure that doesn't happen. |
344 size = std::min(maximumAllowedFontSize, size); | 351 size = std::min(maximumAllowedFontSize, size); |
345 | 352 |
346 setSize(scope.fontDescription(), effectiveZoom, size); | 353 setSize(scope.fontDescription(), effectiveZoom, size); |
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
660 FontOrientation fontOrientation; | 667 FontOrientation fontOrientation; |
661 NonCJKGlyphOrientation glyphOrientation; | 668 NonCJKGlyphOrientation glyphOrientation; |
662 getFontAndGlyphOrientation(documentStyle, fontOrientation, glyphOrientation)
; | 669 getFontAndGlyphOrientation(documentStyle, fontOrientation, glyphOrientation)
; |
663 fontDescription.setOrientation(fontOrientation); | 670 fontDescription.setOrientation(fontOrientation); |
664 fontDescription.setNonCJKGlyphOrientation(glyphOrientation); | 671 fontDescription.setNonCJKGlyphOrientation(glyphOrientation); |
665 documentStyle->setFontDescription(fontDescription); | 672 documentStyle->setFontDescription(fontDescription); |
666 documentStyle->font().update(fontSelector); | 673 documentStyle->font().update(fontSelector); |
667 } | 674 } |
668 | 675 |
669 } | 676 } |
OLD | NEW |