WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
[patch]
Patch
bug-14762-20130207194805.patch (text/plain), 14.41 KB, created by
Robert Hogan
on 2013-02-07 11:51:31 PST
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Robert Hogan
Created:
2013-02-07 11:51:31 PST
Size:
14.41 KB
patch
obsolete
>Subversion Revision: 142151 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index eca4ca60ca9d2255f52ab016682328cfa2ef6056..7da0303fd34c79ef81216c29b3d9ea333d3b1628 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,34 @@ >+2013-02-07 Robert Hogan <robert@webkit.org> >+ >+ percentage top value of position:relative element not calculated using parent's min-height unless height set >+ https://bugs.webkit.org/show_bug.cgi?id=14762 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Percentage height "is calculated with respect to the height of the generated box's containing block" says >+ http://www.w3.org/TR/CSS21/visudet.html#the-height-property and "If the height of the containing block is not >+ specified explicitly (i.e., it depends on content height), and this element is not absolutely positioned, the >+ value computes to 'auto'." So when calculating the used height of a replaced element do not crawl through ancestor >+ blocks except when traversing anonymous blocks. Ensure that anonymous table cells are not skipped through though. >+ >+ http://www.w3.org/TR/CSS21/tables.html#height-layout adds "In CSS 2.1, the height of a cell box is the minimum >+ height required by the content." This height is decided by allowing table cells to report their height as auto. >+ It's not clear why http://trac.webkit.org/changeset/91242 decided it should no longer do this - doing so caused >+ us to regress in our rendering of computed-image-width-with-percent-height-inside-table-cell-and-fixed-ancestor.html. >+ >+ Tests: fast/replaced/computed-image-width-with-percent-height-and-fixed-ancestor.html >+ fast/replaced/computed-image-width-with-percent-height-inside-table-cell-and-fixed-ancestor.html >+ fast/block/percent-top-parent-respects-min-height.html >+ >+ * rendering/RenderBoxModelObject.cpp: >+ (WebCore::RenderBoxModelObject::hasAutoHeightOrContainingBlockWithAutoHeight): >+ (WebCore): >+ (WebCore::RenderBoxModelObject::relativePositionOffset): >+ * rendering/RenderBoxModelObject.h: >+ (RenderBoxModelObject): >+ * rendering/RenderReplaced.cpp: >+ (WebCore::RenderReplaced::hasReplacedLogicalHeight): >+ > 2013-01-27 Robert Hogan <robert@webkit.org> > > CSS 2.1 failure: floats-149 fails >diff --git a/Source/WebCore/rendering/RenderBoxModelObject.cpp b/Source/WebCore/rendering/RenderBoxModelObject.cpp >index 8858f0e2a7dea3c416a5ec03843076c7be98f92d..57c3ada889fea6a15f54719d7973d55b41ded001 100644 >--- a/Source/WebCore/rendering/RenderBoxModelObject.cpp >+++ b/Source/WebCore/rendering/RenderBoxModelObject.cpp >@@ -377,6 +377,31 @@ static LayoutSize accumulateInFlowPositionOffsets(const RenderObject* child) > return offset; > } > >+bool RenderBoxModelObject::hasAutoHeightOrContainingBlockWithAutoHeight() const >+{ >+ Length logicalHeightLength = style()->logicalHeight(); >+ if (logicalHeightLength.isAuto()) >+ return true; >+ >+ // For percentage heights: The percentage is calculated with respect to the height of the generated box's >+ // containing block. If the height of the containing block is not specified explicitly (i.e., it depends >+ // on content height), and this element is not absolutely positioned, the value computes to 'auto'. >+ if (!logicalHeightLength.isPercent() || isOutOfFlowPositioned() || document()->inQuirksMode()) >+ return false; >+ >+ RenderBlock* cb = containingBlock(); >+ while (cb->isAnonymousBlock()) { >+ if (cb->isTableCell()) >+ return true; >+ cb = cb->containingBlock(); >+ } >+ >+ if (!cb->style()->logicalHeight().isAuto() || (!cb->style()->logicalTop().isAuto() && !cb->style()->logicalBottom().isAuto())) >+ return false; >+ >+ return true; >+} >+ > LayoutSize RenderBoxModelObject::relativePositionOffset() const > { > LayoutSize offset = accumulateInFlowPositionOffsets(this); >@@ -403,13 +428,13 @@ LayoutSize RenderBoxModelObject::relativePositionOffset() const > // calculate the percent offset based on this height. > // See <https://bugs.webkit.org/show_bug.cgi?id=26396>. > if (!style()->top().isAuto() >- && (!containingBlock->style()->height().isAuto() >+ && (!containingBlock->hasAutoHeightOrContainingBlockWithAutoHeight() > || !style()->top().isPercent() > || containingBlock->stretchesToViewport())) > offset.expand(0, valueForLength(style()->top(), containingBlock->availableHeight(), view())); > > else if (!style()->bottom().isAuto() >- && (!containingBlock->style()->height().isAuto() >+ && (!containingBlock->hasAutoHeightOrContainingBlockWithAutoHeight() > || !style()->bottom().isPercent() > || containingBlock->stretchesToViewport())) > offset.expand(0, -valueForLength(style()->bottom(), containingBlock->availableHeight(), view())); >diff --git a/Source/WebCore/rendering/RenderBoxModelObject.h b/Source/WebCore/rendering/RenderBoxModelObject.h >index 65fe06fb3e162e2534850018381aa7b1de072aa1..07919a9c9c428b9dc108a3be0ac58f3a019197e4 100644 >--- a/Source/WebCore/rendering/RenderBoxModelObject.h >+++ b/Source/WebCore/rendering/RenderBoxModelObject.h >@@ -246,6 +246,8 @@ protected: > > static void clipRoundedInnerRect(GraphicsContext*, const LayoutRect&, const RoundedRect& clipRect); > >+ bool hasAutoHeightOrContainingBlockWithAutoHeight() const; >+ > public: > // For RenderBlocks and RenderInlines with m_style->styleType() == FIRST_LETTER, this tracks their remaining text fragments > RenderObject* firstLetterRemainingText() const; >diff --git a/Source/WebCore/rendering/RenderReplaced.cpp b/Source/WebCore/rendering/RenderReplaced.cpp >index 1386e00b5645f10eecbedfd8aa3703dc0c8fac02..2d0a04f8f56bf5dead8f1f6d9291e2ee8d357feb 100644 >--- a/Source/WebCore/rendering/RenderReplaced.cpp >+++ b/Source/WebCore/rendering/RenderReplaced.cpp >@@ -233,33 +233,13 @@ bool RenderReplaced::hasReplacedLogicalWidth() const > return firstContainingBlockWithLogicalWidth(this); > } > >-static inline bool hasAutoHeightOrContainingBlockWithAutoHeight(const RenderReplaced* replaced) >-{ >- Length logicalHeightLength = replaced->style()->logicalHeight(); >- if (logicalHeightLength.isAuto()) >- return true; >- >- // For percentage heights: The percentage is calculated with respect to the height of the generated box's >- // containing block. If the height of the containing block is not specified explicitly (i.e., it depends >- // on content height), and this element is not absolutely positioned, the value computes to 'auto'. >- if (!logicalHeightLength.isPercent() || replaced->isOutOfFlowPositioned() || replaced->document()->inQuirksMode()) >- return false; >- >- for (RenderBlock* cb = replaced->containingBlock(); !cb->isRenderView(); cb = cb->containingBlock()) { >- if (cb->isTableCell() || (!cb->style()->logicalHeight().isAuto() || (!cb->style()->top().isAuto() && !cb->style()->bottom().isAuto()))) >- return false; >- } >- >- return true; >-} >- > bool RenderReplaced::hasReplacedLogicalHeight() const > { > if (style()->logicalHeight().isAuto()) > return false; > > if (style()->logicalHeight().isSpecified()) { >- if (hasAutoHeightOrContainingBlockWithAutoHeight(this)) >+ if (hasAutoHeightOrContainingBlockWithAutoHeight()) > return false; > return true; > } >diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog >index a9fcde3b8a6b422811829070f80535fca7425332..379e33ffbf4ba2d9f8ad5e4376bd017ed9dcd1b7 100644 >--- a/LayoutTests/ChangeLog >+++ b/LayoutTests/ChangeLog >@@ -1,3 +1,17 @@ >+2013-02-07 Robert Hogan <robert@webkit.org> >+ >+ percentage top value of position:relative element not calculated using parent's min-height unless height set >+ https://bugs.webkit.org/show_bug.cgi?id=14762 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ * fast/block/percent-top-parent-respects-min-height-expected.txt: Added. >+ * fast/block/percent-top-parent-respects-min-height.html: Added. >+ * fast/replaced/computed-image-width-with-percent-height-and-fixed-ancestor-expected.html: Added. >+ * fast/replaced/computed-image-width-with-percent-height-and-fixed-ancestor.html: Added. >+ * fast/replaced/computed-image-width-with-percent-height-inside-table-cell-and-fixed-ancestor-expected.html: Added. >+ * fast/replaced/computed-image-width-with-percent-height-inside-table-cell-and-fixed-ancestor.html: Added. >+ > 2013-01-27 Robert Hogan <robert@webkit.org> > > CSS 2.1 failure: floats-149 fails >diff --git a/LayoutTests/fast/block/percent-top-parent-respects-min-height-expected.txt b/LayoutTests/fast/block/percent-top-parent-respects-min-height-expected.txt >new file mode 100644 >index 0000000000000000000000000000000000000000..f961f4498be8b51b116f4db7542f159933ed6cb8 >--- /dev/null >+++ b/LayoutTests/fast/block/percent-top-parent-respects-min-height-expected.txt >@@ -0,0 +1,4 @@ >+https://bugs.webkit.org/show_bug.cgi?id=14762: There should be no red below. >+ >+PASS >+PASS >diff --git a/LayoutTests/fast/block/percent-top-parent-respects-min-height.html b/LayoutTests/fast/block/percent-top-parent-respects-min-height.html >new file mode 100644 >index 0000000000000000000000000000000000000000..b992c202948e5a6a8815bffa062a4f64ed653ba6 >--- /dev/null >+++ b/LayoutTests/fast/block/percent-top-parent-respects-min-height.html >@@ -0,0 +1,41 @@ >+<!DOCTYPE html> >+<html> >+ <head> >+ <style> >+ div { width: 250px; } >+ .container { >+ background: green; >+ position: relative; >+ min-height: 200px; >+ height: 10%; >+ } >+ .box { >+ height: 100px; >+ position: relative; >+ top: 50%; >+ background: blue; >+ } >+ .ref { >+ height: 100px; >+ position: absolute; >+ top: 150px; >+ background: red; >+ } >+ </style> >+ <script src="../../resources/check-layout.js"></script> >+ </head> >+ <body> >+ <p>https://bugs.webkit.org/show_bug.cgi?id=14762: There should be no red below.</p> >+ <div class="container"> >+ <div class="ref"></div> >+ <div class="box" data-total-y="0"></div> >+ </div> >+ <div class="container" style="-webkit-writing-mode: vertical-lr"> >+ <div class="ref"></div> >+ <div class="box" data-total-y="100"></div> >+ </div> >+ <script> >+ checkLayout('.box') >+ </script> >+ </body> >+</html> >diff --git a/LayoutTests/fast/replaced/computed-image-width-with-percent-height-and-fixed-ancestor-expected.html b/LayoutTests/fast/replaced/computed-image-width-with-percent-height-and-fixed-ancestor-expected.html >new file mode 100644 >index 0000000000000000000000000000000000000000..95335eb6cb972e9a998f39f9dfe825da3fbe1147 >--- /dev/null >+++ b/LayoutTests/fast/replaced/computed-image-width-with-percent-height-and-fixed-ancestor-expected.html >@@ -0,0 +1,19 @@ >+<!DOCTYPE html> >+<html> >+<head> >+ <style> >+ #img { height:100px; width:100px; background: blue; } >+ </style> >+</head> >+<body> >+ <p>The square below should be 100px by 100px. >+ https://bugs.webkit.org/show_bug.cgi?id=103812 >+ In strict mode, an image with height set to 100% and a fixed height ancestor should expand to its instrinsic height and width. >+ Percentage height "is calculated with respect to the height of the generated box's containing block." </p> >+ <br> >+ <div> >+ <div id="img"></div> >+ </div> >+</body> >+</html> >+ >diff --git a/LayoutTests/fast/replaced/computed-image-width-with-percent-height-and-fixed-ancestor.html b/LayoutTests/fast/replaced/computed-image-width-with-percent-height-and-fixed-ancestor.html >new file mode 100644 >index 0000000000000000000000000000000000000000..2bb84bc38e3a6bbb3722c0064ff44c16da96f9de >--- /dev/null >+++ b/LayoutTests/fast/replaced/computed-image-width-with-percent-height-and-fixed-ancestor.html >@@ -0,0 +1,20 @@ >+<!DOCTYPE html> >+<html> >+<head> >+ <style> >+ img { height: 100%; } >+ body { height: 400px; } >+ </style> >+</head> >+<body> >+ <p>The square below should be 100px by 100px. >+ https://bugs.webkit.org/show_bug.cgi?id=103812 >+ In strict mode, an image with height set to 100% and a fixed height ancestor should expand to its instrinsic height and width. >+ Percentage height "is calculated with respect to the height of the generated box's containing block." </p> >+ <br> >+ <div> >+ <img src="resources/square-blue-100x100.png"> >+ </div> >+</body> >+</html> >+ >diff --git a/LayoutTests/fast/replaced/computed-image-width-with-percent-height-inside-table-cell-and-fixed-ancestor-expected.html b/LayoutTests/fast/replaced/computed-image-width-with-percent-height-inside-table-cell-and-fixed-ancestor-expected.html >new file mode 100644 >index 0000000000000000000000000000000000000000..3522a58a423f3afb80150a5e7f1d67a40d3602cd >--- /dev/null >+++ b/LayoutTests/fast/replaced/computed-image-width-with-percent-height-inside-table-cell-and-fixed-ancestor-expected.html >@@ -0,0 +1,16 @@ >+<!DOCTYPE html> >+<html> >+<head> >+ <style> >+ #img { height:100px; width:100px; background: blue; } >+ </style> >+</head> >+<body> >+ The square below should be 100px by 100px. >+ <br> >+ <div> >+ <div id="img"></div> >+ </div> >+</body> >+</html> >+ >diff --git a/LayoutTests/fast/replaced/computed-image-width-with-percent-height-inside-table-cell-and-fixed-ancestor.html b/LayoutTests/fast/replaced/computed-image-width-with-percent-height-inside-table-cell-and-fixed-ancestor.html >new file mode 100644 >index 0000000000000000000000000000000000000000..5f9c2ce131403d02e65ed9a5eb9a8541f982c268 >--- /dev/null >+++ b/LayoutTests/fast/replaced/computed-image-width-with-percent-height-inside-table-cell-and-fixed-ancestor.html >@@ -0,0 +1,21 @@ >+<!DOCTYPE html> >+<html> >+<head> >+ <style> >+ img { height: 100%; } >+ div { display: table; height: auto; } >+ body { height: 400px; } >+ </style> >+</head> >+<body> >+ The square below should be 100px by 100px. >+ <!-- https://bugs.webkit.org/show_bug.cgi?id=103812 --> >+ <!-- In strict mode, an image with height set to 100% and a fixed height ancestor should expand to its instrinsic height and width. --> >+ <!-- Percentage height "is calculated with respect to the height of the generated box's containing block." --> >+ <br> >+ <div> >+ <img src="resources/square-blue-100x100.png"> >+ </div> >+</body> >+</html> >+
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Flags:
jchaffraix
:
review+
jchaffraix
:
commit-queue-
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 14762
:
15679
|
184298
| 187140