Diff
Modified: trunk/LayoutTests/ChangeLog (277526 => 277527)
--- trunk/LayoutTests/ChangeLog 2021-05-15 01:50:00 UTC (rev 277526)
+++ trunk/LayoutTests/ChangeLog 2021-05-15 02:05:22 UTC (rev 277527)
@@ -1,3 +1,19 @@
+2021-05-14 Darin Adler <da...@apple.com>
+
+ output element doesn't react properly to node tree mutations
+ https://bugs.webkit.org/show_bug.cgi?id=196532
+
+ Reviewed by Ryosuke Niwa.
+
+ * TestExpectations: Removed an expectation for a directory that no longer exists.
+ * platform/mac-wk2/TestExpectations: Removed an expectation for a test that no longer exists.
+ * platform/mac/TestExpectations: Removed an expectation for a directory that no longer exists.
+
+ * platform/gtk/imported/w3c/web-platform-tests/custom-elements/builtin-coverage-expected.txt:
+ * platform/ios-wk2/imported/w3c/web-platform-tests/custom-elements/builtin-coverage-expected.txt:
+ * platform/mac-wk2/imported/w3c/web-platform-tests/custom-elements/builtin-coverage-expected.txt:
+ Updated since HTMLOptionElement now has a constructor. Still not passing, but closer to correct.
+
2021-05-14 Eric Carlson <eric.carl...@apple.com>
[GPUP] a media element with a data url and "crossorigin='anonymous'" doesn't load
Modified: trunk/LayoutTests/TestExpectations (277526 => 277527)
--- trunk/LayoutTests/TestExpectations 2021-05-15 01:50:00 UTC (rev 277526)
+++ trunk/LayoutTests/TestExpectations 2021-05-15 02:05:22 UTC (rev 277527)
@@ -63,7 +63,6 @@
fast/scrolling/ipad [ Skip ]
fast/text/mac [ Skip ]
scrollingcoordinator [ Skip ]
-media/mac [ Skip ]
media/ios [ Skip ]
media/modern-media-controls/tracks-support [ Skip ]
fast/text-autosizing [ Skip ]
Modified: trunk/LayoutTests/imported/w3c/ChangeLog (277526 => 277527)
--- trunk/LayoutTests/imported/w3c/ChangeLog 2021-05-15 01:50:00 UTC (rev 277526)
+++ trunk/LayoutTests/imported/w3c/ChangeLog 2021-05-15 02:05:22 UTC (rev 277527)
@@ -1,3 +1,23 @@
+2021-05-14 Darin Adler <da...@apple.com>
+
+ output element doesn't react properly to node tree mutations
+ https://bugs.webkit.org/show_bug.cgi?id=196532
+
+ Reviewed by Ryosuke Niwa.
+
+ * web-platform-tests/custom-elements/builtin-coverage-expected.txt:
+ Updated since HTMLOptionElement now has a constructor. Still not passing, but closer to correct.
+
+ * web-platform-tests/custom-elements/form-associated/form-reset-callback-expected.txt:
+ Updated due to changes in HTMLOptionElement, but still not passing.
+
+ * web-platform-tests/html/semantics/forms/the-output-element/mutations.window-expected.txt:
+ Updated to reflect passing test.
+
+ * web-platform-tests/html/semantics/forms/the-output-element/mutations.window.js:
+ Updated to a newer version of the upstream version of this. Decided to just update this one file
+ rather than importing the latest version across more tests at this time.
+
2021-05-14 Ziran Sun <z...@igalia.com>
Wrong static position for out-of-flow positioned element with different writing-mode than its containing block
Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/custom-elements/builtin-coverage-expected.txt (277526 => 277527)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/custom-elements/builtin-coverage-expected.txt 2021-05-15 01:50:00 UTC (rev 277526)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/custom-elements/builtin-coverage-expected.txt 2021-05-15 02:05:22 UTC (rev 277527)
@@ -544,7 +544,9 @@
[native code]
}"
PASS output: Define a customized built-in element
-FAIL output: Operator 'new' should instantiate a customized built-in element Illegal constructor
+FAIL output: Operator 'new' should instantiate a customized built-in element assert_equals: Cloning a customized built-in element should succeed. expected function "class extends HTMLOutputElement {}" but got function "function HTMLOutputElement() {
+ [native code]
+}"
FAIL output: document.createElement() should instantiate a customized built-in element assert_equals: expected function "class extends HTMLOutputElement {}" but got function "function HTMLOutputElement() {
[native code]
}"
Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/custom-elements/form-associated/form-reset-callback-expected.txt (277526 => 277527)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/custom-elements/form-associated/form-reset-callback-expected.txt 2021-05-15 01:50:00 UTC (rev 277526)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/custom-elements/form-associated/form-reset-callback-expected.txt 2021-05-15 02:05:22 UTC (rev 277527)
@@ -1,6 +1,6 @@
+default
-
FAIL form.reset() should trigger formResetCallback assert_true: expected true got false
FAIL form.reset(): formResetCallback is called after reset of the last built-in form control and before the next statement. assert_true: expected true got false
FAIL Clicking a reset button invokes formResetCallback in a microtask assert_true: expected true got false
Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/forms/the-output-element/mutations.window-expected.txt (277526 => 277527)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/forms/the-output-element/mutations.window-expected.txt 2021-05-15 01:50:00 UTC (rev 277526)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/forms/the-output-element/mutations.window-expected.txt 2021-05-15 02:05:22 UTC (rev 277527)
@@ -1,4 +1,4 @@
-FAIL Descendant mutations and output.value and .defaultValue assert_equals: .defaultValue after setting textContent expected "x" but got ""
+PASS Descendant mutations and output.value and .defaultValue
PASS output and output.form.reset()
Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/forms/the-output-element/mutations.window.js (277526 => 277527)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/forms/the-output-element/mutations.window.js 2021-05-15 01:50:00 UTC (rev 277526)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/forms/the-output-element/mutations.window.js 2021-05-15 02:05:22 UTC (rev 277527)
@@ -15,7 +15,7 @@
assert_equal_values(output, "x", "after setting textContent");
output.value = "some";
assert_values(output, "some", "x", "after setting value");
- child.textContent = "y";
+ output.textContent = "y";
assert_values(output, "y", "x", "after setting textContent again");
}, "Descendant mutations and output.value and .defaultValue");
Modified: trunk/LayoutTests/platform/gtk/imported/w3c/web-platform-tests/custom-elements/builtin-coverage-expected.txt (277526 => 277527)
--- trunk/LayoutTests/platform/gtk/imported/w3c/web-platform-tests/custom-elements/builtin-coverage-expected.txt 2021-05-15 01:50:00 UTC (rev 277526)
+++ trunk/LayoutTests/platform/gtk/imported/w3c/web-platform-tests/custom-elements/builtin-coverage-expected.txt 2021-05-15 02:05:22 UTC (rev 277527)
@@ -544,7 +544,9 @@
[native code]
}"
PASS output: Define a customized built-in element
-FAIL output: Operator 'new' should instantiate a customized built-in element Illegal constructor
+FAIL output: Operator 'new' should instantiate a customized built-in element assert_equals: Cloning a customized built-in element should succeed. expected function "class extends HTMLOutputElement {}" but got function "function HTMLOutputElement() {
+ [native code]
+}"
FAIL output: document.createElement() should instantiate a customized built-in element assert_equals: expected function "class extends HTMLOutputElement {}" but got function "function HTMLOutputElement() {
[native code]
}"
Modified: trunk/LayoutTests/platform/ios-wk2/imported/w3c/web-platform-tests/custom-elements/builtin-coverage-expected.txt (277526 => 277527)
--- trunk/LayoutTests/platform/ios-wk2/imported/w3c/web-platform-tests/custom-elements/builtin-coverage-expected.txt 2021-05-15 01:50:00 UTC (rev 277526)
+++ trunk/LayoutTests/platform/ios-wk2/imported/w3c/web-platform-tests/custom-elements/builtin-coverage-expected.txt 2021-05-15 02:05:22 UTC (rev 277527)
@@ -544,7 +544,9 @@
[native code]
}"
PASS output: Define a customized built-in element
-FAIL output: Operator 'new' should instantiate a customized built-in element Illegal constructor
+FAIL output: Operator 'new' should instantiate a customized built-in element assert_equals: Cloning a customized built-in element should succeed. expected function "class extends HTMLOutputElement {}" but got function "function HTMLOutputElement() {
+ [native code]
+}"
FAIL output: document.createElement() should instantiate a customized built-in element assert_equals: expected function "class extends HTMLOutputElement {}" but got function "function HTMLOutputElement() {
[native code]
}"
Modified: trunk/LayoutTests/platform/mac/TestExpectations (277526 => 277527)
--- trunk/LayoutTests/platform/mac/TestExpectations 2021-05-15 01:50:00 UTC (rev 277526)
+++ trunk/LayoutTests/platform/mac/TestExpectations 2021-05-15 02:05:22 UTC (rev 277527)
@@ -14,7 +14,6 @@
editing/pasteboard/mac [ Pass ]
fast/dom/Range/mac [ Pass ]
fast/scrolling/latching [ Pass ]
-media/mac [ Pass ]
model-element [ Pass ]
fast/forms/search/search-padding-cancel-results-buttons.html [ Pass ]
@@ -2276,4 +2275,4 @@
webkit.org/b/223645 [ BigSur ] media/video-played-ranges-1.html [ Pass Failure ]
-webkit.org/b/225804 imported/w3c/web-platform-tests/webxr/xrBoundedReferenceSpace_updates.https.html [ Pass Failure ]
\ No newline at end of file
+webkit.org/b/225804 imported/w3c/web-platform-tests/webxr/xrBoundedReferenceSpace_updates.https.html [ Pass Failure ]
Modified: trunk/LayoutTests/platform/mac-wk2/TestExpectations (277526 => 277527)
--- trunk/LayoutTests/platform/mac-wk2/TestExpectations 2021-05-15 01:50:00 UTC (rev 277526)
+++ trunk/LayoutTests/platform/mac-wk2/TestExpectations 2021-05-15 02:05:22 UTC (rev 277527)
@@ -1357,8 +1357,6 @@
webkit.org/b/224690 compositing/video/video-border-radius-clipping.html [ Pass ImageOnlyFailure ]
-webkit.org/b/224696 [ arm64 ] http/wpt/webrtc/change-encoded-transform.html [ Pass Crash ]
-
webkit.org/b/224698 [ BigSur Release arm64 ] inspector/console/console-oom.html [ Pass Crash ]
webkit.org/b/224845 [ BigSur Debug arm64 ] http/wpt/preload/change-link-rel-attribute.html [ Pass Crash ]
@@ -1403,4 +1401,4 @@
webkit.org/b/225667 http/tests/webAPIStatistics/screen-functions-accessed-data-collection.html [ Slow ]
-webkit.org/b/225668 http/tests/xmlhttprequest/redirect-cross-origin-tripmine.html [ Slow ]
\ No newline at end of file
+webkit.org/b/225668 http/tests/xmlhttprequest/redirect-cross-origin-tripmine.html [ Slow ]
Modified: trunk/LayoutTests/platform/mac-wk2/imported/w3c/web-platform-tests/custom-elements/builtin-coverage-expected.txt (277526 => 277527)
--- trunk/LayoutTests/platform/mac-wk2/imported/w3c/web-platform-tests/custom-elements/builtin-coverage-expected.txt 2021-05-15 01:50:00 UTC (rev 277526)
+++ trunk/LayoutTests/platform/mac-wk2/imported/w3c/web-platform-tests/custom-elements/builtin-coverage-expected.txt 2021-05-15 02:05:22 UTC (rev 277527)
@@ -544,7 +544,9 @@
[native code]
}"
PASS output: Define a customized built-in element
-FAIL output: Operator 'new' should instantiate a customized built-in element Illegal constructor
+FAIL output: Operator 'new' should instantiate a customized built-in element assert_equals: Cloning a customized built-in element should succeed. expected function "class extends HTMLOutputElement {}" but got function "function HTMLOutputElement() {
+ [native code]
+}"
FAIL output: document.createElement() should instantiate a customized built-in element assert_equals: expected function "class extends HTMLOutputElement {}" but got function "function HTMLOutputElement() {
[native code]
}"
Modified: trunk/Source/WebCore/ChangeLog (277526 => 277527)
--- trunk/Source/WebCore/ChangeLog 2021-05-15 01:50:00 UTC (rev 277526)
+++ trunk/Source/WebCore/ChangeLog 2021-05-15 02:05:22 UTC (rev 277527)
@@ -1,3 +1,69 @@
+2021-05-14 Darin Adler <da...@apple.com>
+
+ output element doesn't react properly to node tree mutations
+ https://bugs.webkit.org/show_bug.cgi?id=196532
+
+ Reviewed by Ryosuke Niwa.
+
+ * dom/ContainerNode.cpp:
+ (WebCore::ContainerNode::replaceAll): Refactored most of the functions
+ replaceAllChildren and replaceAllChildrenWithNewText into this new one,
+ and named it based on the name of the operation in the HTML specification.
+ The function is incomplete, but preserves existing behavior.
+ (WebCore::ContainerNode::stringReplaceAll): Refactored the rest of the
+ replaceAllChildrenWithNewText function and renamed to the name from the
+ HTML specification.
+ * dom/ContainerNode.h: Updated for the above changes.
+
+ * dom/Node.cpp:
+ (WebCore::Node::setTextContent): Updated for name change above.
+ * dom/Range.cpp:
+ (WebCore::Range::surroundContents): Ditto.
+ * editing/ios/EditorIOS.mm:
+ (WebCore::Editor::setTextAsChildOfElement): Ditto.
+ * html/HTMLElement.cpp:
+ (WebCore::HTMLElement::setInnerText): Ditto.
+
+ * html/HTMLOutputElement.cpp:
+ (WebCore::HTMLOutputElement::HTMLOutputElement): Moved data member
+ initialization into the class definition.
+ (WebCore::HTMLOutputElement::create): Added an overload that takes just
+ a document, for use when invoked from as a constructor.
+ (WebCore::HTMLOutputElement::parseAttribute): Tightened the logic for the
+ for attribute. I decided it's better to call through to the base class, even
+ though we often don't do that for attributes that don't expect the base
+ class to pay attention to.
+ (WebCore::HTMLOutputElement::childrenChanged): Deleted. No need for this in
+ the improved HTML specification version of this element's algorithms.
+ (WebCore::HTMLOutputElement::reset): Updated based on the HTML specification,
+ using the default value algorithm rather than the default value mode flag we
+ were using before.
+ (WebCore::HTMLOutputElement::setValue): Updated based on the HTML specification,
+ always setting the default value override based on the current default value,
+ and using stringReplaceAll. There's no need for the old setTextContentInternal,
+ since that was all due to the need to avoid infinite recursion in childrenChanged.
+ (WebCore::HTMLOutputElement::defaultValue const): Updated based on the HTML
+ specification, deriving the default value from the default value override and
+ the descendant text content.
+ (WebCore::HTMLOutputElement::setDefaultValue): Updated based on the HTML
+ specification, doing a string replace all with the value if the default
+ value override is null, and updating the default value override otherwise.
+ (WebCore::HTMLOutputElement::htmlFor): Updated to rename m_tokens to m_forTokens.
+ (WebCore::HTMLOutputElement::setTextContentInternal): Deleted.
+
+ * html/HTMLOutputElement.h: Moved DOMTokenList to be a forward declaration
+ instead of an include. Adde a constructor that takes only a document to be used
+ from _javascript_. Made the canContainRangeEndPoint override be private like the
+ other overrides. Removed the childrenChange override and the
+ setTextContentInternal function. Removed m_isDefaultValueMode,
+ m_isSetTextContentInProgress, and m_defaultValue. Added m_defaultValueOverride.
+ Renamed m_tokens to m_forTokens.
+
+ * html/HTMLOutputElement.idl: Updated to match the HTML specification. This
+ involved adding a constructor, adding SameObject for the htmlFor attribute,
+ making the form attribute nullable, and removing [LegacyNullToEmptyString]
+ from the defaultValue and value attributes.
+
2021-05-14 Sam Weinig <wei...@apple.com>
Use PixelBufferFormat to specify ImageBuffer::getPixelData destination format allowing for more control over data conversion
Modified: trunk/Source/WebCore/dom/ContainerNode.cpp (277526 => 277527)
--- trunk/Source/WebCore/dom/ContainerNode.cpp 2021-05-15 01:50:00 UTC (rev 277526)
+++ trunk/Source/WebCore/dom/ContainerNode.cpp 2021-05-15 02:05:22 UTC (rev 277527)
@@ -663,25 +663,18 @@
}
// https://dom.spec.whatwg.org/#concept-node-replace-all
-void ContainerNode::replaceAllChildren(std::nullptr_t)
+void ContainerNode::replaceAll(Node* node)
{
- ChildListMutationScope mutation(*this);
- removeChildren();
-}
-
-// https://dom.spec.whatwg.org/#concept-node-replace-all
-void ContainerNode::replaceAllChildrenWithNewText(const String& text)
-{
- if (text.isEmpty()) {
- replaceAllChildren(nullptr);
+ if (!node) {
+ ChildListMutationScope mutation(*this);
+ removeChildren();
return;
}
- auto node = document().createTextNode(text);
+ // FIXME: The code below is roughly correct for a new text node with no parent, but needs enhancement to work properly for more complex cases.
+
if (!hasChildNodes()) {
- // appendChildWithoutPreInsertionValidityCheck() can only throw when node has a parent and we already asserted it doesn't.
- auto result = appendChildWithoutPreInsertionValidityCheck(node);
- ASSERT_UNUSED(result, !result.hasException());
+ appendChildWithoutPreInsertionValidityCheck(*node);
return;
}
@@ -689,11 +682,10 @@
ChildListMutationScope mutation(*this);
removeAllChildrenWithScriptAssertion(ChildChange::Source::API, DeferChildrenChanged::Yes);
- executeNodeInsertionWithScriptAssertion(*this, node.get(), ChildChange::Source::API, ReplacedAllChildren::Yes, [&] {
- ASSERT(!ensurePreInsertionValidity(node, nullptr).hasException());
+ executeNodeInsertionWithScriptAssertion(*this, *node, ChildChange::Source::API, ReplacedAllChildren::Yes, [&] {
InspectorInstrumentation::willInsertDOMNode(document(), *this);
node->setTreeScopeRecursively(treeScope());
- appendChildCommon(node);
+ appendChildCommon(*node);
});
rebuildSVGExtensionsElementsIfNecessary();
@@ -700,6 +692,12 @@
dispatchSubtreeModifiedEvent();
}
+// https://dom.spec.whatwg.org/#string-replace-all
+void ContainerNode::stringReplaceAll(const String& string)
+{
+ replaceAll(string.isEmpty() ? nullptr : document().createTextNode(string).ptr());
+}
+
inline void ContainerNode::rebuildSVGExtensionsElementsIfNecessary()
{
if (document().svgExtensions() && !is<SVGUseElement>(shadowHost()))
Modified: trunk/Source/WebCore/dom/ContainerNode.h (277526 => 277527)
--- trunk/Source/WebCore/dom/ContainerNode.h 2021-05-15 01:50:00 UTC (rev 277526)
+++ trunk/Source/WebCore/dom/ContainerNode.h 2021-05-15 02:05:22 UTC (rev 277527)
@@ -57,8 +57,8 @@
ExceptionOr<void> replaceChild(Node& newChild, Node& oldChild);
WEBCORE_EXPORT ExceptionOr<void> removeChild(Node& child);
WEBCORE_EXPORT ExceptionOr<void> appendChild(Node& newChild);
- void replaceAllChildrenWithNewText(const String&);
- void replaceAllChildren(std::nullptr_t);
+ void stringReplaceAll(const String&);
+ void replaceAll(Node*);
// These methods are only used during parsing.
// They don't send DOM mutation events or handle reparenting.
Modified: trunk/Source/WebCore/dom/Node.cpp (277526 => 277527)
--- trunk/Source/WebCore/dom/Node.cpp 2021-05-15 01:50:00 UTC (rev 277526)
+++ trunk/Source/WebCore/dom/Node.cpp 2021-05-15 02:05:22 UTC (rev 277527)
@@ -1589,7 +1589,7 @@
return setNodeValue(text);
case ELEMENT_NODE:
case DOCUMENT_FRAGMENT_NODE:
- downcast<ContainerNode>(*this).replaceAllChildrenWithNewText(text);
+ downcast<ContainerNode>(*this).stringReplaceAll(text);
return { };
case DOCUMENT_NODE:
case DOCUMENT_TYPE_NODE:
Modified: trunk/Source/WebCore/dom/Range.cpp (277526 => 277527)
--- trunk/Source/WebCore/dom/Range.cpp 2021-05-15 01:50:00 UTC (rev 277526)
+++ trunk/Source/WebCore/dom/Range.cpp 2021-05-15 02:05:22 UTC (rev 277527)
@@ -824,7 +824,7 @@
// Step 4: If newParent has children, replace all with null within newParent.
if (newParent.hasChildNodes())
- downcast<ContainerNode>(newParent).replaceAllChildren(nullptr);
+ downcast<ContainerNode>(newParent).replaceAll(nullptr);
// Step 5: Insert newParent into context object.
auto insertResult = insertNode(newParent);
Modified: trunk/Source/WebCore/editing/ios/EditorIOS.mm (277526 => 277527)
--- trunk/Source/WebCore/editing/ios/EditorIOS.mm 2021-05-15 01:50:00 UTC (rev 277526)
+++ trunk/Source/WebCore/editing/ios/EditorIOS.mm 2021-05-15 02:05:22 UTC (rev 277527)
@@ -337,7 +337,7 @@
// What follows is more expensive if there is a selection, so clear it since it's going to change anyway.
m_document.selection().clear();
- element.replaceAllChildrenWithNewText(text);
+ element.stringReplaceAll(text);
VisiblePosition afterContents = makeContainerOffsetPosition(&element, element.countChildNodes());
if (afterContents.isNull())
Modified: trunk/Source/WebCore/html/HTMLElement.cpp (277526 => 277527)
--- trunk/Source/WebCore/html/HTMLElement.cpp 2021-05-15 01:50:00 UTC (rev 277526)
+++ trunk/Source/WebCore/html/HTMLElement.cpp 2021-05-15 02:05:22 UTC (rev 277527)
@@ -555,7 +555,7 @@
// FIXME: This doesn't take whitespace collapsing into account at all.
if (!text.contains('\n') && !text.contains('\r')) {
- replaceAllChildrenWithNewText(text);
+ stringReplaceAll(text);
return { };
}
@@ -565,19 +565,19 @@
auto* r = renderer();
if ((r && r->style().preserveNewline()) || (isConnected() && isTextControlInnerTextElement())) {
if (!text.contains('\r')) {
- replaceAllChildrenWithNewText(text);
+ stringReplaceAll(text);
return { };
}
String textWithConsistentLineBreaks = text;
textWithConsistentLineBreaks.replace("\r\n", "\n");
textWithConsistentLineBreaks.replace('\r', '\n');
- replaceAllChildrenWithNewText(textWithConsistentLineBreaks);
+ stringReplaceAll(textWithConsistentLineBreaks);
return { };
}
+ // FIXME: This should use replaceAll(), after we fix that to work properly for DocumentFragment.
// Add text nodes and <br> elements.
auto fragment = textToFragment(document(), text);
- // FIXME: This should use a variant of replaceAllChildrenWithNewText() which accepts DocumentFragments as input.
// It's safe to dispatch events on the new fragment since author scripts have no access to it yet.
ScriptDisallowedScope::EventAllowedScope allowedScope(fragment.get());
return replaceChildrenWithFragment(*this, WTFMove(fragment));
Modified: trunk/Source/WebCore/html/HTMLOutputElement.cpp (277526 => 277527)
--- trunk/Source/WebCore/html/HTMLOutputElement.cpp 2021-05-15 01:50:00 UTC (rev 277526)
+++ trunk/Source/WebCore/html/HTMLOutputElement.cpp 2021-05-15 02:05:22 UTC (rev 277527)
@@ -1,5 +1,6 @@
/*
* Copyright (c) 2010 Google Inc. All rights reserved.
+ * Copyright (c) 2021 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -31,6 +32,7 @@
#include "config.h"
#include "HTMLOutputElement.h"
+#include "DOMTokenList.h"
#include "HTMLFormElement.h"
#include "HTMLNames.h"
#include <wtf/IsoMallocInlines.h>
@@ -40,13 +42,8 @@
WTF_MAKE_ISO_ALLOCATED_IMPL(HTMLOutputElement);
-using namespace HTMLNames;
-
inline HTMLOutputElement::HTMLOutputElement(const QualifiedName& tagName, Document& document, HTMLFormElement* form)
: HTMLFormControlElement(tagName, document, form)
- , m_isDefaultValueMode(true)
- , m_isSetTextContentInProgress(false)
- , m_defaultValue(emptyString())
{
}
@@ -55,6 +52,11 @@
return adoptRef(*new HTMLOutputElement(tagName, document, form));
}
+Ref<HTMLOutputElement> HTMLOutputElement::create(Document& document)
+{
+ return create(HTMLNames::outputTag, document, nullptr);
+}
+
const AtomString& HTMLOutputElement::formControlType() const
{
static MainThreadNeverDestroyed<const AtomString> output("output", AtomString::ConstructFromLiteral);
@@ -68,35 +70,15 @@
void HTMLOutputElement::parseAttribute(const QualifiedName& name, const AtomString& value)
{
- if (name == forAttr) {
- if (m_tokens)
- m_tokens->associatedAttributeValueChanged(value);
- } else
- HTMLFormControlElement::parseAttribute(name, value);
+ if (name == forAttr && m_forTokens)
+ m_forTokens->associatedAttributeValueChanged(value);
+ HTMLFormControlElement::parseAttribute(name, value);
}
-void HTMLOutputElement::childrenChanged(const ChildChange& change)
-{
- HTMLFormControlElement::childrenChanged(change);
-
- if (change.source == ChildChange::Source::Parser || m_isSetTextContentInProgress) {
- m_isSetTextContentInProgress = false;
- return;
- }
-
- if (m_isDefaultValueMode)
- m_defaultValue = textContent();
-}
-
void HTMLOutputElement::reset()
{
- // The reset algorithm for output elements is to set the element's
- // value mode flag to "default" and then to set the element's textContent
- // attribute to the default value.
- m_isDefaultValueMode = true;
- if (m_defaultValue == value())
- return;
- setTextContentInternal(m_defaultValue);
+ stringReplaceAll(defaultValue());
+ m_defaultValueOverride = { };
}
String HTMLOutputElement::value() const
@@ -106,41 +88,28 @@
void HTMLOutputElement::setValue(const String& value)
{
- // The value mode flag set to "value" when the value attribute is set.
- m_isDefaultValueMode = false;
- if (value == this->value())
- return;
- setTextContentInternal(value);
+ m_defaultValueOverride = defaultValue();
+ stringReplaceAll(value);
}
String HTMLOutputElement::defaultValue() const
{
- return m_defaultValue;
+ return m_defaultValueOverride.isNull() ? textContent() : m_defaultValueOverride;
}
void HTMLOutputElement::setDefaultValue(const String& value)
{
- if (m_defaultValue == value)
- return;
- m_defaultValue = value;
- // The spec requires the value attribute set to the default value
- // when the element's value mode flag to "default".
- if (m_isDefaultValueMode)
- setTextContentInternal(value);
+ if (m_defaultValueOverride.isNull())
+ stringReplaceAll(value);
+ else
+ m_defaultValueOverride = value;
}
DOMTokenList& HTMLOutputElement::htmlFor()
{
- if (!m_tokens)
- m_tokens = makeUnique<DOMTokenList>(*this, forAttr);
- return *m_tokens;
+ if (!m_forTokens)
+ m_forTokens = makeUnique<DOMTokenList>(*this, forAttr);
+ return *m_forTokens;
}
-void HTMLOutputElement::setTextContentInternal(const String& value)
-{
- ASSERT(!m_isSetTextContentInProgress);
- m_isSetTextContentInProgress = true;
- setTextContent(value);
-}
-
} // namespace
Modified: trunk/Source/WebCore/html/HTMLOutputElement.h (277526 => 277527)
--- trunk/Source/WebCore/html/HTMLOutputElement.h 2021-05-15 01:50:00 UTC (rev 277526)
+++ trunk/Source/WebCore/html/HTMLOutputElement.h 2021-05-15 02:05:22 UTC (rev 277527)
@@ -1,5 +1,6 @@
/*
* Copyright (c) 2010 Google Inc. All rights reserved.
+ * Copyright (c) 2021 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -30,15 +31,17 @@
#pragma once
-#include "DOMTokenList.h"
#include "HTMLFormControlElement.h"
namespace WebCore {
+class DOMTokenList;
+
class HTMLOutputElement final : public HTMLFormControlElement {
WTF_MAKE_ISO_ALLOCATED(HTMLOutputElement);
public:
static Ref<HTMLOutputElement> create(const QualifiedName&, Document&, HTMLFormElement*);
+ static Ref<HTMLOutputElement> create(Document&);
String value() const;
void setValue(const String&);
@@ -46,11 +49,10 @@
void setDefaultValue(const String&);
DOMTokenList& htmlFor();
- bool canContainRangeEndPoint() const final { return false; }
-
private:
HTMLOutputElement(const QualifiedName&, Document&, HTMLFormElement*);
+ bool canContainRangeEndPoint() const final { return false; }
bool computeWillValidate() const final { return false; }
void parseAttribute(const QualifiedName&, const AtomString&) final;
const AtomString& formControlType() const final;
@@ -57,15 +59,10 @@
bool isEnumeratable() const final { return true; }
bool supportLabels() const final { return true; }
bool supportsFocus() const final;
- void childrenChanged(const ChildChange&) final;
void reset() final;
- void setTextContentInternal(const String&);
-
- bool m_isDefaultValueMode;
- bool m_isSetTextContentInProgress;
- String m_defaultValue;
- std::unique_ptr<DOMTokenList> m_tokens;
+ String m_defaultValueOverride;
+ std::unique_ptr<DOMTokenList> m_forTokens;
};
} // namespace WebCore
Modified: trunk/Source/WebCore/html/HTMLOutputElement.idl (277526 => 277527)
--- trunk/Source/WebCore/html/HTMLOutputElement.idl 2021-05-15 01:50:00 UTC (rev 277526)
+++ trunk/Source/WebCore/html/HTMLOutputElement.idl 2021-05-15 02:05:22 UTC (rev 277527)
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2010 Google Inc. All rights reserved.
+ * Copyright (C) 2021 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -25,14 +26,15 @@
[
Exposed=Window
] interface HTMLOutputElement : HTMLElement {
- [PutForwards=value] readonly attribute DOMTokenList htmlFor;
+ [CallWith=Document, HTMLConstructor] constructor();
- readonly attribute HTMLFormElement form;
+ [SameObject, PutForwards=value] readonly attribute DOMTokenList htmlFor;
+ readonly attribute HTMLFormElement? form;
[CEReactions=NotNeeded, Reflect] attribute DOMString name;
readonly attribute DOMString type;
- [CEReactions] attribute [LegacyNullToEmptyString] DOMString defaultValue;
- [CEReactions] attribute [LegacyNullToEmptyString] DOMString value;
+ [CEReactions] attribute DOMString defaultValue;
+ [CEReactions] attribute DOMString value;
readonly attribute boolean willValidate;
readonly attribute ValidityState validity;