Changeset 85267 in webkit


Ignore:
Timestamp:
Apr 28, 2011 5:10:34 PM (13 years ago)
Author:
commit-queue@webkit.org
Message:

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 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):
Location:
trunk
Files:
8 added
12 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r85264 r85267  
     12011-04-28  Chang Shu  <cshu@webkit.org>
     2
     3        Reviewed by Eric Seidel.
     4
     5        isContentEditable is not working properly with document.designMode
     6        https://bugs.webkit.org/show_bug.cgi?id=53031
     7
     8        1. Added test cases for checking isContentEditable with designMode.
     9        2. Added a new test case for setting contenteditable attribute to "inherit" as the
     10        original code will cause a crash.
     11        3. Ryosuke Niwa also helped to fix test cases under editing/style that cause infinite loop.
     12
     13        * editing/style/iframe-onload-crash-mac.html:
     14        * editing/style/iframe-onload-crash-unix.html:
     15        * editing/style/iframe-onload-crash-win.html:
     16        * fast/dom/HTMLElement/attr-invalid-string-expected.txt:
     17        * fast/dom/HTMLElement/attr-invalid-string.html:
     18        * fast/dom/HTMLElement/iscontenteditable-designmodeon-allinherit-expected.txt: Added.
     19        * fast/dom/HTMLElement/iscontenteditable-designmodeon-allinherit-subframe-expected.txt: Added.
     20        * fast/dom/HTMLElement/iscontenteditable-designmodeon-allinherit-subframe.html: Added.
     21        * fast/dom/HTMLElement/iscontenteditable-designmodeon-allinherit.html: Added.
     22        * fast/dom/HTMLElement/iscontenteditable-designmodeon-ancestor-expected.txt: Added.
     23        * fast/dom/HTMLElement/iscontenteditable-designmodeon-ancestor.html: Added.
     24        * fast/dom/HTMLElement/iscontenteditable-designmodeon-expected.txt: Added.
     25        * fast/dom/HTMLElement/iscontenteditable-designmodeon.html: Added.
     26
    1272011-04-28  Mike Reed  <reed@google.com>
    228
  • trunk/LayoutTests/editing/style/iframe-onload-crash-mac.html

    r81266 r85267  
    55}
    66
    7 document.designMode='on';
    8 document.execCommand('selectall');
    9 document.execCommand('italic');
    10 document.execCommand('RemoveFormat');
    11 document.execCommand('inserthtml', false);
    12 document.body.innerHTML='PASS';">x
     7if (document.counter)
     8    document.counter++;
     9else
     10    document.counter = 1;
     11
     12if (document.counter <= 16) {
     13    document.designMode='on';
     14    document.execCommand('selectall');
     15    document.execCommand('italic');
     16    document.execCommand('RemoveFormat');
     17    document.execCommand('inserthtml', false);
     18    document.body.innerHTML='PASS';
     19} ">x
  • trunk/LayoutTests/editing/style/iframe-onload-crash-unix.html

    r81266 r85267  
    55}
    66
    7 document.designMode='on';
    8 document.execCommand('selectall');
    9 document.execCommand('italic');
    10 document.execCommand('RemoveFormat');
    11 document.execCommand('inserthtml', false);
    12 document.body.innerHTML='PASS';">x
     7if (document.counter)
     8    document.counter++;
     9else
     10    document.counter = 1;
     11
     12if (document.counter <= 16) {
     13    document.designMode='on';
     14    document.execCommand('selectall');
     15    document.execCommand('italic');
     16    document.execCommand('RemoveFormat');
     17    document.execCommand('inserthtml', false);
     18    document.body.innerHTML='PASS';
     19} ">x
  • trunk/LayoutTests/editing/style/iframe-onload-crash-win.html

    r81266 r85267  
    55}
    66
    7 document.designMode='on';
    8 document.execCommand('selectall');
    9 document.execCommand('italic');
    10 document.execCommand('RemoveFormat');
    11 document.execCommand('inserthtml', false);
    12 document.body.innerHTML='PASS';">x
     7if (document.counter)
     8    document.counter++;
     9else
     10    document.counter = 1;
     11
     12if (document.counter <= 16) {
     13    document.designMode='on';
     14    document.execCommand('selectall');
     15    document.execCommand('italic');
     16    document.execCommand('RemoveFormat');
     17    document.execCommand('inserthtml', false);
     18    document.body.innerHTML='PASS';
     19} ">x
  • trunk/LayoutTests/fast/dom/HTMLElement/attr-invalid-string-expected.txt

    r76528 r85267  
    77
    88
    9 PASS document.getElementById("div").getAttribute("contentEditable") is "abc"
    10 PASS document.getElementById("div").contentEditable is "inherit"
    11 PASS document.getElementById("div").isContentEditable is false
    12 PASS window.getComputedStyle(div, "").getPropertyValue("-webkit-user-modify") is "read-only"
     9
     10PASS document.getElementById("d").getAttribute("contentEditable") is "abc"
     11PASS document.getElementById("d").contentEditable is "inherit"
     12PASS document.getElementById("d").isContentEditable is false
     13PASS window.getComputedStyle(d, "").getPropertyValue("-webkit-user-modify") is "read-only"
     14PASS document.getElementById("d2").getAttribute("contentEditable") is "inherit"
     15PASS document.getElementById("d2").contentEditable is "inherit"
     16PASS document.getElementById("d2").isContentEditable is false
     17PASS window.getComputedStyle(d2, "").getPropertyValue("-webkit-user-modify") is "read-only"
    1318
    1419PASS successfullyParsed is true
  • trunk/LayoutTests/fast/dom/HTMLElement/attr-invalid-string.html

    r76528 r85267  
    99<div id="console"></p>
    1010<div id="result"></div>
    11 <div id="div" contentEditable="abc"></div>
     11<div id="d" contentEditable="abc"></div>
     12<div id="d2" contentEditable="inherit"></div>
    1213<script>
    1314description('When contentEditable attribute is invalid string, element.contentEditable returns "inherit".')
    1415
    15 shouldBe('document.getElementById("div").getAttribute("contentEditable")','"abc"');
    16 shouldBe('document.getElementById("div").contentEditable', '"inherit"');
    17 shouldBe('document.getElementById("div").isContentEditable', 'false');
    18 shouldBe('window.getComputedStyle(div, "").getPropertyValue("-webkit-user-modify")', '"read-only"');
     16shouldBe('document.getElementById("d").getAttribute("contentEditable")','"abc"');
     17shouldBe('document.getElementById("d").contentEditable', '"inherit"');
     18shouldBe('document.getElementById("d").isContentEditable', 'false');
     19shouldBe('window.getComputedStyle(d, "").getPropertyValue("-webkit-user-modify")', '"read-only"');
    1920
    20 document.getElementById("div").style.display= 'none';
     21shouldBe('document.getElementById("d2").getAttribute("contentEditable")','"inherit"');
     22shouldBe('document.getElementById("d2").contentEditable', '"inherit"');
     23shouldBe('document.getElementById("d2").isContentEditable', 'false');
     24shouldBe('window.getComputedStyle(d2, "").getPropertyValue("-webkit-user-modify")', '"read-only"');
     25
     26document.getElementById("d").style.display= 'none';
     27document.getElementById("d2").style.display= 'none';
    2128
    2229window.successfullyParsed = true;
  • trunk/Source/WebCore/ChangeLog

    r85266 r85267  
     12011-04-28  Chang Shu  <cshu@webkit.org>
     2
     3        Reviewed by Eric Seidel.
     4
     5        isContentEditable is not working properly with document.designMode
     6        https://bugs.webkit.org/show_bug.cgi?id=53031
     7
     8        The specification (http://dev.w3.org/html5/spec/Overview.html#attr-contenteditable)
     9        indicates that the element.isContentEditable relies on document.designMode if its
     10        and its ancestors' contenteditable attributes are set to inherit.
     11
     12        1. Sync document render style after document.designMode is changed.
     13        2. Removed the code that does unnecessary and incorrect handling for contenteditable
     14        attribute with "inherit" value.
     15        3. Ryosuke Niwa also helped to fix the code in ApplyStyleCommand that causes an assertion.
     16
     17        Tests: fast/dom/HTMLElement/iscontenteditable-designmodeon-allinherit-subframe.html
     18               fast/dom/HTMLElement/iscontenteditable-designmodeon-allinherit.html
     19               fast/dom/HTMLElement/iscontenteditable-designmodeon-ancestor.html
     20               fast/dom/HTMLElement/iscontenteditable-designmodeon.html
     21
     22        * css/CSSStyleSelector.cpp:
     23        (WebCore::CSSStyleSelector::styleForDocument):
     24        * dom/Document.cpp:
     25        (WebCore::Document::setDesignMode):
     26        * dom/Node.cpp:
     27        (WebCore::Node::rendererIsEditable):
     28        * editing/ApplyStyleCommand.cpp:
     29        (WebCore::ApplyStyleCommand::surroundNodeRangeWithElement):
     30        * html/HTMLElement.cpp:
     31        (WebCore::HTMLElement::setContentEditable):
     32
    1332011-04-28  Sheriff Bot  <webkit.review.bot@gmail.com>
    234
  • trunk/Source/WebCore/css/CSSStyleSelector.cpp

    r85256 r85267  
    12201220    documentStyle->setZoom(frame ? frame->pageZoomFactor() : 1);
    12211221    documentStyle->setPageScaleTransform(frame ? frame->pageScaleFactor() : 1);
    1222    
     1222    documentStyle->setUserModify(document->inDesignMode() ? READ_WRITE : READ_ONLY);
     1223
    12231224    Element* docElement = document->documentElement();
    12241225    RenderObject* docElementRenderer = docElement ? docElement->renderer() : 0;
  • trunk/Source/WebCore/dom/Document.cpp

    r85256 r85267  
    40384038{
    40394039    m_designMode = value;
     4040    for (Frame* frame = m_frame; frame && frame->document(); frame = frame->tree()->traverseNext(m_frame))
     4041        frame->document()->scheduleForcedStyleRecalc();
    40404042}
    40414043
  • trunk/Source/WebCore/dom/Node.cpp

    r85256 r85267  
    764764bool Node::rendererIsEditable(EditableLevel editableLevel) const
    765765{
    766     if (document()->inDesignMode() || (document()->frame() && document()->frame()->page() && document()->frame()->page()->isEditable()))
     766    if (document()->frame() && document()->frame()->page() && document()->frame()->page()->isEditable())
    767767        return true;
    768768
  • trunk/Source/WebCore/editing/ApplyStyleCommand.cpp

    r83618 r85267  
    13171317    while (node) {
    13181318        RefPtr<Node> next = node->nextSibling();
    1319         removeNode(node);
    1320         appendNode(node, element);
     1319        if (node->isContentEditable()) {
     1320            removeNode(node);
     1321            appendNode(node, element);
     1322        }
    13211323        if (node == endNode)
    13221324            break;
  • trunk/Source/WebCore/html/HTMLElement.cpp

    r84991 r85267  
    679679        attr->decl()->removeProperty(CSSPropertyWebkitNbspMode, false);
    680680        attr->decl()->removeProperty(CSSPropertyWebkitLineBreak, false);
    681     } else if (equalIgnoringCase(enabled, "inherit")) {
    682         addCSSProperty(attr, CSSPropertyWebkitUserModify, CSSValueInherit);
    683         attr->decl()->removeProperty(CSSPropertyWordWrap, false);
    684         attr->decl()->removeProperty(CSSPropertyWebkitNbspMode, false);
    685         attr->decl()->removeProperty(CSSPropertyWebkitLineBreak, false);
    686681    } else if (equalIgnoringCase(enabled, "plaintext-only")) {
    687682        addCSSProperty(attr, CSSPropertyWebkitUserModify, CSSValueReadWritePlaintextOnly);
Note: See TracChangeset for help on using the changeset viewer.