<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[197055] trunk/Source/WebCore</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/197055">197055</a></dd>
<dt>Author</dt> <dd>rniwa@webkit.org</dd>
<dt>Date</dt> <dd>2016-02-24 15:37:51 -0800 (Wed, 24 Feb 2016)</dd>
</dl>
<h3>Log Message</h3>
<pre>Use more references in FocusNavigationScope
https://bugs.webkit.org/show_bug.cgi?id=154637
Reviewed by Chris Dumez.
Use references in various functions of FocusNavigationScope as well as m_treeScope.
* page/FocusController.cpp:
(WebCore::FocusNavigationScope::FocusNavigationScope): Takes TreeScope& instead of TreeScope*.
(WebCore::FocusNavigationScope::rootNode): Returns ContainerNode& instead of ContainerNode*.
(WebCore::FocusNavigationScope::owner):
(WebCore::FocusNavigationScope::scopeOf): Takes Node& instead of Node*. Renamed from focusNavigationScopeOf.
(WebCore::FocusNavigationScope::scopeOwnedByShadowHost): Ditto. Renamed from focusNavigationScopeOwnedByShadowHost.
(WebCore::FocusNavigationScope::scopeOwnedByIFrame): Ditto. Renamed from focusNavigationScopeOwnedByIFrame.
(WebCore::FocusController::findFocusableElementDescendingDownIntoFrameDocument):
(WebCore::FocusController::advanceFocusInDocumentOrder):
(WebCore::FocusController::findFocusableElementAcrossFocusScope): Define currentScope inside the loop now that
the copy constructor of FocusNavigationScope no longer exists (since m_treeScope is a reference).
(WebCore::FocusController::findFocusableElementRecursively):
(WebCore::nextElementWithGreaterTabIndex):
(WebCore::FocusController::nextFocusableElement):
(WebCore::FocusController::previousFocusableElement):</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCorepageFocusControllercpp">trunk/Source/WebCore/page/FocusController.cpp</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (197054 => 197055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2016-02-24 23:19:18 UTC (rev 197054)
+++ trunk/Source/WebCore/ChangeLog        2016-02-24 23:37:51 UTC (rev 197055)
</span><span class="lines">@@ -1,3 +1,28 @@
</span><ins>+2016-02-24 Ryosuke Niwa <rniwa@webkit.org>
+
+ Use more references in FocusNavigationScope
+ https://bugs.webkit.org/show_bug.cgi?id=154637
+
+ Reviewed by Chris Dumez.
+
+ Use references in various functions of FocusNavigationScope as well as m_treeScope.
+
+ * page/FocusController.cpp:
+ (WebCore::FocusNavigationScope::FocusNavigationScope): Takes TreeScope& instead of TreeScope*.
+ (WebCore::FocusNavigationScope::rootNode): Returns ContainerNode& instead of ContainerNode*.
+ (WebCore::FocusNavigationScope::owner):
+ (WebCore::FocusNavigationScope::scopeOf): Takes Node& instead of Node*. Renamed from focusNavigationScopeOf.
+ (WebCore::FocusNavigationScope::scopeOwnedByShadowHost): Ditto. Renamed from focusNavigationScopeOwnedByShadowHost.
+ (WebCore::FocusNavigationScope::scopeOwnedByIFrame): Ditto. Renamed from focusNavigationScopeOwnedByIFrame.
+ (WebCore::FocusController::findFocusableElementDescendingDownIntoFrameDocument):
+ (WebCore::FocusController::advanceFocusInDocumentOrder):
+ (WebCore::FocusController::findFocusableElementAcrossFocusScope): Define currentScope inside the loop now that
+ the copy constructor of FocusNavigationScope no longer exists (since m_treeScope is a reference).
+ (WebCore::FocusController::findFocusableElementRecursively):
+ (WebCore::nextElementWithGreaterTabIndex):
+ (WebCore::FocusController::nextFocusableElement):
+ (WebCore::FocusController::previousFocusableElement):
+
</ins><span class="cx"> 2016-02-24 Adam Bergkvist <adam.bergkvist@ericsson.com>
</span><span class="cx">
</span><span class="cx"> WebRTC: Add MediaEndpoint interface (WebRTC backend abstraction)
</span></span></pre></div>
<a id="trunkSourceWebCorepageFocusControllercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/FocusController.cpp (197054 => 197055)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/FocusController.cpp        2016-02-24 23:19:18 UTC (rev 197054)
+++ trunk/Source/WebCore/page/FocusController.cpp        2016-02-24 23:37:51 UTC (rev 197055)
</span><span class="lines">@@ -69,11 +69,11 @@
</span><span class="cx">
</span><span class="cx"> class FocusNavigationScope {
</span><span class="cx"> public:
</span><del>- ContainerNode* rootNode() const;
</del><ins>+ ContainerNode& rootNode() const;
</ins><span class="cx"> Element* owner() const;
</span><del>- WEBCORE_EXPORT static FocusNavigationScope focusNavigationScopeOf(Node*);
- static FocusNavigationScope focusNavigationScopeOwnedByShadowHost(Node*);
- static FocusNavigationScope focusNavigationScopeOwnedByIFrame(HTMLFrameOwnerElement*);
</del><ins>+ WEBCORE_EXPORT static FocusNavigationScope scopeOf(Node&);
+ static FocusNavigationScope scopeOwnedByShadowHost(Element&);
+ static FocusNavigationScope scopeOwnedByIFrame(HTMLFrameOwnerElement&);
</ins><span class="cx">
</span><span class="cx"> Node* nextInScope(const Node*) const;
</span><span class="cx"> Node* previousInScope(const Node*) const;
</span><span class="lines">@@ -82,8 +82,8 @@
</span><span class="cx"> private:
</span><span class="cx"> Node* firstChildInScope(const Node*) const;
</span><span class="cx">
</span><del>- explicit FocusNavigationScope(TreeScope*);
- TreeScope* m_rootTreeScope;
</del><ins>+ explicit FocusNavigationScope(TreeScope&);
+ TreeScope& m_rootTreeScope;
</ins><span class="cx"> };
</span><span class="cx">
</span><span class="cx"> // FIXME: Focus navigation should work with shadow trees that have slots.
</span><span class="lines">@@ -137,50 +137,47 @@
</span><span class="cx"> return parentInScope(node);
</span><span class="cx"> }
</span><span class="cx">
</span><del>-FocusNavigationScope::FocusNavigationScope(TreeScope* treeScope)
</del><ins>+FocusNavigationScope::FocusNavigationScope(TreeScope& treeScope)
</ins><span class="cx"> : m_rootTreeScope(treeScope)
</span><span class="cx"> {
</span><del>- ASSERT(treeScope);
</del><span class="cx"> }
</span><span class="cx">
</span><del>-ContainerNode* FocusNavigationScope::rootNode() const
</del><ins>+ContainerNode& FocusNavigationScope::rootNode() const
</ins><span class="cx"> {
</span><del>- return &m_rootTreeScope->rootNode();
</del><ins>+ return m_rootTreeScope.rootNode();
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> Element* FocusNavigationScope::owner() const
</span><span class="cx"> {
</span><del>- ContainerNode* root = rootNode();
- if (is<ShadowRoot>(*root))
- return downcast<ShadowRoot>(*root).host();
- if (Frame* frame = root->document().frame())
</del><ins>+ ContainerNode& root = rootNode();
+ if (is<ShadowRoot>(root))
+ return downcast<ShadowRoot>(root).host();
+ if (Frame* frame = root.document().frame())
</ins><span class="cx"> return frame->ownerElement();
</span><span class="cx"> return nullptr;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-FocusNavigationScope FocusNavigationScope::focusNavigationScopeOf(Node* node)
</del><ins>+FocusNavigationScope FocusNavigationScope::scopeOf(Node& startingNode)
</ins><span class="cx"> {
</span><del>- ASSERT(node);
- Node* root = node;
- for (Node* n = node; n; n = parentInScope(n))
- root = n;
</del><ins>+ Node* root = nullptr;
+ for (Node* currentNode = &startingNode; currentNode; currentNode = parentInScope(currentNode))
+ root = currentNode;
</ins><span class="cx"> // The result is not always a ShadowRoot nor a DocumentNode since
</span><span class="cx"> // a starting node is in an orphaned tree in composed shadow tree.
</span><del>- return FocusNavigationScope(&root->treeScope());
</del><ins>+ return FocusNavigationScope(root->treeScope());
</ins><span class="cx"> }
</span><span class="cx">
</span><del>-FocusNavigationScope FocusNavigationScope::focusNavigationScopeOwnedByShadowHost(Node* node)
</del><ins>+FocusNavigationScope FocusNavigationScope::scopeOwnedByShadowHost(Element& element)
</ins><span class="cx"> {
</span><del>- ASSERT(node);
- ASSERT(downcast<Element>(*node).shadowRoot());
- return FocusNavigationScope(downcast<Element>(*node).shadowRoot());
</del><ins>+ ASSERT(element.shadowRoot());
+ return FocusNavigationScope(*element.shadowRoot());
</ins><span class="cx"> }
</span><span class="cx">
</span><del>-FocusNavigationScope FocusNavigationScope::focusNavigationScopeOwnedByIFrame(HTMLFrameOwnerElement* frame)
</del><ins>+FocusNavigationScope FocusNavigationScope::scopeOwnedByIFrame(HTMLFrameOwnerElement& frame)
</ins><span class="cx"> {
</span><del>- ASSERT(frame);
- ASSERT(frame->contentFrame());
- return FocusNavigationScope(frame->contentFrame()->document());
</del><ins>+ ASSERT(frame.contentFrame());
+ ASSERT(frame.contentFrame()->document());
+ return FocusNavigationScope(*frame.contentFrame()->document());
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> static inline void dispatchEventsOnWindowAndFocusedElement(Document* document, bool focused)
</span><span class="lines">@@ -301,7 +298,7 @@
</span><span class="cx"> HTMLFrameOwnerElement& owner = downcast<HTMLFrameOwnerElement>(*element);
</span><span class="cx"> if (!owner.contentFrame())
</span><span class="cx"> break;
</span><del>- Element* foundElement = findFocusableElement(direction, FocusNavigationScope::focusNavigationScopeOwnedByIFrame(&owner), 0, event);
</del><ins>+ Element* foundElement = findFocusableElement(direction, FocusNavigationScope::scopeOwnedByIFrame(owner), 0, event);
</ins><span class="cx"> if (!foundElement)
</span><span class="cx"> break;
</span><span class="cx"> ASSERT(element != foundElement);
</span><span class="lines">@@ -355,7 +352,7 @@
</span><span class="cx">
</span><span class="cx"> document->updateLayoutIgnorePendingStylesheets();
</span><span class="cx">
</span><del>- RefPtr<Element> element = findFocusableElementAcrossFocusScope(direction, FocusNavigationScope::focusNavigationScopeOf(currentNode ? currentNode : document), currentNode, event);
</del><ins>+ RefPtr<Element> element = findFocusableElementAcrossFocusScope(direction, FocusNavigationScope::scopeOf(currentNode ? *currentNode : *document), currentNode, event);
</ins><span class="cx">
</span><span class="cx"> if (!element) {
</span><span class="cx"> // We didn't find a node to focus, so we should try to pass focus to Chrome.
</span><span class="lines">@@ -367,7 +364,7 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> // Chrome doesn't want focus, so we should wrap focus.
</span><del>- element = findFocusableElementRecursively(direction, FocusNavigationScope::focusNavigationScopeOf(m_page.mainFrame().document()), 0, event);
</del><ins>+ element = findFocusableElementRecursively(direction, FocusNavigationScope::scopeOf(*m_page.mainFrame().document()), 0, event);
</ins><span class="cx"> element = findFocusableElementDescendingDownIntoFrameDocument(direction, element.get(), event);
</span><span class="cx">
</span><span class="cx"> if (!element)
</span><span class="lines">@@ -424,23 +421,21 @@
</span><span class="cx"> ASSERT(!is<Element>(currentNode) || !isNonFocusableShadowHost(*downcast<Element>(currentNode), *event));
</span><span class="cx"> Element* found;
</span><span class="cx"> if (currentNode && direction == FocusDirectionForward && isFocusableShadowHost(*currentNode, *event)) {
</span><del>- Element* foundInInnerFocusScope = findFocusableElementRecursively(direction, FocusNavigationScope::focusNavigationScopeOwnedByShadowHost(currentNode), 0, event);
</del><ins>+ Element* foundInInnerFocusScope = findFocusableElementRecursively(direction, FocusNavigationScope::scopeOwnedByShadowHost(downcast<Element>(*currentNode)), 0, event);
</ins><span class="cx"> found = foundInInnerFocusScope ? foundInInnerFocusScope : findFocusableElementRecursively(direction, scope, currentNode, event);
</span><span class="cx"> } else
</span><span class="cx"> found = findFocusableElementRecursively(direction, scope, currentNode, event);
</span><span class="cx">
</span><span class="cx"> // If there's no focusable node to advance to, move up the focus scopes until we find one.
</span><del>- FocusNavigationScope currentScope = scope;
- while (!found) {
- Element* owner = currentScope.owner();
- if (!owner)
- break;
- currentScope = FocusNavigationScope::focusNavigationScopeOf(owner);
</del><ins>+ Element* owner = scope.owner();
+ while (!found && owner) {
+ FocusNavigationScope currentScope = FocusNavigationScope::scopeOf(*owner);
</ins><span class="cx"> if (direction == FocusDirectionBackward && isFocusableShadowHost(*owner, *event)) {
</span><span class="cx"> found = owner;
</span><span class="cx"> break;
</span><span class="cx"> }
</span><span class="cx"> found = findFocusableElementRecursively(direction, currentScope, owner, event);
</span><ins>+ owner = currentScope.owner();
</ins><span class="cx"> }
</span><span class="cx"> found = findFocusableElementDescendingDownIntoFrameDocument(direction, found, event);
</span><span class="cx"> return found;
</span><span class="lines">@@ -455,16 +450,16 @@
</span><span class="cx"> if (direction == FocusDirectionForward) {
</span><span class="cx"> if (!isNonFocusableShadowHost(*found, *event))
</span><span class="cx"> return found;
</span><del>- Element* foundInInnerFocusScope = findFocusableElementRecursively(direction, FocusNavigationScope::focusNavigationScopeOwnedByShadowHost(found), 0, event);
</del><ins>+ Element* foundInInnerFocusScope = findFocusableElementRecursively(direction, FocusNavigationScope::scopeOwnedByShadowHost(*found), 0, event);
</ins><span class="cx"> return foundInInnerFocusScope ? foundInInnerFocusScope : findFocusableElementRecursively(direction, scope, found, event);
</span><span class="cx"> }
</span><span class="cx"> ASSERT(direction == FocusDirectionBackward);
</span><span class="cx"> if (isFocusableShadowHost(*found, *event)) {
</span><del>- Element* foundInInnerFocusScope = findFocusableElementRecursively(direction, FocusNavigationScope::focusNavigationScopeOwnedByShadowHost(found), 0, event);
</del><ins>+ Element* foundInInnerFocusScope = findFocusableElementRecursively(direction, FocusNavigationScope::scopeOwnedByShadowHost(*found), 0, event);
</ins><span class="cx"> return foundInInnerFocusScope ? foundInInnerFocusScope : found;
</span><span class="cx"> }
</span><span class="cx"> if (isNonFocusableShadowHost(*found, *event)) {
</span><del>- Element* foundInInnerFocusScope = findFocusableElementRecursively(direction, FocusNavigationScope::focusNavigationScopeOwnedByShadowHost(found), 0, event);
</del><ins>+ Element* foundInInnerFocusScope = findFocusableElementRecursively(direction, FocusNavigationScope::scopeOwnedByShadowHost(*found), 0, event);
</ins><span class="cx"> return foundInInnerFocusScope ? foundInInnerFocusScope :findFocusableElementRecursively(direction, scope, found, event);
</span><span class="cx"> }
</span><span class="cx"> return found;
</span><span class="lines">@@ -495,7 +490,7 @@
</span><span class="cx"> // Search is inclusive of start
</span><span class="cx"> int winningTabIndex = std::numeric_limits<short>::max() + 1;
</span><span class="cx"> Element* winner = nullptr;
</span><del>- for (Node* node = scope.rootNode(); node; node = scope.nextInScope(node)) {
</del><ins>+ for (Node* node = &scope.rootNode(); node; node = scope.nextInScope(node)) {
</ins><span class="cx"> if (!is<Element>(*node))
</span><span class="cx"> continue;
</span><span class="cx"> Element& element = downcast<Element>(*node);
</span><span class="lines">@@ -529,13 +524,13 @@
</span><span class="cx"> Element* FocusController::nextFocusableElement(Node& start)
</span><span class="cx"> {
</span><span class="cx"> Ref<KeyboardEvent> keyEvent = KeyboardEvent::createForDummy();
</span><del>- return nextFocusableElement(FocusNavigationScope::focusNavigationScopeOf(&start), &start, keyEvent.ptr());
</del><ins>+ return nextFocusableElement(FocusNavigationScope::scopeOf(start), &start, keyEvent.ptr());
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> Element* FocusController::previousFocusableElement(Node& start)
</span><span class="cx"> {
</span><span class="cx"> Ref<KeyboardEvent> keyEvent = KeyboardEvent::createForDummy();
</span><del>- return previousFocusableElement(FocusNavigationScope::focusNavigationScopeOf(&start), &start, keyEvent.ptr());
</del><ins>+ return previousFocusableElement(FocusNavigationScope::scopeOf(start), &start, keyEvent.ptr());
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> Element* FocusController::nextFocusableElement(const FocusNavigationScope& scope, Node* start, KeyboardEvent* event)
</span><span class="lines">@@ -570,13 +565,13 @@
</span><span class="cx">
</span><span class="cx"> // There are no nodes with a tabindex greater than start's tabindex,
</span><span class="cx"> // so find the first node with a tabindex of 0.
</span><del>- return findElementWithExactTabIndex(scope, scope.rootNode(), 0, event, FocusDirectionForward);
</del><ins>+ return findElementWithExactTabIndex(scope, &scope.rootNode(), 0, event, FocusDirectionForward);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> Element* FocusController::previousFocusableElement(const FocusNavigationScope& scope, Node* start, KeyboardEvent* event)
</span><span class="cx"> {
</span><span class="cx"> Node* last = nullptr;
</span><del>- for (Node* node = scope.rootNode(); node; node = scope.lastChildInScope(node))
</del><ins>+ for (Node* node = &scope.rootNode(); node; node = scope.lastChildInScope(node))
</ins><span class="cx"> last = node;
</span><span class="cx"> ASSERT(last);
</span><span class="cx">
</span></span></pre>
</div>
</div>
</body>
</html>