https://bugs.webkit.org/show_bug.cgi?id=80794
Patch by Arpita Bahuguna <arpitabahuguna@gmail.com> on 2012-10-07
Reviewed by Daniel Bates.
Source/WebCore:
The :first-line pseudo-element style is not applied for content
which is generated from the :before/:after pseudo-elements.
Test: fast/css/first-line-style-for-before-after-content.html
* rendering/RenderObject.cpp:
(WebCore::firstLineStyleForCachedUncachedType):
Added a new static helper function incorporating the common
functionality of both uncachedFirstLineStyle() and firstLineStyleSlowCase()
functions. It also modifies the functionality to handle the
scenario when :first-line style needs to be applied on content
generated from :before/:after.
While getting the :first-line style we should also consider the case
when the content is generated from a :before/:after pseudo-element in
which case the RenderInline's parent should be considered for
obtaining the first-line style.
(WebCore):
(WebCore::RenderObject::uncachedFirstLineStyle):
(WebCore::RenderObject::firstLineStyleSlowCase):
Moved the duplicate code between the two functions to the common
helper function firstLineStyleForCachedUncachedType().
LayoutTests:
* fast/css/first-line-style-for-before-after-content-expected.html: Added.
* fast/css/first-line-style-for-before-after-content.html: Added.
Added ref test for verification of the scenario when :first-line style
is applied to content generated from :before/:after pseudo-elements.
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@130616
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2012-10-07 Arpita Bahuguna <arpitabahuguna@gmail.com>
+
+ :first-line pseudo selector ignoring words created from :before
+ https://bugs.webkit.org/show_bug.cgi?id=80794
+
+ Reviewed by Daniel Bates.
+
+ * fast/css/first-line-style-for-before-after-content-expected.html: Added.
+ * fast/css/first-line-style-for-before-after-content.html: Added.
+ Added ref test for verification of the scenario when :first-line style
+ is applied to content generated from :before/:after pseudo-elements.
+
2012-10-07 Nick Carter <nick@chromium.org>
[chromium] Crash in WebCore::GraphicsLayerChromium::setContentsToImage
--- /dev/null
+<!DOCTYPE html>
+<html>
+<head>
+<style>
+p {
+ width: 200px;
+}
+.firstline {
+ color: green;
+}
+.firstletter {
+ color: blue;
+}
+</style>
+</head>
+<body>
+ <div>Test for Bugzilla <a href="https://bugs.webkit.org/show_bug.cgi?id=80794">Bug 80794</a>: :first-line pseudo selector ignoring words created from :before.</div>
+ <div>The :first-line pseudo-element style is not applied to content generated from :before/:after pseudo-elements.</div>
+ <br>
+
+ <div>In the following paragraph the first-letter should be displayed in blue color and the first-line in green color including the words 'The first line'. This test verifies the behavior with :before style specified on a block flow element.</div>
+ <p><span class="firstletter">T</span><span class="firstline">he first line of this paragraph</span> should be displayed in green color.</p>
+
+ <div>In the following paragraph the first-letter should be displayed in blue color and the first-line in green color including the words 'The first line'. This test verifies the behavior with :before style specified on an inline element.</div>
+ <p><span class="firstletter">T</span><span class="firstline">he first line of this paragraph</span> should be displayed in green color.</p>
+
+ <div>In the following paragraph the first-letter should be displayed in blue color and the first-line in green color including the words 'in green color.'. This test verifies the behavior with :after style specified on a block flow element.</div>
+ <p><span class="firstletter">D</span><span class="firstline">isplay in green color.</span></p>
+
+ <div>In the following paragraph the first-letter should be displayed in blue color and the first-line in green color including the words 'in green color.'. This test verifies the behavior with :after style specified on an inline element.</div>
+ <p><span class="firstletter">D</span><span class="firstline">isplay in green color.</span></p>
+</body>
+</html>
+
--- /dev/null
+<!DOCTYPE html>
+<html>
+<head>
+<style>
+p {
+ width: 200px;
+}
+p.before:before {
+ content: 'The first line';
+}
+p.after:after {
+ content: 'in green color.';
+}
+span.before:before {
+ content: 'The first line';
+}
+span.after:after {
+ content: 'in green color.';
+}
+p:first-line {
+ color: green;
+}
+p:first-letter {
+ color: blue;
+}
+</style>
+</head>
+<body>
+ <div>Test for Bugzilla <a href="https://bugs.webkit.org/show_bug.cgi?id=80794">Bug 80794</a>: :first-line pseudo selector ignoring words created from :before.</div>
+ <div>The :first-line pseudo-element style is not applied to content generated from :before/:after pseudo-elements.</div>
+ <br>
+
+ <div>In the following paragraph the first-letter should be displayed in blue color and the first-line in green color including the words 'The first line'. This test verifies the behavior with :before style specified on a block flow element.</div>
+ <p class="before"> of this paragraph should be displayed in green color.</p>
+
+ <div>In the following paragraph the first-letter should be displayed in blue color and the first-line in green color including the words 'The first line'. This test verifies the behavior with :before style specified on an inline element.</div>
+ <p><span class="before"> of this paragraph should be displayed in green color.</span></p>
+
+ <div>In the following paragraph the first-letter should be displayed in blue color and the first-line in green color including the words 'in green color.'. This test verifies the behavior with :after style specified on a block flow element.</div>
+ <p class="after">Display </p>
+
+ <div>In the following paragraph the first-letter should be displayed in blue color and the first-line in green color including the words 'in green color.'. This test verifies the behavior with :after style specified on an inline element.</div>
+ <p><span class="after">Display </span></p>
+</body>
+</html>
+
+2012-10-07 Arpita Bahuguna <arpitabahuguna@gmail.com>
+
+ :first-line pseudo selector ignoring words created from :before
+ https://bugs.webkit.org/show_bug.cgi?id=80794
+
+ Reviewed by Daniel Bates.
+
+ The :first-line pseudo-element style is not applied for content
+ which is generated from the :before/:after pseudo-elements.
+
+ Test: fast/css/first-line-style-for-before-after-content.html
+
+ * rendering/RenderObject.cpp:
+ (WebCore::firstLineStyleForCachedUncachedType):
+ Added a new static helper function incorporating the common
+ functionality of both uncachedFirstLineStyle() and firstLineStyleSlowCase()
+ functions. It also modifies the functionality to handle the
+ scenario when :first-line style needs to be applied on content
+ generated from :before/:after.
+
+ While getting the :first-line style we should also consider the case
+ when the content is generated from a :before/:after pseudo-element in
+ which case the RenderInline's parent should be considered for
+ obtaining the first-line style.
+
+ (WebCore):
+ (WebCore::RenderObject::uncachedFirstLineStyle):
+ (WebCore::RenderObject::firstLineStyleSlowCase):
+ Moved the duplicate code between the two functions to the common
+ helper function firstLineStyleForCachedUncachedType().
+
2012-10-07 Peter Wang <peter.wang@torchmobile.com.cn>
Web Inspector: The front-end should provide the position in original source file when set a breakpoint
setNeedsLayout(false);
}
+enum StyleCacheState {
+ Cached,
+ Uncached
+};
+
+static PassRefPtr<RenderStyle> firstLineStyleForCachedUncachedType(StyleCacheState type, const RenderObject* renderer, RenderStyle* style)
+{
+ const RenderObject* rendererForFirstLineStyle = renderer;
+ if (renderer->isBeforeOrAfterContent())
+ rendererForFirstLineStyle = renderer->parent();
+
+ if (rendererForFirstLineStyle->isBlockFlow()) {
+ if (RenderBlock* firstLineBlock = rendererForFirstLineStyle->firstLineBlock()) {
+ if (type == Cached)
+ return firstLineBlock->getCachedPseudoStyle(FIRST_LINE, style);
+ return firstLineBlock->getUncachedPseudoStyle(FIRST_LINE, style, firstLineBlock == renderer ? style : 0);
+ }
+ } else if (!rendererForFirstLineStyle->isAnonymous() && rendererForFirstLineStyle->isRenderInline()) {
+ RenderStyle* parentStyle = rendererForFirstLineStyle->parent()->firstLineStyle();
+ if (parentStyle != rendererForFirstLineStyle->parent()->style()) {
+ if (type == Cached) {
+ // A first-line style is in effect. Cache a first-line style for ourselves.
+ rendererForFirstLineStyle->style()->setHasPseudoStyle(FIRST_LINE_INHERITED);
+ return rendererForFirstLineStyle->getCachedPseudoStyle(FIRST_LINE_INHERITED, parentStyle);
+ }
+ return rendererForFirstLineStyle->getUncachedPseudoStyle(FIRST_LINE_INHERITED, parentStyle, style);
+ }
+ }
+ return 0;
+}
+
PassRefPtr<RenderStyle> RenderObject::uncachedFirstLineStyle(RenderStyle* style) const
{
if (!document()->styleSheetCollection()->usesFirstLineRules())
ASSERT(!isText());
- RefPtr<RenderStyle> result;
-
- if (isBlockFlow()) {
- if (RenderBlock* firstLineBlock = this->firstLineBlock())
- result = firstLineBlock->getUncachedPseudoStyle(FIRST_LINE, style, firstLineBlock == this ? style : 0);
- } else if (!isAnonymous() && isRenderInline()) {
- RenderStyle* parentStyle = parent()->firstLineStyle();
- if (parentStyle != parent()->style())
- result = getUncachedPseudoStyle(FIRST_LINE_INHERITED, parentStyle, style);
- }
-
- return result.release();
+ return firstLineStyleForCachedUncachedType(Uncached, this, style);
}
RenderStyle* RenderObject::firstLineStyleSlowCase() const
{
ASSERT(document()->styleSheetCollection()->usesFirstLineRules());
- RenderStyle* style = m_style.get();
- const RenderObject* renderer = isText() ? parent() : this;
- if (renderer->isBlockFlow()) {
- if (RenderBlock* firstLineBlock = renderer->firstLineBlock())
- style = firstLineBlock->getCachedPseudoStyle(FIRST_LINE, style);
- } else if (!renderer->isAnonymous() && renderer->isRenderInline()) {
- RenderStyle* parentStyle = renderer->parent()->firstLineStyle();
- if (parentStyle != renderer->parent()->style()) {
- // A first-line style is in effect. Cache a first-line style for ourselves.
- renderer->style()->setHasPseudoStyle(FIRST_LINE_INHERITED);
- style = renderer->getCachedPseudoStyle(FIRST_LINE_INHERITED, parentStyle);
- }
- }
+ if (RefPtr<RenderStyle> style = firstLineStyleForCachedUncachedType(Cached, isText() ? parent() : this, m_style.get()))
+ return style.get();
- return style;
+ return m_style.get();
}
RenderStyle* RenderObject::getCachedPseudoStyle(PseudoId pseudo, RenderStyle* parentStyle) const