Some refinements for Node and Document
https://bugs.webkit.org/show_bug.cgi?id=194764
Reviewed by Ryosuke Niwa.
Source/WebCore:
* accessibility/AccessibilityObject.cpp:
(WebCore::AccessibilityObject::press): Use shadowHost instead of
deprecatedShadowAncestorNode.
(WebCore::AccessibilityObject::axObjectCache const): Tweak coding style.
(WebCore::AccessibilityObject::focusedUIElement const): Use existing page
function to streamline.
* accessibility/AccessibilityRenderObject.cpp:
(WebCore::AccessibilityRenderObject::accessKey const): Use
attributeWithoutSynchronization for efficiency and consistency with other
code working with the accesskey attribute.
* dom/ContainerNode.cpp:
(WebCore::ContainerNode::childrenChanged): Added call to
invalidateAccessKeyCache, replacing old scheme tied to style recalculation.
* dom/DecodedDataDocumentParser.cpp:
(WebCore::DecodedDataDocumentParser::appendBytes): Update for name and return
type change of createDecoderIfNeeded to decoder.
(WebCore::DecodedDataDocumentParser::flush): Ditto.
* dom/Document.cpp:
(WebCore::Document::elementForAccessKey): Renamed from getElementForAccessKey
to match WebKit coding style. Changed to use unique_ptr instead of separate
boolean to keep track of map validity status.
(WebCore::Document::buildAccessKeyCache): Renamed from buildAccessKeyMap to
clarify that this is a cache. Changed to use composedTreeDescendants rather
than explicit calls to shadowRoot. Use add instead of set so that first element
in document order wins, instead of last element in document order. Updated
to make a new map in a new unique_ptr instead of populating a map.
(WebCore::Document::invalidateAccessKeyCacheSlowCase): Renamed from
invalidateAccessKeyMap, and left an inline part in the header so the fast case
of quickly checking for a null pointer can be inlined.
(WebCore::Document::doctype const): Use downcast instead of static_cast.
(WebCore::Document::scheduleStyleRecalc): Moved call to invalidateAccessKeyMap
from here to childrenChanged and accesskey attribute change handling.
(WebCore::Document::processFormatDetection): Set m_isTelephoneNumberParsingAllowed
directly since this is the only place that does it and we don't need to factor
that one line of code into a function.
(WebCore::Document::getOverrideStyle): Moved to header since it's just a stub
that always returns nullptr and can be inlined.
(WebCore::Document::setIsTelephoneNumberParsingAllowed): Deleted.
(WebCore::Document::ensureTemplateDocument): Removed nullptr frame argument to
the create function, since Document::create now always involves no frame.
(WebCore::Document::didAssociateFormControl): Changed argument type to a reference
and simplified the logic with a local variable.
(WebCore::Document::didAssociateFormControlsTimerFired): Simplified the null
checks and rearranged things so that m_associatedFormControls will always
get cleared even if the document is no longer associated with a page.
* dom/Document.h: Removed unnnecessary explicit values for enumerations (first
value is always zero, etc.) and formatted simple enumerations in a single line
for easier reading. Moved Document::create fucntion bodies out of line, removed
the frame argument from the simple "create with URL" overload and made the frame
argument for createNonRenderedPlaceholder be a reference rather than a pointer.
Renamed getElementByAccessKey to elementForAccessKey, invalidateAccessKeyMap to
invalidateAccessKeyCache, buildAccessKeyMap to buildAccessKeCache,
m_elementsByAccessKey to m_accessKeyCache and changed its type.
Removed bogus "DOM methods" comment, unused setParserFeature friend declaration,
setIsTelephoneNumberParsingAllowed function, and m_accessKeyMapValid flag.
* dom/Document.idl: Added comment highlighting that getOverrideStyle is just a
placeholder returning null.
* dom/Element.cpp:
(WebCore::Element::attributeChanged): Call invalidateAccessKeyCache when the
value of the accesskey attribute is changed. Also moved the class attribute code
so the attributes here are in alphabetical order (only class and id were out of
alphabetical order).
* dom/Node.cpp:
(WebCore::Node::isDescendantOrShadowDescendantOf const): Rewrote to no longer
use deprecatedShadowAncestorNode and used boolean operators to make it a
single line and easier to understand. Also added a FIXME since the
containsIncludingShadowDOM function is so similar, yet differently written.
(WebCore::Node::contains const): Rewrote as a single line to make this easier
to read and to *slightly* improve the speed in the "this == node" case.
(WebCore::Node::containsIncludingHostElements const): Use downcast.
(WebCore::Node::deprecatedShadowAncestorNode const): Deleted.
* dom/Node.h: Deleted now-unused deprecatedShadowAncestorNode.
* editing/ReplaceSelectionCommand.cpp:
(WebCore::ReplacementFragment::ReplacementFragment): Rewrote to use shadowHost
instead of deprecatedShadowAncestorNode.
* html/FormAssociatedElement.cpp:
(WebCore::FormAssociatedElement::resetFormOwner): Pass reference to
didAssociateFormControl.
(WebCore::FormAssociatedElement::formAttributeChanged): Ditto.
* html/HTMLAreaElement.cpp:
(WebCore::HTMLAreaElement::parseAttribute): Removed special case for accesskey
attribute, because we want to call the base class parseAttribute in that case.
* html/HTMLFormElement.cpp:
(WebCore::HTMLFormElement::insertedIntoAncestor): Pass reference to
didAssociateFormControl.
* html/HTMLSelectElement.cpp:
(WebCore::HTMLSelectElement::parseAttribute): Removed special case for accesskey
attribute with mysterious FIXME, because we want to call the base class
parseAttribute in that case. The old code had no effect before; the access key
logic would still find the attribute; if the goal is to ignore the attribute
for these elements we will need a different solution.
* html/HTMLTextAreaElement.cpp:
(WebCore::HTMLTextAreaElement::parseAttribute): Ditto.
* loader/DocumentLoader.cpp:
(WebCore::DocumentLoader::DocumentLoader): Removed code that was always passing
nullptr as the frame for the newly created DocumentWriter. It used m_frame, but
m_frame was always null.
(WebCore::DocumentLoader::attachToFrame): Pass reference to DocumentWriter::setFrame.
* loader/DocumentWriter.cpp:
(WebCore::DocumentWriter::DocumentWriter): Deleted. The old version set m_frame to
the passed in frame, which was always nullptr, and initialized some booleans and an
enumeration, which are now initialized in the class definition.
(WebCore::DocumentWriter::createDocument): Pass a reference for the frame.
(WebCore::DocumentWriter::begin): Updated now that State is an enum class.
(WebCore::DocumentWriter::decoder): Renamed from createDecoderIfNeeded and changed
to return a reference.
(WebCore::DocumentWriter::addData): Use RELEASE_ASSERT instead of if/CRASH and
updated now that State is an enum class.
(WebCore::DocumentWriter::insertDataSynchronously): Updated now that State is an
enum class.
(WebCore::DocumentWriter::end): Ditto.
* loader/DocumentWriter.h: Removed unneeded include and forward declaration.
Removed the frame pointer argument to the constructor, caller was always passing a
nullptr. Changed argument to setFrame to be a reference. Renamed createDecoderIfNeeded
to decoder and changed it to return a reference. Initialized m_frame,
m_hasReceivedSomeData, m_encodingWasChosenByUser, and m_state here so we don't need
to initialize them in a constructor. Renamed the enum from WriterState to State since
it's a member of DocumentWriter already, and made it an enum class rather than ending
each enumeration value with WritingState.
* page/DragController.cpp:
(WebCore::isEnabledColorInput): Removed boolean argument setToShadowAncestor. The
one caller that formerly passed true now calls the new hasEnabledColorInputAsShadowHost
function instead.
(WebCore::hasEnabledColorInputAsShadowHost): Added.
(WebCore::elementUnderMouse): Use shadowHost instead of deprecatedShadowAncestorNode.
Also added FIXME since it seems this should instead be using parentElementInComposedTree.
(WebCore::DragController::concludeEditDrag): Removed "false" argument to isEnabledColorInput.
(WebCore::DragController::canProcessDrag): Removed "true" argument to isEnabledColorInput
and added call to hasEnabledColorInputAsShadowHost. Also put the value of the node to drag
into a local variable to simplify code.
(WebCore::DragController::draggableElement const): Removed "false" argument to isEnabledColorInput.
* page/EventHandler.cpp:
(WebCore::EventHandler::handleAccessKey): Update name of elementForAccessKey.
* page/FocusController.cpp:
(WebCore::clearSelectionIfNeeded): Use shadowHost instead of deprecatedShadowAncestorNode.
* workers/service/context/ServiceWorkerThreadProxy.cpp:
(WebCore::createPageForServiceWorker): Pass reference instead of pointer for frame to
Document::createNonRenderedPlaceholder.
Source/WebInspectorUI:
* UserInterface/Models/NativeFunctionParameters.js: Removed getOverrideStyle
because this deprecated non-working function is no longer something web authors
should be thinking about or typing.
Source/WebKit:
* WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMDocumentGtk.cpp:
(webkit_dom_document_get_override_style): Changed to return nullptr directly instead of
calling a bunch of WebCore code first. No real value in checking arguments or doing any work.
* WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp:
(WebKit::WebFrameLoaderClient::shouldAlwaysUsePluginDocument const): Deleted.
No need to override the function inherited from the base class, nor to keep track of the
unnecessary task of implementing this some day.
* WebProcess/WebCoreSupport/WebFrameLoaderClient.h: Updated for the above.
Source/WebKitLegacy/mac:
* DOM/DOMDocument.mm:
(-[DOMDocument getOverrideStyle:pseudoElement:]): Return nil without calling
through to WebCore or even looking at the arguments.
(-[DOMDocument getOverrideStyle::]): Ditto.
LayoutTests:
fast/forms/access-key-shadow-and-ordering-expected.txt: Added.
fast/forms/access-key-shadow-and-ordering.html: Added.
Canonical link: https://commits.webkit.org/209297@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@241932 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2019-02-22 06:46:37 +00:00
|
|
|
<!DOCTYPE html>
|
|
|
|
<html>
|
|
|
|
<head>
|
|
|
|
<script>
|
|
|
|
function log(message)
|
|
|
|
{
|
|
|
|
var item = document.createElement("div");
|
|
|
|
item.appendChild(document.createTextNode(message));
|
|
|
|
document.getElementById("console").appendChild(item);
|
|
|
|
}
|
|
|
|
function pressKey(key)
|
|
|
|
{
|
|
|
|
if (navigator.userAgent.search(/\bMac OS X\b/) != -1)
|
|
|
|
modifiers = ["ctrlKey", "altKey"];
|
|
|
|
else
|
|
|
|
modifiers = ["altKey"];
|
|
|
|
eventSender.keyDown(key, modifiers);
|
|
|
|
}
|
|
|
|
function test()
|
|
|
|
{
|
|
|
|
document.getElementById("host2").attachShadow({ mode: 'closed' }).innerHTML = '<button accesskey="2" onfocus="log(\'2: correct button focused, in shadow\')" onclick="log(\'2: correct button clicked, in shadow\')">2c</button>';
|
|
|
|
document.getElementById("host3").attachShadow({ mode: 'closed' }).innerHTML = '<button accesskey="3" onfocus="log(\'3: wrong button focused, later in document and in shadow\')" onclick="log(\'3: wrong button clicked, later in document and in shadow\')">3w</button>';
|
|
|
|
document.getElementById("host4").attachShadow({ mode: 'closed' }).innerHTML = '<button accesskey="4" onfocus="log(\'4: correct button focused, earlier in document and in shadow\')" onclick="log(\'4: correct button clicked, earlier in document and in shadow\')">4c</button>';
|
|
|
|
document.getElementById("host5").attachShadow({ mode: 'closed' }).innerHTML = '<button accesskey="5" onfocus="log(\'5: correct button focused, earlier in document and in shadow\')" onclick="log(\'5: correct button clicked, earlier in document and in shadow\')">5c</button><slot></slot>';
|
|
|
|
document.getElementById("host6").attachShadow({ mode: 'closed' }).innerHTML = '<slot></slot><button accesskey="6" onfocus="log(\'6: wrong button focused, later in document and in shadow\')" onclick="log(\'6: correct button clicked, later in document and in shadow\')">6w</button>';
|
|
|
|
|
|
|
|
if (!window.testRunner)
|
|
|
|
return;
|
|
|
|
testRunner.dumpAsText();
|
|
|
|
|
|
|
|
for (var i = 1; i <= 6; i++)
|
|
|
|
pressKey(i.toString());
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
</head>
|
|
|
|
<body onload="test()">
|
|
|
|
<p>This test checks to see what happens when the same accesskey is set on multiple elements including cases where the elements are in the a shadow tree.</p>
|
|
|
|
<hr>
|
|
|
|
<button accesskey="1" onfocus="log('1: correct button focused, earlier in document')" onclick="log('1: correct button clicked, earlier in document')">1c</button>
|
|
|
|
<button accesskey="1" onfocus="log('1: wrong button focused, later in document')" onclick="log('1: wrong button clicked, later in document')">1w</button>
|
|
|
|
|
|
|
|
<span id="host2"></span>
|
|
|
|
|
|
|
|
<button accesskey="3" onfocus="log('3: correct button focused, earlier in document')" onclick="log('3: correct button clicked, earlier in document')">3c</button>
|
|
|
|
<span id="host3"></span>
|
|
|
|
|
|
|
|
<span id="host4"></span>
|
|
|
|
<button accesskey="4" onfocus="log('4: wrong button focused, later in document')" onclick="log('4: wrong button clicked, later in document')">4w</button>
|
|
|
|
|
|
|
|
<span id="host5"><button accesskey="5" onfocus="log('5: wrong button focused, later in document in slot')" onclick="log('5: wrong button clicked, later in document in slot')">5w</button></span>
|
|
|
|
|
|
|
|
<span id="host6"><button accesskey="6" onfocus="log('6: correct button focused, earlier in document in slot')" onclick="log('6: correct button clicked, earlier in document in slot')">6c</button></span>
|
|
|
|
|
|
|
|
<hr>
|
|
|
|
<div id="console"></div>
|
|
|
|
</body>
|
|
|
|
</html>
|