Changeset 100656 in webkit


Ignore:
Timestamp:
Nov 17, 2011 12:09:34 PM (12 years ago)
Author:
fsamuel@chromium.org
Message:

Pass Aspect Ratio to RenderStyle
https://bugs.webkit.org/show_bug.cgi?id=72350

Reviewed by Ojan Vafai.

  • css/CSSComputedStyleDeclaration.cpp:

(WebCore::CSSComputedStyleDeclaration::getPropertyCSSValue):

  • css/CSSStyleApplyProperty.cpp:

(WebCore::ApplyPropertyAspectRatio::applyInheritValue):
(WebCore::ApplyPropertyAspectRatio::applyInitialValue):
(WebCore::ApplyPropertyAspectRatio::applyValue):
(WebCore::ApplyPropertyAspectRatio::createHandler):
(WebCore::CSSStyleApplyProperty::CSSStyleApplyProperty):

  • css/CSSStyleSelector.cpp:

(WebCore::CSSStyleSelector::applyProperty):

  • css/CSSValue.h:

(WebCore::CSSValue::isAspectRatioValue):

  • rendering/style/RenderStyle.h:

(WebCore::InheritedFlags::hasAspectRatio):
(WebCore::InheritedFlags::aspectRatio):
(WebCore::InheritedFlags::aspectRatioDenominator):
(WebCore::InheritedFlags::aspectRatioNumerator):
(WebCore::InheritedFlags::setHasAspectRatio):
(WebCore::InheritedFlags::setAspectRatioDenominator):
(WebCore::InheritedFlags::setAspectRatioNumerator):
(WebCore::InheritedFlags::initialHasAspectRatio):
(WebCore::InheritedFlags::initialAspectRatioDenominator):
(WebCore::InheritedFlags::initialAspectRatioNumerator):

  • rendering/style/StyleRareNonInheritedData.cpp:

(WebCore::StyleRareNonInheritedData::StyleRareNonInheritedData):
(WebCore::StyleRareNonInheritedData::operator==):

  • rendering/style/StyleRareNonInheritedData.h:
Location:
trunk/Source/WebCore
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r100652 r100656  
     12011-11-17  Fady Samuel  <fsamuel@chromium.org>
     2
     3        Pass Aspect Ratio to RenderStyle
     4        https://bugs.webkit.org/show_bug.cgi?id=72350
     5
     6        Reviewed by Ojan Vafai.
     7
     8        * css/CSSComputedStyleDeclaration.cpp:
     9        (WebCore::CSSComputedStyleDeclaration::getPropertyCSSValue):
     10        * css/CSSStyleApplyProperty.cpp:
     11        (WebCore::ApplyPropertyAspectRatio::applyInheritValue):
     12        (WebCore::ApplyPropertyAspectRatio::applyInitialValue):
     13        (WebCore::ApplyPropertyAspectRatio::applyValue):
     14        (WebCore::ApplyPropertyAspectRatio::createHandler):
     15        (WebCore::CSSStyleApplyProperty::CSSStyleApplyProperty):
     16        * css/CSSStyleSelector.cpp:
     17        (WebCore::CSSStyleSelector::applyProperty):
     18        * css/CSSValue.h:
     19        (WebCore::CSSValue::isAspectRatioValue):
     20        * rendering/style/RenderStyle.h:
     21        (WebCore::InheritedFlags::hasAspectRatio):
     22        (WebCore::InheritedFlags::aspectRatio):
     23        (WebCore::InheritedFlags::aspectRatioDenominator):
     24        (WebCore::InheritedFlags::aspectRatioNumerator):
     25        (WebCore::InheritedFlags::setHasAspectRatio):
     26        (WebCore::InheritedFlags::setAspectRatioDenominator):
     27        (WebCore::InheritedFlags::setAspectRatioNumerator):
     28        (WebCore::InheritedFlags::initialHasAspectRatio):
     29        (WebCore::InheritedFlags::initialAspectRatioDenominator):
     30        (WebCore::InheritedFlags::initialAspectRatioNumerator):
     31        * rendering/style/StyleRareNonInheritedData.cpp:
     32        (WebCore::StyleRareNonInheritedData::StyleRareNonInheritedData):
     33        (WebCore::StyleRareNonInheritedData::operator==):
     34        * rendering/style/StyleRareNonInheritedData.h:
     35
    1362011-11-09  Robert Hogan  <robert@webkit.org>
    237
  • trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp

    r100604 r100656  
    18771877        case CSSPropertyWebkitAppearance:
    18781878            return primitiveValueCache->createValue(style->appearance());
     1879        case CSSPropertyWebkitAspectRatio:
     1880            if (!style->hasAspectRatio())
     1881                return primitiveValueCache->createIdentifierValue(CSSValueNone);
     1882            return primitiveValueCache->createValue(style->aspectRatio(), CSSPrimitiveValue::CSS_NUMBER);
    18791883        case CSSPropertyWebkitBackfaceVisibility:
    18801884            return primitiveValueCache->createIdentifierValue((style->backfaceVisibility() == BackfaceVisibilityHidden) ? CSSValueHidden : CSSValueVisible);
     
    20712075
    20722076        /* Unimplemented CSS 3 properties (including CSS3 shorthand properties) */
    2073         case CSSPropertyWebkitAspectRatio:
    20742077        case CSSPropertyWebkitTextEmphasis:
    20752078        case CSSPropertyTextLineThrough:
  • trunk/Source/WebCore/css/CSSStyleApplyProperty.cpp

    r100604 r100656  
    2626#include "CSSStyleApplyProperty.h"
    2727
     28#include "CSSAspectRatioValue.h"
    2829#include "CSSCursorImageValue.h"
    2930#include "CSSFlexValue.h"
     
    832833};
    833834
     835class ApplyPropertyAspectRatio {
     836public:
     837    static void applyInheritValue(CSSStyleSelector* selector)
     838    {
     839        if (!selector->parentStyle()->hasAspectRatio())
     840            return;
     841        selector->style()->setAspectRatioDenominator(selector->parentStyle()->aspectRatioDenominator());
     842        selector->style()->setAspectRatioNumerator(selector->parentStyle()->aspectRatioNumerator());
     843    }
     844
     845    static void applyInitialValue(CSSStyleSelector* selector)
     846    {
     847        selector->style()->setHasAspectRatio(RenderStyle::initialHasAspectRatio());
     848        selector->style()->setAspectRatioDenominator(RenderStyle::initialAspectRatioDenominator());
     849        selector->style()->setAspectRatioNumerator(RenderStyle::initialAspectRatioNumerator());
     850    }
     851
     852    static void applyValue(CSSStyleSelector* selector, CSSValue* value)
     853    {
     854        if (!value->isAspectRatioValue()) {
     855            selector->style()->setHasAspectRatio(false);
     856            return;
     857        }
     858        CSSAspectRatioValue* aspectRatioValue = static_cast<CSSAspectRatioValue*>(value);
     859        selector->style()->setHasAspectRatio(true);
     860        selector->style()->setAspectRatioDenominator(aspectRatioValue->denominatorValue());
     861        selector->style()->setAspectRatioNumerator(aspectRatioValue->numeratorValue());
     862    }
     863
     864    static PropertyHandler createHandler()
     865    {
     866        return PropertyHandler(&applyInheritValue, &applyInitialValue, &applyValue);
     867    }
     868};
     869
    834870const CSSStyleApplyProperty& CSSStyleApplyProperty::sharedCSSStyleApplyProperty()
    835871{
     
    842878    for (int i = 0; i < numCSSProperties; ++i)
    843879        m_propertyMap[i] = PropertyHandler();
     880
     881    setPropertyHandler(CSSPropertyWebkitAspectRatio, ApplyPropertyAspectRatio::createHandler());
    844882
    845883    setPropertyHandler(CSSPropertyColor, ApplyPropertyColor<InheritFromParent, &RenderStyle::color, &RenderStyle::setColor, &RenderStyle::setVisitedLinkColor, &RenderStyle::invalidColor, RenderStyle::initialColor>::createHandler());
  • trunk/Source/WebCore/css/CSSStyleSelector.cpp

    r100604 r100656  
    3030
    3131#include "Attribute.h"
     32#include "CachedImage.h"
    3233#include "ContentData.h"
     34#include "Counter.h"
    3335#include "CounterContent.h"
    34 #include "CursorList.h"
    3536#include "CSSBorderImageValue.h"
    3637#include "CSSCursorImageValue.h"
     
    5455#include "CSSTimingFunctionValue.h"
    5556#include "CSSValueList.h"
    56 #include "CachedImage.h"
    57 #include "Counter.h"
     57#include "CursorList.h"
    5858#if ENABLE(CSS_FILTERS)
    5959#include "FilterOperation.h"
     
    38233823    case CSSPropertyTextUnderlineStyle:
    38243824    case CSSPropertyTextUnderlineWidth:
    3825     case CSSPropertyWebkitAspectRatio:
    38263825    case CSSPropertyWebkitFontSizeDelta:
    38273826    case CSSPropertyWebkitTextDecorationsInEffect:
     
    39263925    case CSSPropertyWebkitBackgroundOrigin:
    39273926    case CSSPropertyBackgroundImage:
     3927    case CSSPropertyWebkitAspectRatio:
    39283928    case CSSPropertyBackgroundSize:
    39293929    case CSSPropertyWebkitBackgroundSize:
  • trunk/Source/WebCore/css/CSSValue.h

    r100481 r100656  
    6060    bool isValueList() const { return m_isList; }
    6161
     62    bool isAspectRatioValue() const { return m_classType == AspectRatioClass; }
    6263    bool isBorderImageValue() const { return m_classType == BorderImageClass; }
    6364    bool isBorderImageSliceValue() const { return m_classType == BorderImageSliceClass; }
  • trunk/Source/WebCore/rendering/style/RenderStyle.h

    r100604 r100656  
    702702    float opacity() const { return rareNonInheritedData->opacity; }
    703703    ControlPart appearance() const { return static_cast<ControlPart>(rareNonInheritedData->m_appearance); }
     704    // aspect ratio convenience method
     705    bool hasAspectRatio() const { return rareNonInheritedData->m_hasAspectRatio; }
     706    float aspectRatio() const { return aspectRatioNumerator() / aspectRatioDenominator(); }
     707    float aspectRatioDenominator() const { return rareNonInheritedData->m_aspectRatioDenominator; }
     708    float aspectRatioNumerator() const { return rareNonInheritedData->m_aspectRatioNumerator; }
    704709    EBoxAlignment boxAlign() const { return static_cast<EBoxAlignment>(rareNonInheritedData->m_deprecatedFlexibleBox->align); }
    705710    EBoxDirection boxDirection() const { return static_cast<EBoxDirection>(inherited_flags._box_direction); }
     
    10551060    void setCaptionSide(ECaptionSide v) { inherited_flags._caption_side = v; }
    10561061
     1062    void setHasAspectRatio(bool b) { SET_VAR(rareNonInheritedData, m_hasAspectRatio, b); }
     1063    void setAspectRatioDenominator(float v) { SET_VAR(rareNonInheritedData, m_aspectRatioDenominator, v); }
     1064    void setAspectRatioNumerator(float v) { SET_VAR(rareNonInheritedData, m_aspectRatioNumerator, v); }
    10571065    void setCounterIncrement(short v) { SET_VAR(rareNonInheritedData, m_counterIncrement, v) }
    10581066    void setCounterReset(short v) { SET_VAR(rareNonInheritedData, m_counterReset, v) }
     
    14641472    static EResize initialResize() { return RESIZE_NONE; }
    14651473    static ControlPart initialAppearance() { return NoControlPart; }
     1474    static bool initialHasAspectRatio() { return false; }
     1475    static float initialAspectRatioDenominator() { return 1; }
     1476    static float initialAspectRatioNumerator() { return 1; }
    14661477    static Order initialRTLOrdering() { return LogicalOrder; }
    14671478    static float initialTextStrokeWidth() { return 0; }
  • trunk/Source/WebCore/rendering/style/StyleRareNonInheritedData.cpp

    r100604 r100656  
    3636StyleRareNonInheritedData::StyleRareNonInheritedData()
    3737    : opacity(RenderStyle::initialOpacity())
     38    , m_aspectRatioDenominator(RenderStyle::initialAspectRatioDenominator())
     39    , m_aspectRatioNumerator(RenderStyle::initialAspectRatioNumerator())
    3840    , m_counterIncrement(0)
    3941    , m_counterReset(0)
     
    6769    , m_wrapFlow(RenderStyle::initialWrapFlow())
    6870    , m_wrapThrough(RenderStyle::initialWrapThrough())
     71    , m_hasAspectRatio(false)
    6972#if USE(ACCELERATED_COMPOSITING)
    7073    , m_runningAcceleratedAnimation(false)
     
    7780    : RefCounted<StyleRareNonInheritedData>()
    7881    , opacity(o.opacity)
     82    , m_aspectRatioDenominator(o.m_aspectRatioDenominator)
     83    , m_aspectRatioNumerator(o.m_aspectRatioNumerator)
    7984    , m_counterIncrement(o.m_counterIncrement)
    8085    , m_counterReset(o.m_counterReset)
     
    128133    , m_wrapFlow(o.m_wrapFlow)
    129134    , m_wrapThrough(o.m_wrapThrough)
     135    , m_hasAspectRatio(o.m_hasAspectRatio)
    130136#if USE(ACCELERATED_COMPOSITING)
    131137    , m_runningAcceleratedAnimation(o.m_runningAcceleratedAnimation)
     
    163169        && m_borderFit == o.m_borderFit
    164170        && m_textCombine == o.m_textCombine
     171        && m_aspectRatioDenominator == o.m_aspectRatioDenominator
     172        && m_aspectRatioNumerator == o.m_aspectRatioNumerator
    165173        && m_counterIncrement == o.m_counterIncrement
    166174        && m_counterReset == o.m_counterReset
     175        && m_hasAspectRatio == o.m_hasAspectRatio
    167176#if USE(ACCELERATED_COMPOSITING)
    168177        && !m_runningAcceleratedAnimation && !o.m_runningAcceleratedAnimation
  • trunk/Source/WebCore/rendering/style/StyleRareNonInheritedData.h

    r100604 r100656  
    9090    float opacity; // Whether or not we're transparent.
    9191
     92    float m_aspectRatioDenominator;
     93    float m_aspectRatioNumerator;
     94
    9295    short m_counterIncrement;
    9396    short m_counterReset;
     
    162165    unsigned m_wrapThrough: 1; // WrapThrough
    163166
     167    bool m_hasAspectRatio : 1; // Whether or not an aspect ratio has been specified.
    164168#if USE(ACCELERATED_COMPOSITING)
    165169    bool m_runningAcceleratedAnimation : 1;
Note: See TracChangeset for help on using the changeset viewer.