Changeset 25641 in webkit


Ignore:
Timestamp:
Sep 19, 2007 11:04:30 AM (17 years ago)
Author:
adele
Message:

WebCore:

Reviewed by Maciej.

Fix for <rdar://problem/5472062> -webkit-user-select: none makes selection difficult
and for <rdar://problem/5472056> REGRESSION: Cannot type into edit fields on a form (sccsheriff.org)

Tests:

This fix has a few steps:
1) Removes the ignore value for the -webkit-user-select property. We now decide when to prevent selection from starting by calling canStartSelection on the node.
2) Implements canStartSelection which returns false for all elements that used to have -webkit-user-select:ignore set, true for content editable nodes,

and walks up the tree to ask the parent before allowing selection to be started on any other nodes.

3) We used to disallow selection from starting within -webkit-user-select:none blocks, but now we only use canStartSelection for that. This will allow easy selections

in cases like iChat where there's a mix of selectable and non-selectable content.

4) Makes -webkit-user-select inherited. After removing the "ignore" value, -webkit-user-select would behave like it was inherited anyways since we already allowed the text value to override the none value.

  • css/html4.css: Removed all usage of -webkit-user-select: ignore. This is now handled internally with canStartSelection(). Now -webkit-user-select won't be unintentionally overridden by nodes that don't want to allow selection to be started, but do want to honor the -webkit-user-select to determine whether or not selection is allowed at all.
  • editing/SelectionController.cpp: (WebCore::SelectionController::selectAll): Don't try to determine whether selection is allowed inside the root node here. VisiblePosition and Selection creation will keep Selection endpoints out of -webkit-user-select:none regions.


  • dom/Node.h:
  • dom/Node.cpp: (WebCore::Node::canStartSelection): Added. Always allows selection to be started in a content editable node. If there's a parent, ask the parent if starting a selection is allowed. If there's no parent, default to allowing selection.
  • html/HTMLAnchorElement.h:
  • html/HTMLAnchorElement.cpp: (WebCore::HTMLAnchorElement::canStartSelection): Added. If its not a link, then calls the base class. Disallows selection for non-editable links. Allows selection for editable links. This logic used to be done in CSSStyleSelector by changing the user-select property.
  • html/HTMLButtonElement.h: (WebCore::HTMLButtonElement::canStartSelection): Added. Disallows selection from starting in buttons.
  • html/HTMLImageElement.h: (WebCore::HTMLImageElement::canStartSelection): Added. Disallows selection from starting in images.
  • html/HTMLInputElement.h:
  • html/HTMLInputElement.cpp: (WebCore::HTMLInputElement::canStartSelection): Added. Disallows selection from anything that's not a text field. Text fields call up to the base class. When they're editable, text controls will always be selectable because of the case for content editable content. Otherwise, they'll respect their parent element's decision about starting a selection.
  • html/HTMLSelectElement.h: (WebCore::HTMLSelectElement::canStartSelection): Added. Disallows selection from starting in popup buttons.
  • page/EventHandler.cpp: (WebCore::EventHandler::selectClosestWordFromMouseEvent): Use canMouseDownStartSelect instead of the ambiguously named shouldSelect(). (WebCore::EventHandler::handleMousePressEventTripleClick): ditto. (WebCore::EventHandler::handleMousePressEventSingleClick): ditto. (WebCore::EventHandler::updateSelectionForMouseDrag): Use canMouseDragExtendSelect. (WebCore::EventHandler::selectCursor): Paint an ibeam in any region that allows you to click to create a selection. (WebCore::EventHandler::canMouseDownStartSelect): Now fires the selectStart event, and calls canStartSelection instead of checking the user-select property. (WebCore::EventHandler::canMouseDragExtendSelect): This is identical to canMouseDownStartSelect because of 12823, even though it seems strange that we would fire the selectStart event here.
  • page/EventHandler.h:
  • page/FocusController.cpp: (WebCore::clearSelectionIfNeeded): Calls canStartSelection instead of checking the user-select property to decide when to prevent selection creation.
  • rendering/RenderObject.cpp: (WebCore::RenderObject::draggableNode): ditto.
  • rendering/RenderObject.h: Removed helper methods that are no longer needed.
  • rendering/RenderStyle.h: Made userSelect inherited. After removing the "ignore" value, -webkit-user-select would behave like it was inherited anyways since we already allowed the text value to override the none value. Removed the SELECT_AUTO and SELECT_IGNORE values since they're no longer used. (WebCore::): (WebCore::RenderStyle::userSelect): (WebCore::RenderStyle::setUserSelect): (WebCore::RenderStyle::initialUserSelect):
  • rendering/RenderStyle.cpp: (WebCore::StyleRareNonInheritedData::StyleRareNonInheritedData): (WebCore::StyleRareNonInheritedData::operator==): (WebCore::StyleRareInheritedData::StyleRareInheritedData): (WebCore::StyleRareInheritedData::operator==): (WebCore::RenderStyle::diff):
  • css/CSSComputedStyleDeclaration.cpp: (WebCore::CSSComputedStyleDeclaration::getPropertyCSSValue): Remove case for SELECT_AUTO and SELECT_IGNORE
  • css/CSSStyleSelector.cpp: (WebCore::CSSStyleSelector::adjustRenderStyle): Remove adjustment for links. This is now handled in HTMLAnchorElement::canStartSelection. (WebCore::CSSStyleSelector::applyProperty): Map CSS_VAL_AUTO to SELECT_TEXT. Remove CSS_VAL_IGNORE.

LayoutTests:

Reviewed by Maciej.

Tests for <rdar://problem/5472062> -webkit-user-select: none makes selection difficult
and for <rdar://problem/5472056> REGRESSION: Cannot type into edit fields on a form (sccsheriff.org)

  • fast/css/computed-style-expected.txt: Updated for default -webkit-user-select value.
  • fast/css/computed-style-without-renderer-expected.txt: ditto.
  • editing/selection/5333725.html: Re-enabled.
  • editing/selection/5333725.html-disabled: Removed.
  • editing/selection/user-select-text-inside-user-select-ignore.html-disabled: Removed. Adjusted this test to be more specific and renamed it to textfield-inside-anchor.
  • editing/selection/user-select-text-inside-user-select-ignore-expected.txt: Removed.
  • fast/forms/textfield-inside-anchor-expected.txt: Added.
  • fast/forms/textfield-inside-anchor.html: Added.
Location:
trunk
Files:
2 added
2 deleted
25 edited
1 moved

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r25636 r25641  
     12007-09-18  Adele Peterson  <adele@apple.com>
     2
     3        Reviewed by Maciej.
     4
     5        Tests for <rdar://problem/5472062> -webkit-user-select: none makes selection difficult
     6        and for <rdar://problem/5472056> REGRESSION: Cannot type into edit fields on a form (sccsheriff.org)
     7
     8        * fast/css/computed-style-expected.txt: Updated for default -webkit-user-select value.
     9        * fast/css/computed-style-without-renderer-expected.txt: ditto.
     10
     11        * editing/selection/5333725.html: Re-enabled.
     12        * editing/selection/5333725.html-disabled: Removed.
     13
     14        * editing/selection/user-select-text-inside-user-select-ignore.html-disabled: Removed. Adjusted this test to be more specific and renamed it to textfield-inside-anchor.
     15        * editing/selection/user-select-text-inside-user-select-ignore-expected.txt: Removed.
     16        * fast/forms/textfield-inside-anchor-expected.txt: Added.
     17        * fast/forms/textfield-inside-anchor.html: Added.
     18
    1192007-09-19  Antti Koivisto  <antti@apple.com>
    220
  • trunk/LayoutTests/fast/css/computed-style-expected.txt

    r25468 r25641  
    126126-webkit-user-drag: auto;
    127127-webkit-user-modify: read-only;
    128 -webkit-user-select: auto;
     128-webkit-user-select: text;
    129129-webkit-dashboard-region: null;
    130130-webkit-border-bottom-left-radius: 0px;
  • trunk/LayoutTests/fast/css/computed-style-without-renderer-expected.txt

    r25468 r25641  
    125125    -webkit-user-drag: auto
    126126    -webkit-user-modify: read-only
    127     -webkit-user-select: auto
     127    -webkit-user-select: text
    128128    -webkit-dashboard-region: null
    129129    -webkit-border-bottom-left-radius: 0px
  • trunk/WebCore/ChangeLog

    r25638 r25641  
    1 2007-09-19  George Staikos  <staikos@kde.org>
    2 
    3         As discussed with Brady and Maciej, on platforms without pthreads, use
    4         IconDatabaseNone for now and don't use pthreads.  Fixes Qt Win32 build
    5         for now.
    6 
    7         * loader/icon/IconDatabase.h:
    8 
    9 2007-09-19  Antti Koivisto  <antti@apple.com>
     12007-09-18  Adele Peterson  <adele@apple.com>
    102
    113        Reviewed by Maciej.
    124
    13         Fix <rdar://problem/5488539>
    14         (9A550) iPhone Banner on O2.UK site not clickable with Safari due to styled noscript element
    15        
    16         Don't create renderer for noscript if scripts are enabled.
    17        
    18         Test: fast/dom/noscript-style.html
    19 
    20         * html/HTMLElement.cpp:
    21         (WebCore::HTMLElement::mapToEntry):
    22         (WebCore::HTMLElement::parseMappedAttribute):
    23         (WebCore::HTMLElement::checkDTD):
    24         (WebCore::HTMLElement::rendererIsNeeded):
    25         (WebCore::HTMLElement::createRenderer):
    26         * html/HTMLElement.h:
     5        Fix for <rdar://problem/5472062> -webkit-user-select: none makes selection difficult
     6        and for <rdar://problem/5472056> REGRESSION: Cannot type into edit fields on a form (sccsheriff.org)
     7
     8        Tests:
     9
     10        This fix has a few steps:
     11        1) Removes the ignore value for the -webkit-user-select property.  We now decide when to prevent selection from starting by calling canStartSelection on the node.
     12        2) Implements canStartSelection which returns false for all elements that used to have -webkit-user-select:ignore set, true for content editable nodes,
     13           and walks up the tree to ask the parent before allowing selection to be started on any other nodes.
     14        3) We used to disallow selection from starting within -webkit-user-select:none blocks, but now we only use canStartSelection for that.  This will allow easy selections
     15           in cases like iChat where there's a mix of selectable and non-selectable content.
     16        4) Makes -webkit-user-select inherited.  After removing the "ignore" value, -webkit-user-select would behave like it was inherited anyways since we already allowed the text value to override the none value.
     17
     18
     19        * css/html4.css: Removed all usage of -webkit-user-select: ignore.  This is now handled internally with canStartSelection().
     20          Now -webkit-user-select won't be unintentionally overridden by nodes that don't want to allow selection to be started, but do want to honor the -webkit-user-select to
     21          determine whether or not selection is allowed at all.
     22
     23        * editing/SelectionController.cpp: (WebCore::SelectionController::selectAll):
     24          Don't try to determine whether selection is allowed inside the root node here.  VisiblePosition and Selection creation will keep Selection endpoints out of -webkit-user-select:none regions.
     25       
     26        * dom/Node.h:
     27        * dom/Node.cpp: (WebCore::Node::canStartSelection): Added. Always allows selection to be started in a content editable node.  If there's a parent, ask the parent if starting a selection is allowed.
     28          If there's no parent, default to allowing selection.
     29        * html/HTMLAnchorElement.h:
     30        * html/HTMLAnchorElement.cpp: (WebCore::HTMLAnchorElement::canStartSelection): Added. If its not a link, then calls the base class. Disallows selection for non-editable links.
     31          Allows selection for editable links.
     32          This logic used to be done in CSSStyleSelector by changing the user-select property.
     33        * html/HTMLButtonElement.h: (WebCore::HTMLButtonElement::canStartSelection): Added. Disallows selection from starting in buttons.
     34        * html/HTMLImageElement.h: (WebCore::HTMLImageElement::canStartSelection): Added. Disallows selection from starting in images.
     35        * html/HTMLInputElement.h:
     36        * html/HTMLInputElement.cpp: (WebCore::HTMLInputElement::canStartSelection): Added. Disallows selection from anything that's not a text field.  Text fields call up to the base class.
     37          When they're editable, text controls will always be selectable because of the case for content editable content. Otherwise, they'll respect their parent element's decision about starting a selection.
     38        * html/HTMLSelectElement.h: (WebCore::HTMLSelectElement::canStartSelection): Added. Disallows selection from starting in popup buttons.
     39
     40        * page/EventHandler.cpp:
     41        (WebCore::EventHandler::selectClosestWordFromMouseEvent): Use canMouseDownStartSelect instead of the ambiguously named shouldSelect().
     42        (WebCore::EventHandler::handleMousePressEventTripleClick): ditto.
     43        (WebCore::EventHandler::handleMousePressEventSingleClick): ditto.
     44        (WebCore::EventHandler::updateSelectionForMouseDrag): Use canMouseDragExtendSelect.
     45        (WebCore::EventHandler::selectCursor): Paint an ibeam in any region that allows you to click to create a selection.
     46        (WebCore::EventHandler::canMouseDownStartSelect): Now fires the selectStart event, and calls canStartSelection instead of checking the user-select property.
     47        (WebCore::EventHandler::canMouseDragExtendSelect): This is identical to canMouseDownStartSelect because of 12823, even though it seems strange that we would fire the selectStart event here.
     48        * page/EventHandler.h:
     49        * page/FocusController.cpp: (WebCore::clearSelectionIfNeeded): Calls canStartSelection instead of checking the user-select property to decide when to prevent selection creation.
     50        * rendering/RenderObject.cpp: (WebCore::RenderObject::draggableNode): ditto.
     51        * rendering/RenderObject.h: Removed helper methods that are no longer needed.
     52
     53        * rendering/RenderStyle.h: Made userSelect inherited.  After removing the "ignore" value, -webkit-user-select would behave like it was inherited
     54          anyways since we already allowed the text value to override the none value.
     55          Removed the SELECT_AUTO and SELECT_IGNORE values since they're no longer used.
     56        (WebCore::):
     57        (WebCore::RenderStyle::userSelect):
     58        (WebCore::RenderStyle::setUserSelect):
     59        (WebCore::RenderStyle::initialUserSelect):
     60        * rendering/RenderStyle.cpp:
     61        (WebCore::StyleRareNonInheritedData::StyleRareNonInheritedData):
     62        (WebCore::StyleRareNonInheritedData::operator==):
     63        (WebCore::StyleRareInheritedData::StyleRareInheritedData):
     64        (WebCore::StyleRareInheritedData::operator==):
     65        (WebCore::RenderStyle::diff):
     66
     67        * css/CSSComputedStyleDeclaration.cpp: (WebCore::CSSComputedStyleDeclaration::getPropertyCSSValue): Remove case for SELECT_AUTO and SELECT_IGNORE
     68        * css/CSSStyleSelector.cpp:
     69        (WebCore::CSSStyleSelector::adjustRenderStyle):  Remove adjustment for links.  This is now handled in HTMLAnchorElement::canStartSelection.
     70        (WebCore::CSSStyleSelector::applyProperty): Map CSS_VAL_AUTO to SELECT_TEXT.  Remove CSS_VAL_IGNORE.
    2771
    28722007-09-18  Timothy Hatcher  <timothy@apple.com>
  • trunk/WebCore/css/CSSComputedStyleDeclaration.cpp

    r25468 r25641  
    15821582        case CSS_PROP__WEBKIT_USER_SELECT:
    15831583            switch (style->userSelect()) {
    1584                 case SELECT_AUTO:
    1585                     return new CSSPrimitiveValue(CSS_VAL_AUTO);
    15861584                case SELECT_NONE:
    15871585                    return new CSSPrimitiveValue(CSS_VAL_NONE);
    15881586                case SELECT_TEXT:
    15891587                    return new CSSPrimitiveValue(CSS_VAL_TEXT);
    1590                 case SELECT_IGNORE:
    1591                     return new CSSPrimitiveValue(CSS_VAL_IGNORE);
    15921588            }
    15931589            break;
  • trunk/WebCore/css/CSSParser.cpp

    r24793 r25641  
    12311231        break;
    12321232    case CSS_PROP__WEBKIT_USER_SELECT: // auto | none | text
    1233         if (id == CSS_VAL_AUTO || id == CSS_VAL_NONE || id == CSS_VAL_TEXT || id == CSS_VAL_IGNORE)
     1233        if (id == CSS_VAL_AUTO || id == CSS_VAL_NONE || id == CSS_VAL_TEXT)
    12341234            valid_primitive = true;
    12351235        break;
  • trunk/WebCore/css/CSSStyleSelector.cpp

    r25468 r25641  
    11311131            style->setOverflowY(OVISIBLE);
    11321132    }
    1133 
    1134     // Links should be user selectable when content editable
    1135     if (e && e->isLink() && ((e->document()->frame() && e->document()->frame()->isContentEditable()) || style->userModify() == READ_WRITE || style->userModify() == READ_WRITE_PLAINTEXT_ONLY))
    1136         style->setUserSelect(SELECT_AUTO);
    11371133
    11381134    // Cull out any useless layers and also repeat patterns into additional layers.
     
    41784174        switch (primitiveValue->getIdent()) {
    41794175            case CSS_VAL_AUTO:
    4180                 style->setUserSelect(SELECT_AUTO);
     4176                style->setUserSelect(SELECT_TEXT);
    41814177                break;
    41824178            case CSS_VAL_NONE:
     
    41854181            case CSS_VAL_TEXT:
    41864182                style->setUserSelect(SELECT_TEXT);
    4187                 break;
    4188             case CSS_VAL_IGNORE:
    4189                 style->setUserSelect(SELECT_IGNORE);
    41904183            default:
    41914184                return;
  • trunk/WebCore/css/html4.css

    r24324 r25641  
    385385input[type="radio"], input[type="checkbox"] {
    386386    margin: 3px 0.5ex;
    387     -webkit-user-select: ignore;
    388387    padding: initial;
    389388    background-color: initial;
     
    411410    padding: initial;
    412411    border: initial;
    413     -webkit-user-select: ignore;
    414412    margin: 2px;
    415413}
     
    417415input[type="range"]::-webkit-slider-thumb {
    418416    -webkit-appearance: sliderthumb-horizontal;
    419     -webkit-user-select: ignore
    420417}
    421418
     
    430427input[type="button"]:active:disabled, input[type="submit"]:active:disabled, input[type="reset"]:active:disabled, input[type="file"]:active:disabled::-webkit-file-upload-button, button:active:disabled {
    431428    border-style: outset
    432 }
    433 
    434 select, keygen, button, input[type="button"], input[type="image"], input[type="submit"], input[type="reset"], input[type="checkbox"], input[type="radio"], input[type="file"]::-webkit-file-upload-button, img {
    435     -webkit-user-select: ignore
    436429}
    437430
     
    574567    color: -webkit-link;
    575568    text-decoration: underline;
    576     -webkit-user-select: ignore
    577569}
    578570
  • trunk/WebCore/dom/Node.cpp

    r25345 r25641  
    10981098{
    10991099    return renderer() ? renderer()->nextOffset(current) : current + 1;
     1100}
     1101
     1102bool Node::canStartSelection() const
     1103{
     1104    if (isContentEditable())
     1105        return true;
     1106    return parent() ? parent()->canStartSelection() : true;
    11001107}
    11011108
  • trunk/WebCore/dom/Node.h

    r25345 r25641  
    363363    virtual void selectAll() { }
    364364
     365    // Whether or not a selection can be started in this object
     366    virtual bool canStartSelection() const;
     367
    365368#ifndef NDEBUG
    366369    virtual void dump(TextStream*, DeprecatedString indent = "") const;
  • trunk/WebCore/editing/SelectionController.cpp

    r25502 r25641  
    11741174   
    11751175    Node* root = isContentEditable() ? highestEditableRoot(m_sel.start()) : document->documentElement();
    1176     if (!root || !root->renderer() || !root->renderer()->canSelect())
     1176    if (!root)
    11771177        return;
    11781178    Selection newSelection(Selection::selectionFromContentsOfNode(root));
  • trunk/WebCore/html/HTMLAnchorElement.cpp

    r24415 r25641  
    291291}
    292292
     293bool HTMLAnchorElement::canStartSelection() const
     294{
     295    // FIXME: We probably want this same behavior in SVGAElement too
     296    if (!isLink())
     297        return HTMLElement::canStartSelection();
     298    return isContentEditable();
     299}
     300
    293301String HTMLAnchorElement::accessKey() const
    294302{
  • trunk/WebCore/html/HTMLAnchorElement.h

    r21927 r25641  
    4949    virtual void accessKeyAction(bool fullAction);
    5050    virtual bool isURLAttribute(Attribute*) const;
     51
     52    virtual bool canStartSelection() const;
    5153
    5254    String accessKey() const;
  • trunk/WebCore/html/HTMLButtonElement.h

    r21174 r25641  
    5050    virtual void accessKeyAction(bool sendToAnyElement);
    5151
     52    virtual bool canStartSelection() const { return false; }
     53
    5254    String accessKey() const;
    5355    void setAccessKey(const String&);
  • trunk/WebCore/html/HTMLImageElement.h

    r20954 r25641  
    5050    virtual void insertedIntoDocument();
    5151    virtual void removedFromDocument();
     52
     53    virtual bool canStartSelection() const { return false; }
    5254
    5355    int width(bool ignorePendingStylesheets = false) const;
  • trunk/WebCore/html/HTMLInputElement.cpp

    r25345 r25641  
    455455            break;
    456456    }
     457}
     458
     459bool HTMLInputElement::canStartSelection() const
     460{
     461    if (!isTextField())
     462        return false;
     463    return HTMLFormControlElementWithState::canStartSelection();
    457464}
    458465
  • trunk/WebCore/html/HTMLInputElement.h

    r25345 r25641  
    9999    virtual void restoreState(const String&);
    100100
     101    virtual bool canStartSelection() const;
     102   
    101103    bool canHaveSelection() const;
    102104    int selectionStart() const;
  • trunk/WebCore/html/HTMLSelectElement.h

    r24363 r25641  
    5555    virtual void dispatchFocusEvent();
    5656    virtual void dispatchBlurEvent();
     57   
     58    virtual bool canStartSelection() const { return false; }
    5759
    5860    int selectedIndex() const;
  • trunk/WebCore/page/EventHandler.cpp

    r25468 r25641  
    153153    Selection newSelection;
    154154
    155     if (innerNode && innerNode->renderer() && m_mouseDownMayStartSelect && innerNode->renderer()->shouldSelect()) {
     155    if (innerNode && innerNode->renderer() && m_mouseDownMayStartSelect) {
    156156        VisiblePosition pos(innerNode->renderer()->positionForPoint(result.localPoint()));
    157157        if (pos.isNotNull()) {
     
    194194   
    195195    Node* innerNode = event.targetNode();
    196     if (!(innerNode && innerNode->renderer() && m_mouseDownMayStartSelect
    197           && innerNode->renderer()->shouldSelect()))
     196    if (!(innerNode && innerNode->renderer() && m_mouseDownMayStartSelect))
    198197        return false;
    199198
     
    221220   
    222221    Node* innerNode = event.targetNode();
    223     if (!(innerNode && innerNode->renderer() && m_mouseDownMayStartSelect
    224           && innerNode->renderer()->shouldSelect()))
     222    if (!(innerNode && innerNode->renderer() && m_mouseDownMayStartSelect))
    225223        return false;
    226224
     
    409407    if (!targetRenderer)
    410408        return;
    411 
    412     if (!targetRenderer->shouldSelect())
     409       
     410    if (!canMouseDragExtendSelect(targetNode))
    413411        return;
    414412
     
    728726            if (m_frame->view() && layer && layer->isPointInResizeControl(m_frame->view()->windowToContents(event.event().pos())))
    729727                inResizer = true;
    730             if ((editable || (renderer && renderer->isText() && renderer->canSelect())) && !inResizer && !scrollbar)
     728            if ((editable || (renderer && renderer->isText() && node->canStartSelection())) && !inResizer && !scrollbar)
    731729                return iBeamCursor();
    732730            return pointerCursor();
     
    13641362}
    13651363
     1364// Whether or not a mouse down can begin the creation of a selection.  Fires the selectStart event.
    13661365bool EventHandler::canMouseDownStartSelect(Node* node)
    13671366{
     
    13691368        return true;
    13701369   
    1371     // Check to see if -webkit-user-select has been set to none
    1372     if (!node->renderer()->canSelect())
    1373         return false;
    1374    
    13751370    // Some controls and images can't start a select on a mouse down.
    1376     for (RenderObject* curr = node->renderer(); curr; curr = curr->parent())
    1377         if (curr->style()->userSelect() == SELECT_IGNORE)
    1378             return false;
     1371    if (!node->canStartSelection())
     1372        return false;
     1373           
     1374    for (RenderObject* curr = node->renderer(); curr; curr = curr->parent())   
     1375        if (Node* node = curr->element())
     1376            return EventTargetNodeCast(node)->dispatchHTMLEvent(selectstartEvent, true, true);
     1377   
     1378    return true;
     1379}
     1380
     1381bool EventHandler::canMouseDragExtendSelect(Node* node)
     1382{
     1383    if (!node || !node->renderer())
     1384        return true;
     1385           
     1386    for (RenderObject* curr = node->renderer(); curr; curr = curr->parent())   
     1387        if (Node* node = curr->element())
     1388            return EventTargetNodeCast(node)->dispatchHTMLEvent(selectstartEvent, true, true);
    13791389   
    13801390    return true;
  • trunk/WebCore/page/EventHandler.h

    r25468 r25641  
    196196
    197197    static bool canMouseDownStartSelect(Node*);
     198    static bool canMouseDragExtendSelect(Node*);
    198199
    199200    void handleAutoscroll(RenderObject*);
  • trunk/WebCore/page/FocusController.cpp

    r25345 r25641  
    246246       
    247247    if (Node* mousePressNode = newFocusedFrame->eventHandler()->mousePressNode())
    248         if (mousePressNode->renderer() && mousePressNode->renderer()->style()->userSelect() == SELECT_IGNORE)
     248        if (mousePressNode->renderer() && !mousePressNode->canStartSelection())
    249249            if (Node* root = s->rootEditableElement())
    250250                if (Node* shadowAncestorNode = root->shadowAncestorNode())
  • trunk/WebCore/rendering/RenderObject.cpp

    r25468 r25641  
    20072007#endif // NDEBUG
    20082008
    2009 static Node* selectStartNode(const RenderObject* object)
    2010 {
    2011     Node* node = 0;
    2012     bool forcedOn = false;
    2013 
    2014     for (const RenderObject* curr = object; curr; curr = curr->parent()) {
    2015         if (curr->style()->userSelect() == SELECT_TEXT)
    2016             forcedOn = true;
    2017         if (!forcedOn && curr->style()->userSelect() == SELECT_NONE)
    2018             return 0;
    2019 
    2020         if (!node)
    2021             node = curr->element();
    2022     }
    2023 
    2024     // somewhere up the render tree there must be an element!
    2025     ASSERT(node);
    2026 
    2027     return node;
    2028 }
    2029 
    2030 bool RenderObject::canSelect() const
    2031 {
    2032     return selectStartNode(this) != 0;
    2033 }
    2034 
    2035 bool RenderObject::shouldSelect() const
    2036 {
    2037     if (Node* node = selectStartNode(this))
    2038         return EventTargetNodeCast(node)->dispatchHTMLEvent(selectstartEvent, true, true);
    2039 
    2040     return false;
    2041 }
    2042 
    20432009Color RenderObject::selectionBackgroundColor() const
    20442010{
     
    20892055                return curr->node();
    20902056            }
    2091             if (curr->shouldSelect())
     2057            if (elt->canStartSelection())
    20922058                // In this case we have a click in the unselected portion of text.  If this text is
    20932059                // selectable, we want to start the selection process instead of looking for a parent
  • trunk/WebCore/rendering/RenderObject.h

    r25468 r25641  
    756756    virtual bool hasSelectedChildren() const { return false; }
    757757
    758     // Whether or not a selection can be attempted on this object.
    759     bool canSelect() const;
    760 
    761     // Whether or not a selection can be attempted on this object.  Should only be called right before actually beginning a selection,
    762     // since it fires the selectstart DOM event.
    763     bool shouldSelect() const;
    764 
    765758    // Obtains the selection colors that should be used when painting a selection.
    766759    Color selectionBackgroundColor() const;
  • trunk/WebCore/rendering/RenderStyle.cpp

    r25468 r25641  
    427427    , m_counterDirectives(0)
    428428    , userDrag(RenderStyle::initialUserDrag())
    429     , userSelect(RenderStyle::initialUserSelect())
    430429    , textOverflow(RenderStyle::initialTextOverflow())
    431430    , marginTopCollapse(MCOLLAPSE)
     
    451450    , m_counterDirectives(0)
    452451    , userDrag(o.userDrag)
    453     , userSelect(o.userSelect)
    454452    , textOverflow(o.textOverflow)
    455453    , marginTopCollapse(o.marginTopCollapse)
     
    498496        && m_counterDirectives == o.m_counterDirectives
    499497        && userDrag == o.userDrag
    500         && userSelect == o.userSelect
    501498        && textOverflow == o.textOverflow
    502499        && marginTopCollapse == o.marginTopCollapse
     
    532529    , textSizeAdjust(RenderStyle::initialTextSizeAdjust())
    533530    , resize(RenderStyle::initialResize())
     531    , userSelect(RenderStyle::initialUserSelect())
    534532{
    535533}
     
    550548    , textSizeAdjust(o.textSizeAdjust)
    551549    , resize(o.resize)
     550    , userSelect(o.userSelect)
    552551{
    553552}
     
    571570        && nbspMode == o.nbspMode
    572571        && khtmlLineBreak == o.khtmlLineBreak
    573         && textSizeAdjust == o.textSizeAdjust;
     572        && textSizeAdjust == o.textSizeAdjust
     573        && userSelect == o.userSelect;
    574574}
    575575
     
    10611061        visual->textDecoration != other->visual->textDecoration ||
    10621062        rareInheritedData->userModify != other->rareInheritedData->userModify ||
    1063         rareNonInheritedData->userSelect != other->rareNonInheritedData->userSelect ||
     1063        rareInheritedData->userSelect != other->rareInheritedData->userSelect ||
    10641064        rareNonInheritedData->userDrag != other->rareNonInheritedData->userDrag ||
    10651065        rareNonInheritedData->m_borderFit != other->rareNonInheritedData->m_borderFit ||
  • trunk/WebCore/rendering/RenderStyle.h

    r25468 r25641  
    714714
    715715enum EUserSelect {
    716     SELECT_AUTO, SELECT_NONE, SELECT_TEXT, SELECT_IGNORE
     716    SELECT_NONE, SELECT_TEXT
    717717};
    718718
     
    848848
    849849    unsigned userDrag : 2; // EUserDrag
    850     unsigned userSelect : 2;  // EUserSelect
    851850    bool textOverflow : 1; // Whether or not lines that spill out should be truncated with "..."
    852851    unsigned marginTopCollapse : 2; // EMarginCollapse
     
    891890    bool textSizeAdjust : 1; // An Apple extension.
    892891    unsigned resize : 2; // EResize
     892    unsigned userSelect : 1;  // EUserSelect
    893893};
    894894
     
    14621462    EUserModify userModify() const { return static_cast<EUserModify>(rareInheritedData->userModify); }
    14631463    EUserDrag userDrag() const { return static_cast<EUserDrag>(rareNonInheritedData->userDrag); }
    1464     EUserSelect userSelect() const { return static_cast<EUserSelect>(rareNonInheritedData->userSelect); }
     1464    EUserSelect userSelect() const { return static_cast<EUserSelect>(rareInheritedData->userSelect); }
    14651465    bool textOverflow() const { return rareNonInheritedData->textOverflow; }
    14661466    EMarginCollapse marginTopCollapse() const { return static_cast<EMarginCollapse>(rareNonInheritedData->marginTopCollapse); }
     
    17041704    void setUserModify(EUserModify u) { SET_VAR(rareInheritedData, userModify, u); }
    17051705    void setUserDrag(EUserDrag d) { SET_VAR(rareNonInheritedData, userDrag, d); }
    1706     void setUserSelect(EUserSelect s) { SET_VAR(rareNonInheritedData, userSelect, s); }
     1706    void setUserSelect(EUserSelect s) { SET_VAR(rareInheritedData, userSelect, s); }
    17071707    void setTextOverflow(bool b) { SET_VAR(rareNonInheritedData, textOverflow, b); }
    17081708    void setMarginTopCollapse(EMarginCollapse c) { SET_VAR(rareNonInheritedData, marginTopCollapse, c); }
     
    18521852    static EUserModify initialUserModify() { return READ_ONLY; }
    18531853    static EUserDrag initialUserDrag() { return DRAG_AUTO; }
    1854     static EUserSelect initialUserSelect() { return SELECT_AUTO; }
     1854    static EUserSelect initialUserSelect() { return SELECT_TEXT; }
    18551855    static bool initialTextOverflow() { return false; }
    18561856    static EMarginCollapse initialMarginTopCollapse() { return MCOLLAPSE; }
Note: See TracChangeset for help on using the changeset viewer.