| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 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 18 matching lines...) Expand all Loading... |
| 29 */ | 29 */ |
| 30 | 30 |
| 31 #include "sky/engine/config.h" | 31 #include "sky/engine/config.h" |
| 32 #include "sky/engine/core/css/CSSToLengthConversionData.h" | 32 #include "sky/engine/core/css/CSSToLengthConversionData.h" |
| 33 | 33 |
| 34 #include "sky/engine/core/rendering/RenderView.h" | 34 #include "sky/engine/core/rendering/RenderView.h" |
| 35 #include "sky/engine/core/rendering/style/RenderStyle.h" | 35 #include "sky/engine/core/rendering/style/RenderStyle.h" |
| 36 | 36 |
| 37 namespace blink { | 37 namespace blink { |
| 38 | 38 |
| 39 CSSToLengthConversionData::CSSToLengthConversionData(const RenderStyle* style, c
onst RenderStyle* rootStyle, const RenderView* renderView, bool computingFontSiz
e) | 39 CSSToLengthConversionData::CSSToLengthConversionData(const RenderStyle* style, c
onst RenderView* renderView, bool computingFontSize) |
| 40 : m_style(style) | 40 : m_style(style) |
| 41 , m_rootStyle(rootStyle) | |
| 42 , m_viewportWidth(renderView ? renderView->layoutViewportWidth() : 0) | 41 , m_viewportWidth(renderView ? renderView->layoutViewportWidth() : 0) |
| 43 , m_viewportHeight(renderView ? renderView->layoutViewportHeight() : 0) | 42 , m_viewportHeight(renderView ? renderView->layoutViewportHeight() : 0) |
| 44 , m_computingFontSize(computingFontSize) | 43 , m_computingFontSize(computingFontSize) |
| 45 { | 44 { |
| 46 } | 45 } |
| 47 | 46 |
| 48 double CSSToLengthConversionData::viewportWidthPercent() const | 47 double CSSToLengthConversionData::viewportWidthPercent() const |
| 49 { | 48 { |
| 50 m_style->setHasViewportUnits(); | 49 m_style->setHasViewportUnits(); |
| 51 return m_viewportWidth / 100; | 50 return m_viewportWidth / 100; |
| 52 } | 51 } |
| 53 double CSSToLengthConversionData::viewportHeightPercent() const | 52 double CSSToLengthConversionData::viewportHeightPercent() const |
| 54 { | 53 { |
| 55 m_style->setHasViewportUnits(); | 54 m_style->setHasViewportUnits(); |
| 56 return m_viewportHeight / 100; | 55 return m_viewportHeight / 100; |
| 57 } | 56 } |
| 58 double CSSToLengthConversionData::viewportMinPercent() const | 57 double CSSToLengthConversionData::viewportMinPercent() const |
| 59 { | 58 { |
| 60 m_style->setHasViewportUnits(); | 59 m_style->setHasViewportUnits(); |
| 61 return std::min(m_viewportWidth, m_viewportHeight) / 100; | 60 return std::min(m_viewportWidth, m_viewportHeight) / 100; |
| 62 } | 61 } |
| 63 double CSSToLengthConversionData::viewportMaxPercent() const | 62 double CSSToLengthConversionData::viewportMaxPercent() const |
| 64 { | 63 { |
| 65 m_style->setHasViewportUnits(); | 64 m_style->setHasViewportUnits(); |
| 66 return std::max(m_viewportWidth, m_viewportHeight) / 100; | 65 return std::max(m_viewportWidth, m_viewportHeight) / 100; |
| 67 } | 66 } |
| 68 | 67 |
| 69 } // namespace blink | 68 } // namespace blink |
| OLD | NEW |