Title: [200557] trunk/Source/WebCore
- Revision
- 200557
- Author
- [email protected]
- Date
- 2016-05-08 11:35:23 -0700 (Sun, 08 May 2016)
Log Message
Change HTMLSlotElement::assignedNodes to take a IDL dictionary instead of a WebCore::Dictionary
https://bugs.webkit.org/show_bug.cgi?id=157457
Reviewed by Chris Dumez.
* html/HTMLSlotElement.cpp:
(WebCore::HTMLSlotElement::removedFrom): Fixed typo in comment.
(WebCore::HTMLSlotElement::assignedNodes): Renamed assignedNodesForBindings back to this
and changed the argument type to Optional<AssignedNodesOptions> instead of Dictionary.
Also streamlined the logic a bit.
(WebCore::HTMLSlotElement::enqueueSlotChangeEvent): Changed to use a pointer to the
enqueued event instead of a boolean. With only a boolean, we could end up clearing the
flag in cases where we don't really want to.
(WebCore::HTMLSlotElement::dispatchEvent): Ditto.
(WebCore::HTMLSlotElement::assignedNodesForBindings): Deleted.
* html/HTMLSlotElement.h: Use pragma once. Added AssignedNodeOptions. Changed for the
above, including changing the data member.
* html/HTMLSlotElement.idl: Removed use of ImplementedAs. Fixed the type of the options
dictionary.
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (200556 => 200557)
--- trunk/Source/WebCore/ChangeLog 2016-05-08 18:29:04 UTC (rev 200556)
+++ trunk/Source/WebCore/ChangeLog 2016-05-08 18:35:23 UTC (rev 200557)
@@ -1,3 +1,25 @@
+2016-05-07 Darin Adler <[email protected]>
+
+ Change HTMLSlotElement::assignedNodes to take a IDL dictionary instead of a WebCore::Dictionary
+ https://bugs.webkit.org/show_bug.cgi?id=157457
+
+ Reviewed by Chris Dumez.
+
+ * html/HTMLSlotElement.cpp:
+ (WebCore::HTMLSlotElement::removedFrom): Fixed typo in comment.
+ (WebCore::HTMLSlotElement::assignedNodes): Renamed assignedNodesForBindings back to this
+ and changed the argument type to Optional<AssignedNodesOptions> instead of Dictionary.
+ Also streamlined the logic a bit.
+ (WebCore::HTMLSlotElement::enqueueSlotChangeEvent): Changed to use a pointer to the
+ enqueued event instead of a boolean. With only a boolean, we could end up clearing the
+ flag in cases where we don't really want to.
+ (WebCore::HTMLSlotElement::dispatchEvent): Ditto.
+ (WebCore::HTMLSlotElement::assignedNodesForBindings): Deleted.
+ * html/HTMLSlotElement.h: Use pragma once. Added AssignedNodeOptions. Changed for the
+ above, including changing the data member.
+ * html/HTMLSlotElement.idl: Removed use of ImplementedAs. Fixed the type of the options
+ dictionary.
+
2016-05-08 Chris Dumez <[email protected]>
[Bindings] Add convert<>() template specializations for integer types
Modified: trunk/Source/WebCore/html/HTMLSlotElement.cpp (200556 => 200557)
--- trunk/Source/WebCore/html/HTMLSlotElement.cpp 2016-05-08 18:29:04 UTC (rev 200556)
+++ trunk/Source/WebCore/html/HTMLSlotElement.cpp 2016-05-08 18:35:23 UTC (rev 200557)
@@ -28,8 +28,6 @@
#if ENABLE(SHADOW_DOM) || ENABLE(DETAILS_ELEMENT)
-#include "Dictionary.h"
-#include "ElementChildIterator.h"
#include "Event.h"
#include "EventNames.h"
#include "HTMLNames.h"
@@ -68,7 +66,7 @@
void HTMLSlotElement::removedFrom(ContainerNode& insertionPoint)
{
- // ContainerNode::removeBetween always sets the removed chid's tree scope to Document's but InShadowRoot flag is unset in Node::removedFrom.
+ // ContainerNode::removeBetween always sets the removed child's tree scope to Document's but InShadowRoot flag is unset in Node::removedFrom.
// So if InShadowRoot flag is set but this element's tree scope is Document's, this element has just been removed from a shadow root.
if (insertionPoint.isInShadowTree() && isInShadowTree() && &treeScope() == &document()) {
auto* oldShadowRoot = insertionPoint.containingShadowRoot();
@@ -112,42 +110,37 @@
}
}
-const Vector<Node*> HTMLSlotElement::assignedNodesForBindings(const Dictionary& options) const
+Vector<Node*> HTMLSlotElement::assignedNodes(const AssignedNodesOptions& options) const
{
- bool shouldFlatten = false;
- options.get("flatten", shouldFlatten);
-
- Vector<Node*> nodes;
auto* assignedNodes = this->assignedNodes();
if (!assignedNodes)
- return nodes;
+ return { };
- if (shouldFlatten)
- flattenAssignedNodes(nodes, *assignedNodes);
- else
- nodes = *assignedNodes;
+ if (!options.flatten)
+ return *assignedNodes;
+ Vector<Node*> nodes;
+ flattenAssignedNodes(nodes, *assignedNodes);
return nodes;
}
void HTMLSlotElement::enqueueSlotChangeEvent()
{
- if (m_hasEnqueuedSlotChangeEvent)
+ if (m_enqueuedSlotChangeEvent)
return;
bool bubbles = false;
bool cancelable = false;
auto event = Event::create(eventNames().slotchangeEvent, bubbles, cancelable);
event->setTarget(this);
+ m_enqueuedSlotChangeEvent = event.ptr();
document().enqueueSlotchangeEvent(WTFMove(event));
-
- m_hasEnqueuedSlotChangeEvent = true;
}
bool HTMLSlotElement::dispatchEvent(Event& event)
{
- if (event.type() == eventNames().slotchangeEvent)
- m_hasEnqueuedSlotChangeEvent = false;
+ if (&event == m_enqueuedSlotChangeEvent)
+ m_enqueuedSlotChangeEvent = nullptr;
return HTMLElement::dispatchEvent(event);
}
Modified: trunk/Source/WebCore/html/HTMLSlotElement.h (200556 => 200557)
--- trunk/Source/WebCore/html/HTMLSlotElement.h 2016-05-08 18:29:04 UTC (rev 200556)
+++ trunk/Source/WebCore/html/HTMLSlotElement.h 2016-05-08 18:35:23 UTC (rev 200557)
@@ -23,13 +23,11 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef HTMLSlotElement_h
-#define HTMLSlotElement_h
+#pragma once
#if ENABLE(SHADOW_DOM) || ENABLE(DETAILS_ELEMENT)
#include "HTMLElement.h"
-#include "Range.h"
namespace WebCore {
@@ -38,23 +36,24 @@
static Ref<HTMLSlotElement> create(const QualifiedName&, Document&);
const Vector<Node*>* assignedNodes() const;
- const Vector<Node*> assignedNodesForBindings(const Dictionary& options) const;
+ struct AssignedNodesOptions {
+ bool flatten;
+ };
+ Vector<Node*> assignedNodes(const AssignedNodesOptions&) const;
void enqueueSlotChangeEvent();
private:
HTMLSlotElement(const QualifiedName&, Document&);
- InsertionNotificationRequest insertedInto(ContainerNode&) override;
- void removedFrom(ContainerNode&) override;
- void attributeChanged(const QualifiedName&, const AtomicString& oldValue, const AtomicString& newValue, AttributeModificationReason) override;
+ InsertionNotificationRequest insertedInto(ContainerNode&) final;
+ void removedFrom(ContainerNode&) final;
+ void attributeChanged(const QualifiedName&, const AtomicString& oldValue, const AtomicString& newValue, AttributeModificationReason) final;
+ bool dispatchEvent(Event&) final;
- bool dispatchEvent(Event&) override;
-
- bool m_hasEnqueuedSlotChangeEvent { false };
+ Event* m_enqueuedSlotChangeEvent { nullptr };
};
}
#endif
-#endif
Modified: trunk/Source/WebCore/html/HTMLSlotElement.idl (200556 => 200557)
--- trunk/Source/WebCore/html/HTMLSlotElement.idl 2016-05-08 18:29:04 UTC (rev 200556)
+++ trunk/Source/WebCore/html/HTMLSlotElement.idl 2016-05-08 18:35:23 UTC (rev 200557)
@@ -23,14 +23,15 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-// https://w3c.github.io/webcomponents/spec/shadow/#idl-def-HTMLSlotElement
[
Conditional=SHADOW_DOM,
EnabledAtRuntime=ShadowDOM,
JSGenerateToNativeObject
] interface HTMLSlotElement : HTMLElement {
-
[Reflect] attribute DOMString name;
- [ImplementedAs=assignedNodesForBindings] sequence<Node> assignedNodes(optional Dictionary options);
+ sequence<Node> assignedNodes(optional AssignedNodesOptions options);
+};
+dictionary AssignedNodesOptions {
+ boolean flatten = false;
};
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes