2011-04-28 Chang Shu <cshu@webkit.org>
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 29 Apr 2011 00:10:34 +0000 (00:10 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 29 Apr 2011 00:10:34 +0000 (00:10 +0000)
        Reviewed by Eric Seidel.

        isContentEditable is not working properly with document.designMode
        https://bugs.webkit.org/show_bug.cgi?id=53031

        1. Added test cases for checking isContentEditable with designMode.
        2. Added a new test case for setting contenteditable attribute to "inherit" as the
        original code will cause a crash.
        3. Ryosuke Niwa also helped to fix test cases under editing/style that cause infinite loop.

        * editing/style/iframe-onload-crash-mac.html:
        * editing/style/iframe-onload-crash-unix.html:
        * editing/style/iframe-onload-crash-win.html:
        * fast/dom/HTMLElement/attr-invalid-string-expected.txt:
        * fast/dom/HTMLElement/attr-invalid-string.html:
        * fast/dom/HTMLElement/iscontenteditable-designmodeon-allinherit-expected.txt: Added.
        * fast/dom/HTMLElement/iscontenteditable-designmodeon-allinherit-subframe-expected.txt: Added.
        * fast/dom/HTMLElement/iscontenteditable-designmodeon-allinherit-subframe.html: Added.
        * fast/dom/HTMLElement/iscontenteditable-designmodeon-allinherit.html: Added.
        * fast/dom/HTMLElement/iscontenteditable-designmodeon-ancestor-expected.txt: Added.
        * fast/dom/HTMLElement/iscontenteditable-designmodeon-ancestor.html: Added.
        * fast/dom/HTMLElement/iscontenteditable-designmodeon-expected.txt: Added.
        * fast/dom/HTMLElement/iscontenteditable-designmodeon.html: Added.
2011-04-28  Chang Shu  <cshu@webkit.org>

        Reviewed by Eric Seidel.

        isContentEditable is not working properly with document.designMode
        https://bugs.webkit.org/show_bug.cgi?id=53031

        The specification (http://dev.w3.org/html5/spec/Overview.html#attr-contenteditable)
        indicates that the element.isContentEditable relies on document.designMode if its
        and its ancestors' contenteditable attributes are set to inherit.

        1. Sync document render style after document.designMode is changed.
        2. Removed the code that does unnecessary and incorrect handling for contenteditable
        attribute with "inherit" value.
        3. Ryosuke Niwa also helped to fix the code in ApplyStyleCommand that causes an assertion.

        Tests: fast/dom/HTMLElement/iscontenteditable-designmodeon-allinherit-subframe.html
               fast/dom/HTMLElement/iscontenteditable-designmodeon-allinherit.html
               fast/dom/HTMLElement/iscontenteditable-designmodeon-ancestor.html
               fast/dom/HTMLElement/iscontenteditable-designmodeon.html

        * css/CSSStyleSelector.cpp:
        (WebCore::CSSStyleSelector::styleForDocument):
        * dom/Document.cpp:
        (WebCore::Document::setDesignMode):
        * dom/Node.cpp:
        (WebCore::Node::rendererIsEditable):
        * editing/ApplyStyleCommand.cpp:
        (WebCore::ApplyStyleCommand::surroundNodeRangeWithElement):
        * html/HTMLElement.cpp:
        (WebCore::HTMLElement::setContentEditable):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@85267 268f45cc-cd09-0410-ab3c-d52691b4dbfc

20 files changed:
LayoutTests/ChangeLog
LayoutTests/editing/style/iframe-onload-crash-mac.html
LayoutTests/editing/style/iframe-onload-crash-unix.html
LayoutTests/editing/style/iframe-onload-crash-win.html
LayoutTests/fast/dom/HTMLElement/attr-invalid-string-expected.txt
LayoutTests/fast/dom/HTMLElement/attr-invalid-string.html
LayoutTests/fast/dom/HTMLElement/iscontenteditable-designmodeon-allinherit-expected.txt [new file with mode: 0644]
LayoutTests/fast/dom/HTMLElement/iscontenteditable-designmodeon-allinherit-subframe-expected.txt [new file with mode: 0644]
LayoutTests/fast/dom/HTMLElement/iscontenteditable-designmodeon-allinherit-subframe.html [new file with mode: 0644]
LayoutTests/fast/dom/HTMLElement/iscontenteditable-designmodeon-allinherit.html [new file with mode: 0644]
LayoutTests/fast/dom/HTMLElement/iscontenteditable-designmodeon-ancestor-expected.txt [new file with mode: 0644]
LayoutTests/fast/dom/HTMLElement/iscontenteditable-designmodeon-ancestor.html [new file with mode: 0644]
LayoutTests/fast/dom/HTMLElement/iscontenteditable-designmodeon-expected.txt [new file with mode: 0644]
LayoutTests/fast/dom/HTMLElement/iscontenteditable-designmodeon.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/css/CSSStyleSelector.cpp
Source/WebCore/dom/Document.cpp
Source/WebCore/dom/Node.cpp
Source/WebCore/editing/ApplyStyleCommand.cpp
Source/WebCore/html/HTMLElement.cpp

index 261fbc7..7f24d2e 100644 (file)
@@ -1,3 +1,29 @@
+2011-04-28  Chang Shu  <cshu@webkit.org>
+
+        Reviewed by Eric Seidel.
+
+        isContentEditable is not working properly with document.designMode
+        https://bugs.webkit.org/show_bug.cgi?id=53031
+
+        1. Added test cases for checking isContentEditable with designMode.
+        2. Added a new test case for setting contenteditable attribute to "inherit" as the
+        original code will cause a crash.
+        3. Ryosuke Niwa also helped to fix test cases under editing/style that cause infinite loop.
+
+        * editing/style/iframe-onload-crash-mac.html:
+        * editing/style/iframe-onload-crash-unix.html:
+        * editing/style/iframe-onload-crash-win.html:
+        * fast/dom/HTMLElement/attr-invalid-string-expected.txt:
+        * fast/dom/HTMLElement/attr-invalid-string.html:
+        * fast/dom/HTMLElement/iscontenteditable-designmodeon-allinherit-expected.txt: Added.
+        * fast/dom/HTMLElement/iscontenteditable-designmodeon-allinherit-subframe-expected.txt: Added.
+        * fast/dom/HTMLElement/iscontenteditable-designmodeon-allinherit-subframe.html: Added.
+        * fast/dom/HTMLElement/iscontenteditable-designmodeon-allinherit.html: Added.
+        * fast/dom/HTMLElement/iscontenteditable-designmodeon-ancestor-expected.txt: Added.
+        * fast/dom/HTMLElement/iscontenteditable-designmodeon-ancestor.html: Added.
+        * fast/dom/HTMLElement/iscontenteditable-designmodeon-expected.txt: Added.
+        * fast/dom/HTMLElement/iscontenteditable-designmodeon.html: Added.
+
 2011-04-28  Mike Reed  <reed@google.com>
 
         Reviewed by Eric Seidel.
index dc0355e..79dafef 100644 (file)
@@ -4,9 +4,16 @@ if (window.layoutTestController) {
     layoutTestController.setEditingBehavior('mac');
 }
 
-document.designMode='on';
-document.execCommand('selectall');
-document.execCommand('italic');
-document.execCommand('RemoveFormat');
-document.execCommand('inserthtml', false);
-document.body.innerHTML='PASS';">x
+if (document.counter)
+    document.counter++;
+else
+    document.counter = 1;
+
+if (document.counter <= 16) {
+    document.designMode='on';
+    document.execCommand('selectall');
+    document.execCommand('italic');
+    document.execCommand('RemoveFormat');
+    document.execCommand('inserthtml', false);
+    document.body.innerHTML='PASS';
+} ">x
index e7db22d..a3f8ba2 100644 (file)
@@ -4,9 +4,16 @@ if (window.layoutTestController) {
     layoutTestController.setEditingBehavior('unix');
 }
 
-document.designMode='on';
-document.execCommand('selectall');
-document.execCommand('italic');
-document.execCommand('RemoveFormat');
-document.execCommand('inserthtml', false);
-document.body.innerHTML='PASS';">x
+if (document.counter)
+    document.counter++;
+else
+    document.counter = 1;
+
+if (document.counter <= 16) {
+    document.designMode='on';
+    document.execCommand('selectall');
+    document.execCommand('italic');
+    document.execCommand('RemoveFormat');
+    document.execCommand('inserthtml', false);
+    document.body.innerHTML='PASS';
+} ">x
index bafd7e1..567366b 100644 (file)
@@ -4,9 +4,16 @@ if (window.layoutTestController) {
     layoutTestController.setEditingBehavior('win');
 }
 
-document.designMode='on';
-document.execCommand('selectall');
-document.execCommand('italic');
-document.execCommand('RemoveFormat');
-document.execCommand('inserthtml', false);
-document.body.innerHTML='PASS';">x
+if (document.counter)
+    document.counter++;
+else
+    document.counter = 1;
+
+if (document.counter <= 16) {
+    document.designMode='on';
+    document.execCommand('selectall');
+    document.execCommand('italic');
+    document.execCommand('RemoveFormat');
+    document.execCommand('inserthtml', false);
+    document.body.innerHTML='PASS';
+} ">x
index ef3e0dd..96b9c70 100644 (file)
@@ -6,10 +6,15 @@ On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE
 
 
 
-PASS document.getElementById("div").getAttribute("contentEditable") is "abc"
-PASS document.getElementById("div").contentEditable is "inherit"
-PASS document.getElementById("div").isContentEditable is false
-PASS window.getComputedStyle(div, "").getPropertyValue("-webkit-user-modify") is "read-only"
+
+PASS document.getElementById("d").getAttribute("contentEditable") is "abc"
+PASS document.getElementById("d").contentEditable is "inherit"
+PASS document.getElementById("d").isContentEditable is false
+PASS window.getComputedStyle(d, "").getPropertyValue("-webkit-user-modify") is "read-only"
+PASS document.getElementById("d2").getAttribute("contentEditable") is "inherit"
+PASS document.getElementById("d2").contentEditable is "inherit"
+PASS document.getElementById("d2").isContentEditable is false
+PASS window.getComputedStyle(d2, "").getPropertyValue("-webkit-user-modify") is "read-only"
 
 PASS successfullyParsed is true
 
index 9bf0793..47eb6f2 100644 (file)
@@ -8,16 +8,23 @@
 <p id="description"></p>
 <div id="console"></p>
 <div id="result"></div>
-<div id="div" contentEditable="abc"></div>
+<div id="d" contentEditable="abc"></div>
+<div id="d2" contentEditable="inherit"></div>
 <script>
 description('When contentEditable attribute is invalid string, element.contentEditable returns "inherit".')
 
-shouldBe('document.getElementById("div").getAttribute("contentEditable")','"abc"');
-shouldBe('document.getElementById("div").contentEditable', '"inherit"');
-shouldBe('document.getElementById("div").isContentEditable', 'false');
-shouldBe('window.getComputedStyle(div, "").getPropertyValue("-webkit-user-modify")', '"read-only"');
+shouldBe('document.getElementById("d").getAttribute("contentEditable")','"abc"');
+shouldBe('document.getElementById("d").contentEditable', '"inherit"');
+shouldBe('document.getElementById("d").isContentEditable', 'false');
+shouldBe('window.getComputedStyle(d, "").getPropertyValue("-webkit-user-modify")', '"read-only"');
 
-document.getElementById("div").style.display= 'none';
+shouldBe('document.getElementById("d2").getAttribute("contentEditable")','"inherit"');
+shouldBe('document.getElementById("d2").contentEditable', '"inherit"');
+shouldBe('document.getElementById("d2").isContentEditable', 'false');
+shouldBe('window.getComputedStyle(d2, "").getPropertyValue("-webkit-user-modify")', '"read-only"');
+
+document.getElementById("d").style.display= 'none';
+document.getElementById("d2").style.display= 'none';
 
 window.successfullyParsed = true;
 </script>
diff --git a/LayoutTests/fast/dom/HTMLElement/iscontenteditable-designmodeon-allinherit-expected.txt b/LayoutTests/fast/dom/HTMLElement/iscontenteditable-designmodeon-allinherit-expected.txt
new file mode 100644 (file)
index 0000000..36aea43
--- /dev/null
@@ -0,0 +1,24 @@
+Content should be editable if its and its ancestor's contentEditable not set, and document.designMode is enabled.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+
+
+
+
+document.designMode = "on"
+PASS document.getElementById("div").contentEditable is "inherit"
+PASS document.getElementById("div").isContentEditable is true
+PASS window.getComputedStyle(div, "").getPropertyValue("-webkit-user-modify") is "read-write"
+PASS document.getElementById("p").contentEditable is "inherit"
+PASS document.getElementById("p").isContentEditable is true
+PASS window.getComputedStyle(p, "").getPropertyValue("-webkit-user-modify") is "read-write"
+
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
+
+
+
diff --git a/LayoutTests/fast/dom/HTMLElement/iscontenteditable-designmodeon-allinherit-subframe-expected.txt b/LayoutTests/fast/dom/HTMLElement/iscontenteditable-designmodeon-allinherit-subframe-expected.txt
new file mode 100644 (file)
index 0000000..b102404
--- /dev/null
@@ -0,0 +1,19 @@
+document.designMode inherits from parent documents.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+
+
+
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
+
+
+
+document.designMode = "on"
+PASS subDocument.getElementById("div").contentEditable is "inherit"
+PASS subDocument.getElementById("div").isContentEditable is true
+
diff --git a/LayoutTests/fast/dom/HTMLElement/iscontenteditable-designmodeon-allinherit-subframe.html b/LayoutTests/fast/dom/HTMLElement/iscontenteditable-designmodeon-allinherit-subframe.html
new file mode 100644 (file)
index 0000000..f51ba73
--- /dev/null
@@ -0,0 +1,30 @@
+<!DOCTYPE html>
+<html>
+<head>
+<link rel="stylesheet" href="../../js/resources/js-test-style.css">
+<script src="../../js/resources/js-test-pre.js"></script>
+</head>
+<body>
+<p id="description"></p>
+<div id="console"></p>
+<div id="result"></div>
+<script>
+description('document.designMode inherits from parent documents.')
+
+function runTest()
+{
+    evalAndLog('document.designMode = "on"');
+
+    subDocument = document.getElementById("subframe").contentDocument;
+    shouldBe('subDocument.getElementById("div").contentEditable', '"inherit"');
+    shouldBe('subDocument.getElementById("div").isContentEditable', 'true');
+
+    document.getElementById("subframe").style.display= 'none';
+}
+
+window.successfullyParsed = true;
+</script>
+<script src="../../js/resources/js-test-post.js"></script>
+<iframe id="subframe" onload="runTest()" src="data:text/html,<div id='div'></div>"></iframe>
+</body>
+</html>
diff --git a/LayoutTests/fast/dom/HTMLElement/iscontenteditable-designmodeon-allinherit.html b/LayoutTests/fast/dom/HTMLElement/iscontenteditable-designmodeon-allinherit.html
new file mode 100644 (file)
index 0000000..b7ce582
--- /dev/null
@@ -0,0 +1,37 @@
+<!DOCTYPE html>
+<html>
+<head>
+<link rel="stylesheet" href="../../js/resources/js-test-style.css">
+<script src="../../js/resources/js-test-pre.js"></script>
+</head>
+<body>
+<p id="description"></p>
+<div id="console"></p>
+<div id="result"></div>
+<div id="parent_of_div">
+    <div id="div"></div>
+</div>
+<div id="parent_of_p">
+    <p id="p"></p>
+</div>
+<script>
+description('Content should be editable if its and its ancestor\'s contentEditable not set, and document.designMode is enabled.')
+
+evalAndLog('document.designMode = "on"');
+
+shouldBe('document.getElementById("div").contentEditable', '"inherit"');
+shouldBe('document.getElementById("div").isContentEditable', 'true');
+shouldBe('window.getComputedStyle(div, "").getPropertyValue("-webkit-user-modify")', '"read-write"');
+
+shouldBe('document.getElementById("p").contentEditable', '"inherit"');
+shouldBe('document.getElementById("p").isContentEditable', 'true');
+shouldBe('window.getComputedStyle(p, "").getPropertyValue("-webkit-user-modify")', '"read-write"');
+
+document.getElementById("parent_of_div").style.display= 'none';
+document.getElementById("parent_of_p").style.display= 'none';
+
+window.successfullyParsed = true;
+</script>
+<script src="../../js/resources/js-test-post.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/fast/dom/HTMLElement/iscontenteditable-designmodeon-ancestor-expected.txt b/LayoutTests/fast/dom/HTMLElement/iscontenteditable-designmodeon-ancestor-expected.txt
new file mode 100644 (file)
index 0000000..b722e8c
--- /dev/null
@@ -0,0 +1,32 @@
+isContentEditable should not change if its ancestor's contentEditable is set, no matter whether document.designMode is enabled or not.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+
+
+
+
+
+
+document.designMode = "on"
+PASS document.getElementById("div").contentEditable is "inherit"
+PASS document.getElementById("div").isContentEditable is false
+PASS window.getComputedStyle(div, "").getPropertyValue("-webkit-user-modify") is "read-only"
+PASS document.getElementById("div2").contentEditable is "inherit"
+PASS document.getElementById("div2").isContentEditable is false
+PASS window.getComputedStyle(div2, "").getPropertyValue("-webkit-user-modify") is "read-only"
+PASS document.getElementById("p").contentEditable is "inherit"
+PASS document.getElementById("p").isContentEditable is true
+PASS window.getComputedStyle(p, "").getPropertyValue("-webkit-user-modify") is "read-write"
+PASS document.getElementById("p2").contentEditable is "inherit"
+PASS document.getElementById("p2").isContentEditable is true
+PASS window.getComputedStyle(p2, "").getPropertyValue("-webkit-user-modify") is "read-write"
+
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
+
+
+
diff --git a/LayoutTests/fast/dom/HTMLElement/iscontenteditable-designmodeon-ancestor.html b/LayoutTests/fast/dom/HTMLElement/iscontenteditable-designmodeon-ancestor.html
new file mode 100644 (file)
index 0000000..055d14f
--- /dev/null
@@ -0,0 +1,56 @@
+<!DOCTYPE html>
+<html>
+<head>
+<link rel="stylesheet" href="../../js/resources/js-test-style.css">
+<script src="../../js/resources/js-test-pre.js"></script>
+</head>
+<body>
+<p id="description"></p>
+<div id="console"></p>
+<div id="result"></div>
+<div id="parent_of_div" contentEditable="false">
+    <div id="div"></div>
+</div>
+<div id="parent_of_div2">
+    <div id="div2"></div>
+</div>
+<div id="parent_of_p" contentEditable="true">
+    <p id="p"></p>
+</div>
+<div id="parent_of_p2">
+    <p id="p2"></p>
+</div>
+<script>
+description('isContentEditable should not change if its ancestor\'s contentEditable is set, no matter whether document.designMode is enabled or not.')
+
+document.getElementById("parent_of_div2").contentEditable = false;
+document.getElementById("parent_of_p2").contentEditable = true;
+
+evalAndLog('document.designMode = "on"');
+
+shouldBe('document.getElementById("div").contentEditable', '"inherit"');
+shouldBe('document.getElementById("div").isContentEditable', 'false');
+shouldBe('window.getComputedStyle(div, "").getPropertyValue("-webkit-user-modify")', '"read-only"');
+
+shouldBe('document.getElementById("div2").contentEditable', '"inherit"');
+shouldBe('document.getElementById("div2").isContentEditable', 'false');
+shouldBe('window.getComputedStyle(div2, "").getPropertyValue("-webkit-user-modify")', '"read-only"');
+
+shouldBe('document.getElementById("p").contentEditable', '"inherit"');
+shouldBe('document.getElementById("p").isContentEditable', 'true');
+shouldBe('window.getComputedStyle(p, "").getPropertyValue("-webkit-user-modify")', '"read-write"');
+
+shouldBe('document.getElementById("p2").contentEditable', '"inherit"');
+shouldBe('document.getElementById("p2").isContentEditable', 'true');
+shouldBe('window.getComputedStyle(p2, "").getPropertyValue("-webkit-user-modify")', '"read-write"');
+
+document.getElementById("parent_of_div").style.display= 'none';
+document.getElementById("parent_of_div2").style.display= 'none';
+document.getElementById("parent_of_p").style.display= 'none';
+document.getElementById("parent_of_p2").style.display= 'none';
+
+window.successfullyParsed = true;
+</script>
+<script src="../../js/resources/js-test-post.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/fast/dom/HTMLElement/iscontenteditable-designmodeon-expected.txt b/LayoutTests/fast/dom/HTMLElement/iscontenteditable-designmodeon-expected.txt
new file mode 100644 (file)
index 0000000..e04921c
--- /dev/null
@@ -0,0 +1,36 @@
+isContentEditable should not change if its contentEditable is set, no matter whether document.designMode is enabled or not.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+
+
+
+
+
+
+document.designMode = "on"
+PASS document.getElementById("div").getAttribute("contentEditable") is "false"
+PASS document.getElementById("div").contentEditable is "false"
+PASS document.getElementById("div").isContentEditable is false
+PASS window.getComputedStyle(div, "").getPropertyValue("-webkit-user-modify") is "read-only"
+PASS document.getElementById("div2").getAttribute("contentEditable") is "false"
+PASS document.getElementById("div2").contentEditable is "false"
+PASS document.getElementById("div2").isContentEditable is false
+PASS window.getComputedStyle(div2, "").getPropertyValue("-webkit-user-modify") is "read-only"
+PASS document.getElementById("p").getAttribute("contentEditable") is "true"
+PASS document.getElementById("p").contentEditable is "true"
+PASS document.getElementById("p").isContentEditable is true
+PASS window.getComputedStyle(p, "").getPropertyValue("-webkit-user-modify") is "read-write"
+PASS document.getElementById("p2").getAttribute("contentEditable") is "true"
+PASS document.getElementById("p2").contentEditable is "true"
+PASS document.getElementById("p2").isContentEditable is true
+PASS window.getComputedStyle(p2, "").getPropertyValue("-webkit-user-modify") is "read-write"
+
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
+
+
+
diff --git a/LayoutTests/fast/dom/HTMLElement/iscontenteditable-designmodeon.html b/LayoutTests/fast/dom/HTMLElement/iscontenteditable-designmodeon.html
new file mode 100644 (file)
index 0000000..5c9dec5
--- /dev/null
@@ -0,0 +1,52 @@
+<!DOCTYPE html>
+<html>
+<head>
+<link rel="stylesheet" href="../../js/resources/js-test-style.css">
+<script src="../../js/resources/js-test-pre.js"></script>
+</head>
+<body>
+<p id="description"></p>
+<div id="console"></p>
+<div id="result"></div>
+<div id="div" contentEditable="false"></div>
+<div id="div2"></div>
+<p id="p" contentEditable="true"></p>
+<p id="p2"></p>
+<script>
+description('isContentEditable should not change if its contentEditable is set, no matter whether document.designMode is enabled or not.')
+
+document.getElementById("div2").contentEditable = false;
+document.getElementById("p2").contentEditable = true;
+
+evalAndLog('document.designMode = "on"');
+
+shouldBe('document.getElementById("div").getAttribute("contentEditable")','"false"');
+shouldBe('document.getElementById("div").contentEditable', '"false"');
+shouldBe('document.getElementById("div").isContentEditable', 'false');
+shouldBe('window.getComputedStyle(div, "").getPropertyValue("-webkit-user-modify")', '"read-only"');
+
+shouldBe('document.getElementById("div2").getAttribute("contentEditable")','"false"');
+shouldBe('document.getElementById("div2").contentEditable', '"false"');
+shouldBe('document.getElementById("div2").isContentEditable', 'false');
+shouldBe('window.getComputedStyle(div2, "").getPropertyValue("-webkit-user-modify")', '"read-only"');
+
+shouldBe('document.getElementById("p").getAttribute("contentEditable")','"true"');
+shouldBe('document.getElementById("p").contentEditable', '"true"');
+shouldBe('document.getElementById("p").isContentEditable', 'true');
+shouldBe('window.getComputedStyle(p, "").getPropertyValue("-webkit-user-modify")', '"read-write"');
+
+shouldBe('document.getElementById("p2").getAttribute("contentEditable")','"true"');
+shouldBe('document.getElementById("p2").contentEditable', '"true"');
+shouldBe('document.getElementById("p2").isContentEditable', 'true');
+shouldBe('window.getComputedStyle(p2, "").getPropertyValue("-webkit-user-modify")', '"read-write"');
+
+document.getElementById("div").style.display= 'none';
+document.getElementById("div2").style.display= 'none';
+document.getElementById("p").style.display= 'none';
+document.getElementById("p2").style.display= 'none';
+
+window.successfullyParsed = true;
+</script>
+<script src="../../js/resources/js-test-post.js"></script>
+</body>
+</html>
index 6d2d285..3725679 100644 (file)
@@ -1,3 +1,35 @@
+2011-04-28  Chang Shu  <cshu@webkit.org>
+
+        Reviewed by Eric Seidel.
+
+        isContentEditable is not working properly with document.designMode
+        https://bugs.webkit.org/show_bug.cgi?id=53031
+
+        The specification (http://dev.w3.org/html5/spec/Overview.html#attr-contenteditable)
+        indicates that the element.isContentEditable relies on document.designMode if its
+        and its ancestors' contenteditable attributes are set to inherit.
+
+        1. Sync document render style after document.designMode is changed.
+        2. Removed the code that does unnecessary and incorrect handling for contenteditable
+        attribute with "inherit" value.
+        3. Ryosuke Niwa also helped to fix the code in ApplyStyleCommand that causes an assertion.
+
+        Tests: fast/dom/HTMLElement/iscontenteditable-designmodeon-allinherit-subframe.html
+               fast/dom/HTMLElement/iscontenteditable-designmodeon-allinherit.html
+               fast/dom/HTMLElement/iscontenteditable-designmodeon-ancestor.html
+               fast/dom/HTMLElement/iscontenteditable-designmodeon.html
+
+        * css/CSSStyleSelector.cpp:
+        (WebCore::CSSStyleSelector::styleForDocument):
+        * dom/Document.cpp:
+        (WebCore::Document::setDesignMode):
+        * dom/Node.cpp:
+        (WebCore::Node::rendererIsEditable):
+        * editing/ApplyStyleCommand.cpp:
+        (WebCore::ApplyStyleCommand::surroundNodeRangeWithElement):
+        * html/HTMLElement.cpp:
+        (WebCore::HTMLElement::setContentEditable):
+
 2011-04-28  Sheriff Bot  <webkit.review.bot@gmail.com>
 
         Unreviewed, rolling out r85101.
index 7e7121f..6cbe166 100644 (file)
@@ -1219,7 +1219,8 @@ PassRefPtr<RenderStyle> CSSStyleSelector::styleForDocument(Document* document)
     documentStyle->setVisuallyOrdered(document->visuallyOrdered());
     documentStyle->setZoom(frame ? frame->pageZoomFactor() : 1);
     documentStyle->setPageScaleTransform(frame ? frame->pageScaleFactor() : 1);
-    
+    documentStyle->setUserModify(document->inDesignMode() ? READ_WRITE : READ_ONLY);
+
     Element* docElement = document->documentElement();
     RenderObject* docElementRenderer = docElement ? docElement->renderer() : 0;
     if (docElementRenderer) {
index f237d3d..f70d630 100644 (file)
@@ -4037,6 +4037,8 @@ void Document::setTransformSource(PassOwnPtr<TransformSource> source)
 void Document::setDesignMode(InheritedBool value)
 {
     m_designMode = value;
+    for (Frame* frame = m_frame; frame && frame->document(); frame = frame->tree()->traverseNext(m_frame))
+        frame->document()->scheduleForcedStyleRecalc();
 }
 
 Document::InheritedBool Document::getDesignMode() const
index 3a0733a..1407d7e 100644 (file)
@@ -763,7 +763,7 @@ bool Node::isContentEditable() const
 
 bool Node::rendererIsEditable(EditableLevel editableLevel) const
 {
-    if (document()->inDesignMode() || (document()->frame() && document()->frame()->page() && document()->frame()->page()->isEditable()))
+    if (document()->frame() && document()->frame()->page() && document()->frame()->page()->isEditable())
         return true;
 
     // Ideally we'd call ASSERT(!needsStyleRecalc()) here, but
index c9649d0..4f1bc93 100644 (file)
@@ -1316,8 +1316,10 @@ void ApplyStyleCommand::surroundNodeRangeWithElement(PassRefPtr<Node> passedStar
     RefPtr<Node> node = startNode;
     while (node) {
         RefPtr<Node> next = node->nextSibling();
-        removeNode(node);
-        appendNode(node, element);
+        if (node->isContentEditable()) {
+            removeNode(node);
+            appendNode(node, element);
+        }
         if (node == endNode)
             break;
         node = next;
index 854a825..8f1841b 100644 (file)
@@ -678,11 +678,6 @@ void HTMLElement::setContentEditable(Attribute* attr)
         attr->decl()->removeProperty(CSSPropertyWordWrap, false);
         attr->decl()->removeProperty(CSSPropertyWebkitNbspMode, false);
         attr->decl()->removeProperty(CSSPropertyWebkitLineBreak, false);
-    } else if (equalIgnoringCase(enabled, "inherit")) {
-        addCSSProperty(attr, CSSPropertyWebkitUserModify, CSSValueInherit);
-        attr->decl()->removeProperty(CSSPropertyWordWrap, false);
-        attr->decl()->removeProperty(CSSPropertyWebkitNbspMode, false);
-        attr->decl()->removeProperty(CSSPropertyWebkitLineBreak, false);
     } else if (equalIgnoringCase(enabled, "plaintext-only")) {
         addCSSProperty(attr, CSSPropertyWebkitUserModify, CSSValueReadWritePlaintextOnly);
         addCSSProperty(attr, CSSPropertyWordWrap, CSSValueBreakWord);