forked from WebKit/WebKit-http
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
https://bugs.webkit.org/show_bug.cgi?id=94740 Patch by Sukolsak Sakshuwong <sukolsak@gmail.com> on 2012-08-28 Reviewed by Ryosuke Niwa. Source/WebCore: This bug happened when we selected "1<progress><a style>2</a></progress>" and executed a create link command because 1. The selection ended at <progress>, not the text node inside it, because <progress> is an atomic node. 2. We called removeInlineStyle() to remove conflicting styles. Since the selection started at the text node "1" and ended at <progress>, we did not get to remove <a>. 3. We called fixRangeAndApplyInlineStyle(), which in turn called applyInlineStyleToNodeRange(). This method split the node range into smaller runs. In this case, the run was the whole "1<progress><a style>2</a></progress>". 4. We called removeStyleFromRunBeforeApplyingStyle(). This method tried to remove <a> by calling removeInlineStyleFromElement() on <a> with extractedStyle = 0. But the method expected that extractedStyle was not null. So, it crashed. This bug doesn't happen with non-atomic nodes because if <a> is inside a non-atomic node, <a> will be covered by the selection. Therefore, it will be removed in step #2 and we will never call removeInlineStyleFromElement() on <a> again. Thus, the assertion that extractedStyle is not null is reasonable. Hence, this patch fixes this bug by skipping over atomic nodes when we apply style. Test: editing/style/apply-style-atomic.html * editing/ApplyStyleCommand.cpp: (WebCore::ApplyStyleCommand::removeStyleFromRunBeforeApplyingStyle): (WebCore::ApplyStyleCommand::removeInlineStyle): LayoutTests: * editing/style/apply-style-atomic-expected.txt: Added. * editing/style/apply-style-atomic.html: Added. git-svn-id: http://svn.webkit.org/repository/webkit/trunk@126865 268f45cc-cd09-0410-ab3c-d52691b4dbfc
- Loading branch information
1 parent
c09e79f
commit d5720d8
Showing
5 changed files
with
98 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
Test that WebKit does not crash when we apply style to atomic elements and that the style is not applied inside atomic elements. | ||
| <a> | ||
| href="a" | ||
| "<#selection-anchor>1" | ||
| <progress> | ||
| <a> | ||
| style="" | ||
| "2" | ||
| <shadow:root> | ||
| <div> | ||
| shadow:pseudoId="-webkit-progress-inner-element" | ||
| <div> | ||
| shadow:pseudoId="-webkit-progress-bar" | ||
| <div> | ||
| style="width: -100%;" | ||
| shadow:pseudoId="-webkit-progress-value" | ||
| <#selection-focus> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<script src="../../resources/dump-as-markup.js"></script> | ||
</head> | ||
<body> | ||
<div id="edit" contentEditable="true">1<progress><a style>2</a></progress></div> | ||
<script> | ||
Markup.description('Test that WebKit does not crash when we apply style to atomic elements ' + | ||
'and that the style is not applied inside atomic elements.') | ||
|
||
function select(node) { | ||
var range = document.createRange(); | ||
range.selectNodeContents(node); | ||
window.getSelection().addRange(range); | ||
} | ||
|
||
var edit = document.getElementById("edit"); | ||
select(edit); | ||
document.execCommand("createlink", false, "a"); | ||
Markup.dump(edit); | ||
</script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters