Skip to content

Commit

Permalink
Merge r222168 - Always update display: contents styles in RenderTreeU…
Browse files Browse the repository at this point in the history
…pdater.

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

Patch by Emilio Cobos Álvarez <emilio@crisal.io> on 2017-09-18
Reviewed by Antti Koivisto.

Source/WebCore:

Otherwise we keep an old style around, making following style updates wrong.

Test: fast/css/display-contents-style-update.html

* style/RenderTreeUpdater.cpp:
(WebCore::RenderTreeUpdater::updateElementRenderer):

LayoutTests:

* fast/css/display-contents-style-update-expected.html: Added.
* fast/css/display-contents-style-update.html: Added.
  • Loading branch information
emilio authored and carlosgcampos committed Oct 16, 2017
1 parent d429380 commit 736a33d
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 7 deletions.
10 changes: 10 additions & 0 deletions LayoutTests/ChangeLog
@@ -1,3 +1,13 @@
2017-09-18 Emilio Cobos Álvarez <emilio@crisal.io>

Always update display: contents styles in RenderTreeUpdater.
https://bugs.webkit.org/show_bug.cgi?id=177065

Reviewed by Antti Koivisto.

* fast/css/display-contents-style-update-expected.html: Added.
* fast/css/display-contents-style-update.html: Added.

2017-09-18 Antti Koivisto <antti@apple.com>

Avoid style resolution when clearing focused element.
Expand Down
@@ -1,3 +1,2 @@
Pass.
WebKit didn't Crash.

@@ -0,0 +1,4 @@
<!doctype html>
<div style="color: green;">
Passes if the text is green and there's no border.
</div>
15 changes: 15 additions & 0 deletions LayoutTests/fast/css/display-contents-style-update.html
@@ -0,0 +1,15 @@
<!doctype html>
<div id="contents" style="display: contents; color: green; border: 10px solid red;">
<div>
Passes if the text is green and there's no border.
</div>
</div>
<script>
document.body.offsetTop;

let contents = document.getElementById("contents");

contents.style.color = "red";
document.body.offsetTop;
contents.style.color = "green";
</script>
14 changes: 14 additions & 0 deletions Source/WebCore/ChangeLog
@@ -1,3 +1,17 @@
2017-09-18 Emilio Cobos Álvarez <emilio@crisal.io>

Always update display: contents styles in RenderTreeUpdater.
https://bugs.webkit.org/show_bug.cgi?id=177065

Reviewed by Antti Koivisto.

Otherwise we keep an old style around, making following style updates wrong.

Test: fast/css/display-contents-style-update.html

* style/RenderTreeUpdater.cpp:
(WebCore::RenderTreeUpdater::updateElementRenderer):

2017-09-18 Antti Koivisto <antti@apple.com>

Avoid style resolution when clearing focused element.
Expand Down
10 changes: 4 additions & 6 deletions Source/WebCore/style/RenderTreeUpdater.cpp
Expand Up @@ -306,12 +306,10 @@ void RenderTreeUpdater::updateElementRenderer(Element& element, const Style::Ele
}

bool hasDisplayContents = update.style->display() == CONTENTS;
if (hasDisplayContents != element.hasDisplayContents()) {
if (!hasDisplayContents)
element.resetComputedStyle();
else
element.storeDisplayContentsStyle(RenderStyle::clonePtr(*update.style));
}
if (hasDisplayContents)
element.storeDisplayContentsStyle(RenderStyle::clonePtr(*update.style));
else
element.resetComputedStyle();

bool shouldCreateNewRenderer = !element.renderer() && !hasDisplayContents;
if (shouldCreateNewRenderer) {
Expand Down

0 comments on commit 736a33d

Please sign in to comment.