Commit ffe769be authored by pdr@google.com's avatar pdr@google.com

Repaint borders and outlines on pseudo content changes

https://bugs.webkit.org/show_bug.cgi?id=122070

Reviewed by Andreas Kling.

Source/WebCore:

This patch fixes a regression from wkrev.com/150259 where pseudo content with
borders or outlines would fail to repaint if the color property changed.
The root bug is that border-color and outline-color properties use 'color' if
no explicit border-color or outline-color are given, and changing color should
repaint borders and outlines even if the text content is empty.

Relevant spec sections:
border: http://www.w3.org/TR/CSS1/#border-color
outline: http://www.w3.org/TR/CSS2/ui.html#propdef-outline-color

This patch also renames StyleDifferenceRepaintIfText to
StyleDifferenceRepaintIfTextOrBorderOrOutline and updates the relevant functions.

Test: fast/repaint/hover-pseudo-borders.html

* rendering/RenderElement.cpp:
(WebCore::RenderElement::hasImmediateNonWhitespaceTextChildOrBorderOrOutline):

    This function has been renamed to reflect that it returns true for borders
    or outlines as well.

(WebCore::RenderElement::shouldRepaintForStyleDifference):
* rendering/RenderElement.h:
* rendering/style/RenderStyle.cpp:
(WebCore::RenderStyle::changeRequiresRepaintIfTextOrBorderOrOutline):
(WebCore::RenderStyle::diff):
* rendering/style/RenderStyle.h:
* rendering/style/RenderStyleConstants.h:
* rendering/svg/SVGResourcesCache.cpp:
(WebCore::SVGResourcesCache::clientStyleChanged):
    These have also been renamed to reflect the new borders and outlines check.

LayoutTests:

* fast/repaint/hover-pseudo-borders.html: Added.
* platform/mac/fast/repaint/hover-pseudo-borders-expected.png: Added.
* platform/mac/fast/repaint/hover-pseudo-borders-expected.txt: Added.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@156619 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 3ab7ef3a
2013-09-29 Philip Rogers <pdr@google.com>
Repaint borders and outlines on pseudo content changes
https://bugs.webkit.org/show_bug.cgi?id=122070
Reviewed by Andreas Kling.
* fast/repaint/hover-pseudo-borders.html: Added.
* platform/mac/fast/repaint/hover-pseudo-borders-expected.png: Added.
* platform/mac/fast/repaint/hover-pseudo-borders-expected.txt: Added.
2013-09-29 Zan Dobersek <zdobersek@igalia.com>
Unreviewed GTK gardening. Skip the IndexedDB tests for now as the feature is going
<!DOCTYPE html>
<html>
<head>
<style>
.hitregion {
width: 100px;
height: 100px;
background-color: red;
}
.hitregion:after {
content: "";
border: 40px solid;
outline: 10px solid;
position: absolute;
width: 0;
height: 0;
margin-left: 140px;
margin-top: 10px;
}
.hitregion:hover {
background-color: green; /* Changes the left box's color. */
}
.hitregion:hover:after {
color: green; /* Changes the right box's color. */
}
</style>
<script src="resources/repaint.js"></script>
<script>
function repaintTest() {
if (!window.testRunner)
return;
eventSender.mouseMoveTo(50, 50);
eventSender.mouseDown();
eventSender.mouseUp();
}
window.addEventListener("load", runRepaintTest);
</script>
</head>
<body>
<!--
REGRESSION: :hover doesn't work on :after content with borders or outlines.
To test this bug outside DRT, hover on the square below.
This test passes if there are two green squares.
-->
<div class="hitregion"></div>
</body>
</html>
layer at (0,0) size 800x600
RenderView at (0,0) size 800x600
layer at (0,0) size 800x116
RenderBlock {HTML} at (0,0) size 800x116
RenderBody {BODY} at (8,8) size 784x100
RenderBlock {DIV} at (0,0) size 100x100 [bgcolor=#008000]
layer at (148,18) size 80x80
RenderBlock (positioned) at (148,18) size 80x80 [color=#008000] [border: (40px solid #008000)]
RenderText at (0,0) size 0x0
caret: position 0 of child 3 {DIV} of body
2013-09-29 Philip Rogers <pdr@google.com>
Repaint borders and outlines on pseudo content changes
https://bugs.webkit.org/show_bug.cgi?id=122070
Reviewed by Andreas Kling.
This patch fixes a regression from wkrev.com/150259 where pseudo content with
borders or outlines would fail to repaint if the color property changed.
The root bug is that border-color and outline-color properties use 'color' if
no explicit border-color or outline-color are given, and changing color should
repaint borders and outlines even if the text content is empty.
Relevant spec sections:
border: http://www.w3.org/TR/CSS1/#border-color
outline: http://www.w3.org/TR/CSS2/ui.html#propdef-outline-color
This patch also renames StyleDifferenceRepaintIfText to
StyleDifferenceRepaintIfTextOrBorderOrOutline and updates the relevant functions.
Test: fast/repaint/hover-pseudo-borders.html
* rendering/RenderElement.cpp:
(WebCore::RenderElement::hasImmediateNonWhitespaceTextChildOrBorderOrOutline):
This function has been renamed to reflect that it returns true for borders
or outlines as well.
(WebCore::RenderElement::shouldRepaintForStyleDifference):
* rendering/RenderElement.h:
* rendering/style/RenderStyle.cpp:
(WebCore::RenderStyle::changeRequiresRepaintIfTextOrBorderOrOutline):
(WebCore::RenderStyle::diff):
* rendering/style/RenderStyle.h:
* rendering/style/RenderStyleConstants.h:
* rendering/svg/SVGResourcesCache.cpp:
(WebCore::SVGResourcesCache::clientStyleChanged):
These have also been renamed to reflect the new borders and outlines check.
2013-09-29 Antti Koivisto <antti@apple.com>
Tighten typing in inline rendering
......@@ -284,18 +284,20 @@ StyleDifference RenderElement::adjustStyleDifference(StyleDifference diff, unsig
return diff;
}
inline bool RenderElement::hasImmediateNonWhitespaceTextChild() const
inline bool RenderElement::hasImmediateNonWhitespaceTextChildOrBorderOrOutline() const
{
for (const RenderObject* renderer = firstChild(); renderer; renderer = renderer->nextSibling()) {
if (renderer->isText() && !toRenderText(renderer)->isAllCollapsibleWhitespace())
return true;
if (renderer->style()->hasOutline() || renderer->style()->hasBorder())
return true;
}
return false;
}
inline bool RenderElement::shouldRepaintForStyleDifference(StyleDifference diff) const
{
return diff == StyleDifferenceRepaint || (diff == StyleDifferenceRepaintIfText && hasImmediateNonWhitespaceTextChild());
return diff == StyleDifferenceRepaint || (diff == StyleDifferenceRepaintIfTextOrBorderOrOutline && hasImmediateNonWhitespaceTextChildOrBorderOrOutline());
}
void RenderElement::updateFillImages(const FillLayer* oldLayers, const FillLayer* newLayers)
......
......@@ -113,7 +113,7 @@ private:
virtual RenderObject* lastChildSlow() const OVERRIDE FINAL { return lastChild(); }
bool shouldRepaintForStyleDifference(StyleDifference) const;
bool hasImmediateNonWhitespaceTextChild() const;
bool hasImmediateNonWhitespaceTextChildOrBorderOrOutline() const;
void updateFillImages(const FillLayer*, const FillLayer*);
void updateImage(StyleImage*, StyleImage*);
......
......@@ -792,7 +792,7 @@ bool RenderStyle::changeRequiresRepaint(const RenderStyle* other, unsigned&) con
return false;
}
bool RenderStyle::changeRequiresRepaintIfText(const RenderStyle* other, unsigned&) const
bool RenderStyle::changeRequiresRepaintIfTextOrBorderOrOutline(const RenderStyle* other, unsigned&) const
{
if (inherited->color != other->inherited->color
|| inherited_flags._text_decorations != other->inherited_flags._text_decorations
......@@ -864,8 +864,8 @@ StyleDifference RenderStyle::diff(const RenderStyle* other, unsigned& changedCon
return StyleDifferenceRecompositeLayer;
#endif
if (changeRequiresRepaintIfText(other, changedContextSensitiveProperties))
return StyleDifferenceRepaintIfText;
if (changeRequiresRepaintIfTextOrBorderOrOutline(other, changedContextSensitiveProperties))
return StyleDifferenceRepaintIfTextOrBorderOrOutline;
// Cursors are not checked, since they will be set appropriately in response to mouse events,
// so they don't need to cause any repaint or layout.
......
......@@ -1812,7 +1812,7 @@ private:
bool changeRequiresPositionedLayoutOnly(const RenderStyle*, unsigned& changedContextSensitiveProperties) const;
bool changeRequiresLayerRepaint(const RenderStyle*, unsigned& changedContextSensitiveProperties) const;
bool changeRequiresRepaint(const RenderStyle*, unsigned& changedContextSensitiveProperties) const;
bool changeRequiresRepaintIfText(const RenderStyle*, unsigned& changedContextSensitiveProperties) const;
bool changeRequiresRepaintIfTextOrBorderOrOutline(const RenderStyle*, unsigned& changedContextSensitiveProperties) const;
bool changeRequiresRecompositeLayer(const RenderStyle*, unsigned& changedContextSensitiveProperties) const;
void setVisitedLinkColor(const Color&);
......
......@@ -38,7 +38,7 @@ enum PrintColorAdjust {
// - StyleDifferenceEqual - The two styles are identical
// - StyleDifferenceRecompositeLayer - The layer needs its position and transform updated, but no repaint
// - StyleDifferenceRepaint - The object just needs to be repainted.
// - StyleDifferenceRepaintIfText - The object needs to be repainted if it contains text.
// - StyleDifferenceRepaintIfTextOrBorderOrOutline - The object needs to be repainted if it contains text or a border or outline.
// - StyleDifferenceRepaintLayer - The layer and its descendant layers needs to be repainted.
// - StyleDifferenceLayoutPositionedMovementOnly - Only the position of this positioned object has been updated
// - StyleDifferenceSimplifiedLayout - Only overflow needs to be recomputed
......@@ -50,7 +50,7 @@ enum StyleDifference {
StyleDifferenceRecompositeLayer,
#endif
StyleDifferenceRepaint,
StyleDifferenceRepaintIfText,
StyleDifferenceRepaintIfTextOrBorderOrOutline,
StyleDifferenceRepaintLayer,
StyleDifferenceLayoutPositionedMovementOnly,
StyleDifferenceSimplifiedLayout,
......
......@@ -126,7 +126,7 @@ void SVGResourcesCache::clientStyleChanged(RenderObject* renderer, StyleDifferen
return;
// In this case the proper SVGFE*Element will decide whether the modified CSS properties require a relayout or repaint.
if (renderer->isSVGResourceFilterPrimitive() && (diff == StyleDifferenceRepaint || diff == StyleDifferenceRepaintIfText))
if (renderer->isSVGResourceFilterPrimitive() && (diff == StyleDifferenceRepaint || diff == StyleDifferenceRepaintIfTextOrBorderOrOutline))
return;
// Dynamic changes of CSS properties like 'clip-path' may require us to recompute the associated resources for a renderer.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment