Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(36)

Side by Side Diff: Source/core/rendering/RenderReplaced.cpp

Issue 341773004: Use available width for replaced element with intrinsic ratio but no dimensions (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebase and add NeedsRebaseline to zoom test with off-by-one (or so) errors Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « LayoutTests/svg/custom/inline-svg-use-available-width-in-stf.html ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * Copyright (C) 2000 Dirk Mueller (mueller@kde.org) 3 * Copyright (C) 2000 Dirk Mueller (mueller@kde.org)
4 * Copyright (C) 2004, 2006, 2007 Apple Inc. All rights reserved. 4 * Copyright (C) 2004, 2006, 2007 Apple Inc. All rights reserved.
5 * Copyright (C) Research In Motion Limited 2011-2012. All rights reserved. 5 * Copyright (C) Research In Motion Limited 2011-2012. All rights reserved.
6 * 6 *
7 * This library is free software; you can redistribute it and/or 7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Library General Public 8 * modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either 9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version. 10 * version 2 of the License, or (at your option) any later version.
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 198
199 if (adjustedPaintOffset.x() + visualOverflowRect().x() >= paintInfo.rect.max X() || adjustedPaintOffset.x() + visualOverflowRect().maxX() <= paintInfo.rect.x ()) 199 if (adjustedPaintOffset.x() + visualOverflowRect().x() >= paintInfo.rect.max X() || adjustedPaintOffset.x() + visualOverflowRect().maxX() <= paintInfo.rect.x ())
200 return false; 200 return false;
201 201
202 if (top >= paintInfo.rect.maxY() || bottom <= paintInfo.rect.y()) 202 if (top >= paintInfo.rect.maxY() || bottom <= paintInfo.rect.y())
203 return false; 203 return false;
204 204
205 return true; 205 return true;
206 } 206 }
207 207
208 static inline RenderBlock* firstContainingBlockWithLogicalWidth(const RenderRepl aced* replaced)
209 {
210 // We have to lookup the containing block, which has an explicit width, whic h must not be equal to our direct containing block.
211 // If the embedded document appears _after_ we performed the initial layout, our intrinsic size is 300x150. If our containing
212 // block doesn't provide an explicit width, it's set to the 300 default, com ing from the initial layout run.
213 RenderBlock* containingBlock = replaced->containingBlock();
214 if (!containingBlock)
215 return 0;
216
217 for (; !containingBlock->isRenderView() && !containingBlock->isBody(); conta iningBlock = containingBlock->containingBlock()) {
218 if (containingBlock->style()->logicalWidth().isSpecified()
219 && containingBlock->style()->logicalMinWidth().isSpecified()
220 && (containingBlock->style()->logicalMaxWidth().isSpecified() || con tainingBlock->style()->logicalMaxWidth().isUndefined()))
221 return containingBlock;
222 }
223
224 return 0;
225 }
226
227 bool RenderReplaced::hasReplacedLogicalHeight() const 208 bool RenderReplaced::hasReplacedLogicalHeight() const
228 { 209 {
229 if (style()->logicalHeight().isAuto()) 210 if (style()->logicalHeight().isAuto())
230 return false; 211 return false;
231 212
232 if (style()->logicalHeight().isSpecified()) { 213 if (style()->logicalHeight().isSpecified()) {
233 if (hasAutoHeightOrContainingBlockWithAutoHeight()) 214 if (hasAutoHeightOrContainingBlockWithAutoHeight())
234 return false; 215 return false;
235 return true; 216 return true;
236 } 217 }
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
381 } 362 }
382 363
383 // If 'height' and 'width' both have computed values of 'auto' and t he element has an intrinsic ratio but no intrinsic height or width, then the use d value of 364 // If 'height' and 'width' both have computed values of 'auto' and t he element has an intrinsic ratio but no intrinsic height or width, then the use d value of
384 // 'width' is undefined in CSS 2.1. However, it is suggested that, i f the containing block's width does not itself depend on the replaced element's width, then 365 // 'width' is undefined in CSS 2.1. However, it is suggested that, i f the containing block's width does not itself depend on the replaced element's width, then
385 // the used value of 'width' is calculated from the constraint equat ion used for block-level, non-replaced elements in normal flow. 366 // the used value of 'width' is calculated from the constraint equat ion used for block-level, non-replaced elements in normal flow.
386 if (computedHeightIsAuto && !hasIntrinsicWidth && !hasIntrinsicHeigh t) { 367 if (computedHeightIsAuto && !hasIntrinsicWidth && !hasIntrinsicHeigh t) {
387 if (shouldComputePreferred == ComputePreferred) 368 if (shouldComputePreferred == ComputePreferred)
388 return 0; 369 return 0;
389 // The aforementioned 'constraint equation' used for block-level , non-replaced elements in normal flow: 370 // The aforementioned 'constraint equation' used for block-level , non-replaced elements in normal flow:
390 // 'margin-left' + 'border-left-width' + 'padding-left' + 'width ' + 'padding-right' + 'border-right-width' + 'margin-right' = width of containin g block 371 // 'margin-left' + 'border-left-width' + 'padding-left' + 'width ' + 'padding-right' + 'border-right-width' + 'margin-right' = width of containin g block
391 LayoutUnit logicalWidth; 372 LayoutUnit logicalWidth = containingBlock()->availableLogicalWid th();
392 // FIXME: This walking up the containgBlock chain to find the fi rst one with a specified width is bonkers.
393 // If nothing else, it requires making sure that computeReplaced LogicalWidthRespectingMinMaxWidth cannot
394 // depend on the width of the replaced element or we infinite lo op. Right now we do that in
395 // firstContainingBlockWithLogicalWidth by checking that width/m in-width/max-width are all specified.
396 //
397 // Firefox 27 seems to only do this if the <svg> has a viewbox.
398 if (RenderBlock* blockWithWidth = firstContainingBlockWithLogica lWidth(this)) {
399 logicalWidth = blockWithWidth->computeReplacedLogicalWidthRe spectingMinMaxWidth(blockWithWidth->computeReplacedLogicalWidthUsing(blockWithWi dth->style()->logicalWidth()), shouldComputePreferred);
400 } else {
401 // FIXME: If shouldComputePreferred == ComputePreferred, the n we're reading this during preferred width
402 // computation, at which point this is reading stale data fr om a previous layout.
403 logicalWidth = containingBlock()->availableLogicalWidth();
404 }
405 373
406 // This solves above equation for 'width' (== logicalWidth). 374 // This solves above equation for 'width' (== logicalWidth).
407 LayoutUnit marginStart = minimumValueForLength(style()->marginSt art(), logicalWidth); 375 LayoutUnit marginStart = minimumValueForLength(style()->marginSt art(), logicalWidth);
408 LayoutUnit marginEnd = minimumValueForLength(style()->marginEnd( ), logicalWidth); 376 LayoutUnit marginEnd = minimumValueForLength(style()->marginEnd( ), logicalWidth);
409 logicalWidth = std::max<LayoutUnit>(0, logicalWidth - (marginSta rt + marginEnd + (width() - clientWidth()))); 377 logicalWidth = std::max<LayoutUnit>(0, logicalWidth - (marginSta rt + marginEnd + (width() - clientWidth())));
410 return computeReplacedLogicalWidthRespectingMinMaxWidth(logicalW idth, shouldComputePreferred); 378 return computeReplacedLogicalWidthRespectingMinMaxWidth(logicalW idth, shouldComputePreferred);
411 } 379 }
412 } 380 }
413 381
414 // 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'. 382 // 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'.
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
600 return LayoutRect(); 568 return LayoutRect();
601 569
602 // The selectionRect can project outside of the overflowRect, so take their union 570 // The selectionRect can project outside of the overflowRect, so take their union
603 // for repainting to avoid selection painting glitches. 571 // for repainting to avoid selection painting glitches.
604 LayoutRect r = isSelected() ? localSelectionRect() : visualOverflowRect(); 572 LayoutRect r = isSelected() ? localSelectionRect() : visualOverflowRect();
605 mapRectToPaintInvalidationBacking(paintInvalidationContainer, r); 573 mapRectToPaintInvalidationBacking(paintInvalidationContainer, r);
606 return r; 574 return r;
607 } 575 }
608 576
609 } 577 }
OLDNEW
« no previous file with comments | « LayoutTests/svg/custom/inline-svg-use-available-width-in-stf.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698