Changeset 85669 in webkit


Ignore:
Timestamp:
May 3, 2011 3:14:46 PM (13 years ago)
Author:
rniwa@webkit.org
Message:

2011-05-03 Ryosuke Niwa <rniwa@webkit.org>

Reviewed by Darin Adler.

WebKit allows selection that crosses the shadow boundary of a readonly input element
https://bugs.webkit.org/show_bug.cgi?id=60000

Added pixel tests to ensure WebKit doesn't create a selection that spans across
the shadow DOM boundary of a readonly input element. Also rebaselined a test that
previously exhibited this behavior.

  • editing/selection/resources/select-across-readonly-input.js: Added. (moveMouseToMiddleOfElement):
  • editing/selection/select-across-readonly-input-1.html: Added.
  • editing/selection/select-across-readonly-input-2.html: Added.
  • editing/selection/select-across-readonly-input-3.html: Added.
  • editing/selection/select-across-readonly-input-4.html: Added.
  • editing/selection/select-across-readonly-input-5.html: Added.
  • platform/mac/editing/selection/select-across-readonly-input-1-expected.png: Added.
  • platform/mac/editing/selection/select-across-readonly-input-1-expected.txt: Added.
  • platform/mac/editing/selection/select-across-readonly-input-2-expected.png: Added.
  • platform/mac/editing/selection/select-across-readonly-input-2-expected.txt: Added.
  • platform/mac/editing/selection/select-across-readonly-input-3-expected.png: Added.
  • platform/mac/editing/selection/select-across-readonly-input-3-expected.txt: Added.
  • platform/mac/editing/selection/select-across-readonly-input-4-expected.png: Added.
  • platform/mac/editing/selection/select-across-readonly-input-4-expected.txt: Added.
  • platform/mac/editing/selection/select-across-readonly-input-5-expected.png: Added.
  • platform/mac/editing/selection/select-across-readonly-input-5-expected.txt: Added.
  • platform/mac/fast/forms/input-readonly-autoscroll-expected.txt:

2011-05-03 Ryosuke Niwa <rniwa@webkit.org>

Reviewed by Darin Adler.

WebKit allows selection that crosses the shadow boundary of a readonly input element
https://bugs.webkit.org/show_bug.cgi?id=60000

The bug was caused by VisibleSelection's not validating shadow DOM boundaries.
Fixed the bug by adding an extra adjustment, adjustSelectionToAvoidCrossingShadowBoundaries,
in its validation process.

Tests: editing/selection/select-across-readonly-input-1.html

editing/selection/select-across-readonly-input-2.html
editing/selection/select-across-readonly-input-3.html
editing/selection/select-across-readonly-input-4.html
editing/selection/select-across-readonly-input-5.html

  • editing/VisibleSelection.cpp: (WebCore::VisibleSelection::validate): Calls adjustSelectionToAvoidCrossingShadowBoundaries. (WebCore::VisibleSelection::adjustSelectionToAvoidCrossingShadowBoundaries): Added.
  • editing/VisibleSelection.h:
Location:
trunk
Files:
16 added
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r85666 r85669  
     12011-05-03  Ryosuke Niwa  <rniwa@webkit.org>
     2
     3        Reviewed by Darin Adler.
     4
     5        WebKit allows selection that crosses the shadow boundary of a readonly input element
     6        https://bugs.webkit.org/show_bug.cgi?id=60000
     7
     8        Added pixel tests to ensure WebKit doesn't create a selection that spans across
     9        the shadow DOM boundary of a readonly input element. Also rebaselined a test that
     10        previously exhibited this behavior.
     11
     12        * editing/selection/resources/select-across-readonly-input.js: Added.
     13        (moveMouseToMiddleOfElement):
     14        * editing/selection/select-across-readonly-input-1.html: Added.
     15        * editing/selection/select-across-readonly-input-2.html: Added.
     16        * editing/selection/select-across-readonly-input-3.html: Added.
     17        * editing/selection/select-across-readonly-input-4.html: Added.
     18        * editing/selection/select-across-readonly-input-5.html: Added.
     19        * platform/mac/editing/selection/select-across-readonly-input-1-expected.png: Added.
     20        * platform/mac/editing/selection/select-across-readonly-input-1-expected.txt: Added.
     21        * platform/mac/editing/selection/select-across-readonly-input-2-expected.png: Added.
     22        * platform/mac/editing/selection/select-across-readonly-input-2-expected.txt: Added.
     23        * platform/mac/editing/selection/select-across-readonly-input-3-expected.png: Added.
     24        * platform/mac/editing/selection/select-across-readonly-input-3-expected.txt: Added.
     25        * platform/mac/editing/selection/select-across-readonly-input-4-expected.png: Added.
     26        * platform/mac/editing/selection/select-across-readonly-input-4-expected.txt: Added.
     27        * platform/mac/editing/selection/select-across-readonly-input-5-expected.png: Added.
     28        * platform/mac/editing/selection/select-across-readonly-input-5-expected.txt: Added.
     29        * platform/mac/fast/forms/input-readonly-autoscroll-expected.txt:
     30
    1312011-05-03  Alpha Lam  <hclam@chromium.org>
    232
  • trunk/LayoutTests/platform/mac/fast/forms/input-readonly-autoscroll-expected.txt

    r63291 r85669  
    2727      text run at (1,0) width 158: "abcdefghijklmnopqrstuvwxyz"
    2828selection start: position 1 of child 0 {#text} of child 0 {DIV} of child 5 {INPUT} of body
    29 selection end:   position 1 of child 5 {INPUT} of body
     29selection end:   position 26 of child 0 {#text} of child 0 {DIV} of child 5 {INPUT} of body
  • trunk/Source/WebCore/ChangeLog

    r85668 r85669  
     12011-05-03  Ryosuke Niwa  <rniwa@webkit.org>
     2
     3        Reviewed by Darin Adler.
     4
     5        WebKit allows selection that crosses the shadow boundary of a readonly input element
     6        https://bugs.webkit.org/show_bug.cgi?id=60000
     7
     8        The bug was caused by VisibleSelection's not validating shadow DOM boundaries.
     9        Fixed the bug by adding an extra adjustment, adjustSelectionToAvoidCrossingShadowBoundaries,
     10        in its validation process.
     11
     12        Tests: editing/selection/select-across-readonly-input-1.html
     13               editing/selection/select-across-readonly-input-2.html
     14               editing/selection/select-across-readonly-input-3.html
     15               editing/selection/select-across-readonly-input-4.html
     16               editing/selection/select-across-readonly-input-5.html
     17
     18        * editing/VisibleSelection.cpp:
     19        (WebCore::VisibleSelection::validate): Calls adjustSelectionToAvoidCrossingShadowBoundaries.
     20        (WebCore::VisibleSelection::adjustSelectionToAvoidCrossingShadowBoundaries): Added.
     21        * editing/VisibleSelection.h:
     22
    1232011-05-03  Eric Seidel  <eric@webkit.org>
    224
  • trunk/Source/WebCore/editing/VisibleSelection.cpp

    r82588 r85669  
    411411    setBaseAndExtentToDeepEquivalents();
    412412    setStartAndEndFromBaseAndExtentRespectingGranularity(granularity);
     413    adjustSelectionToAvoidCrossingShadowBoundaries();
    413414    adjustSelectionToAvoidCrossingEditingBoundaries();
    414415    updateSelectionType();
     
    450451    }
    451452    m_selectionType = base == extent ? CaretSelection : RangeSelection;
     453}
     454
     455void VisibleSelection::adjustSelectionToAvoidCrossingShadowBoundaries()
     456{
     457    if (m_base.isNull() || m_start.isNull() || m_end.isNull())
     458        return;
     459
     460    Node* startRootNode = m_start.anchorNode()->shadowTreeRootNode();
     461    Node* endRootNode = m_end.anchorNode()->shadowTreeRootNode();
     462
     463    if (!startRootNode && !endRootNode)
     464        return;
     465
     466    if (startRootNode == endRootNode)
     467        return;
     468
     469    if (m_baseIsFirst) {
     470        m_extent = startRootNode ? lastPositionInNode(startRootNode) : positionBeforeNode(endRootNode->shadowHost());
     471        m_end = m_extent;
     472    } else {
     473        m_extent = endRootNode ? firstPositionInNode(endRootNode) : positionAfterNode(startRootNode->shadowHost());
     474        m_start = m_extent;
     475    }
    452476}
    453477
  • trunk/Source/WebCore/editing/VisibleSelection.h

    r80752 r85669  
    113113    void setBaseAndExtentToDeepEquivalents();
    114114    void setStartAndEndFromBaseAndExtentRespectingGranularity(TextGranularity);
     115    void adjustSelectionToAvoidCrossingShadowBoundaries();
    115116    void adjustSelectionToAvoidCrossingEditingBoundaries();
    116117    void updateSelectionType();
Note: See TracChangeset for help on using the changeset viewer.