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 | 3 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights |
4 * reserved. | 4 * reserved. |
5 * Copyright (C) 2011 Adobe Systems Incorporated. All rights reserved. | 5 * Copyright (C) 2011 Adobe Systems Incorporated. All rights reserved. |
6 * | 6 * |
7 * This library is free software; you can redistribute it and/or | 7 * This library is free software; you can redistribute it and/or |
8 * modify it under the terms of the GNU Library General Public | 8 * modify it under the terms of the GNU Library General Public |
9 * License as published by the Free Software Foundation; either | 9 * License as published by the Free Software Foundation; either |
10 * version 2 of the License, or (at your option) any later version. | 10 * version 2 of the License, or (at your option) any later version. |
(...skipping 1390 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1401 | 1401 |
1402 StyleImage* ComputedStyle::ListStyleImage() const { | 1402 StyleImage* ComputedStyle::ListStyleImage() const { |
1403 return rare_inherited_data_->list_style_image_.Get(); | 1403 return rare_inherited_data_->list_style_image_.Get(); |
1404 } | 1404 } |
1405 void ComputedStyle::SetListStyleImage(StyleImage* v) { | 1405 void ComputedStyle::SetListStyleImage(StyleImage* v) { |
1406 if (rare_inherited_data_->list_style_image_ != v) | 1406 if (rare_inherited_data_->list_style_image_ != v) |
1407 rare_inherited_data_.Access()->list_style_image_ = v; | 1407 rare_inherited_data_.Access()->list_style_image_ = v; |
1408 } | 1408 } |
1409 | 1409 |
1410 Color ComputedStyle::GetColor() const { | 1410 Color ComputedStyle::GetColor() const { |
1411 return inherited_data_->color_; | 1411 return ColorInternal(); |
1412 } | 1412 } |
1413 void ComputedStyle::SetColor(const Color& v) { | 1413 void ComputedStyle::SetColor(const Color& v) { |
1414 SET_VAR(inherited_data_, color_, v); | 1414 SetColorInternal(v); |
1415 } | 1415 } |
1416 | 1416 |
1417 FloatRoundedRect ComputedStyle::GetRoundedBorderFor( | 1417 FloatRoundedRect ComputedStyle::GetRoundedBorderFor( |
1418 const LayoutRect& border_rect, | 1418 const LayoutRect& border_rect, |
1419 bool include_logical_left_edge, | 1419 bool include_logical_left_edge, |
1420 bool include_logical_right_edge) const { | 1420 bool include_logical_right_edge) const { |
1421 FloatRoundedRect rounded_rect(PixelSnappedIntRect(border_rect)); | 1421 FloatRoundedRect rounded_rect(PixelSnappedIntRect(border_rect)); |
1422 if (HasBorderRadius()) { | 1422 if (HasBorderRadius()) { |
1423 FloatRoundedRect::Radii radii = | 1423 FloatRoundedRect::Radii radii = |
1424 CalcRadiiFor(Border(), BorderTopLeftRadius(), BorderTopRightRadius(), | 1424 CalcRadiiFor(Border(), BorderTopLeftRadius(), BorderTopRightRadius(), |
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1652 } | 1652 } |
1653 | 1653 |
1654 CSSTransitionData& ComputedStyle::AccessTransitions() { | 1654 CSSTransitionData& ComputedStyle::AccessTransitions() { |
1655 if (!rare_non_inherited_data_.Access()->transitions_) | 1655 if (!rare_non_inherited_data_.Access()->transitions_) |
1656 rare_non_inherited_data_.Access()->transitions_ = | 1656 rare_non_inherited_data_.Access()->transitions_ = |
1657 CSSTransitionData::Create(); | 1657 CSSTransitionData::Create(); |
1658 return *rare_non_inherited_data_->transitions_; | 1658 return *rare_non_inherited_data_->transitions_; |
1659 } | 1659 } |
1660 | 1660 |
1661 const Font& ComputedStyle::GetFont() const { | 1661 const Font& ComputedStyle::GetFont() const { |
1662 return inherited_data_->font_; | 1662 return FontInternal(); |
1663 } | 1663 } |
1664 const FontDescription& ComputedStyle::GetFontDescription() const { | 1664 const FontDescription& ComputedStyle::GetFontDescription() const { |
1665 return inherited_data_->font_.GetFontDescription(); | 1665 return FontInternal().GetFontDescription(); |
1666 } | 1666 } |
1667 float ComputedStyle::SpecifiedFontSize() const { | 1667 float ComputedStyle::SpecifiedFontSize() const { |
1668 return GetFontDescription().SpecifiedSize(); | 1668 return GetFontDescription().SpecifiedSize(); |
1669 } | 1669 } |
1670 float ComputedStyle::ComputedFontSize() const { | 1670 float ComputedStyle::ComputedFontSize() const { |
1671 return GetFontDescription().ComputedSize(); | 1671 return GetFontDescription().ComputedSize(); |
1672 } | 1672 } |
1673 LayoutUnit ComputedStyle::ComputedFontSizeAsFixed() const { | 1673 LayoutUnit ComputedStyle::ComputedFontSizeAsFixed() const { |
1674 return LayoutUnit::FromFloatRound(GetFontDescription().ComputedSize()); | 1674 return LayoutUnit::FromFloatRound(GetFontDescription().ComputedSize()); |
1675 } | 1675 } |
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1848 } | 1848 } |
1849 | 1849 |
1850 float ComputedStyle::WordSpacing() const { | 1850 float ComputedStyle::WordSpacing() const { |
1851 return GetFontDescription().WordSpacing(); | 1851 return GetFontDescription().WordSpacing(); |
1852 } | 1852 } |
1853 float ComputedStyle::LetterSpacing() const { | 1853 float ComputedStyle::LetterSpacing() const { |
1854 return GetFontDescription().LetterSpacing(); | 1854 return GetFontDescription().LetterSpacing(); |
1855 } | 1855 } |
1856 | 1856 |
1857 bool ComputedStyle::SetFontDescription(const FontDescription& v) { | 1857 bool ComputedStyle::SetFontDescription(const FontDescription& v) { |
1858 if (inherited_data_->font_.GetFontDescription() != v) { | 1858 if (FontInternal().GetFontDescription() != v) { |
1859 inherited_data_.Access()->font_ = Font(v); | 1859 SetFontInternal(Font(v)); |
1860 return true; | 1860 return true; |
1861 } | 1861 } |
1862 return false; | 1862 return false; |
1863 } | 1863 } |
1864 | 1864 |
1865 void ComputedStyle::SetFont(const Font& font) { | 1865 void ComputedStyle::SetFont(const Font& font) { |
1866 inherited_data_.Access()->font_ = font; | 1866 SetFontInternal(font); |
1867 } | 1867 } |
1868 | 1868 |
1869 bool ComputedStyle::HasIdenticalAscentDescentAndLineGap( | 1869 bool ComputedStyle::HasIdenticalAscentDescentAndLineGap( |
1870 const ComputedStyle& other) const { | 1870 const ComputedStyle& other) const { |
1871 const SimpleFontData* font_data = GetFont().PrimaryFont(); | 1871 const SimpleFontData* font_data = GetFont().PrimaryFont(); |
1872 const SimpleFontData* other_font_data = other.GetFont().PrimaryFont(); | 1872 const SimpleFontData* other_font_data = other.GetFont().PrimaryFont(); |
1873 return font_data && other_font_data && | 1873 return font_data && other_font_data && |
1874 font_data->GetFontMetrics().HasIdenticalAscentDescentAndLineGap( | 1874 font_data->GetFontMetrics().HasIdenticalAscentDescentAndLineGap( |
1875 other_font_data->GetFontMetrics()); | 1875 other_font_data->GetFontMetrics()); |
1876 } | 1876 } |
1877 | 1877 |
1878 const Length& ComputedStyle::SpecifiedLineHeight() const { | 1878 const Length& ComputedStyle::SpecifiedLineHeight() const { |
1879 return inherited_data_->line_height_; | 1879 return LineHeightInternal(); |
1880 } | 1880 } |
1881 Length ComputedStyle::LineHeight() const { | 1881 Length ComputedStyle::LineHeight() const { |
1882 const Length& lh = inherited_data_->line_height_; | 1882 const Length& lh = LineHeightInternal(); |
1883 // Unlike getFontDescription().computedSize() and hence fontSize(), this is | 1883 // Unlike getFontDescription().computedSize() and hence fontSize(), this is |
1884 // recalculated on demand as we only store the specified line height. | 1884 // recalculated on demand as we only store the specified line height. |
1885 // FIXME: Should consider scaling the fixed part of any calc expressions | 1885 // FIXME: Should consider scaling the fixed part of any calc expressions |
1886 // too, though this involves messily poking into CalcExpressionLength. | 1886 // too, though this involves messily poking into CalcExpressionLength. |
1887 if (lh.IsFixed()) { | 1887 if (lh.IsFixed()) { |
1888 float multiplier = TextAutosizingMultiplier(); | 1888 float multiplier = TextAutosizingMultiplier(); |
1889 return Length( | 1889 return Length( |
1890 TextAutosizer::ComputeAutosizedFontSize(lh.Value(), multiplier), | 1890 TextAutosizer::ComputeAutosizedFontSize(lh.Value(), multiplier), |
1891 kFixed); | 1891 kFixed); |
1892 } | 1892 } |
1893 | 1893 |
1894 return lh; | 1894 return lh; |
1895 } | 1895 } |
1896 | 1896 |
1897 void ComputedStyle::SetLineHeight(const Length& specified_line_height) { | 1897 void ComputedStyle::SetLineHeight(const Length& specified_line_height) { |
1898 SET_VAR(inherited_data_, line_height_, specified_line_height); | 1898 SetLineHeightInternal(specified_line_height); |
1899 } | 1899 } |
1900 | 1900 |
1901 int ComputedStyle::ComputedLineHeight() const { | 1901 int ComputedStyle::ComputedLineHeight() const { |
1902 const Length& lh = LineHeight(); | 1902 const Length& lh = LineHeight(); |
1903 | 1903 |
1904 // Negative value means the line height is not set. Use the font's built-in | 1904 // Negative value means the line height is not set. Use the font's built-in |
1905 // spacing, if avalible. | 1905 // spacing, if avalible. |
1906 if (lh.IsNegative() && GetFont().PrimaryFont()) | 1906 if (lh.IsNegative() && GetFont().PrimaryFont()) |
1907 return GetFont().PrimaryFont()->GetFontMetrics().LineSpacing(); | 1907 return GetFont().PrimaryFont()->GetFontMetrics().LineSpacing(); |
1908 | 1908 |
(...skipping 27 matching lines...) Expand all Loading... |
1936 | 1936 |
1937 void ComputedStyle::SetLetterSpacing(float letter_spacing) { | 1937 void ComputedStyle::SetLetterSpacing(float letter_spacing) { |
1938 FontSelector* current_font_selector = GetFont().GetFontSelector(); | 1938 FontSelector* current_font_selector = GetFont().GetFontSelector(); |
1939 FontDescription desc(GetFontDescription()); | 1939 FontDescription desc(GetFontDescription()); |
1940 desc.SetLetterSpacing(letter_spacing); | 1940 desc.SetLetterSpacing(letter_spacing); |
1941 SetFontDescription(desc); | 1941 SetFontDescription(desc); |
1942 GetFont().Update(current_font_selector); | 1942 GetFont().Update(current_font_selector); |
1943 } | 1943 } |
1944 | 1944 |
1945 void ComputedStyle::SetTextAutosizingMultiplier(float multiplier) { | 1945 void ComputedStyle::SetTextAutosizingMultiplier(float multiplier) { |
1946 SET_VAR(inherited_data_, text_autosizing_multiplier_, multiplier); | 1946 SetTextAutosizingMultiplierInternal(multiplier); |
1947 | 1947 |
1948 float size = SpecifiedFontSize(); | 1948 float size = SpecifiedFontSize(); |
1949 | 1949 |
1950 DCHECK(std::isfinite(size)); | 1950 DCHECK(std::isfinite(size)); |
1951 if (!std::isfinite(size) || size < 0) | 1951 if (!std::isfinite(size) || size < 0) |
1952 size = 0; | 1952 size = 0; |
1953 else | 1953 else |
1954 size = std::min(kMaximumAllowedFontSize, size); | 1954 size = std::min(kMaximumAllowedFontSize, size); |
1955 | 1955 |
1956 FontSelector* current_font_selector = GetFont().GetFontSelector(); | 1956 FontSelector* current_font_selector = GetFont().GetFontSelector(); |
(...skipping 525 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2482 if (value < 0) | 2482 if (value < 0) |
2483 fvalue -= 0.5f; | 2483 fvalue -= 0.5f; |
2484 else | 2484 else |
2485 fvalue += 0.5f; | 2485 fvalue += 0.5f; |
2486 } | 2486 } |
2487 | 2487 |
2488 return RoundForImpreciseConversion<int>(fvalue / zoom_factor); | 2488 return RoundForImpreciseConversion<int>(fvalue / zoom_factor); |
2489 } | 2489 } |
2490 | 2490 |
2491 } // namespace blink | 2491 } // namespace blink |
OLD | NEW |