Changeset 31155 in webkit


Ignore:
Timestamp:
Mar 19, 2008, 10:58:22 AM (17 years ago)
Author:
hyatt@apple.com
Message:

2008-03-19 David Hyatt <hyatt@apple.com>

New implementation of full page zoom. Because of how much doesn't transform when zooming, and because
of the need to obey viewport constraints, I decided to take a completely different approach. Now CSS
lengths and intrinsic sizes are simply adjusted by the zoom factor. This approach works much better and
avoids pixel cracks more than the old approach. In addition widgets "just work", namely plugins zoom
and scrollbars do not.

This patch also implements the IE zoom CSS property. This property allows fine-grained control over
zooming at the element level. It takes values of normal | <number> | <percentage> to match WinIE. In
addition, in the vein of text-size-adjust for text zooming, I have extended the zoom property with an
extra value, reset. The reset keyword can be used to prevent a section of the page from scaling at all
when a zoom is applied.

Reviewed by olliej

  • css/CSSComputedStyleDeclaration.cpp: (WebCore::): (WebCore::CSSComputedStyleDeclaration::getPropertyCSSValue): Support the new 'zoom' property for getComputedStyle.
  • css/CSSParser.cpp: (WebCore::CSSParser::parseValue): Code that parses the 'zoom' property.
  • css/CSSPrimitiveValue.cpp: (WebCore::CSSPrimitiveValue::computeLengthInt): (WebCore::CSSPrimitiveValue::computeLengthIntForLength): (WebCore::CSSPrimitiveValue::computeLengthShort): (WebCore::CSSPrimitiveValue::computeLengthFloat): (WebCore::CSSPrimitiveValue::computeLengthDouble):
  • css/CSSPrimitiveValue.h: Extend all of the computeLength methods to take a multiplier so that lengths can be adjusted by the zoom factor.
  • css/CSSPropertyNames.in: Add the new zoom property to the list of properties we understand.
  • css/CSSStyleSelector.cpp: (WebCore::CSSStyleSelector::applyDeclarations): (WebCore::CSSStyleSelector::applyProperty): (WebCore::CSSStyleSelector::mapBackgroundSize): (WebCore::CSSStyleSelector::mapBackgroundXPosition): (WebCore::CSSStyleSelector::mapBackgroundYPosition): (WebCore::CSSStyleSelector::getComputedSizeFromSpecifiedSize):
  • css/CSSStyleSelector.h: (WebCore::CSSStyleSelector::setStyle): Pass in the zoom factor when computing all lengths in CSS.
  • css/CSSValueKeywords.in: Add support for the 'reset' keyword of the zoom property.
  • dom/Document.cpp: (WebCore::Document::recalcStyle): Set the 'zoom' CSS property on the RenderView. This is how we implement full page zoom.
  • html/CanvasRenderingContext2D.cpp: (WebCore::size): Make sure the back end canvas size ignores zooming when rendering images.
  • html/HTMLImageElement.cpp: (WebCore::HTMLImageElement::width): (WebCore::HTMLImageElement::height): (WebCore::HTMLImageElement::naturalWidth): (WebCore::HTMLImageElement::naturalHeight): Use the unzoomed width/height if we have no style information in HTMLImageElement.cpp.
  • loader/CachedImage.cpp: (WebCore::CachedImage::ref): (WebCore::CachedImage::imageSize): (WebCore::CachedImage::imageRect):
  • loader/CachedImage.h: (WebCore::CachedImage::canRender): Force access to the CachedImage metrics to take a multiplier so that people have to think about the zoom factor. The "intrinsic size" of the image then takes that into account.
  • loader/ImageDocument.cpp: (WebCore::ImageTokenizer::finish): (WebCore::ImageDocument::scale): (WebCore::ImageDocument::resizeImageToFit): (WebCore::ImageDocument::imageChanged): (WebCore::ImageDocument::restoreImageSize): (WebCore::ImageDocument::imageFitsInWindow): Make sure image documents respect the zoom.
  • page/AnimationController.cpp: (WebCore::ImplicitAnimation::animate): Make the 'zoom' CSS property work with CSS transitions.
  • page/Frame.h: (WebCore::Frame::pageZoomFactor): (WebCore::Frame::textZoomFactor): Add accessors for obtaining the pageZoom vs. textZoom.
  • page/FrameView.cpp: (WebCore::FrameView::adjustViewSize): Remove the old zoom implementation that used transforms.
  • page/mac/WebCoreAXObject.mm: (-[WebCoreAXObject accessibilityIsIgnored]): Pass in the zoom factor.
  • rendering/InlineFlowBox.cpp: (WebCore::InlineFlowBox::paintBackground): (WebCore::InlineFlowBox::paintBoxDecorations): Pass in the zoom factor when testing for size.
  • rendering/RenderBox.cpp: (WebCore::RenderBox::calculateBackgroundSize): (WebCore::RenderBox::imageChanged): (WebCore::RenderBox::paintBackgroundExtended): (WebCore::RenderBox::calcHeight):
  • rendering/RenderFrameSet.cpp: (WebCore::RenderFrameSet::layout):
  • rendering/RenderHTMLCanvas.cpp: (WebCore::RenderHTMLCanvas::canvasSizeChanged):
  • rendering/RenderHTMLCanvas.h: (WebCore::RenderHTMLCanvas::renderName): (WebCore::RenderHTMLCanvas::intrinsicSizeChanged):
  • rendering/RenderImage.cpp: (WebCore::RenderImage::setImageSizeForAltText): (WebCore::RenderImage::imageChanged): (WebCore::RenderImage::calcReplacedWidth): (WebCore::RenderImage::calcReplacedHeight):
  • rendering/RenderImage.h: (WebCore::RenderImage::intrinsicSizeChanged):
  • rendering/RenderListMarker.cpp: (WebCore::RenderListMarker::layout): (WebCore::RenderListMarker::imageChanged): (WebCore::RenderListMarker::getRelativeMarkerRect):
  • rendering/RenderObject.cpp: (WebCore::RenderObject::mustRepaintBackgroundOrBorder): (WebCore::RenderObject::paintBorder): Pass in the zoom factor when testing for size.
  • rendering/RenderReplaced.cpp: (WebCore::RenderReplaced::RenderReplaced): (WebCore::RenderReplaced::setStyle): (WebCore::RenderReplaced::intrinsicSizeChanged):
  • rendering/RenderReplaced.h: Added a new call when the zoom factor changes, intrinsicSizeChanged(). Replaced element subclasses respond to this via overrides.
  • rendering/RenderStyle.cpp: (WebCore::StyleVisualData::StyleVisualData): (WebCore::StyleInheritedData::StyleInheritedData): (WebCore::StyleInheritedData::operator==): (WebCore::RenderStyle::diff):
  • rendering/RenderStyle.h: (WebCore::StyleVisualData::operator==): (WebCore::RenderStyle::zoom): (WebCore::RenderStyle::zoomInEffect): (WebCore::RenderStyle::setZoom): (WebCore::RenderStyle::setZoomInEffect): (WebCore::RenderStyle::initialZoom): Support for 'zoom' in the RenderStyle. "zoomInEffect" represents the computed zoom taking into account all the zooms specified on ancestors.
  • rendering/RenderTableCol.cpp: (WebCore::RenderTableCol::imageChanged):
  • rendering/RenderTableRow.cpp: (WebCore::RenderTableRow::imageChanged):
  • rendering/RenderTableSection.cpp: (WebCore::RenderTableSection::imageChanged):
  • rendering/RenderVideo.h: (WebCore::RenderVideo::intrinsicSizeChanged): Pass in the zoom factor.
  • rendering/RenderView.cpp: (WebCore::RenderView::calcHeight): (WebCore::RenderView::calcWidth): (WebCore::RenderView::layout): (WebCore::RenderView::viewHeight): (WebCore::RenderView::viewWidth):
  • rendering/RenderView.h: (WebCore::RenderView::zoomFactor): Back out the old implementation.
Location:
trunk/WebCore
Files:
38 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r31154 r31155  
     12008-03-19  David Hyatt  <hyatt@apple.com>
     2
     3        New implementation of full page zoom.  Because of how much doesn't transform when zooming, and because
     4        of the need to obey viewport constraints, I decided to take a completely different approach.  Now CSS
     5        lengths and intrinsic sizes are simply adjusted by the zoom factor.  This approach works much better and
     6        avoids pixel cracks more than the old approach.   In addition widgets "just work", namely plugins zoom
     7        and scrollbars do not.
     8
     9        This patch also implements the IE zoom CSS property.  This property allows fine-grained control over
     10        zooming at the element level.  It takes values of normal | <number> | <percentage> to match WinIE.  In
     11        addition, in the vein of text-size-adjust for text zooming, I have extended the zoom property with an
     12        extra value, reset.  The reset keyword can be used to prevent a section of the page from scaling at all
     13        when a zoom is applied.
     14
     15        Reviewed by olliej
     16
     17        * css/CSSComputedStyleDeclaration.cpp:
     18        (WebCore::):
     19        (WebCore::CSSComputedStyleDeclaration::getPropertyCSSValue):
     20        Support the new 'zoom' property for getComputedStyle.
     21
     22        * css/CSSParser.cpp:
     23        (WebCore::CSSParser::parseValue):
     24        Code that parses the 'zoom' property.
     25
     26        * css/CSSPrimitiveValue.cpp:
     27        (WebCore::CSSPrimitiveValue::computeLengthInt):
     28        (WebCore::CSSPrimitiveValue::computeLengthIntForLength):
     29        (WebCore::CSSPrimitiveValue::computeLengthShort):
     30        (WebCore::CSSPrimitiveValue::computeLengthFloat):
     31        (WebCore::CSSPrimitiveValue::computeLengthDouble):
     32        * css/CSSPrimitiveValue.h:
     33        Extend all of the computeLength methods to take a multiplier so that lengths can be adjusted by the
     34        zoom factor.
     35
     36        * css/CSSPropertyNames.in:
     37        Add the new zoom property to the list of properties we understand.
     38
     39        * css/CSSStyleSelector.cpp:
     40        (WebCore::CSSStyleSelector::applyDeclarations):
     41        (WebCore::CSSStyleSelector::applyProperty):
     42        (WebCore::CSSStyleSelector::mapBackgroundSize):
     43        (WebCore::CSSStyleSelector::mapBackgroundXPosition):
     44        (WebCore::CSSStyleSelector::mapBackgroundYPosition):
     45        (WebCore::CSSStyleSelector::getComputedSizeFromSpecifiedSize):
     46        * css/CSSStyleSelector.h:
     47        (WebCore::CSSStyleSelector::setStyle):
     48        Pass in the zoom factor when computing all lengths in CSS.
     49
     50        * css/CSSValueKeywords.in:
     51        Add support for the 'reset' keyword of the zoom property.
     52
     53        * dom/Document.cpp:
     54        (WebCore::Document::recalcStyle):
     55        Set the 'zoom' CSS property on the RenderView.  This is how we implement full page zoom.
     56
     57        * html/CanvasRenderingContext2D.cpp:
     58        (WebCore::size):
     59        Make sure the back end canvas size ignores zooming when rendering images.
     60
     61        * html/HTMLImageElement.cpp:
     62        (WebCore::HTMLImageElement::width):
     63        (WebCore::HTMLImageElement::height):
     64        (WebCore::HTMLImageElement::naturalWidth):
     65        (WebCore::HTMLImageElement::naturalHeight):
     66        Use the unzoomed width/height if we have no style information in HTMLImageElement.cpp.
     67
     68        * loader/CachedImage.cpp:
     69        (WebCore::CachedImage::ref):
     70        (WebCore::CachedImage::imageSize):
     71        (WebCore::CachedImage::imageRect):
     72        * loader/CachedImage.h:
     73        (WebCore::CachedImage::canRender):
     74        Force access to the CachedImage metrics to take a multiplier so that people have to think about
     75        the zoom factor.  The "intrinsic size" of the image then takes that into account.
     76
     77        * loader/ImageDocument.cpp:
     78        (WebCore::ImageTokenizer::finish):
     79        (WebCore::ImageDocument::scale):
     80        (WebCore::ImageDocument::resizeImageToFit):
     81        (WebCore::ImageDocument::imageChanged):
     82        (WebCore::ImageDocument::restoreImageSize):
     83        (WebCore::ImageDocument::imageFitsInWindow):
     84        Make sure image documents respect the zoom.
     85
     86        * page/AnimationController.cpp:
     87        (WebCore::ImplicitAnimation::animate):
     88        Make the 'zoom' CSS property work with CSS transitions.
     89
     90        * page/Frame.h:
     91        (WebCore::Frame::pageZoomFactor):
     92        (WebCore::Frame::textZoomFactor):
     93        Add accessors for obtaining the pageZoom vs. textZoom.
     94
     95        * page/FrameView.cpp:
     96        (WebCore::FrameView::adjustViewSize):
     97        Remove the old zoom implementation that used transforms.
     98
     99        * page/mac/WebCoreAXObject.mm:
     100        (-[WebCoreAXObject accessibilityIsIgnored]):
     101        Pass in the zoom factor.
     102
     103        * rendering/InlineFlowBox.cpp:
     104        (WebCore::InlineFlowBox::paintBackground):
     105        (WebCore::InlineFlowBox::paintBoxDecorations):
     106        Pass in the zoom factor when testing for size.
     107
     108        * rendering/RenderBox.cpp:
     109        (WebCore::RenderBox::calculateBackgroundSize):
     110        (WebCore::RenderBox::imageChanged):
     111        (WebCore::RenderBox::paintBackgroundExtended):
     112        (WebCore::RenderBox::calcHeight):
     113        * rendering/RenderFrameSet.cpp:
     114        (WebCore::RenderFrameSet::layout):
     115        * rendering/RenderHTMLCanvas.cpp:
     116        (WebCore::RenderHTMLCanvas::canvasSizeChanged):
     117        * rendering/RenderHTMLCanvas.h:
     118        (WebCore::RenderHTMLCanvas::renderName):
     119        (WebCore::RenderHTMLCanvas::intrinsicSizeChanged):
     120        * rendering/RenderImage.cpp:
     121        (WebCore::RenderImage::setImageSizeForAltText):
     122        (WebCore::RenderImage::imageChanged):
     123        (WebCore::RenderImage::calcReplacedWidth):
     124        (WebCore::RenderImage::calcReplacedHeight):
     125        * rendering/RenderImage.h:
     126        (WebCore::RenderImage::intrinsicSizeChanged):
     127        * rendering/RenderListMarker.cpp:
     128        (WebCore::RenderListMarker::layout):
     129        (WebCore::RenderListMarker::imageChanged):
     130        (WebCore::RenderListMarker::getRelativeMarkerRect):
     131        * rendering/RenderObject.cpp:
     132        (WebCore::RenderObject::mustRepaintBackgroundOrBorder):
     133        (WebCore::RenderObject::paintBorder):
     134        Pass in the zoom factor when testing for size.
     135
     136        * rendering/RenderReplaced.cpp:
     137        (WebCore::RenderReplaced::RenderReplaced):
     138        (WebCore::RenderReplaced::setStyle):
     139        (WebCore::RenderReplaced::intrinsicSizeChanged):
     140        * rendering/RenderReplaced.h:
     141        Added a new call when the zoom factor changes, intrinsicSizeChanged().  Replaced element subclasses
     142        respond to this via overrides.
     143
     144        * rendering/RenderStyle.cpp:
     145        (WebCore::StyleVisualData::StyleVisualData):
     146        (WebCore::StyleInheritedData::StyleInheritedData):
     147        (WebCore::StyleInheritedData::operator==):
     148        (WebCore::RenderStyle::diff):
     149        * rendering/RenderStyle.h:
     150        (WebCore::StyleVisualData::operator==):
     151        (WebCore::RenderStyle::zoom):
     152        (WebCore::RenderStyle::zoomInEffect):
     153        (WebCore::RenderStyle::setZoom):
     154        (WebCore::RenderStyle::setZoomInEffect):
     155        (WebCore::RenderStyle::initialZoom):
     156        Support for 'zoom' in the RenderStyle.  "zoomInEffect" represents the computed zoom taking into account
     157        all the zooms specified on ancestors.
     158
     159        * rendering/RenderTableCol.cpp:
     160        (WebCore::RenderTableCol::imageChanged):
     161        * rendering/RenderTableRow.cpp:
     162        (WebCore::RenderTableRow::imageChanged):
     163        * rendering/RenderTableSection.cpp:
     164        (WebCore::RenderTableSection::imageChanged):
     165        * rendering/RenderVideo.h:
     166        (WebCore::RenderVideo::intrinsicSizeChanged):
     167        Pass in the zoom factor.
     168
     169        * rendering/RenderView.cpp:
     170        (WebCore::RenderView::calcHeight):
     171        (WebCore::RenderView::calcWidth):
     172        (WebCore::RenderView::layout):
     173        (WebCore::RenderView::viewHeight):
     174        (WebCore::RenderView::viewWidth):
     175        * rendering/RenderView.h:
     176        (WebCore::RenderView::zoomFactor):
     177        Back out the old implementation.
     178
    11792008-03-19  Adam Roben  <aroben@apple.com>
    2180
  • trunk/WebCore/css/CSSComputedStyleDeclaration.cpp

    r30649 r31155  
    122122    CSS_PROP_WORD_WRAP,
    123123    CSS_PROP_Z_INDEX,
     124    CSS_PROP_ZOOM,
    124125
    125126    CSS_PROP__WEBKIT_APPEARANCE,
     
    788789                return new CSSPrimitiveValue(CSS_VAL_AUTO);
    789790            return new CSSPrimitiveValue(style->zIndex(), CSSPrimitiveValue::CSS_NUMBER);
     791        case CSS_PROP_ZOOM:
     792            return new CSSPrimitiveValue(style->zoom(), CSSPrimitiveValue::CSS_NUMBER);
    790793        case CSS_PROP__WEBKIT_BOX_SIZING:
    791794            if (style->boxSizing() == CONTENT_BOX)
  • trunk/WebCore/css/CSSParser.cpp

    r31051 r31155  
    10911091        break;
    10921092
     1093    case CSS_PROP_ZOOM:          // normal | reset | <number> | <percentage> | inherit
     1094        if (id == CSS_VAL_NORMAL || id == CSS_VAL_RESET)
     1095            valid_primitive = true;
     1096        else
     1097            valid_primitive = (!id && validUnit(value, FNumber | FPercent, true));
     1098        break;
     1099       
    10931100    case CSS_PROP_TABLE_LAYOUT:         // auto | fixed | inherit
    10941101        if (id == CSS_VAL_AUTO || id == CSS_VAL_FIXED)
  • trunk/WebCore/css/CSSPrimitiveValue.cpp

    r29189 r31155  
    241241int CSSPrimitiveValue::computeLengthInt(RenderStyle* style, double multiplier)
    242242{
    243     double result = multiplier * computeLengthDouble(style);
     243    double result = computeLengthDouble(style, multiplier);
    244244
    245245    // This conversion is imprecise, often resulting in values of, e.g., 44.99998.  We
     
    272272int CSSPrimitiveValue::computeLengthIntForLength(RenderStyle* style, double multiplier)
    273273{
    274     double result = multiplier * computeLengthDouble(style);
     274    double result = computeLengthDouble(style, multiplier);
    275275
    276276    // This conversion is imprecise, often resulting in values of, e.g., 44.99998.  We
     
    298298short CSSPrimitiveValue::computeLengthShort(RenderStyle* style, double multiplier)
    299299{
    300     double result = multiplier * computeLengthDouble(style);
     300    double result = computeLengthDouble(style, multiplier);
    301301
    302302    // This conversion is imprecise, often resulting in values of, e.g., 44.99998.  We
     
    309309}
    310310
    311 float CSSPrimitiveValue::computeLengthFloat(RenderStyle* style, bool applyZoomFactor)
    312 {
    313     return static_cast<float>(computeLengthDouble(style, applyZoomFactor));
    314 }
    315 
    316 double CSSPrimitiveValue::computeLengthDouble(RenderStyle* style, bool applyZoomFactor)
     311float CSSPrimitiveValue::computeLengthFloat(RenderStyle* style, bool computingFontSize)
     312{
     313    return static_cast<float>(computeLengthDouble(style, 1.0, computingFontSize));
     314}
     315
     316float CSSPrimitiveValue::computeLengthFloat(RenderStyle* style, double multiplier, bool computingFontSize)
     317{
     318    return static_cast<float>(computeLengthDouble(style, multiplier, computingFontSize));
     319}
     320
     321double CSSPrimitiveValue::computeLengthDouble(RenderStyle* style, double multiplier, bool computingFontSize)
    317322{
    318323    unsigned short type = primitiveType();
     324
     325    // We do not apply the zoom factor when we are computing the value of the font-size property.  The zooming
     326    // for font sizes is much more complicated, since we have to worry about enforcing the minimum font size preference
     327    // as well as enforcing the implicit "smart minimum."  In addition the CSS property text-size-adjust is used to
     328    // prevent text from zooming at all.  Therefore we will not apply the zoom here if we are computing font-size.
     329    bool applyZoomMultiplier = !computingFontSize;
    319330
    320331    double factor = 1.0;
    321332    switch (type) {
    322333        case CSS_EMS:
    323             factor = applyZoomFactor ? style->fontDescription().computedSize() : style->fontDescription().specifiedSize();
     334            applyZoomMultiplier = false;
     335            factor = computingFontSize ? style->fontDescription().specifiedSize() : style->fontDescription().computedSize();
    324336            break;
    325337        case CSS_EXS:
    326             // FIXME: We have a bug right now where the zoom will be applied multiple times to EX units.
     338            // FIXME: We have a bug right now where the zoom will be applied twice to EX units.
    327339            // We really need to compute EX using fontMetrics for the original specifiedSize and not use
    328340            // our actual constructed rendering font.
     341            applyZoomMultiplier = false;
    329342            factor = style->font().xHeight();
    330343            break;
     
    351364    }
    352365
    353     return getDoubleValue() * factor;
     366    return getDoubleValue() * factor * (applyZoomMultiplier ? multiplier : 1.0f);
    354367}
    355368
  • trunk/WebCore/css/CSSPrimitiveValue.h

    r29250 r31155  
    105105    short computeLengthShort(RenderStyle*);
    106106    short computeLengthShort(RenderStyle*, double multiplier);
    107     float computeLengthFloat(RenderStyle*, bool applyZoomFactor = true);
    108     double computeLengthDouble(RenderStyle*, bool applyZoomFactor = true);
     107    float computeLengthFloat(RenderStyle*, bool computingFontSize = false);
     108    float computeLengthFloat(RenderStyle*, double multiplier, bool computingFontSize = false);
     109    double computeLengthDouble(RenderStyle*, double multiplier = 1.0, bool computingFontSize = false);
    109110
    110111    // use with care!!!
  • trunk/WebCore/css/CSSPropertyNames.in

    r30699 r31155  
    142142word-wrap
    143143z-index
     144zoom
    144145-webkit-transition
    145146-webkit-transition-duration
  • trunk/WebCore/css/CSSStyleSelector.cpp

    r31007 r31155  
    21892189                    case CSS_PROP__WEBKIT_TEXT_SIZE_ADJUST:
    21902190                    case CSS_PROP_FONT_VARIANT:
     2191                    case CSS_PROP_ZOOM:
    21912192                        // these have to be applied first, because other properties use the computed
    21922193                        // values of these porperties.
     
    22432244        primitiveValue = static_cast<CSSPrimitiveValue*>(value);
    22442245
     2246    float zoomFactor = m_style->effectiveZoom();
     2247
    22452248    Length l;
    22462249    bool apply = false;
     
    22502253    bool isInherit = m_parentNode && valueType == CSSValue::CSS_INHERIT;
    22512254    bool isInitial = valueType == CSSValue::CSS_INITIAL || (!m_parentNode && valueType == CSSValue::CSS_INHERIT);
    2252 
     2255   
    22532256    // These properties are used to set the correct margins/padding on RTL lists.
    22542257    if (id == CSS_PROP__WEBKIT_MARGIN_START)
     
    26092612        if (!primitiveValue)
    26102613            return;
    2611         short spacing =  primitiveValue->computeLengthShort(m_style);
     2614        short spacing =  primitiveValue->computeLengthShort(m_style, zoomFactor);
    26122615        m_style->setHorizontalBorderSpacing(spacing);
    26132616        return;
     
    26172620        if (!primitiveValue)
    26182621            return;
    2619         short spacing =  primitiveValue->computeLengthShort(m_style);
     2622        short spacing =  primitiveValue->computeLengthShort(m_style, zoomFactor);
    26202623        m_style->setVerticalBorderSpacing(spacing);
    26212624        return;
     
    27832786            break;
    27842787        case CSS_VAL_INVALID:
    2785             width = primitiveValue->computeLengthShort(m_style);
     2788            width = primitiveValue->computeLengthShort(m_style, zoomFactor);
    27862789            break;
    27872790        default:
     
    28362839            if (!primitiveValue)
    28372840                return;
    2838             width = primitiveValue->computeLengthInt(m_style);
     2841            width = primitiveValue->computeLengthInt(m_style, zoomFactor);
    28392842        }
    28402843        switch (id) {
     
    29802983            if (type > CSSPrimitiveValue::CSS_PERCENTAGE && type < CSSPrimitiveValue::CSS_DEG)
    29812984                // Handle our quirky margin units if we have them.
    2982                 l = Length(primitiveValue->computeLengthIntForLength(m_style), Fixed,
     2985                l = Length(primitiveValue->computeLengthIntForLength(m_style, zoomFactor), Fixed,
    29832986                           primitiveValue->isQuirkValue());
    29842987            else if (type == CSSPrimitiveValue::CSS_PERCENTAGE)
     
    30803083            unsigned short type = primitiveValue->primitiveType();
    30813084            if (type > CSSPrimitiveValue::CSS_PERCENTAGE && type < CSSPrimitiveValue::CSS_DEG)
    3082                 l = Length(primitiveValue->computeLengthIntForLength(m_style), Fixed);
     3085                l = Length(primitiveValue->computeLengthIntForLength(m_style, zoomFactor), Fixed);
    30833086            else if (type == CSSPrimitiveValue::CSS_PERCENTAGE)
    30843087                l = Length(primitiveValue->getDoubleValue(), Percent);
     
    31363139          Length l;
    31373140          if (type > CSSPrimitiveValue::CSS_PERCENTAGE && type < CSSPrimitiveValue::CSS_DEG)
    3138             l = Length(primitiveValue->computeLengthIntForLength(m_style), Fixed);
     3141            l = Length(primitiveValue->computeLengthIntForLength(m_style, zoomFactor), Fixed);
    31393142          else if (type == CSSPrimitiveValue::CSS_PERCENTAGE)
    31403143            l = Length(primitiveValue->getDoubleValue(), Percent);
     
    32003203                                               type != CSSPrimitiveValue::CSS_EXS));
    32013204            if (type > CSSPrimitiveValue::CSS_PERCENTAGE && type < CSSPrimitiveValue::CSS_DEG)
    3202                 size = primitiveValue->computeLengthFloat(m_parentStyle, false);
     3205                size = primitiveValue->computeLengthFloat(m_parentStyle, true);
    32033206            else if (type == CSSPrimitiveValue::CSS_PERCENTAGE)
    32043207                size = (primitiveValue->getFloatValue() * oldSize) / 100.0f;
     
    32633266            lineHeight = Length(-100.0, Percent);
    32643267        else if (type > CSSPrimitiveValue::CSS_PERCENTAGE && type < CSSPrimitiveValue::CSS_DEG) {
    3265             double multiplier = 1.0;
    3266             // Scale for the font zoom factor only for types other than "em" and "ex", since those are
    3267             // already based on the font size.
    3268             if (type != CSSPrimitiveValue::CSS_EMS && type != CSSPrimitiveValue::CSS_EXS && m_style->textSizeAdjust() &&
    3269                 m_document->frame() && m_document->frame()->shouldApplyTextZoom()) {
    3270                 multiplier = m_document->frame()->zoomFactor();
    3271             }
     3268            double multiplier = m_style->effectiveZoom();
     3269            if (m_style->textSizeAdjust() && m_document->frame() && m_document->frame()->shouldApplyTextZoom())
     3270                multiplier *= m_document->frame()->textZoomFactor();
    32723271            lineHeight = Length(primitiveValue->computeLengthIntForLength(m_style, multiplier), Fixed);
    32733272        } else if (type == CSSPrimitiveValue::CSS_PERCENTAGE)
     
    35403539    }
    35413540
     3541    case CSS_PROP_ZOOM:
     3542    {
     3543        // Reset the zoom in effect before we do anything.  This allows the setZoom method to accurately compute a new
     3544        // zoom in effect.
     3545        m_style->setEffectiveZoom(m_parentStyle ? m_parentStyle->effectiveZoom() : RenderStyle::initialZoom());
     3546       
     3547        // Now we can handle inherit and initial.
     3548        HANDLE_INHERIT_AND_INITIAL(zoom, Zoom)
     3549       
     3550        // Handle normal/reset, numbers and percentages.
     3551        int type = primitiveValue->primitiveType();
     3552        if (primitiveValue->getIdent() == CSS_VAL_NORMAL)
     3553            m_style->setZoom(RenderStyle::initialZoom());
     3554        else if (primitiveValue->getIdent() == CSS_VAL_RESET) {
     3555            m_style->setEffectiveZoom(RenderStyle::initialZoom());
     3556            m_style->setZoom(RenderStyle::initialZoom());
     3557        } else if (type == CSSPrimitiveValue::CSS_PERCENTAGE)
     3558            m_style->setZoom(primitiveValue->getFloatValue() / 100.0f);
     3559        else if (type == CSSPrimitiveValue::CSS_NUMBER)
     3560            m_style->setZoom(primitiveValue->getFloatValue());
     3561        return;
     3562    }
    35423563// shorthand properties
    35433564    case CSS_PROP_BACKGROUND:
     
    38753896            return;
    38763897
    3877         int width = pair->first()->computeLengthInt(m_style);
    3878         int height = pair->second()->computeLengthInt(m_style);
     3898        int width = pair->first()->computeLengthInt(m_style, zoomFactor);
     3899        int height = pair->second()->computeLengthInt(m_style, zoomFactor);
    38793900        if (width < 0 || height < 0)
    38803901            return;
     
    39083929    case CSS_PROP_OUTLINE_OFFSET:
    39093930        HANDLE_INHERIT_AND_INITIAL(outlineOffset, OutlineOffset)
    3910         m_style->setOutlineOffset(primitiveValue->computeLengthInt(m_style));
     3931        m_style->setOutlineOffset(primitiveValue->computeLengthInt(m_style, zoomFactor));
    39113932        return;
    39123933
     
    39283949        for (int i = 0; i < len; i++) {
    39293950            ShadowValue* item = static_cast<ShadowValue*>(list->item(i));
    3930             int x = item->x->computeLengthInt(m_style);
    3931             int y = item->y->computeLengthInt(m_style);
    3932             int blur = item->blur ? item->blur->computeLengthInt(m_style) : 0;
     3951            int x = item->x->computeLengthInt(m_style, zoomFactor);
     3952            int y = item->y->computeLengthInt(m_style, zoomFactor);
     3953            int blur = item->blur ? item->blur->computeLengthInt(m_style, zoomFactor) : 0;
    39333954            Color color;
    39343955            if (item->color)
     
    40404061            return;
    40414062        }
    4042         m_style->setColumnGap(primitiveValue->computeLengthFloat(m_style));
     4063        m_style->setColumnGap(primitiveValue->computeLengthFloat(m_style, zoomFactor));
    40434064        return;
    40444065    }
     
    40544075            return;
    40554076        }
    4056         m_style->setColumnWidth(primitiveValue->computeLengthFloat(m_style));
     4077        m_style->setColumnWidth(primitiveValue->computeLengthFloat(m_style, zoomFactor));
    40574078        return;
    40584079    }
     
    43174338                    result *= 5;
    43184339                CSSPrimitiveValue val(result, CSSPrimitiveValue::CSS_EMS);
    4319                 width = val.computeLengthFloat(m_style);
     4340                width = val.computeLengthFloat(m_style, zoomFactor);
    43204341                break;
    43214342            }
    43224343            default:
    4323                 width = primitiveValue->computeLengthFloat(m_style);
     4344                width = primitiveValue->computeLengthFloat(m_style, zoomFactor);
    43244345                break;
    43254346        }
     
    44604481        int type = primitiveValue->primitiveType();
    44614482        if (type > CSSPrimitiveValue::CSS_PERCENTAGE && type < CSSPrimitiveValue::CSS_DEG)
    4462             l = Length(primitiveValue->computeLengthIntForLength(m_style), Fixed);
     4483            l = Length(primitiveValue->computeLengthIntForLength(m_style, zoomFactor), Fixed);
    44634484        else if (type == CSSPrimitiveValue::CSS_PERCENTAGE)
    44644485            l = Length(primitiveValue->getDoubleValue(), Percent);
     
    44744495        int type = primitiveValue->primitiveType();
    44754496        if (type > CSSPrimitiveValue::CSS_PERCENTAGE && type < CSSPrimitiveValue::CSS_DEG)
    4476             l = Length(primitiveValue->computeLengthIntForLength(m_style), Fixed);
     4497            l = Length(primitiveValue->computeLengthIntForLength(m_style, zoomFactor), Fixed);
    44774498        else if(type == CSSPrimitiveValue::CSS_PERCENTAGE)
    44784499            l = Length(primitiveValue->getDoubleValue(), Percent);
     
    46624683    int secondType = second->primitiveType();
    46634684   
     4685    float zoomFactor = m_style->effectiveZoom();
     4686
    46644687    if (firstType == CSSPrimitiveValue::CSS_UNKNOWN)
    46654688        firstLength = Length(Auto);
    46664689    else if (firstType > CSSPrimitiveValue::CSS_PERCENTAGE && firstType < CSSPrimitiveValue::CSS_DEG)
    4667         firstLength = Length(first->computeLengthIntForLength(m_style), Fixed);
     4690        firstLength = Length(first->computeLengthIntForLength(m_style, zoomFactor), Fixed);
    46684691    else if (firstType == CSSPrimitiveValue::CSS_PERCENTAGE)
    46694692        firstLength = Length(first->getDoubleValue(), Percent);
     
    46744697        secondLength = Length(Auto);
    46754698    else if (secondType > CSSPrimitiveValue::CSS_PERCENTAGE && secondType < CSSPrimitiveValue::CSS_DEG)
    4676         secondLength = Length(second->computeLengthIntForLength(m_style), Fixed);
     4699        secondLength = Length(second->computeLengthIntForLength(m_style, zoomFactor), Fixed);
    46774700    else if (secondType == CSSPrimitiveValue::CSS_PERCENTAGE)
    46784701        secondLength = Length(second->getDoubleValue(), Percent);
     
    46944717    if (!value->isPrimitiveValue())
    46954718        return;
     4719
     4720    float zoomFactor = m_style->effectiveZoom();
    46964721
    46974722    CSSPrimitiveValue* primitiveValue = static_cast<CSSPrimitiveValue*>(value);
     
    46994724    int type = primitiveValue->primitiveType();
    47004725    if (type > CSSPrimitiveValue::CSS_PERCENTAGE && type < CSSPrimitiveValue::CSS_DEG)
    4701         l = Length(primitiveValue->computeLengthIntForLength(m_style), Fixed);
     4726        l = Length(primitiveValue->computeLengthIntForLength(m_style, zoomFactor), Fixed);
    47024727    else if (type == CSSPrimitiveValue::CSS_PERCENTAGE)
    47034728        l = Length(primitiveValue->getDoubleValue(), Percent);
     
    47174742        return;
    47184743
     4744    float zoomFactor = m_style->effectiveZoom();
     4745   
    47194746    CSSPrimitiveValue* primitiveValue = static_cast<CSSPrimitiveValue*>(value);
    47204747    Length l;
    47214748    int type = primitiveValue->primitiveType();
    47224749    if (type > CSSPrimitiveValue::CSS_PERCENTAGE && type < CSSPrimitiveValue::CSS_DEG)
    4723         l = Length(primitiveValue->computeLengthIntForLength(m_style), Fixed);
     4750        l = Length(primitiveValue->computeLengthIntForLength(m_style, zoomFactor), Fixed);
    47244751    else if (type == CSSPrimitiveValue::CSS_PERCENTAGE)
    47254752        l = Length(primitiveValue->getDoubleValue(), Percent);
     
    48874914    int minLogicalSize = settings->minimumLogicalFontSize();
    48884915
    4889     float zoomPercent = m_document->frame() && m_document->frame()->shouldApplyTextZoom() ? m_document->frame()->zoomFactor() : 1.0f;
    4890     float zoomedSize = specifiedSize * zoomPercent;
     4916    float zoomFactor = m_style->effectiveZoom();
     4917    if (m_document->frame() && m_document->frame()->shouldApplyTextZoom())
     4918        zoomFactor *= m_document->frame()->textZoomFactor();
     4919
     4920    float zoomedSize = specifiedSize * zoomFactor;
    48914921
    48924922    // Apply the hard minimum first.  We only apply the hard minimum if after zooming we're still too small.
  • trunk/WebCore/css/CSSStyleSelector.h

    r30949 r31155  
    106106
    107107    public:
     108        void setStyle(RenderStyle* s) { m_style = s; } // Used by the document when setting up its root style.
    108109        void setFontSize(FontDescription&, float size);
    109110
  • trunk/WebCore/css/CSSValueKeywords.in

    r29492 r31155  
    566566ease-out
    567567ease-in-out
     568
     569#
     570# CSS_PROP_ZOOM
     571#
     572reset
  • trunk/WebCore/dom/Document.cpp

    r31147 r31155  
    10861086        _style->setDisplay(BLOCK);
    10871087        _style->setVisuallyOrdered(visuallyOrdered);
    1088        
    1089         if (frame() && frame()->shouldApplyPageZoom() && !ownerElement()) {
    1090             // Set up our zoom transform on the document.
    1091             _style->setTransformOriginX(Length(0, Fixed));
    1092             _style->setTransformOriginY(Length(0, Fixed));
    1093             TransformOperations ops;
    1094             RefPtr<TransformOperation> transformOp = new ScaleTransformOperation(frame()->zoomFactor(), frame()->zoomFactor());
    1095             ops.append(transformOp);
    1096             _style->setTransform(ops);
    1097         }
    1098        
    1099         // FIXME: This code is necessary because RenderLayer is buggy regarding transform repainting on the root (not sure why).
    1100         // We can remove it when those bugs are resolved.
    1101         if (oldStyle && oldStyle->transform() != _style->transform()) {
    1102             setChanged(); // Necessary to force the view to relayout.
    1103             renderer()->repaint();
    1104         }
    1105 
     1088        _style->setZoom(frame()->pageZoomFactor());
     1089        m_styleSelector->setStyle(_style);
     1090   
    11061091        FontDescription fontDescription;
    11071092        fontDescription.setUsePrinterFont(printing());
  • trunk/WebCore/html/CanvasRenderingContext2D.cpp

    r30954 r31155  
    889889{
    890890    if (CachedImage* cachedImage = image->cachedImage())
    891         return cachedImage->imageSize();
     891        return cachedImage->imageSize(1.0f); // FIXME: Not sure about this.
    892892    return IntSize();
    893893}
  • trunk/WebCore/html/HTMLImageElement.cpp

    r31122 r31155  
    2727#include "CSSValueKeywords.h"
    2828#include "EventNames.h"
     29#include "Frame.h"
    2930#include "HTMLDocument.h"
    3031#include "HTMLFormElement.h"
     
    217218       
    218219        // if the image is available, use its width
    219         if (m_imageLoader.image())
    220             return m_imageLoader.image()->imageSize().width();
     220        if (m_imageLoader.image()) {
     221            float zoomFactor = document()->frame() ? document()->frame()->pageZoomFactor() : 1.0f;
     222            return m_imageLoader.image()->imageSize(zoomFactor).width();
     223        }
    221224    }
    222225
     
    239242       
    240243        // if the image is available, use its height
    241         if (m_imageLoader.image())
    242             return m_imageLoader.image()->imageSize().height();       
     244        if (m_imageLoader.image()) {
     245            float zoomFactor = document()->frame() ? document()->frame()->pageZoomFactor() : 1.0f;
     246            return m_imageLoader.image()->imageSize(zoomFactor).height();
     247        }
    243248    }
    244249
     
    256261        return 0;
    257262
    258     return m_imageLoader.image()->imageSize().width();
     263    return m_imageLoader.image()->imageSize(1.0f).width();
    259264}
    260265
     
    264269        return 0;
    265270   
    266     return m_imageLoader.image()->imageSize().height();
     271    return m_imageLoader.image()->imageSize(1.0f).height();
    267272}
    268273   
  • trunk/WebCore/loader/CachedImage.cpp

    r28856 r31155  
    7676    CachedResource::ref(c);
    7777
    78     if (!imageRect().isEmpty())
     78    if (m_image && !m_image->rect().isEmpty())
    7979        c->imageChanged(this);
    8080
     
    144144}
    145145
    146 IntSize CachedImage::imageSize() const
    147 {
    148     return (m_image ? m_image->size() : IntSize());
    149 }
    150 
    151 IntRect CachedImage::imageRect() const
    152 {
    153     return (m_image ? m_image->rect() : IntRect());
     146IntSize CachedImage::imageSize(float multiplier) const
     147{
     148    if (!m_image)
     149        return IntSize();
     150    if (multiplier == 1.0f)
     151        return m_image->size();
     152    return IntSize(m_image->size().width() * multiplier, m_image->size().height() * multiplier);
     153}
     154
     155IntRect CachedImage::imageRect(float multiplier) const
     156{
     157    if (!m_image)
     158        return IntRect();
     159    if (multiplier == 1.0f)
     160        return m_image->rect();
     161    return IntRect(m_image->rect().x() * multiplier, m_image->rect().y() * multiplier,
     162                   m_image->rect().width() * multiplier, m_image->rect().height() * multiplier);
    154163}
    155164
  • trunk/WebCore/loader/CachedImage.h

    r28871 r31155  
    2626#include "CachedResource.h"
    2727#include "ImageObserver.h"
     28#include "Image.h"
    2829#include "IntRect.h"
    2930#include <wtf/Vector.h>
     
    3334class DocLoader;
    3435class Cache;
    35 class Image;
    3636
    3737class CachedImage : public CachedResource, public ImageObserver {
     
    4545    Image* image() const;
    4646
    47     bool canRender() const { return !errorOccurred() && imageSize().width() > 0 && imageSize().height() > 0; }
     47    bool canRender(float multiplier) const { return !errorOccurred() && !imageSize(multiplier).isEmpty(); }
    4848
    4949    // These are only used for SVGImage right now
     
    5353    bool imageHasRelativeHeight() const;
    5454   
    55     IntSize imageSize() const;  // returns the size of the complete image
    56     IntRect imageRect() const;  // The size of the image.
     55    // Both of these methods take a zoom multiplier that can be used to increase the natural size of the image by the
     56    // zoom.
     57    IntSize imageSize(float multiplier) const;  // returns the size of the complete image.
     58    IntRect imageRect(float multiplier) const;  // The size of the currently decoded portion of the image.
    5759
    5860    virtual void ref(CachedResourceClient*);
  • trunk/WebCore/loader/ImageDocument.cpp

    r31034 r31155  
    119119        cachedImage->setResponse(m_doc->frame()->loader()->documentLoader()->response());
    120120
    121         IntSize size = cachedImage->imageSize();
     121        IntSize size = cachedImage->imageSize(m_doc->frame()->pageZoomFactor());
    122122        if (size.width())
    123123            m_doc->setTitle(imageTitle(cachedImage->response().suggestedFilename(), size));
     
    187187        return 1.0f;
    188188
    189     IntSize imageSize = m_imageElement->cachedImage()->imageSize();
     189    IntSize imageSize = m_imageElement->cachedImage()->imageSize(frame()->pageZoomFactor());
    190190    IntSize windowSize = IntSize(frame()->view()->width(), frame()->view()->height());
    191191   
     
    201201        return;
    202202
    203     IntSize imageSize = m_imageElement->cachedImage()->imageSize();
     203    IntSize imageSize = m_imageElement->cachedImage()->imageSize(frame()->pageZoomFactor());
    204204
    205205    float scale = this->scale();
     
    241241        return;
    242242
    243     if (m_imageElement->cachedImage()->imageSize().isEmpty())
     243    if (m_imageElement->cachedImage()->imageSize(frame()->pageZoomFactor()).isEmpty())
    244244        return;
    245245   
     
    257257        return;
    258258   
    259     m_imageElement->setWidth(m_imageElement->cachedImage()->imageSize().width());
    260     m_imageElement->setHeight(m_imageElement->cachedImage()->imageSize().height());
     259    m_imageElement->setWidth(m_imageElement->cachedImage()->imageSize(frame()->pageZoomFactor()).width());
     260    m_imageElement->setHeight(m_imageElement->cachedImage()->imageSize(frame()->pageZoomFactor()).height());
    261261   
    262262    ExceptionCode ec;
     
    274274        return true;
    275275
    276     IntSize imageSize = m_imageElement->cachedImage()->imageSize();
     276    IntSize imageSize = m_imageElement->cachedImage()->imageSize(frame()->pageZoomFactor());
    277277    IntSize windowSize = IntSize(frame()->view()->width(), frame()->view()->height());
    278278   
  • trunk/WebCore/page/AnimationController.cpp

    r30319 r31155  
    424424    BLEND(CSS_PROP__WEBKIT_BORDER_BOTTOM_RIGHT_RADIUS, borderBottomRightRadius, setBorderBottomRightRadius);
    425425    BLEND(CSS_PROP_VISIBILITY, visibility, setVisibility);
     426    BLEND(CSS_PROP_ZOOM, zoom, setZoom);
    426427}
    427428
  • trunk/WebCore/page/Frame.h

    r31056 r31155  
    210210    bool shouldApplyTextZoom() const;
    211211    bool shouldApplyPageZoom() const;
     212    float pageZoomFactor() const { return shouldApplyPageZoom() ? zoomFactor() : 1.0f; }
     213    float textZoomFactor() const { return shouldApplyTextZoom() ? zoomFactor() : 1.0f; }
    212214
    213215    bool prohibitsScrolling() const;
  • trunk/WebCore/page/FrameView.cpp

    r31037 r31155  
    255255    if (!root)
    256256        return;
    257        
    258     // Adjust for the zoom factor.  The RenderView is scaled by the zoom, but our viewport is not.
    259     int width = root->overflowWidth();
    260     int height = root->overflowHeight();
    261     if (m_frame->shouldApplyPageZoom()) {
    262         width *= m_frame->zoomFactor(); // FIXME: Will have rounding errors.
    263         height *= m_frame->zoomFactor(); // FIXME: Will have rounding errors.
    264     }
    265     resizeContents(width, height);
     257    resizeContents(root->overflowWidth(), root->overflowHeight());
    266258}
    267259
  • trunk/WebCore/page/mac/WebCoreAXObject.mm

    r30992 r31155  
    876876        RenderImage* image = static_cast<RenderImage*>(m_renderer);
    877877        if (image->cachedImage()) {
    878             IntSize imageSize = image->cachedImage()->imageSize();
     878            IntSize imageSize = image->cachedImage()->imageSize(image->view()->zoomFactor());
    879879            return (imageSize.height() <= 1 || imageSize.width() <= 1);
    880880        }
  • trunk/WebCore/rendering/InlineFlowBox.cpp

    r30603 r31155  
    660660{
    661661    CachedImage* bg = bgLayer->backgroundImage();
    662     bool hasBackgroundImage = bg && bg->canRender();
     662    bool hasBackgroundImage = bg && bg->canRender(object()->style()->effectiveZoom());
    663663    if ((!hasBackgroundImage && !object()->style()->hasBorderRadius()) || (!prevLineBox() && !nextLineBox()) || !parent())
    664664        object()->paintBackgroundExtended(context, c, bgLayer, my, mh, tx, ty, w, h);
     
    734734        if (parent() && object()->style()->hasBorder()) {
    735735            CachedImage* borderImage = object()->style()->borderImage().image();
    736             bool hasBorderImage = borderImage && borderImage->canRender();
     736            bool hasBorderImage = borderImage && borderImage->canRender(styleToUse->effectiveZoom());
    737737            if (hasBorderImage && !borderImage->isLoaded())
    738738                return; // Don't paint anything while we wait for the image to load.
  • trunk/WebCore/rendering/RenderBox.cpp

    r31037 r31155  
    432432            if (bgHeight.isPercent()) {
    433433                int scaledH = bgHeight.calcValue(scaledHeight);
    434                 w = bg->imageSize().width() * scaledH / bg->imageSize().height();
     434                w = bg->imageSize(style()->effectiveZoom()).width() * scaledH / bg->imageSize(style()->effectiveZoom()).height();
    435435            } else if (bgHeight.isFixed())
    436                 w = bg->imageSize().width() * bgHeight.value() / bg->imageSize().height();
     436                w = bg->imageSize(style()->effectiveZoom()).width() * bgHeight.value() / bg->imageSize(style()->effectiveZoom()).height();
    437437        }
    438438
     
    445445            // scale to maintain our aspect ratio.
    446446            if (bgWidth.isPercent())
    447                 h = bg->imageSize().height() * scaledWidth / bg->imageSize().width();
     447                h = bg->imageSize(style()->effectiveZoom()).height() * scaledWidth / bg->imageSize(style()->effectiveZoom()).width();
    448448            else if (bgWidth.isFixed())
    449                 h = bg->imageSize().height() * bgWidth.value() / bg->imageSize().width();
     449                h = bg->imageSize(style()->effectiveZoom()).height() * bgWidth.value() / bg->imageSize(style()->effectiveZoom()).width();
    450450            else if (bgWidth.isAuto()) {
    451451                // If both width and height are auto, we just want to use the image's
    452452                // intrinsic size.
    453                 w = bg->imageSize().width();
    454                 h = bg->imageSize().height();
     453                w = bg->imageSize(style()->effectiveZoom()).width();
     454                h = bg->imageSize(style()->effectiveZoom()).height();
    455455            }
    456456        }
    457457        return IntSize(max(1, w), max(1, h));
    458458    } else
    459         return bg->imageSize();
     459        return bg->imageSize(style()->effectiveZoom());
    460460}
    461461
    462462void RenderBox::imageChanged(CachedImage* image)
    463463{
    464     if (!image || !image->canRender() || !parent() || !view())
     464    if (!image || !image->canRender(style()->effectiveZoom()) || !parent() || !view())
    465465        return;
    466466
     
    625625
    626626    CachedImage* bg = bgLayer->backgroundImage();
    627     bool shouldPaintBackgroundImage = bg && bg->canRender();
     627    bool shouldPaintBackgroundImage = bg && bg->canRender(style()->effectiveZoom());
    628628    Color bgColor = c;
    629629
     
    13181318    if (stretchesToViewHeight() && !document()->printing()) {
    13191319        int margins = collapsedMarginTop() + collapsedMarginBottom();
    1320         int visHeight = view()->zoomedHeight();
     1320        int visHeight = view()->viewHeight();
    13211321        if (isRoot())
    13221322            m_height = max(m_height, visHeight - margins);
  • trunk/WebCore/rendering/RenderFrameSet.cpp

    r31037 r31155  
    460460
    461461    if (!parent()->isFrameSet()) {
    462         m_width = view()->zoomedWidth();
    463         m_height = view()->zoomedHeight();
     462        m_width = view()->viewWidth();
     463        m_height = view()->viewHeight();
    464464    }
    465465
  • trunk/WebCore/rendering/RenderHTMLCanvas.cpp

    r28397 r31155  
    5252{
    5353    IntSize size = static_cast<HTMLCanvasElement*>(node())->size();
     54    IntSize zoomedSize(size.width() * style()->effectiveZoom(), size.height() * style()->effectiveZoom());
     55
    5456    if (size == intrinsicSize())
    5557        return;
  • trunk/WebCore/rendering/RenderHTMLCanvas.h

    r28397 r31155  
    3131namespace WebCore {
    3232
    33     class HTMLCanvasElement;
     33class HTMLCanvasElement;
    3434
    35     class RenderHTMLCanvas : public RenderReplaced {
    36     public:
    37         RenderHTMLCanvas(HTMLCanvasElement*);
     35class RenderHTMLCanvas : public RenderReplaced {
     36public:
     37    RenderHTMLCanvas(HTMLCanvasElement*);
    3838
    39         virtual const char* renderName() const { return "RenderHTMLCanvas"; }
     39    virtual const char* renderName() const { return "RenderHTMLCanvas"; }
    4040
    41         virtual void paintReplaced(PaintInfo& paintInfo, int tx, int ty);
     41    virtual void paintReplaced(PaintInfo& paintInfo, int tx, int ty);
    4242
    43         void canvasSizeChanged();
    44     };
     43    void canvasSizeChanged();
     44   
     45protected:
     46    virtual void intrinsicSizeChanged() { canvasSizeChanged(); }
     47
     48};
    4549
    4650} // namespace WebCore
  • trunk/WebCore/rendering/RenderImage.cpp

    r30243 r31155  
    9595 
    9696    if (newImage) {
    97         imageWidth += newImage->image()->width();
    98         imageHeight += newImage->image()->height();
     97        // imageSize() returns 0 for the error image.  We need the true size of the
     98        // error image, so we have to get it by grabbing image() directly.
     99        imageWidth += newImage->image()->width() * style()->effectiveZoom();
     100        imageHeight += newImage->image()->height() * style()->effectiveZoom();
    99101    }
    100102 
     
    122124        RenderReplaced::imageChanged(newImage);
    123125   
    124     if (newImage != m_cachedImage)
     126    if (newImage != m_cachedImage || !newImage)
    125127        return;
    126128
     
    134136
    135137    // Image dimensions have been changed, see what needs to be done
    136     if (newImage->imageSize() != intrinsicSize() || imageSizeChanged) {
     138    if (newImage->imageSize(style()->effectiveZoom()) != intrinsicSize() || imageSizeChanged) {
    137139        if (!newImage->errorOccurred())
    138             setIntrinsicSize(newImage->imageSize());
     140            setIntrinsicSize(newImage->imageSize(style()->effectiveZoom()));
    139141
    140142        // In the case of generated image content using :before/:after, we might not be in the
     
    343345        width = calcReplacedWidthUsing(style()->width());
    344346    else if (m_cachedImage && m_cachedImage->usesImageContainerSize())
    345         width = m_cachedImage->imageSize().width();
     347        width = m_cachedImage->imageSize(style()->effectiveZoom()).width();
    346348    else if (m_cachedImage && m_cachedImage->imageHasRelativeWidth())
    347349        width = 0; // If the image is relatively-sized, set the width to 0 until there is a set container size.
     
    361363        height = calcReplacedHeightUsing(style()->height());
    362364    else if (m_cachedImage && m_cachedImage->usesImageContainerSize())
    363         height = m_cachedImage->imageSize().height();
     365        height = m_cachedImage->imageSize(style()->effectiveZoom()).height();
    364366    else if (m_cachedImage && m_cachedImage->imageHasRelativeHeight())
    365367        height = 0; // If the image is relatively-sized, set the height to 0 until there is a set container size.
  • trunk/WebCore/rendering/RenderImage.h

    r28397 r31155  
    7474    bool errorOccurred() const { return m_cachedImage && m_cachedImage->errorOccurred(); }
    7575
     76    virtual void intrinsicSizeChanged() { imageChanged(m_cachedImage); }
     77
    7678private:
    7779    int calcAspectRatioWidth() const;
  • trunk/WebCore/rendering/RenderListMarker.cpp

    r29470 r31155  
    634634
    635635    if (isImage()) {
    636         m_width = m_image->image()->width();
    637         m_height = m_image->image()->height();
     636        m_width = m_image->imageSize(style()->effectiveZoom()).width();
     637        m_height = m_image->imageSize(style()->effectiveZoom()).height();
    638638    } else {
    639639        m_width = minPrefWidth();
     
    659659        return;
    660660
    661     if (m_width != m_image->imageSize().width() || m_height != m_image->imageSize().height() || m_image->errorOccurred())
     661    if (m_width != m_image->imageSize(style()->effectiveZoom()).width() || m_height != m_image->imageSize(style()->effectiveZoom()).height() || m_image->errorOccurred())
    662662        setNeedsLayoutAndPrefWidthsRecalc();
    663663    else
     
    823823{
    824824    if (isImage())
    825         return IntRect(m_x, m_y, m_image->imageSize().width(), m_image->imageSize().height());
     825        return IntRect(m_x, m_y, m_image->imageSize(style()->effectiveZoom()).width(), m_image->imageSize(style()->effectiveZoom()).height());
    826826
    827827    switch (style()->listStyleType()) {
  • trunk/WebCore/rendering/RenderObject.cpp

    r31153 r31155  
    835835    // Make sure we have a valid background image.
    836836    CachedImage* bg = bgLayer->backgroundImage();
    837     bool shouldPaintBackgroundImage = bg && bg->canRender();
     837    bool shouldPaintBackgroundImage = bg && bg->canRender(style()->effectiveZoom());
    838838
    839839    // These are always percents or auto.
     
    848848        // Border images are not ok.
    849849        CachedImage* borderImage = style()->borderImage().image();
    850         bool shouldPaintBorderImage = borderImage && borderImage->canRender();
     850        bool shouldPaintBorderImage = borderImage && borderImage->canRender(style()->effectiveZoom());
    851851
    852852        // If the image hasn't loaded, we're still using the normal border style.
     
    12521252{
    12531253    CachedImage* borderImage = style->borderImage().image();
    1254     bool shouldPaintBackgroundImage = borderImage && borderImage->canRender();
     1254    bool shouldPaintBackgroundImage = borderImage && borderImage->canRender(style->effectiveZoom());
    12551255    if (shouldPaintBackgroundImage)
    12561256        shouldPaintBackgroundImage = paintBorderImage(graphicsContext, tx, ty, w, h, style);
  • trunk/WebCore/rendering/RenderReplaced.cpp

    r28397 r31155  
    3535static OverflowRectMap* gOverflowRectMap = 0;
    3636
     37const int cDefaultWidth = 300;
     38const int cDefaultHeight = 150;
     39
    3740RenderReplaced::RenderReplaced(Node* node)
    3841    : RenderBox(node)
    39     , m_intrinsicSize(300, 150)
     42    , m_intrinsicSize(cDefaultWidth, cDefaultHeight)
    4043    , m_selectionState(SelectionNone)
    4144    , m_hasOverflow(false)
     
    5861        gOverflowRectMap->remove(this);
    5962}
    60    
     63
     64void RenderReplaced::setStyle(RenderStyle* newStyle)
     65{
     66    float oldZoom = style() ? style()->effectiveZoom() : RenderStyle::initialZoom();
     67    RenderBox::setStyle(newStyle);
     68    if (newStyle && newStyle->effectiveZoom() != oldZoom)
     69        intrinsicSizeChanged();
     70}
     71
    6172void RenderReplaced::layout()
    6273{
     
    8293    setNeedsLayout(false);
    8394}
    84    
     95 
     96void RenderReplaced::intrinsicSizeChanged()
     97{
     98    m_intrinsicSize = IntSize(cDefaultWidth * style()->effectiveZoom(), cDefaultHeight * style()->effectiveZoom());
     99    setNeedsLayoutAndPrefWidthsRecalc();
     100}
     101
    85102void RenderReplaced::paint(PaintInfo& paintInfo, int tx, int ty)
    86103{
  • trunk/WebCore/rendering/RenderReplaced.h

    r28397 r31155  
    4343    virtual int minimumReplacedHeight() const { return 0; }
    4444
     45    virtual void setStyle(RenderStyle*);
     46
    4547    virtual void paint(PaintInfo&, int tx, int ty);
    4648    virtual void paintReplaced(PaintInfo&, int tx, int ty) { }
     
    6870protected:
    6971    void setIntrinsicSize(const IntSize&);
     72    virtual void intrinsicSizeChanged();
    7073
    7174    bool shouldPaint(PaintInfo&, int& tx, int& ty);
  • trunk/WebCore/rendering/RenderStyle.cpp

    r30949 r31155  
    9292    , counterIncrement(0)
    9393    , counterReset(0)
     94    , m_zoom(RenderStyle::initialZoom())
    9495{
    9596}
     
    106107    , counterIncrement(o.counterIncrement)
    107108    , counterReset(o.counterReset)
     109    , m_zoom(RenderStyle::initialZoom())
    108110{
    109111}
     
    835837    , style_image(RenderStyle::initialListStyleImage())
    836838    , color(RenderStyle::initialColor())
     839    , m_effectiveZoom(RenderStyle::initialZoom())
    837840    , horizontal_border_spacing(RenderStyle::initialHorizontalBorderSpacing())
    838841    , vertical_border_spacing(RenderStyle::initialVerticalBorderSpacing())
     
    855858    , font(o.font)
    856859    , color(o.color)
     860    , m_effectiveZoom(o.m_effectiveZoom)
    857861    , horizontal_border_spacing(o.horizontal_border_spacing)
    858862    , vertical_border_spacing(o.vertical_border_spacing)
     
    881885        font == o.font &&
    882886        color == o.color &&
     887        m_effectiveZoom == o.m_effectiveZoom &&
    883888        horizontal_border_spacing == o.horizontal_border_spacing &&
    884889        vertical_border_spacing == o.vertical_border_spacing &&
     
    12791284        return Layout;
    12801285
     1286    if (inherited->m_effectiveZoom != other->inherited->m_effectiveZoom)
     1287        return Layout;
     1288
    12811289    // Make sure these left/top/right/bottom checks stay below all layout checks and above
    12821290    // all visible checks.
  • trunk/WebCore/rendering/RenderStyle.h

    r30667 r31155  
    430430                 counterIncrement == o.counterIncrement &&
    431431                 counterReset == o.counterReset &&
    432                  textDecoration == o.textDecoration);
     432                 textDecoration == o.textDecoration &&
     433                 m_zoom == o.m_zoom);
    433434    }
    434435    bool operator!=(const StyleVisualData& o) const { return !(*this == o); }
     
    437438    bool hasClip : 1;
    438439    unsigned textDecoration : 4; // Text decorations defined *only* by this element.
    439 
     440   
    440441    short counterIncrement; // ok, so these are not visual mode specific
    441442    short counterReset;     // can't go to inherited, since these are not inherited
     443
     444    float m_zoom;
    442445
    443446private:
     
    12831286    Color color;
    12841287   
     1288    float m_effectiveZoom;
     1289
    12851290    short horizontal_border_spacing;
    12861291    short vertical_border_spacing;
     
    17091714    int letterSpacing() const { return inherited->font.letterSpacing(); }
    17101715
     1716    float zoom() const { return visual->m_zoom; }
     1717    float effectiveZoom() const {  return inherited->m_effectiveZoom; }
     1718   
    17111719    TextDirection direction() const { return static_cast<TextDirection>(inherited_flags._direction); }
    17121720    Length lineHeight() const { return inherited->line_height; }
     
    19851993    void setDirection(TextDirection v) { inherited_flags._direction = v; }
    19861994    void setLineHeight(Length v) { SET_VAR(inherited,line_height,v) }
     1995    void setZoom(float f) { SET_VAR(visual, m_zoom, f); setEffectiveZoom(effectiveZoom() * zoom()); }
     1996    void setEffectiveZoom(float f) { SET_VAR(inherited, m_effectiveZoom, f) }
    19871997
    19881998    void setWhiteSpace(EWhiteSpace v) { inherited_flags._white_space = v; }
     
    22362246    static ETextAlign initialTextAlign() { return TAAUTO; }
    22372247    static ETextDecoration initialTextDecoration() { return TDNONE; }
     2248    static float initialZoom() { return 1.0f; }
    22382249    static int initialOutlineOffset() { return 0; }
    22392250    static float initialOpacity() { return 1.0f; }
  • trunk/WebCore/rendering/RenderTableCol.cpp

    r30415 r31155  
    8686void RenderTableCol::imageChanged(CachedImage* image)
    8787{
    88     if (!image || !image->canRender() || !parent())
     88    if (!image || !image->canRender(style()->effectiveZoom()) || !parent())
    8989        return;
    9090
  • trunk/WebCore/rendering/RenderTableRow.cpp

    r29646 r31155  
    204204void RenderTableRow::imageChanged(CachedImage* image)
    205205{
    206     if (!image || !image->canRender() || !parent())
     206    if (!image || !image->canRender(style()->effectiveZoom()) || !parent())
    207207        return;
    208208   
  • trunk/WebCore/rendering/RenderTableSection.cpp

    r30415 r31155  
    971971void RenderTableSection::imageChanged(CachedImage* image)
    972972{
    973     if (!image || !image->canRender() || !parent())
     973    if (!image || !image->canRender(style()->effectiveZoom()) || !parent())
    974974        return;
    975975   
  • trunk/WebCore/rendering/RenderVideo.h

    r29663 r31155  
    5555    void updateFromElement();
    5656
     57protected:
     58    virtual void intrinsicSizeChanged() { videoSizeChanged(); }
     59
    5760private:
    5861    int calcAspectRatioWidth() const;
  • trunk/WebCore/rendering/RenderView.cpp

    r31037 r31155  
    7474{
    7575    if (!printing() && m_frameView)
    76         m_height = zoomedHeight();
     76        m_height = viewHeight();
    7777}
    7878
     
    8080{
    8181    if (!printing() && m_frameView)
    82         m_width = zoomedWidth();
     82        m_width = viewWidth();
    8383    m_marginLeft = 0;
    8484    m_marginRight = 0;
     
    100100
    101101    // Use calcWidth/Height to get the new width/height, since this will take the full page zoom factor into account.
    102     bool relayoutChildren = !printing() && (!m_frameView || m_width != zoomedWidth() || m_height != zoomedHeight());
     102    bool relayoutChildren = !printing() && (!m_frameView || m_width != viewWidth() || m_height != viewHeight());
    103103    if (relayoutChildren)
    104104        setChildNeedsLayout(true, false);
     
    509509}
    510510
    511 int RenderView::zoomedHeight() const
     511int RenderView::viewHeight() const
    512512{
    513513    int height = 0;
    514     if (!printing() && m_frameView) {
     514    if (!printing() && m_frameView)
    515515        height = m_frameView->visibleHeight();
    516         if (m_frameView->frame()->shouldApplyPageZoom())
    517             height /= m_frameView->frame()->zoomFactor(); // FIXME: Will have rounding errors.
    518     }
    519516    return height;
    520517}
    521518
    522 int RenderView::zoomedWidth() const
     519int RenderView::viewWidth() const
    523520{
    524521    int width = 0;
    525     if (!printing() && m_frameView) {
     522    if (!printing() && m_frameView)
    526523        width = m_frameView->visibleWidth();
    527         if (m_frameView->frame()->shouldApplyPageZoom())
    528             width /= m_frameView->frame()->zoomFactor(); // FIXME: Will have rounding errors.
    529     }
    530524    return width;
    531525}
  • trunk/WebCore/rendering/RenderView.h

    r31037 r31155  
    2626
    2727#include "FrameView.h"
     28#include "Frame.h"
    2829#include "LayoutState.h"
    2930#include "RenderBlock.h"
     
    4950    int docWidth() const;
    5051
    51     // The same as the FrameView's visibleHeight/visibleWidth with the zoom factor applied.
    52     int zoomedHeight() const;
    53     int zoomedWidth() const;
     52    // The same as the FrameView's visibleHeight/visibleWidth but with null check guards.
     53    int viewHeight() const;
     54    int viewWidth() const;
    5455   
     56    float zoomFactor() const { return m_frameView->frame() && m_frameView->frame()->shouldApplyPageZoom() ? m_frameView->frame()->zoomFactor() : 1.0f; }
     57
    5558    FrameView* frameView() const { return m_frameView; }
    5659
Note: See TracChangeset for help on using the changeset viewer.