Changeset 127108 in webkit


Ignore:
Timestamp:
Aug 30, 2012 12:19:55 AM (12 years ago)
Author:
shinyak@chromium.org
Message:

AuthorShadowDOM support for textarea element.
https://bugs.webkit.org/show_bug.cgi?id=91485

Reviewed by Dimitri Glazkov.

Source/WebCore:

We add AuthorShadowDOM support for textarea element.

Unlike other replaced elements (e.g. meter, progress, img), we do not need to add
extra RenderBlock when we add AuthorShadowDOM. However, since inner element will not have
renderer when AuthorShadowDOM does not have any shadow insertion point, we have to check
the existence of the renderer of inner element.

Tests: fast/dom/shadow/shadowdom-for-textarea-with-attribute.html

fast/dom/shadow/shadowdom-for-textarea-with-placeholder.html
fast/dom/shadow/shadowdom-for-textarea-with-style.html
fast/dom/shadow/shadowdom-for-textarea.html

  • dom/ShadowRoot.cpp:

(WebCore::allowsAuthorShadowRoot): Needs allow textarea to have AuthorShadowRoot.

  • rendering/RenderTextControl.cpp: When AuthorShadowDOM does not have any insertion point,

innerTextElement() will not have any renderer. We have to tweak these renderers not to be crashed.
(WebCore::RenderTextControl::textBlockWidth):
(WebCore::RenderTextControl::updateFromElement):
(WebCore::RenderTextControl::computeLogicalHeight):
(WebCore::RenderTextControl::hitInnerTextElement):
(WebCore::RenderTextControl::computePreferredLogicalWidths):

LayoutTests:

We have the following tests.
(1) having only <shadow> insertion point.
(2) not having <shadow> insertion point.
(3) having <shadow> and <content> insertion point.
(4) with rows/cols attribute
(5) with placeholder attribute

  • fast/dom/shadow/shadow-disable-expected.txt:
  • fast/dom/shadow/shadow-disable.html:
  • fast/dom/shadow/shadowdom-for-textarea-complex-shadow-expected.html:
  • fast/dom/shadow/shadowdom-for-textarea-complex-shadow.html:
  • fast/dom/shadow/shadowdom-for-textarea-expected.html: Added.
  • fast/dom/shadow/shadowdom-for-textarea-only-shadow-expected.html:
  • fast/dom/shadow/shadowdom-for-textarea-only-shadow.html:
  • fast/dom/shadow/shadowdom-for-textarea-with-attribute-expected.html: Copied from LayoutTests/fast/dom/shadow/shadowdom-for-textarea-only-shadow-expected.html.
  • fast/dom/shadow/shadowdom-for-textarea-with-attribute.html: Copied from LayoutTests/fast/dom/shadow/shadowdom-for-textarea-only-shadow.html.
  • fast/dom/shadow/shadowdom-for-textarea-with-placeholder-expected.html: Added.
  • fast/dom/shadow/shadowdom-for-textarea-with-placeholder.html: Added.
  • fast/dom/shadow/shadowdom-for-textarea-with-style-expected.html: Added.
  • fast/dom/shadow/shadowdom-for-textarea-with-style.html: Copied from LayoutTests/fast/dom/shadow/shadowdom-for-textarea-only-shadow.html.
  • fast/dom/shadow/shadowdom-for-textarea-without-shadow.html:
  • fast/dom/shadow/shadowdom-for-textarea.html: Added.
  • platform/chromium/TestExpectations:
  • platform/efl/TestExpectations:
Location:
trunk
Files:
5 added
13 edited
3 copied

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r127107 r127108  
     12012-08-30  Shinya Kawanaka  <shinyak@chromium.org>
     2
     3        AuthorShadowDOM support for textarea element.
     4        https://bugs.webkit.org/show_bug.cgi?id=91485
     5
     6        Reviewed by Dimitri Glazkov.
     7
     8        We have the following tests.
     9        (1) having only <shadow> insertion point.
     10        (2) not having <shadow> insertion point.
     11        (3) having <shadow> and <content> insertion point.
     12        (4) with rows/cols attribute
     13        (5) with placeholder attribute
     14
     15        * fast/dom/shadow/shadow-disable-expected.txt:
     16        * fast/dom/shadow/shadow-disable.html:
     17        * fast/dom/shadow/shadowdom-for-textarea-complex-shadow-expected.html:
     18        * fast/dom/shadow/shadowdom-for-textarea-complex-shadow.html:
     19        * fast/dom/shadow/shadowdom-for-textarea-expected.html: Added.
     20        * fast/dom/shadow/shadowdom-for-textarea-only-shadow-expected.html:
     21        * fast/dom/shadow/shadowdom-for-textarea-only-shadow.html:
     22        * fast/dom/shadow/shadowdom-for-textarea-with-attribute-expected.html: Copied from LayoutTests/fast/dom/shadow/shadowdom-for-textarea-only-shadow-expected.html.
     23        * fast/dom/shadow/shadowdom-for-textarea-with-attribute.html: Copied from LayoutTests/fast/dom/shadow/shadowdom-for-textarea-only-shadow.html.
     24        * fast/dom/shadow/shadowdom-for-textarea-with-placeholder-expected.html: Added.
     25        * fast/dom/shadow/shadowdom-for-textarea-with-placeholder.html: Added.
     26        * fast/dom/shadow/shadowdom-for-textarea-with-style-expected.html: Added.
     27        * fast/dom/shadow/shadowdom-for-textarea-with-style.html: Copied from LayoutTests/fast/dom/shadow/shadowdom-for-textarea-only-shadow.html.
     28        * fast/dom/shadow/shadowdom-for-textarea-without-shadow.html:
     29        * fast/dom/shadow/shadowdom-for-textarea.html: Added.
     30        * platform/chromium/TestExpectations:
     31        * platform/efl/TestExpectations:
     32
    1332012-08-29  Andrei Bucur  <abucur@adobe.com>
    234
  • trunk/LayoutTests/fast/dom/shadow/shadow-disable-expected.txt

    r124027 r127108  
    1818SELECT
    1919PASS new WebKitShadowRoot(element) is not null
     20TEXTAREA
     21PASS new WebKitShadowRoot(element) is not null
    2022INPUT
    21 PASS new WebKitShadowRoot(element) threw exception Error: HIERARCHY_REQUEST_ERR: DOM Exception 3.
    22 TEXTAREA
    2323PASS new WebKitShadowRoot(element) threw exception Error: HIERARCHY_REQUEST_ERR: DOM Exception 3.
    2424tref
  • trunk/LayoutTests/fast/dom/shadow/shadow-disable.html

    r124027 r127108  
    2727    document.createElement('audio'),
    2828    document.createElement('video'),
    29     document.createElement('select')
     29    document.createElement('select'),
     30    document.createElement('textarea')
    3031];
    3132
    3233var elementsToFail = [
    3334    document.createElement('input'),
    34     document.createElement('textarea'),
    3535    document.getElementById('tref')
    3636];
  • trunk/LayoutTests/fast/dom/shadow/shadowdom-for-textarea-complex-shadow-expected.html

    r123713 r127108  
    11<!DOCTYPE html>
    2 <script src="resources/polyfill.js"></script>
     2<html>
     3<head>
     4<style>
     5.textarea-like {
     6    width: 255px;
     7    height: 96px;
     8    border: 1px solid black;
     9    overflow-y: scroll;
     10    position: relative;
     11    top: 2px;
     12    margin: 2px 2px 2px 2px;
     13    padding: 2px 2px 2px 2px;
     14    white-space: pre-wrap;
     15    word-wrap: break-word;
     16    font: -webkit-small-control;
     17    font-family: monospace;
     18}
     19</style>
     20</head>
     21<body>
    322
    423<p>A mixed case of a shadow element and content element.</p>
    524<form>
    6     hogehoge<div style="margin: 20px">
    7         <textarea></textarea>
    8     </div>   
    9     <input id="submit" type="submit" value="Submit">
     25    <div class="textarea-like">textarea<p>paragraph<b>bold</b>paragraph</p><div style="margin: 20px">textarea</div></div>
    1026</form>
     27
     28</body>
     29</html>
  • trunk/LayoutTests/fast/dom/shadow/shadowdom-for-textarea-complex-shadow.html

    r123713 r127108  
    11<!DOCTYPE html>
     2<html>
     3<head>
     4<style>
     5textarea {
     6   resize: none;
     7}
     8</style>
     9</head>
     10<body>
    211<script src="resources/polyfill.js"></script>
    312
    413<p>A mixed case of a shadow element and content element.</p>
    514<form>
    6     <textarea id="host">hogehoge</textarea>
    7     <input id="submit" type="submit" value="Submit">
     15    <textarea id="host" rows="6" cols="30">textarea</textarea>
    816</form>
    917
    1018<script>
    11 var host = document.getElementById('host');
     19var p = document.createElement('p');
     20p.innerHTML = "paragraph<b>bold</b>paragraph";
     21host.appendChild(p);
     22
    1223var shadowRoot = new WebKitShadowRoot(host);
    13 shadowRoot.innerHTML = "<content></content><div style='margin: 20px'><shadow></shadow></div>"
     24
     25// <content></content><div style="margin: 20px"><shadow></shadow></div>
     26shadowRoot.appendChild(document.createElement('content'));
     27var div = document.createElement('div');
     28div.setAttribute('style', 'margin: 20px');
     29div.appendChild(document.createElement('shadow'));
     30shadowRoot.appendChild(div);
    1431</script>
     32
     33</body>
     34</html>
  • trunk/LayoutTests/fast/dom/shadow/shadowdom-for-textarea-only-shadow-expected.html

    r123713 r127108  
    44<p>When the AuthorShadowDOM has only a shadow element, this should be rendered like no Shadow DOM is added.</p>
    55<form>
    6     <textarea id="host">Something in the air</textarea>
    7     <input id="submit" type="submit" value="Submit">
     6    <textarea>Something in the air</textarea>
    87</form>
     8
  • trunk/LayoutTests/fast/dom/shadow/shadowdom-for-textarea-only-shadow.html

    r123713 r127108  
    55<form>
    66    <textarea id="host">Something in the air</textarea>
    7     <input id="submit" type="submit" value="Submit">
    87</form>
    98
    109<script>
    11 var host = document.getElementById('host');
    1210var shadowRoot = new WebKitShadowRoot(host);
    13 shadowRoot.innerHTML = "<shadow></shadow>"
     11shadowRoot.appendChild(document.createElement('shadow'));
    1412</script>
  • trunk/LayoutTests/fast/dom/shadow/shadowdom-for-textarea-with-attribute-expected.html

    r127107 r127108  
    44<p>When the AuthorShadowDOM has only a shadow element, this should be rendered like no Shadow DOM is added.</p>
    55<form>
    6     <textarea id="host">Something in the air</textarea>
    7     <input id="submit" type="submit" value="Submit">
     6    <textarea rows="8" cols="20">Something in the air</textarea>
    87</form>
  • trunk/LayoutTests/fast/dom/shadow/shadowdom-for-textarea-with-attribute.html

    r127107 r127108  
    44<p>When the AuthorShadowDOM has only a shadow element, this should be rendered like no Shadow DOM is added.</p>
    55<form>
    6     <textarea id="host">Something in the air</textarea>
    7     <input id="submit" type="submit" value="Submit">
     6    <textarea id="host" rows="8" cols="20">Something in the air</textarea>
    87</form>
    98
    109<script>
    11 var host = document.getElementById('host');
    1210var shadowRoot = new WebKitShadowRoot(host);
    13 shadowRoot.innerHTML = "<shadow></shadow>"
     11shadowRoot.appendChild(document.createElement('shadow'));
    1412</script>
  • trunk/LayoutTests/fast/dom/shadow/shadowdom-for-textarea-with-style.html

    r127107 r127108  
    11<!DOCTYPE html>
     2<html>
     3<head>
     4textarea {
     5    margin: 10px;
     6    border: 2px dashed black;
     7    padding: 10px;
     8}
     9</head>
     10<body>
    211<script src="resources/polyfill.js"></script>
    312
     
    514<form>
    615    <textarea id="host">Something in the air</textarea>
    7     <input id="submit" type="submit" value="Submit">
    816</form>
    917
    1018<script>
    11 var host = document.getElementById('host');
    1219var shadowRoot = new WebKitShadowRoot(host);
    13 shadowRoot.innerHTML = "<shadow></shadow>"
     20shadowRoot.appendChild(document.createElement('shadow'));
    1421</script>
     22</body>
     23</html>
  • trunk/LayoutTests/fast/dom/shadow/shadowdom-for-textarea-without-shadow.html

    r123713 r127108  
    99
    1010<script>
    11 var select = document.getElementById('select');
    12 var shadowRoot = new WebKitShadowRoot(select);
     11var shadowRoot = new WebKitShadowRoot(host);
    1312</script>
  • trunk/LayoutTests/platform/chromium/TestExpectations

    r127107 r127108  
    32473247BUGWK90860 : fast/dom/shadow/shadowdom-for-object-only-shadow.html = IMAGE
    32483248BUGWK90860 : fast/dom/shadow/shadowdom-for-object-without-shadow.html = IMAGE
    3249 BUGWK91485 : fast/dom/shadow/shadowdom-for-textarea-complex-shadow.html = IMAGE
    3250 BUGWK91485 : fast/dom/shadow/shadowdom-for-textarea-without-shadow.html = IMAGE
    32513249BUGWK91487 : fast/dom/shadow/shadowdom-for-select-complex-shadow.html = IMAGE
    32523250BUGWK91487 : fast/dom/shadow/shadowdom-for-select-without-shadow.html = IMAGE
  • trunk/LayoutTests/platform/efl/TestExpectations

    r127101 r127108  
    770770BUGWK90860 : fast/dom/shadow/shadowdom-for-object-only-shadow.html = IMAGE
    771771BUGWK90860 : fast/dom/shadow/shadowdom-for-object-without-shadow.html = IMAGE
    772 BUGWK91485 : fast/dom/shadow/shadowdom-for-textarea-complex-shadow.html = IMAGE
    773 BUGWK91485 : fast/dom/shadow/shadowdom-for-textarea-only-shadow.html = IMAGE
    774 BUGWK91485 : fast/dom/shadow/shadowdom-for-textarea-without-shadow.html = IMAGE
    775772BUGWK91487 : fast/dom/shadow/shadowdom-for-select-complex-shadow.html = IMAGE
    776773BUGWK91487 : fast/dom/shadow/shadowdom-for-select-without-shadow.html = IMAGE
  • trunk/Source/WebCore/ChangeLog

    r127106 r127108  
     12012-08-30  Shinya Kawanaka  <shinyak@chromium.org>
     2
     3        AuthorShadowDOM support for textarea element.
     4        https://bugs.webkit.org/show_bug.cgi?id=91485
     5
     6        Reviewed by Dimitri Glazkov.
     7
     8        We add AuthorShadowDOM support for textarea element.
     9
     10        Unlike other replaced elements (e.g. meter, progress, img), we do not need to add
     11        extra RenderBlock when we add AuthorShadowDOM. However, since inner element will not have
     12        renderer when AuthorShadowDOM does not have any shadow insertion point, we have to check
     13        the existence of the renderer of inner element.
     14
     15        Tests: fast/dom/shadow/shadowdom-for-textarea-with-attribute.html
     16               fast/dom/shadow/shadowdom-for-textarea-with-placeholder.html
     17               fast/dom/shadow/shadowdom-for-textarea-with-style.html
     18               fast/dom/shadow/shadowdom-for-textarea.html
     19
     20        * dom/ShadowRoot.cpp:
     21        (WebCore::allowsAuthorShadowRoot): Needs allow textarea to have AuthorShadowRoot.
     22        * rendering/RenderTextControl.cpp: When AuthorShadowDOM does not have any insertion point,
     23        innerTextElement() will not have any renderer. We have to tweak these renderers not to be crashed.
     24        (WebCore::RenderTextControl::textBlockWidth):
     25        (WebCore::RenderTextControl::updateFromElement):
     26        (WebCore::RenderTextControl::computeLogicalHeight):
     27        (WebCore::RenderTextControl::hitInnerTextElement):
     28        (WebCore::RenderTextControl::computePreferredLogicalWidths):
     29
    1302012-08-29  Adam Barth  <abarth@webkit.org>
    231
  • trunk/Source/WebCore/dom/ShadowRoot.cpp

    r126127 r127108  
    8989    // textarea element also.
    9090    // https://bugs.webkit.org/show_bug.cgi?id=92608
    91     if (isHTMLInputElement(element) || isHTMLTextAreaElement(element))
     91    if (isHTMLInputElement(element))
    9292        return false;
    9393
  • trunk/Source/WebCore/rendering/RenderTextControl.cpp

    r126359 r127108  
    111111    Element* innerText = innerTextElement();
    112112    ASSERT(innerText);
    113     return width() - borderAndPaddingWidth() - innerText->renderBox()->paddingLeft() - innerText->renderBox()->paddingRight();
     113
     114    LayoutUnit unitWidth = width() - borderAndPaddingWidth();
     115    if (innerText->renderer())
     116        unitWidth -= innerText->renderBox()->paddingLeft() + innerText->renderBox()->paddingRight();
     117
     118    return unitWidth;
    114119}
    115120
     
    117122{
    118123    Element* innerText = innerTextElement();
    119     if (innerText)
     124    if (innerText && innerText->renderer())
    120125        updateUserModifyProperty(node(), innerText->renderer()->style());
    121126}
     
    144149    HTMLElement* innerText = innerTextElement();
    145150    ASSERT(innerText);
    146     RenderBox* innerTextBox = innerText->renderBox();
    147     LayoutUnit nonContentHeight = innerTextBox->borderAndPaddingHeight() + innerTextBox->marginHeight();
    148     setHeight(computeControlHeight(innerTextBox->lineHeight(true, HorizontalLine, PositionOfInteriorLineBoxes), nonContentHeight) + borderAndPaddingHeight());
    149 
    150     // We are able to have a horizontal scrollbar if the overflow style is scroll, or if its auto and there's no word wrap.
    151     if (style()->overflowX() == OSCROLL ||  (style()->overflowX() == OAUTO && innerText->renderer()->style()->wordWrap() == NormalWordWrap))
    152         setHeight(height() + scrollbarThickness());
     151    if (RenderBox* innerTextBox = innerText->renderBox()) {
     152        LayoutUnit nonContentHeight = innerTextBox->borderAndPaddingHeight() + innerTextBox->marginHeight();
     153        setHeight(computeControlHeight(innerTextBox->lineHeight(true, HorizontalLine, PositionOfInteriorLineBoxes), nonContentHeight) + borderAndPaddingHeight());
     154
     155        // We are able to have a horizontal scrollbar if the overflow style is scroll, or if its auto and there's no word wrap.
     156        if (style()->overflowX() == OSCROLL ||  (style()->overflowX() == OAUTO && innerText->renderer()->style()->wordWrap() == NormalWordWrap))
     157            setHeight(height() + scrollbarThickness());
     158    }
    153159
    154160    RenderBlock::computeLogicalHeight();
     
    158164{
    159165    HTMLElement* innerText = innerTextElement();
     166    if (!innerText->renderer())
     167        return;
     168
    160169    LayoutPoint adjustedLocation = accumulatedOffset + location();
    161170    LayoutPoint localPoint = pointInContainer - toLayoutSize(adjustedLocation + innerText->renderBox()->location());
     
    258267        // Use average character width. Matches IE.
    259268        AtomicString family = style()->font().family().family();
    260         RenderBox* innerTextRenderBox = innerTextElement()->renderBox();
    261         m_maxPreferredLogicalWidth = preferredContentWidth(getAvgCharWidth(family)) + innerTextRenderBox->paddingLeft() + innerTextRenderBox->paddingRight();
     269        m_maxPreferredLogicalWidth = preferredContentWidth(getAvgCharWidth(family));
     270        if (RenderBox* innerTextRenderBox = innerTextElement()->renderBox())
     271            m_maxPreferredLogicalWidth += innerTextRenderBox->paddingLeft() + innerTextRenderBox->paddingRight();
    262272    }
    263273
Note: See TracChangeset for help on using the changeset viewer.