Changeset 31155 in webkit
- Timestamp:
- Mar 19, 2008, 10:58:22 AM (17 years ago)
- Location:
- trunk/WebCore
- Files:
-
- 38 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r31154 r31155 1 2008-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 1 179 2008-03-19 Adam Roben <aroben@apple.com> 2 180 -
trunk/WebCore/css/CSSComputedStyleDeclaration.cpp
r30649 r31155 122 122 CSS_PROP_WORD_WRAP, 123 123 CSS_PROP_Z_INDEX, 124 CSS_PROP_ZOOM, 124 125 125 126 CSS_PROP__WEBKIT_APPEARANCE, … … 788 789 return new CSSPrimitiveValue(CSS_VAL_AUTO); 789 790 return new CSSPrimitiveValue(style->zIndex(), CSSPrimitiveValue::CSS_NUMBER); 791 case CSS_PROP_ZOOM: 792 return new CSSPrimitiveValue(style->zoom(), CSSPrimitiveValue::CSS_NUMBER); 790 793 case CSS_PROP__WEBKIT_BOX_SIZING: 791 794 if (style->boxSizing() == CONTENT_BOX) -
trunk/WebCore/css/CSSParser.cpp
r31051 r31155 1091 1091 break; 1092 1092 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 1093 1100 case CSS_PROP_TABLE_LAYOUT: // auto | fixed | inherit 1094 1101 if (id == CSS_VAL_AUTO || id == CSS_VAL_FIXED) -
trunk/WebCore/css/CSSPrimitiveValue.cpp
r29189 r31155 241 241 int CSSPrimitiveValue::computeLengthInt(RenderStyle* style, double multiplier) 242 242 { 243 double result = multiplier * computeLengthDouble(style);243 double result = computeLengthDouble(style, multiplier); 244 244 245 245 // This conversion is imprecise, often resulting in values of, e.g., 44.99998. We … … 272 272 int CSSPrimitiveValue::computeLengthIntForLength(RenderStyle* style, double multiplier) 273 273 { 274 double result = multiplier * computeLengthDouble(style);274 double result = computeLengthDouble(style, multiplier); 275 275 276 276 // This conversion is imprecise, often resulting in values of, e.g., 44.99998. We … … 298 298 short CSSPrimitiveValue::computeLengthShort(RenderStyle* style, double multiplier) 299 299 { 300 double result = multiplier * computeLengthDouble(style);300 double result = computeLengthDouble(style, multiplier); 301 301 302 302 // This conversion is imprecise, often resulting in values of, e.g., 44.99998. We … … 309 309 } 310 310 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) 311 float CSSPrimitiveValue::computeLengthFloat(RenderStyle* style, bool computingFontSize) 312 { 313 return static_cast<float>(computeLengthDouble(style, 1.0, computingFontSize)); 314 } 315 316 float CSSPrimitiveValue::computeLengthFloat(RenderStyle* style, double multiplier, bool computingFontSize) 317 { 318 return static_cast<float>(computeLengthDouble(style, multiplier, computingFontSize)); 319 } 320 321 double CSSPrimitiveValue::computeLengthDouble(RenderStyle* style, double multiplier, bool computingFontSize) 317 322 { 318 323 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; 319 330 320 331 double factor = 1.0; 321 332 switch (type) { 322 333 case CSS_EMS: 323 factor = applyZoomFactor ? style->fontDescription().computedSize() : style->fontDescription().specifiedSize(); 334 applyZoomMultiplier = false; 335 factor = computingFontSize ? style->fontDescription().specifiedSize() : style->fontDescription().computedSize(); 324 336 break; 325 337 case CSS_EXS: 326 // FIXME: We have a bug right now where the zoom will be applied multiple timesto EX units.338 // FIXME: We have a bug right now where the zoom will be applied twice to EX units. 327 339 // We really need to compute EX using fontMetrics for the original specifiedSize and not use 328 340 // our actual constructed rendering font. 341 applyZoomMultiplier = false; 329 342 factor = style->font().xHeight(); 330 343 break; … … 351 364 } 352 365 353 return getDoubleValue() * factor ;366 return getDoubleValue() * factor * (applyZoomMultiplier ? multiplier : 1.0f); 354 367 } 355 368 -
trunk/WebCore/css/CSSPrimitiveValue.h
r29250 r31155 105 105 short computeLengthShort(RenderStyle*); 106 106 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); 109 110 110 111 // use with care!!! -
trunk/WebCore/css/CSSPropertyNames.in
r30699 r31155 142 142 word-wrap 143 143 z-index 144 zoom 144 145 -webkit-transition 145 146 -webkit-transition-duration -
trunk/WebCore/css/CSSStyleSelector.cpp
r31007 r31155 2189 2189 case CSS_PROP__WEBKIT_TEXT_SIZE_ADJUST: 2190 2190 case CSS_PROP_FONT_VARIANT: 2191 case CSS_PROP_ZOOM: 2191 2192 // these have to be applied first, because other properties use the computed 2192 2193 // values of these porperties. … … 2243 2244 primitiveValue = static_cast<CSSPrimitiveValue*>(value); 2244 2245 2246 float zoomFactor = m_style->effectiveZoom(); 2247 2245 2248 Length l; 2246 2249 bool apply = false; … … 2250 2253 bool isInherit = m_parentNode && valueType == CSSValue::CSS_INHERIT; 2251 2254 bool isInitial = valueType == CSSValue::CSS_INITIAL || (!m_parentNode && valueType == CSSValue::CSS_INHERIT); 2252 2255 2253 2256 // These properties are used to set the correct margins/padding on RTL lists. 2254 2257 if (id == CSS_PROP__WEBKIT_MARGIN_START) … … 2609 2612 if (!primitiveValue) 2610 2613 return; 2611 short spacing = primitiveValue->computeLengthShort(m_style );2614 short spacing = primitiveValue->computeLengthShort(m_style, zoomFactor); 2612 2615 m_style->setHorizontalBorderSpacing(spacing); 2613 2616 return; … … 2617 2620 if (!primitiveValue) 2618 2621 return; 2619 short spacing = primitiveValue->computeLengthShort(m_style );2622 short spacing = primitiveValue->computeLengthShort(m_style, zoomFactor); 2620 2623 m_style->setVerticalBorderSpacing(spacing); 2621 2624 return; … … 2783 2786 break; 2784 2787 case CSS_VAL_INVALID: 2785 width = primitiveValue->computeLengthShort(m_style );2788 width = primitiveValue->computeLengthShort(m_style, zoomFactor); 2786 2789 break; 2787 2790 default: … … 2836 2839 if (!primitiveValue) 2837 2840 return; 2838 width = primitiveValue->computeLengthInt(m_style );2841 width = primitiveValue->computeLengthInt(m_style, zoomFactor); 2839 2842 } 2840 2843 switch (id) { … … 2980 2983 if (type > CSSPrimitiveValue::CSS_PERCENTAGE && type < CSSPrimitiveValue::CSS_DEG) 2981 2984 // 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, 2983 2986 primitiveValue->isQuirkValue()); 2984 2987 else if (type == CSSPrimitiveValue::CSS_PERCENTAGE) … … 3080 3083 unsigned short type = primitiveValue->primitiveType(); 3081 3084 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); 3083 3086 else if (type == CSSPrimitiveValue::CSS_PERCENTAGE) 3084 3087 l = Length(primitiveValue->getDoubleValue(), Percent); … … 3136 3139 Length l; 3137 3140 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); 3139 3142 else if (type == CSSPrimitiveValue::CSS_PERCENTAGE) 3140 3143 l = Length(primitiveValue->getDoubleValue(), Percent); … … 3200 3203 type != CSSPrimitiveValue::CSS_EXS)); 3201 3204 if (type > CSSPrimitiveValue::CSS_PERCENTAGE && type < CSSPrimitiveValue::CSS_DEG) 3202 size = primitiveValue->computeLengthFloat(m_parentStyle, false);3205 size = primitiveValue->computeLengthFloat(m_parentStyle, true); 3203 3206 else if (type == CSSPrimitiveValue::CSS_PERCENTAGE) 3204 3207 size = (primitiveValue->getFloatValue() * oldSize) / 100.0f; … … 3263 3266 lineHeight = Length(-100.0, Percent); 3264 3267 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(); 3272 3271 lineHeight = Length(primitiveValue->computeLengthIntForLength(m_style, multiplier), Fixed); 3273 3272 } else if (type == CSSPrimitiveValue::CSS_PERCENTAGE) … … 3540 3539 } 3541 3540 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 } 3542 3563 // shorthand properties 3543 3564 case CSS_PROP_BACKGROUND: … … 3875 3896 return; 3876 3897 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); 3879 3900 if (width < 0 || height < 0) 3880 3901 return; … … 3908 3929 case CSS_PROP_OUTLINE_OFFSET: 3909 3930 HANDLE_INHERIT_AND_INITIAL(outlineOffset, OutlineOffset) 3910 m_style->setOutlineOffset(primitiveValue->computeLengthInt(m_style ));3931 m_style->setOutlineOffset(primitiveValue->computeLengthInt(m_style, zoomFactor)); 3911 3932 return; 3912 3933 … … 3928 3949 for (int i = 0; i < len; i++) { 3929 3950 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; 3933 3954 Color color; 3934 3955 if (item->color) … … 4040 4061 return; 4041 4062 } 4042 m_style->setColumnGap(primitiveValue->computeLengthFloat(m_style ));4063 m_style->setColumnGap(primitiveValue->computeLengthFloat(m_style, zoomFactor)); 4043 4064 return; 4044 4065 } … … 4054 4075 return; 4055 4076 } 4056 m_style->setColumnWidth(primitiveValue->computeLengthFloat(m_style ));4077 m_style->setColumnWidth(primitiveValue->computeLengthFloat(m_style, zoomFactor)); 4057 4078 return; 4058 4079 } … … 4317 4338 result *= 5; 4318 4339 CSSPrimitiveValue val(result, CSSPrimitiveValue::CSS_EMS); 4319 width = val.computeLengthFloat(m_style );4340 width = val.computeLengthFloat(m_style, zoomFactor); 4320 4341 break; 4321 4342 } 4322 4343 default: 4323 width = primitiveValue->computeLengthFloat(m_style );4344 width = primitiveValue->computeLengthFloat(m_style, zoomFactor); 4324 4345 break; 4325 4346 } … … 4460 4481 int type = primitiveValue->primitiveType(); 4461 4482 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); 4463 4484 else if (type == CSSPrimitiveValue::CSS_PERCENTAGE) 4464 4485 l = Length(primitiveValue->getDoubleValue(), Percent); … … 4474 4495 int type = primitiveValue->primitiveType(); 4475 4496 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); 4477 4498 else if(type == CSSPrimitiveValue::CSS_PERCENTAGE) 4478 4499 l = Length(primitiveValue->getDoubleValue(), Percent); … … 4662 4683 int secondType = second->primitiveType(); 4663 4684 4685 float zoomFactor = m_style->effectiveZoom(); 4686 4664 4687 if (firstType == CSSPrimitiveValue::CSS_UNKNOWN) 4665 4688 firstLength = Length(Auto); 4666 4689 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); 4668 4691 else if (firstType == CSSPrimitiveValue::CSS_PERCENTAGE) 4669 4692 firstLength = Length(first->getDoubleValue(), Percent); … … 4674 4697 secondLength = Length(Auto); 4675 4698 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); 4677 4700 else if (secondType == CSSPrimitiveValue::CSS_PERCENTAGE) 4678 4701 secondLength = Length(second->getDoubleValue(), Percent); … … 4694 4717 if (!value->isPrimitiveValue()) 4695 4718 return; 4719 4720 float zoomFactor = m_style->effectiveZoom(); 4696 4721 4697 4722 CSSPrimitiveValue* primitiveValue = static_cast<CSSPrimitiveValue*>(value); … … 4699 4724 int type = primitiveValue->primitiveType(); 4700 4725 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); 4702 4727 else if (type == CSSPrimitiveValue::CSS_PERCENTAGE) 4703 4728 l = Length(primitiveValue->getDoubleValue(), Percent); … … 4717 4742 return; 4718 4743 4744 float zoomFactor = m_style->effectiveZoom(); 4745 4719 4746 CSSPrimitiveValue* primitiveValue = static_cast<CSSPrimitiveValue*>(value); 4720 4747 Length l; 4721 4748 int type = primitiveValue->primitiveType(); 4722 4749 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); 4724 4751 else if (type == CSSPrimitiveValue::CSS_PERCENTAGE) 4725 4752 l = Length(primitiveValue->getDoubleValue(), Percent); … … 4887 4914 int minLogicalSize = settings->minimumLogicalFontSize(); 4888 4915 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; 4891 4921 4892 4922 // 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 106 106 107 107 public: 108 void setStyle(RenderStyle* s) { m_style = s; } // Used by the document when setting up its root style. 108 109 void setFontSize(FontDescription&, float size); 109 110 -
trunk/WebCore/css/CSSValueKeywords.in
r29492 r31155 566 566 ease-out 567 567 ease-in-out 568 569 # 570 # CSS_PROP_ZOOM 571 # 572 reset -
trunk/WebCore/dom/Document.cpp
r31147 r31155 1086 1086 _style->setDisplay(BLOCK); 1087 1087 _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 1106 1091 FontDescription fontDescription; 1107 1092 fontDescription.setUsePrinterFont(printing()); -
trunk/WebCore/html/CanvasRenderingContext2D.cpp
r30954 r31155 889 889 { 890 890 if (CachedImage* cachedImage = image->cachedImage()) 891 return cachedImage->imageSize( );891 return cachedImage->imageSize(1.0f); // FIXME: Not sure about this. 892 892 return IntSize(); 893 893 } -
trunk/WebCore/html/HTMLImageElement.cpp
r31122 r31155 27 27 #include "CSSValueKeywords.h" 28 28 #include "EventNames.h" 29 #include "Frame.h" 29 30 #include "HTMLDocument.h" 30 31 #include "HTMLFormElement.h" … … 217 218 218 219 // 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 } 221 224 } 222 225 … … 239 242 240 243 // 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 } 243 248 } 244 249 … … 256 261 return 0; 257 262 258 return m_imageLoader.image()->imageSize( ).width();263 return m_imageLoader.image()->imageSize(1.0f).width(); 259 264 } 260 265 … … 264 269 return 0; 265 270 266 return m_imageLoader.image()->imageSize( ).height();271 return m_imageLoader.image()->imageSize(1.0f).height(); 267 272 } 268 273 -
trunk/WebCore/loader/CachedImage.cpp
r28856 r31155 76 76 CachedResource::ref(c); 77 77 78 if ( !imageRect().isEmpty())78 if (m_image && !m_image->rect().isEmpty()) 79 79 c->imageChanged(this); 80 80 … … 144 144 } 145 145 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()); 146 IntSize 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 155 IntRect 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); 154 163 } 155 164 -
trunk/WebCore/loader/CachedImage.h
r28871 r31155 26 26 #include "CachedResource.h" 27 27 #include "ImageObserver.h" 28 #include "Image.h" 28 29 #include "IntRect.h" 29 30 #include <wtf/Vector.h> … … 33 34 class DocLoader; 34 35 class Cache; 35 class Image;36 36 37 37 class CachedImage : public CachedResource, public ImageObserver { … … 45 45 Image* image() const; 46 46 47 bool canRender( ) const { return !errorOccurred() && imageSize().width() > 0 && imageSize().height() > 0; }47 bool canRender(float multiplier) const { return !errorOccurred() && !imageSize(multiplier).isEmpty(); } 48 48 49 49 // These are only used for SVGImage right now … … 53 53 bool imageHasRelativeHeight() const; 54 54 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. 57 59 58 60 virtual void ref(CachedResourceClient*); -
trunk/WebCore/loader/ImageDocument.cpp
r31034 r31155 119 119 cachedImage->setResponse(m_doc->frame()->loader()->documentLoader()->response()); 120 120 121 IntSize size = cachedImage->imageSize( );121 IntSize size = cachedImage->imageSize(m_doc->frame()->pageZoomFactor()); 122 122 if (size.width()) 123 123 m_doc->setTitle(imageTitle(cachedImage->response().suggestedFilename(), size)); … … 187 187 return 1.0f; 188 188 189 IntSize imageSize = m_imageElement->cachedImage()->imageSize( );189 IntSize imageSize = m_imageElement->cachedImage()->imageSize(frame()->pageZoomFactor()); 190 190 IntSize windowSize = IntSize(frame()->view()->width(), frame()->view()->height()); 191 191 … … 201 201 return; 202 202 203 IntSize imageSize = m_imageElement->cachedImage()->imageSize( );203 IntSize imageSize = m_imageElement->cachedImage()->imageSize(frame()->pageZoomFactor()); 204 204 205 205 float scale = this->scale(); … … 241 241 return; 242 242 243 if (m_imageElement->cachedImage()->imageSize( ).isEmpty())243 if (m_imageElement->cachedImage()->imageSize(frame()->pageZoomFactor()).isEmpty()) 244 244 return; 245 245 … … 257 257 return; 258 258 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()); 261 261 262 262 ExceptionCode ec; … … 274 274 return true; 275 275 276 IntSize imageSize = m_imageElement->cachedImage()->imageSize( );276 IntSize imageSize = m_imageElement->cachedImage()->imageSize(frame()->pageZoomFactor()); 277 277 IntSize windowSize = IntSize(frame()->view()->width(), frame()->view()->height()); 278 278 -
trunk/WebCore/page/AnimationController.cpp
r30319 r31155 424 424 BLEND(CSS_PROP__WEBKIT_BORDER_BOTTOM_RIGHT_RADIUS, borderBottomRightRadius, setBorderBottomRightRadius); 425 425 BLEND(CSS_PROP_VISIBILITY, visibility, setVisibility); 426 BLEND(CSS_PROP_ZOOM, zoom, setZoom); 426 427 } 427 428 -
trunk/WebCore/page/Frame.h
r31056 r31155 210 210 bool shouldApplyTextZoom() const; 211 211 bool shouldApplyPageZoom() const; 212 float pageZoomFactor() const { return shouldApplyPageZoom() ? zoomFactor() : 1.0f; } 213 float textZoomFactor() const { return shouldApplyTextZoom() ? zoomFactor() : 1.0f; } 212 214 213 215 bool prohibitsScrolling() const; -
trunk/WebCore/page/FrameView.cpp
r31037 r31155 255 255 if (!root) 256 256 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()); 266 258 } 267 259 -
trunk/WebCore/page/mac/WebCoreAXObject.mm
r30992 r31155 876 876 RenderImage* image = static_cast<RenderImage*>(m_renderer); 877 877 if (image->cachedImage()) { 878 IntSize imageSize = image->cachedImage()->imageSize( );878 IntSize imageSize = image->cachedImage()->imageSize(image->view()->zoomFactor()); 879 879 return (imageSize.height() <= 1 || imageSize.width() <= 1); 880 880 } -
trunk/WebCore/rendering/InlineFlowBox.cpp
r30603 r31155 660 660 { 661 661 CachedImage* bg = bgLayer->backgroundImage(); 662 bool hasBackgroundImage = bg && bg->canRender( );662 bool hasBackgroundImage = bg && bg->canRender(object()->style()->effectiveZoom()); 663 663 if ((!hasBackgroundImage && !object()->style()->hasBorderRadius()) || (!prevLineBox() && !nextLineBox()) || !parent()) 664 664 object()->paintBackgroundExtended(context, c, bgLayer, my, mh, tx, ty, w, h); … … 734 734 if (parent() && object()->style()->hasBorder()) { 735 735 CachedImage* borderImage = object()->style()->borderImage().image(); 736 bool hasBorderImage = borderImage && borderImage->canRender( );736 bool hasBorderImage = borderImage && borderImage->canRender(styleToUse->effectiveZoom()); 737 737 if (hasBorderImage && !borderImage->isLoaded()) 738 738 return; // Don't paint anything while we wait for the image to load. -
trunk/WebCore/rendering/RenderBox.cpp
r31037 r31155 432 432 if (bgHeight.isPercent()) { 433 433 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(); 435 435 } 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(); 437 437 } 438 438 … … 445 445 // scale to maintain our aspect ratio. 446 446 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(); 448 448 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(); 450 450 else if (bgWidth.isAuto()) { 451 451 // If both width and height are auto, we just want to use the image's 452 452 // 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(); 455 455 } 456 456 } 457 457 return IntSize(max(1, w), max(1, h)); 458 458 } else 459 return bg->imageSize( );459 return bg->imageSize(style()->effectiveZoom()); 460 460 } 461 461 462 462 void RenderBox::imageChanged(CachedImage* image) 463 463 { 464 if (!image || !image->canRender( ) || !parent() || !view())464 if (!image || !image->canRender(style()->effectiveZoom()) || !parent() || !view()) 465 465 return; 466 466 … … 625 625 626 626 CachedImage* bg = bgLayer->backgroundImage(); 627 bool shouldPaintBackgroundImage = bg && bg->canRender( );627 bool shouldPaintBackgroundImage = bg && bg->canRender(style()->effectiveZoom()); 628 628 Color bgColor = c; 629 629 … … 1318 1318 if (stretchesToViewHeight() && !document()->printing()) { 1319 1319 int margins = collapsedMarginTop() + collapsedMarginBottom(); 1320 int visHeight = view()-> zoomedHeight();1320 int visHeight = view()->viewHeight(); 1321 1321 if (isRoot()) 1322 1322 m_height = max(m_height, visHeight - margins); -
trunk/WebCore/rendering/RenderFrameSet.cpp
r31037 r31155 460 460 461 461 if (!parent()->isFrameSet()) { 462 m_width = view()-> zoomedWidth();463 m_height = view()-> zoomedHeight();462 m_width = view()->viewWidth(); 463 m_height = view()->viewHeight(); 464 464 } 465 465 -
trunk/WebCore/rendering/RenderHTMLCanvas.cpp
r28397 r31155 52 52 { 53 53 IntSize size = static_cast<HTMLCanvasElement*>(node())->size(); 54 IntSize zoomedSize(size.width() * style()->effectiveZoom(), size.height() * style()->effectiveZoom()); 55 54 56 if (size == intrinsicSize()) 55 57 return; -
trunk/WebCore/rendering/RenderHTMLCanvas.h
r28397 r31155 31 31 namespace WebCore { 32 32 33 33 class HTMLCanvasElement; 34 34 35 36 37 35 class RenderHTMLCanvas : public RenderReplaced { 36 public: 37 RenderHTMLCanvas(HTMLCanvasElement*); 38 38 39 39 virtual const char* renderName() const { return "RenderHTMLCanvas"; } 40 40 41 41 virtual void paintReplaced(PaintInfo& paintInfo, int tx, int ty); 42 42 43 void canvasSizeChanged(); 44 }; 43 void canvasSizeChanged(); 44 45 protected: 46 virtual void intrinsicSizeChanged() { canvasSizeChanged(); } 47 48 }; 45 49 46 50 } // namespace WebCore -
trunk/WebCore/rendering/RenderImage.cpp
r30243 r31155 95 95 96 96 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(); 99 101 } 100 102 … … 122 124 RenderReplaced::imageChanged(newImage); 123 125 124 if (newImage != m_cachedImage )126 if (newImage != m_cachedImage || !newImage) 125 127 return; 126 128 … … 134 136 135 137 // 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) { 137 139 if (!newImage->errorOccurred()) 138 setIntrinsicSize(newImage->imageSize( ));140 setIntrinsicSize(newImage->imageSize(style()->effectiveZoom())); 139 141 140 142 // In the case of generated image content using :before/:after, we might not be in the … … 343 345 width = calcReplacedWidthUsing(style()->width()); 344 346 else if (m_cachedImage && m_cachedImage->usesImageContainerSize()) 345 width = m_cachedImage->imageSize( ).width();347 width = m_cachedImage->imageSize(style()->effectiveZoom()).width(); 346 348 else if (m_cachedImage && m_cachedImage->imageHasRelativeWidth()) 347 349 width = 0; // If the image is relatively-sized, set the width to 0 until there is a set container size. … … 361 363 height = calcReplacedHeightUsing(style()->height()); 362 364 else if (m_cachedImage && m_cachedImage->usesImageContainerSize()) 363 height = m_cachedImage->imageSize( ).height();365 height = m_cachedImage->imageSize(style()->effectiveZoom()).height(); 364 366 else if (m_cachedImage && m_cachedImage->imageHasRelativeHeight()) 365 367 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 74 74 bool errorOccurred() const { return m_cachedImage && m_cachedImage->errorOccurred(); } 75 75 76 virtual void intrinsicSizeChanged() { imageChanged(m_cachedImage); } 77 76 78 private: 77 79 int calcAspectRatioWidth() const; -
trunk/WebCore/rendering/RenderListMarker.cpp
r29470 r31155 634 634 635 635 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(); 638 638 } else { 639 639 m_width = minPrefWidth(); … … 659 659 return; 660 660 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()) 662 662 setNeedsLayoutAndPrefWidthsRecalc(); 663 663 else … … 823 823 { 824 824 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()); 826 826 827 827 switch (style()->listStyleType()) { -
trunk/WebCore/rendering/RenderObject.cpp
r31153 r31155 835 835 // Make sure we have a valid background image. 836 836 CachedImage* bg = bgLayer->backgroundImage(); 837 bool shouldPaintBackgroundImage = bg && bg->canRender( );837 bool shouldPaintBackgroundImage = bg && bg->canRender(style()->effectiveZoom()); 838 838 839 839 // These are always percents or auto. … … 848 848 // Border images are not ok. 849 849 CachedImage* borderImage = style()->borderImage().image(); 850 bool shouldPaintBorderImage = borderImage && borderImage->canRender( );850 bool shouldPaintBorderImage = borderImage && borderImage->canRender(style()->effectiveZoom()); 851 851 852 852 // If the image hasn't loaded, we're still using the normal border style. … … 1252 1252 { 1253 1253 CachedImage* borderImage = style->borderImage().image(); 1254 bool shouldPaintBackgroundImage = borderImage && borderImage->canRender( );1254 bool shouldPaintBackgroundImage = borderImage && borderImage->canRender(style->effectiveZoom()); 1255 1255 if (shouldPaintBackgroundImage) 1256 1256 shouldPaintBackgroundImage = paintBorderImage(graphicsContext, tx, ty, w, h, style); -
trunk/WebCore/rendering/RenderReplaced.cpp
r28397 r31155 35 35 static OverflowRectMap* gOverflowRectMap = 0; 36 36 37 const int cDefaultWidth = 300; 38 const int cDefaultHeight = 150; 39 37 40 RenderReplaced::RenderReplaced(Node* node) 38 41 : RenderBox(node) 39 , m_intrinsicSize( 300, 150)42 , m_intrinsicSize(cDefaultWidth, cDefaultHeight) 40 43 , m_selectionState(SelectionNone) 41 44 , m_hasOverflow(false) … … 58 61 gOverflowRectMap->remove(this); 59 62 } 60 63 64 void 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 61 72 void RenderReplaced::layout() 62 73 { … … 82 93 setNeedsLayout(false); 83 94 } 84 95 96 void RenderReplaced::intrinsicSizeChanged() 97 { 98 m_intrinsicSize = IntSize(cDefaultWidth * style()->effectiveZoom(), cDefaultHeight * style()->effectiveZoom()); 99 setNeedsLayoutAndPrefWidthsRecalc(); 100 } 101 85 102 void RenderReplaced::paint(PaintInfo& paintInfo, int tx, int ty) 86 103 { -
trunk/WebCore/rendering/RenderReplaced.h
r28397 r31155 43 43 virtual int minimumReplacedHeight() const { return 0; } 44 44 45 virtual void setStyle(RenderStyle*); 46 45 47 virtual void paint(PaintInfo&, int tx, int ty); 46 48 virtual void paintReplaced(PaintInfo&, int tx, int ty) { } … … 68 70 protected: 69 71 void setIntrinsicSize(const IntSize&); 72 virtual void intrinsicSizeChanged(); 70 73 71 74 bool shouldPaint(PaintInfo&, int& tx, int& ty); -
trunk/WebCore/rendering/RenderStyle.cpp
r30949 r31155 92 92 , counterIncrement(0) 93 93 , counterReset(0) 94 , m_zoom(RenderStyle::initialZoom()) 94 95 { 95 96 } … … 106 107 , counterIncrement(o.counterIncrement) 107 108 , counterReset(o.counterReset) 109 , m_zoom(RenderStyle::initialZoom()) 108 110 { 109 111 } … … 835 837 , style_image(RenderStyle::initialListStyleImage()) 836 838 , color(RenderStyle::initialColor()) 839 , m_effectiveZoom(RenderStyle::initialZoom()) 837 840 , horizontal_border_spacing(RenderStyle::initialHorizontalBorderSpacing()) 838 841 , vertical_border_spacing(RenderStyle::initialVerticalBorderSpacing()) … … 855 858 , font(o.font) 856 859 , color(o.color) 860 , m_effectiveZoom(o.m_effectiveZoom) 857 861 , horizontal_border_spacing(o.horizontal_border_spacing) 858 862 , vertical_border_spacing(o.vertical_border_spacing) … … 881 885 font == o.font && 882 886 color == o.color && 887 m_effectiveZoom == o.m_effectiveZoom && 883 888 horizontal_border_spacing == o.horizontal_border_spacing && 884 889 vertical_border_spacing == o.vertical_border_spacing && … … 1279 1284 return Layout; 1280 1285 1286 if (inherited->m_effectiveZoom != other->inherited->m_effectiveZoom) 1287 return Layout; 1288 1281 1289 // Make sure these left/top/right/bottom checks stay below all layout checks and above 1282 1290 // all visible checks. -
trunk/WebCore/rendering/RenderStyle.h
r30667 r31155 430 430 counterIncrement == o.counterIncrement && 431 431 counterReset == o.counterReset && 432 textDecoration == o.textDecoration); 432 textDecoration == o.textDecoration && 433 m_zoom == o.m_zoom); 433 434 } 434 435 bool operator!=(const StyleVisualData& o) const { return !(*this == o); } … … 437 438 bool hasClip : 1; 438 439 unsigned textDecoration : 4; // Text decorations defined *only* by this element. 439 440 440 441 short counterIncrement; // ok, so these are not visual mode specific 441 442 short counterReset; // can't go to inherited, since these are not inherited 443 444 float m_zoom; 442 445 443 446 private: … … 1283 1286 Color color; 1284 1287 1288 float m_effectiveZoom; 1289 1285 1290 short horizontal_border_spacing; 1286 1291 short vertical_border_spacing; … … 1709 1714 int letterSpacing() const { return inherited->font.letterSpacing(); } 1710 1715 1716 float zoom() const { return visual->m_zoom; } 1717 float effectiveZoom() const { return inherited->m_effectiveZoom; } 1718 1711 1719 TextDirection direction() const { return static_cast<TextDirection>(inherited_flags._direction); } 1712 1720 Length lineHeight() const { return inherited->line_height; } … … 1985 1993 void setDirection(TextDirection v) { inherited_flags._direction = v; } 1986 1994 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) } 1987 1997 1988 1998 void setWhiteSpace(EWhiteSpace v) { inherited_flags._white_space = v; } … … 2236 2246 static ETextAlign initialTextAlign() { return TAAUTO; } 2237 2247 static ETextDecoration initialTextDecoration() { return TDNONE; } 2248 static float initialZoom() { return 1.0f; } 2238 2249 static int initialOutlineOffset() { return 0; } 2239 2250 static float initialOpacity() { return 1.0f; } -
trunk/WebCore/rendering/RenderTableCol.cpp
r30415 r31155 86 86 void RenderTableCol::imageChanged(CachedImage* image) 87 87 { 88 if (!image || !image->canRender( ) || !parent())88 if (!image || !image->canRender(style()->effectiveZoom()) || !parent()) 89 89 return; 90 90 -
trunk/WebCore/rendering/RenderTableRow.cpp
r29646 r31155 204 204 void RenderTableRow::imageChanged(CachedImage* image) 205 205 { 206 if (!image || !image->canRender( ) || !parent())206 if (!image || !image->canRender(style()->effectiveZoom()) || !parent()) 207 207 return; 208 208 -
trunk/WebCore/rendering/RenderTableSection.cpp
r30415 r31155 971 971 void RenderTableSection::imageChanged(CachedImage* image) 972 972 { 973 if (!image || !image->canRender( ) || !parent())973 if (!image || !image->canRender(style()->effectiveZoom()) || !parent()) 974 974 return; 975 975 -
trunk/WebCore/rendering/RenderVideo.h
r29663 r31155 55 55 void updateFromElement(); 56 56 57 protected: 58 virtual void intrinsicSizeChanged() { videoSizeChanged(); } 59 57 60 private: 58 61 int calcAspectRatioWidth() const; -
trunk/WebCore/rendering/RenderView.cpp
r31037 r31155 74 74 { 75 75 if (!printing() && m_frameView) 76 m_height = zoomedHeight();76 m_height = viewHeight(); 77 77 } 78 78 … … 80 80 { 81 81 if (!printing() && m_frameView) 82 m_width = zoomedWidth();82 m_width = viewWidth(); 83 83 m_marginLeft = 0; 84 84 m_marginRight = 0; … … 100 100 101 101 // 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()); 103 103 if (relayoutChildren) 104 104 setChildNeedsLayout(true, false); … … 509 509 } 510 510 511 int RenderView:: zoomedHeight() const511 int RenderView::viewHeight() const 512 512 { 513 513 int height = 0; 514 if (!printing() && m_frameView) {514 if (!printing() && m_frameView) 515 515 height = m_frameView->visibleHeight(); 516 if (m_frameView->frame()->shouldApplyPageZoom())517 height /= m_frameView->frame()->zoomFactor(); // FIXME: Will have rounding errors.518 }519 516 return height; 520 517 } 521 518 522 int RenderView:: zoomedWidth() const519 int RenderView::viewWidth() const 523 520 { 524 521 int width = 0; 525 if (!printing() && m_frameView) {522 if (!printing() && m_frameView) 526 523 width = m_frameView->visibleWidth(); 527 if (m_frameView->frame()->shouldApplyPageZoom())528 width /= m_frameView->frame()->zoomFactor(); // FIXME: Will have rounding errors.529 }530 524 return width; 531 525 } -
trunk/WebCore/rendering/RenderView.h
r31037 r31155 26 26 27 27 #include "FrameView.h" 28 #include "Frame.h" 28 29 #include "LayoutState.h" 29 30 #include "RenderBlock.h" … … 49 50 int docWidth() const; 50 51 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; 54 55 56 float zoomFactor() const { return m_frameView->frame() && m_frameView->frame()->shouldApplyPageZoom() ? m_frameView->frame()->zoomFactor() : 1.0f; } 57 55 58 FrameView* frameView() const { return m_frameView; } 56 59
Note:
See TracChangeset
for help on using the changeset viewer.