Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(657)

Unified Diff: Source/core/dom/Element.cpp

Issue 1152623012: WIP: delegatesFocus (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/dom/Element.h ('k') | Source/core/dom/Element.idl » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/dom/Element.cpp
diff --git a/Source/core/dom/Element.cpp b/Source/core/dom/Element.cpp
index a6b1b85232e3b8038577ec7f9c3ea8d490df99d1..a034520cc295865ea05a35f4e40c5ba1e30325a3 100644
--- a/Source/core/dom/Element.cpp
+++ b/Source/core/dom/Element.cpp
@@ -199,20 +199,13 @@ void Element::clearElementFlag(ElementFlags mask)
void Element::clearTabIndexExplicitlyIfNeeded()
{
- if (hasRareData()) {
+ if (hasRareData())
elementRareData()->clearTabIndexExplicitly();
- // As tabindex is removed, unless there is an tabstop attribute,
- // revert tabstop to default to match tabindex at this point (0).
- if (!fastHasAttribute(tabstopAttr))
- setTabStopInternal(true);
- }
}
void Element::setTabIndexExplicitly(short tabIndex)
{
ensureElementRareData().setTabIndexExplicitly(tabIndex);
- if (!fastHasAttribute(tabstopAttr))
- setTabStopInternal(tabIndex >= 0);
}
void Element::setTabIndex(int value)
@@ -1822,7 +1815,12 @@ PassRefPtrWillBeRawPtr<ShadowRoot> Element::createShadowRoot(ScriptState* script
return nullptr;
}
- return createShadowRoot(exceptionState);
+ RefPtrWillBeRawPtr<ShadowRoot> shadowRoot = createShadowRoot(exceptionState);
+
+ if (shadowRootInitDict.hasDelegatesFocus())
+ shadowRoot->setDelegatesFocus(shadowRootInitDict.delegatesFocus());
+
+ return PassRefPtrWillBeRawPtr<ShadowRoot>(shadowRoot);
}
PassRefPtrWillBeRawPtr<ShadowRoot> Element::createShadowRoot(ExceptionState& exceptionState)
@@ -2060,27 +2058,6 @@ void Element::parseAttribute(const QualifiedName& name, const AtomicString& valu
// Clamp tabindex to the range of 'short' to match Firefox's behavior.
setTabIndexExplicitly(max(static_cast<int>(std::numeric_limits<short>::min()), std::min(tabindex, static_cast<int>(std::numeric_limits<short>::max()))));
}
- } else if (RuntimeEnabledFeatures::tabStopAttributeEnabled() && name == tabstopAttr) {
- UseCounter::count(document(), UseCounter::TabStopAttribute);
- if (!hasAttribute(tabstopAttr)) {
- // tabstop attribute removed.
- clearElementFlag(TabStopWasSetExplicitly);
- setTabStopInternal(tabIndex() >= 0);
- } else {
- // Treat empty attribute as true.
- if (equalIgnoringCase(value, "true") || equalIgnoringCase(value, "")) {
- setElementFlag(TabStopWasSetExplicitly, true);
- setTabStopInternal(true);
- } else if (equalIgnoringCase(value, "false")) {
- setElementFlag(TabStopWasSetExplicitly, true);
- setTabStopInternal(false);
- } else {
- // When value is other than "true", "false", "", the value is ignored and
- // falls back the default state.
- clearElementFlag(TabStopWasSetExplicitly);
- setTabStopInternal(tabIndex() >= 0);
- }
- }
}
}
@@ -2217,7 +2194,7 @@ void Element::focus(bool restorePreviousSelection, WebFocusType type)
if (!isFocusable())
return;
- if (shadowRoot() && tabIndex() >= 0 && !tabStop()) {
+ if (shadowRoot() && tabIndex() >= 0 && shadowRoot()->delegatesFocus()) {
if (containsIncludingShadowDOM(document().focusedElement()))
return;
@@ -2333,28 +2310,6 @@ bool Element::isMouseFocusable() const
return isFocusable();
}
-bool Element::tabStop() const
-{
- if (hasElementFlag(TabStopWasSetExplicitly))
- return elementRareData()->tabStop();
- return tabIndex() >= 0;
-}
-
-void Element::setTabStop(bool flag)
-{
- // Reflect the value in the HTML attribute. Note that we cannot use setBooleanAttribute()
- // because the tabstop attribute is an enumerated attribute.
- // After tabstop attribute is set, the property value is modified accordingly.
- setAttribute(tabstopAttr, flag ? "true" : "false");
-}
-
-void Element::setTabStopInternal(bool flag)
-{
- ensureElementRareData().setTabStop(flag);
- if (shadowRoot() && shadowRoot()->containsIncludingShadowDOM(document().focusedElement()))
- setFocus(true);
-}
-
bool Element::isFocusedElementInDocument() const
{
return this == document().focusedElement();
« no previous file with comments | « Source/core/dom/Element.h ('k') | Source/core/dom/Element.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698