Changeset 88418 in webkit


Ignore:
Timestamp:
Jun 8, 2011 8:55:17 PM (13 years ago)
Author:
hayato@chromium.org
Message:

2011-06-08 Hayato Ito <hayato@chromium.org>

Reviewed by Hajime Morita.

Makes sure that document.activeElement won't be an element in shadow root.

https://bugs.webkit.org/show_bug.cgi?id=61413

  • fast/dom/shadow/activeelement-should-be-shadowhost-expected.txt: Added.
  • fast/dom/shadow/activeelement-should-be-shadowhost.html: Added.

2011-06-08 Hayato Ito <hayato@chromium.org>

Reviewed by Hajime Morita.

Makes sure that document.activeElement won't be an element in shadow root.

https://bugs.webkit.org/show_bug.cgi?id=61413

Test: fast/dom/shadow/activeelement-should-be-shadowhost.html

  • html/HTMLDocument.cpp: (WebCore::focusedFrameOwnerElement): (WebCore::HTMLDocument::activeElement):
Location:
trunk
Files:
2 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r88417 r88418  
     12011-06-08  Hayato Ito  <hayato@chromium.org>
     2
     3        Reviewed by Hajime Morita.
     4
     5        Makes sure that document.activeElement won't be an element in shadow root.
     6
     7        https://bugs.webkit.org/show_bug.cgi?id=61413
     8
     9        * fast/dom/shadow/activeelement-should-be-shadowhost-expected.txt: Added.
     10        * fast/dom/shadow/activeelement-should-be-shadowhost.html: Added.
     11
    1122011-06-08  Kent Tamura  <tkent@chromium.org>
    213
  • trunk/Source/WebCore/ChangeLog

    r88415 r88418  
     12011-06-08  Hayato Ito  <hayato@chromium.org>
     2
     3        Reviewed by Hajime Morita.
     4
     5        Makes sure that document.activeElement won't be an element in shadow root.
     6
     7        https://bugs.webkit.org/show_bug.cgi?id=61413
     8
     9        Test: fast/dom/shadow/activeelement-should-be-shadowhost.html
     10
     11        * html/HTMLDocument.cpp:
     12        (WebCore::focusedFrameOwnerElement):
     13        (WebCore::HTMLDocument::activeElement):
     14
    1152011-06-08  Kent Tamura  <tkent@chromium.org>
    216
  • trunk/Source/WebCore/html/HTMLDocument.cpp

    r86707 r88418  
    137137}
    138138
     139static Node* focusedFrameOwnerElement(Frame* focusedFrame, Frame* currentFrame)
     140{
     141    for (; focusedFrame; focusedFrame = focusedFrame->tree()->parent()) {
     142        if (focusedFrame->tree()->parent() == currentFrame)
     143            return focusedFrame->ownerElement();
     144    }
     145    return 0;
     146}
     147
    139148Element* HTMLDocument::activeElement()
    140149{
    141     if (Node* node = focusedNode()) {
    142         if (node->isElementNode())
    143             return static_cast<Element*>(node);
    144     } else if (Page* page = this->page()) {
    145         for (Frame* focusedFrame = page->focusController()->focusedFrame(); focusedFrame; focusedFrame = focusedFrame->tree()->parent()) {
    146             if (focusedFrame->tree()->parent() == frame())
    147                 return focusedFrame->ownerElement();
    148         }
    149     }
     150    Node* node = focusedNode();
     151    if (!node && page())
     152        node = focusedFrameOwnerElement(page()->focusController()->focusedFrame(), frame());
     153    if (!node)
     154        return body();
     155    ASSERT(node->document() == this);
     156    while (node->treeScope() != this) {
     157        node = node->parentOrHostNode();
     158        ASSERT(node);
     159    }
     160    if (node->isElementNode())
     161        return toElement(node);
    150162    return body();
    151163}
Note: See TracChangeset for help on using the changeset viewer.