Changeset 87801 in webkit
- Timestamp:
- Jun 1, 2011 7:10:15 AM (13 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r87799 r87801 1 2011-06-01 Nikolas Zimmermann <nzimmermann@rim.com> 2 3 Reviewed by Rob Buis. 4 5 Remove duplicated code in various computeReplacedLogical*() functions 6 https://bugs.webkit.org/show_bug.cgi?id=61860 7 8 Centralize this calculation in RenderBox::computeReplacedLogicalWidthRespectingMinMaxWidth: 9 int minLogicalWidth = computeReplacedLogicalWidthUsing(style()->logicalMinWidth()); 10 int maxLogicalWidth = !includeMaxWidth || style()->logicalMaxWidth().isUndefined() ? logicalWidth : computeReplacedLogicalWidthUsing(style()->logicalMaxWidth()); 11 return max(minLogicalWidth, min(logicalWidth, maxLogicalWidth)); 12 13 Centralize this calculation in RenderBox::computeReplacedLogicalHeightRespectingMinMaxHeight: 14 int minLogicalHeight = computeReplacedLogicalHeightUsing(style()->logicalMinHeight()); 15 int maxLogicalHeight = style()->logicalMaxHeight().isUndefined() ? logicalHeight : computeReplacedLogicalHeightUsing(style()->logicalMaxHeight()); 16 return max(minLogicalHeight, min(logicalHeight, maxLogicalHeight)); 17 18 Use the new helper methods where possible, deduplicating lots of code. 19 20 * rendering/RenderBox.cpp: 21 (WebCore::RenderBox::computeReplacedLogicalWidth): 22 (WebCore::RenderBox::computeReplacedLogicalWidthRespectingMinMaxWidth): 23 (WebCore::RenderBox::computeReplacedLogicalHeight): 24 (WebCore::RenderBox::computeReplacedLogicalHeightRespectingMinMaxHeight): 25 * rendering/RenderBox.h: 26 * rendering/RenderImage.cpp: 27 (WebCore::RenderImage::computeReplacedLogicalWidth): 28 (WebCore::RenderImage::computeReplacedLogicalHeight): 29 * rendering/RenderPart.cpp: 30 (WebCore::RenderPart::computeEmbeddedDocumentReplacedWidth): 31 (WebCore::RenderPart::computeEmbeddedDocumentReplacedHeight): 32 (WebCore::RenderPart::computeReplacedLogicalWidth): 33 (WebCore::RenderPart::computeReplacedLogicalHeight): 34 * rendering/RenderPart.h: 35 * rendering/RenderReplaced.cpp: 36 (WebCore::RenderReplaced::computeReplacedLogicalWidth): 37 (WebCore::RenderReplaced::computeReplacedLogicalHeight): 38 * rendering/svg/RenderSVGRoot.cpp: 39 (WebCore::RenderSVGRoot::computeReplacedLogicalWidth): 40 (WebCore::RenderSVGRoot::computeReplacedLogicalHeight): 41 1 42 2011-06-01 Sheriff Bot <webkit.review.bot@gmail.com> 2 43 -
trunk/Source/WebCore/rendering/RenderBox.cpp
r87467 r87801 1946 1946 int RenderBox::computeReplacedLogicalWidth(bool includeMaxWidth) const 1947 1947 { 1948 int logicalWidth = computeReplacedLogicalWidthUsing(style()->logicalWidth()); 1948 return computeReplacedLogicalWidthRespectingMinMaxWidth(computeReplacedLogicalWidthUsing(style()->logicalWidth()), includeMaxWidth); 1949 } 1950 1951 int RenderBox::computeReplacedLogicalWidthRespectingMinMaxWidth(int logicalWidth, bool includeMaxWidth) const 1952 { 1949 1953 int minLogicalWidth = computeReplacedLogicalWidthUsing(style()->logicalMinWidth()); 1950 1954 int maxLogicalWidth = !includeMaxWidth || style()->logicalMaxWidth().isUndefined() ? logicalWidth : computeReplacedLogicalWidthUsing(style()->logicalMaxWidth()); 1951 1952 1955 return max(minLogicalWidth, min(logicalWidth, maxLogicalWidth)); 1953 1956 } … … 1974 1977 int RenderBox::computeReplacedLogicalHeight() const 1975 1978 { 1976 int logicalHeight = computeReplacedLogicalHeightUsing(style()->logicalHeight()); 1979 return computeReplacedLogicalHeightRespectingMinMaxHeight(computeReplacedLogicalHeightUsing(style()->logicalHeight())); 1980 } 1981 1982 int RenderBox::computeReplacedLogicalHeightRespectingMinMaxHeight(int logicalHeight) const 1983 { 1977 1984 int minLogicalHeight = computeReplacedLogicalHeightUsing(style()->logicalMinHeight()); 1978 1985 int maxLogicalHeight = style()->logicalMaxHeight().isUndefined() ? logicalHeight : computeReplacedLogicalHeightUsing(style()->logicalMaxHeight()); 1979 1980 1986 return max(minLogicalHeight, min(logicalHeight, maxLogicalHeight)); 1981 1987 } -
trunk/Source/WebCore/rendering/RenderBox.h
r87467 r87801 309 309 int computeLogicalHeightUsing(const Length& height); 310 310 int computeReplacedLogicalWidthUsing(Length width) const; 311 int computeReplacedLogicalWidthRespectingMinMaxWidth(int logicalWidth, bool includeMaxWidth = true) const; 311 312 int computeReplacedLogicalHeightUsing(Length height) const; 313 int computeReplacedLogicalHeightRespectingMinMaxHeight(int logicalHeight) const; 312 314 313 315 virtual int computeReplacedLogicalWidth(bool includeMaxWidth = true) const; -
trunk/Source/WebCore/rendering/RenderImage.cpp
r87152 r87801 478 478 logicalWidth = calcAspectRatioLogicalWidth(); 479 479 480 int minLogicalWidth = computeReplacedLogicalWidthUsing(style()->logicalMinWidth()); 481 int maxLogicalWidth = !includeMaxWidth || style()->logicalMaxWidth().isUndefined() ? logicalWidth : computeReplacedLogicalWidthUsing(style()->logicalMaxWidth()); 482 483 return max(minLogicalWidth, min(logicalWidth, maxLogicalWidth)); 480 return computeReplacedLogicalWidthRespectingMinMaxWidth(logicalWidth, includeMaxWidth); 484 481 } 485 482 … … 497 494 logicalHeight = calcAspectRatioLogicalHeight(); 498 495 499 int minLogicalHeight = computeReplacedLogicalHeightUsing(style()->logicalMinHeight()); 500 int maxLogicalHeight = style()->logicalMaxHeight().isUndefined() ? logicalHeight : computeReplacedLogicalHeightUsing(style()->logicalMaxHeight()); 501 502 return max(minLogicalHeight, min(logicalHeight, maxLogicalHeight)); 496 return computeReplacedLogicalHeightRespectingMinMaxHeight(logicalHeight); 503 497 } 504 498 -
trunk/Source/WebCore/rendering/RenderPart.cpp
r87779 r87801 113 113 } 114 114 115 int RenderPart::computeEmbeddedDocumentReplacedWidth(bool includeMaxWidth, RenderStyle* contentRenderStyle) const 116 { 117 int logicalWidth = computeReplacedLogicalWidthUsing(contentRenderStyle->logicalWidth()); 118 int minLogicalWidth = computeReplacedLogicalWidthUsing(contentRenderStyle->logicalMinWidth()); 119 int maxLogicalWidth = !includeMaxWidth || contentRenderStyle->logicalMaxWidth().isUndefined() ? logicalWidth : computeReplacedLogicalWidthUsing(contentRenderStyle->logicalMaxWidth()); 120 int width = max(minLogicalWidth, min(logicalWidth, maxLogicalWidth)); 121 return width; 122 } 123 124 int RenderPart::computeEmbeddedDocumentReplacedHeight(RenderStyle* contentRenderStyle) const 125 { 126 int logicalHeight = computeReplacedLogicalHeightUsing(contentRenderStyle->logicalHeight()); 127 int minLogicalHeight = computeReplacedLogicalHeightUsing(contentRenderStyle->logicalMinHeight()); 128 int maxLogicalHeight = contentRenderStyle->logicalMaxHeight().isUndefined() ? logicalHeight : computeReplacedLogicalHeightUsing(contentRenderStyle->logicalMaxHeight()); 129 int height = max(minLogicalHeight, min(logicalHeight, maxLogicalHeight)); 130 return height; 115 int RenderPart::computeEmbeddedDocumentReplacedWidth(RenderSVGRoot* contentRenderer, bool includeMaxWidth) const 116 { 117 ASSERT(contentRenderer); 118 ASSERT(contentRenderer->style()); 119 return computeReplacedLogicalWidthRespectingMinMaxWidth(computeReplacedLogicalWidthUsing(contentRenderer->style()->logicalWidth()), includeMaxWidth); 120 } 121 122 int RenderPart::computeEmbeddedDocumentReplacedHeight(RenderSVGRoot* contentRenderer) const 123 { 124 ASSERT(contentRenderer); 125 ASSERT(contentRenderer->style()); 126 return computeReplacedLogicalHeightRespectingMinMaxHeight(computeReplacedLogicalHeightUsing(contentRenderer->style()->logicalHeight())); 131 127 } 132 128 … … 150 146 // If 'height' and 'width' both have computed values of 'auto' and the element also has an intrinsic width, then that intrinsic width is the used value of 'width'. 151 147 if (heightIsAuto && hasIntrinsicWidth) 152 return computeEmbeddedDocumentReplacedWidth( includeMaxWidth, contentRenderStyle);148 return computeEmbeddedDocumentReplacedWidth(contentRenderer, includeMaxWidth); 153 149 154 150 bool hasIntrinsicHeight = contentRenderStyle->height().isFixed(); … … 176 172 // Otherwise, if 'width' has a computed value of 'auto', and the element has an intrinsic width, then that intrinsic width is the used value of 'width'. 177 173 if (hasIntrinsicWidth) 178 return computeEmbeddedDocumentReplacedWidth( includeMaxWidth, contentRenderStyle);174 return computeEmbeddedDocumentReplacedWidth(contentRenderer, includeMaxWidth); 179 175 } 180 176 … … 203 199 // If 'height' and 'width' both have computed values of 'auto' and the element also has an intrinsic height, then that intrinsic height is the used value of 'height'. 204 200 if (widthIsAuto && hasIntrinsicHeight) 205 return computeEmbeddedDocumentReplacedHeight(contentRender Style);201 return computeEmbeddedDocumentReplacedHeight(contentRenderer); 206 202 207 203 // Otherwise, if 'height' has a computed value of 'auto', and the element has an intrinsic ratio then the used value of 'height' is: … … 214 210 // Otherwise, if 'height' has a computed value of 'auto', and the element has an intrinsic height, then that intrinsic height is the used value of 'height'. 215 211 if (hasIntrinsicHeight) 216 return computeEmbeddedDocumentReplacedHeight(contentRender Style);212 return computeEmbeddedDocumentReplacedHeight(contentRenderer); 217 213 } 218 214 -
trunk/Source/WebCore/rendering/RenderPart.h
r87526 r87801 50 50 #if ENABLE(SVG) 51 51 RenderSVGRoot* embeddedSVGContentRenderer() const; 52 int computeEmbeddedDocumentReplacedWidth( bool includeMaxWidth, RenderStyle* contentRenderStyle) const;53 int computeEmbeddedDocumentReplacedHeight(RenderS tyle* contentRenderStyle) const;52 int computeEmbeddedDocumentReplacedWidth(RenderSVGRoot* contentRenderer, bool includeMaxWidth) const; 53 int computeEmbeddedDocumentReplacedHeight(RenderSVGRoot* contentRenderer) const; 54 54 virtual int computeReplacedLogicalWidth(bool includeMaxWidth = true) const; 55 55 virtual int computeReplacedLogicalHeight() const; -
trunk/Source/WebCore/rendering/RenderReplaced.cpp
r87526 r87801 203 203 logicalWidth = intrinsicLogicalWidth(); 204 204 205 int minLogicalWidth = computeReplacedLogicalWidthUsing(style()->logicalMinWidth()); 206 int maxLogicalWidth = !includeMaxWidth || style()->logicalMaxWidth().isUndefined() ? logicalWidth : computeReplacedLogicalWidthUsing(style()->logicalMaxWidth()); 207 208 return max(minLogicalWidth, min(logicalWidth, maxLogicalWidth)); 205 return computeReplacedLogicalWidthRespectingMinMaxWidth(logicalWidth, includeMaxWidth); 209 206 } 210 207 … … 219 216 logicalHeight = intrinsicLogicalHeight(); 220 217 221 int minLogicalHeight = computeReplacedLogicalHeightUsing(style()->logicalMinHeight()); 222 int maxLogicalHeight = style()->logicalMaxHeight().isUndefined() ? logicalHeight : computeReplacedLogicalHeightUsing(style()->logicalMaxHeight()); 223 224 return max(minLogicalHeight, min(logicalHeight, maxLogicalHeight)); 218 return computeReplacedLogicalHeightRespectingMinMaxHeight(logicalHeight); 225 219 } 226 220 -
trunk/Source/WebCore/rendering/svg/RenderSVGRoot.cpp
r87779 r87801 191 191 // 192 192 // Under these conditions, the positioning properties establish the viewport's width. 193 int logicalWidth = ownerRenderer->computeReplacedLogicalWidthUsing(ownerWidth); 194 int minLogicalWidth = ownerRenderer->computeReplacedLogicalWidthUsing(ownerRendererStyle->logicalMinWidth()); 195 int maxLogicalWidth = !includeMaxWidth || ownerRendererStyle->logicalMaxWidth().isUndefined() ? logicalWidth : ownerRenderer->computeReplacedLogicalWidthUsing(ownerRendererStyle->logicalMaxWidth()); 196 return max(minLogicalWidth, min(logicalWidth, maxLogicalWidth)); 193 return ownerRenderer->computeReplacedLogicalWidthRespectingMinMaxWidth(ownerRenderer->computeReplacedLogicalWidthUsing(ownerWidth), includeMaxWidth); 197 194 } 198 195 … … 223 220 // are sufficient to establish the height of the viewport, then these positioning properties establish the viewport's height; 224 221 // otherwise, the ‘height’ attribute on the outermost svg element establishes the viewport's height. 225 int logicalHeight = ownerRenderer->computeReplacedLogicalHeightUsing(ownerHeight); 226 int minLogicalHeight = ownerRenderer->computeReplacedLogicalHeightUsing(ownerRendererStyle->logicalMinHeight()); 227 int maxLogicalHeight = ownerRendererStyle->logicalMaxHeight().isUndefined() ? logicalHeight : ownerRenderer->computeReplacedLogicalHeightUsing(ownerRendererStyle->logicalMaxHeight()); 228 return max(minLogicalHeight, min(logicalHeight, maxLogicalHeight)); 222 return ownerRenderer->computeReplacedLogicalHeightRespectingMinMaxHeight(ownerRenderer->computeReplacedLogicalHeightUsing(ownerHeight)); 229 223 } 230 224
Note: See TracChangeset
for help on using the changeset viewer.