mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
Remove interactive content and form related API from HTMLElement.
In particular this inlines the accessKeyAction, removes isInteractiveContent() which was for special casing certain elements in event dispatch, and removes eventParameterName() which was only needed for inline event handlers. I also moved Node::commonAncestor into NodeRenderingTraversal, the only callers of it passed NodeRenderingTraversal::parent as the second argument, it didn't make sense to have this generic thing. R=abarth@chromium.org, ojan@chromium.org Review URL: https://codereview.chromium.org/693243002
This commit is contained in:
parent
22d5eed1dd
commit
c0bf67d1f9
@ -228,8 +228,6 @@ public:
|
||||
AtomicString computeInheritedLanguage() const;
|
||||
Locale& locale() const;
|
||||
|
||||
virtual void accessKeyAction(bool /*sendToAnyEvent*/) { }
|
||||
|
||||
virtual bool isURLAttribute(const Attribute&) const { return false; }
|
||||
|
||||
virtual bool isLiveLink() const { return false; }
|
||||
|
||||
@ -752,43 +752,6 @@ bool Node::containsIncludingHostElements(const Node& node) const
|
||||
return false;
|
||||
}
|
||||
|
||||
Node* Node::commonAncestor(const Node& other, Node* (*parent)(const Node&))
|
||||
{
|
||||
if (this == other)
|
||||
return this;
|
||||
if (document() != other.document())
|
||||
return 0;
|
||||
int thisDepth = 0;
|
||||
for (Node* node = this; node; node = parent(*node)) {
|
||||
if (node == &other)
|
||||
return node;
|
||||
thisDepth++;
|
||||
}
|
||||
int otherDepth = 0;
|
||||
for (const Node* node = &other; node; node = parent(*node)) {
|
||||
if (node == this)
|
||||
return this;
|
||||
otherDepth++;
|
||||
}
|
||||
Node* thisIterator = this;
|
||||
const Node* otherIterator = &other;
|
||||
if (thisDepth > otherDepth) {
|
||||
for (int i = thisDepth; i > otherDepth; --i)
|
||||
thisIterator = parent(*thisIterator);
|
||||
} else if (otherDepth > thisDepth) {
|
||||
for (int i = otherDepth; i > thisDepth; --i)
|
||||
otherIterator = parent(*otherIterator);
|
||||
}
|
||||
while (thisIterator) {
|
||||
if (thisIterator == otherIterator)
|
||||
return thisIterator;
|
||||
thisIterator = parent(*thisIterator);
|
||||
otherIterator = parent(*otherIterator);
|
||||
}
|
||||
ASSERT(!otherIterator);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void Node::reattach(const AttachContext& context)
|
||||
{
|
||||
AttachContext reattachContext(context);
|
||||
|
||||
@ -404,7 +404,6 @@ public:
|
||||
bool contains(const Node*) const;
|
||||
bool containsIncludingShadowDOM(const Node*) const;
|
||||
bool containsIncludingHostElements(const Node&) const;
|
||||
Node* commonAncestor(const Node&, Node* (*parent)(const Node&));
|
||||
|
||||
// Used to determine whether range offsets use characters or node indices.
|
||||
virtual bool offsetInCharacters() const;
|
||||
|
||||
@ -137,6 +137,43 @@ RenderObject* previousSiblingRenderer(const Node* node)
|
||||
return 0;
|
||||
}
|
||||
|
||||
Node* commonAncestor(Node& a, Node& b)
|
||||
{
|
||||
if (a == b)
|
||||
return &a;
|
||||
if (a.document() != b.document())
|
||||
return 0;
|
||||
int thisDepth = 0;
|
||||
for (Node* node = &a; node; node = parent(node)) {
|
||||
if (node == b)
|
||||
return node;
|
||||
thisDepth++;
|
||||
}
|
||||
int otherDepth = 0;
|
||||
for (const Node* node = &b; node; node = parent(node)) {
|
||||
if (node == a)
|
||||
return &a;
|
||||
otherDepth++;
|
||||
}
|
||||
Node* thisIterator = &a;
|
||||
const Node* otherIterator = &b;
|
||||
if (thisDepth > otherDepth) {
|
||||
for (int i = thisDepth; i > otherDepth; --i)
|
||||
thisIterator = parent(thisIterator);
|
||||
} else if (otherDepth > thisDepth) {
|
||||
for (int i = otherDepth; i > thisDepth; --i)
|
||||
otherIterator = parent(otherIterator);
|
||||
}
|
||||
while (thisIterator) {
|
||||
if (thisIterator == otherIterator)
|
||||
return thisIterator;
|
||||
thisIterator = parent(thisIterator);
|
||||
otherIterator = parent(otherIterator);
|
||||
}
|
||||
ASSERT(!otherIterator);
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
@ -61,6 +61,7 @@ Node* nextSibling(const Node*);
|
||||
Node* previousSibling(const Node*);
|
||||
Node* previous(const Node*, const Node* stayWithin);
|
||||
Node* next(const Node*, const Node* stayWithin);
|
||||
Node* commonAncestor(Node&, Node&);
|
||||
RenderObject* nextSiblingRenderer(const Node*);
|
||||
RenderObject* previousSiblingRenderer(const Node*);
|
||||
|
||||
|
||||
@ -148,9 +148,4 @@ bool HTMLAnchorElement::willRespondToMouseClickEvents()
|
||||
return isLiveLink();
|
||||
}
|
||||
|
||||
bool HTMLAnchorElement::isInteractiveContent() const
|
||||
{
|
||||
return isLiveLink();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -52,7 +52,6 @@ private:
|
||||
virtual bool isURLAttribute(const Attribute&) const override final;
|
||||
virtual bool hasLegalLinkAttribute(const QualifiedName&) const override final;
|
||||
virtual bool canStartSelection() const override final;
|
||||
virtual bool isInteractiveContent() const override final;
|
||||
|
||||
void handleClick(Event*);
|
||||
};
|
||||
|
||||
@ -84,11 +84,6 @@ void HTMLElement::click()
|
||||
dispatchSimulatedClick(0, SendNoEvents);
|
||||
}
|
||||
|
||||
void HTMLElement::accessKeyAction(bool sendMouseEvents)
|
||||
{
|
||||
dispatchSimulatedClick(0, sendMouseEvents ? SendMouseUpDownEvents : SendNoEvents);
|
||||
}
|
||||
|
||||
String HTMLElement::title() const
|
||||
{
|
||||
return getAttribute(HTMLNames::titleAttr);
|
||||
@ -130,17 +125,6 @@ void HTMLElement::setDir(const AtomicString& value)
|
||||
setAttribute(HTMLNames::dirAttr, value);
|
||||
}
|
||||
|
||||
bool HTMLElement::isInteractiveContent() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
const AtomicString& HTMLElement::eventParameterName()
|
||||
{
|
||||
DEFINE_STATIC_LOCAL(const AtomicString, eventString, ("event", AtomicString::ConstructFromLiteral));
|
||||
return eventString;
|
||||
}
|
||||
|
||||
v8::Handle<v8::Object> HTMLElement::wrap(v8::Handle<v8::Object> creationContext, v8::Isolate* isolate)
|
||||
{
|
||||
return createV8HTMLWrapper(this, creationContext, isolate);
|
||||
|
||||
@ -50,14 +50,6 @@ public:
|
||||
|
||||
void click();
|
||||
|
||||
virtual void accessKeyAction(bool sendMouseEvents) override;
|
||||
|
||||
virtual bool isLabelable() const { return false; }
|
||||
// http://www.whatwg.org/specs/web-apps/current-work/multipage/elements.html#interactive-content
|
||||
virtual bool isInteractiveContent() const;
|
||||
|
||||
static const AtomicString& eventParameterName();
|
||||
|
||||
virtual v8::Handle<v8::Object> wrap(v8::Handle<v8::Object> creationContext, v8::Isolate*) override;
|
||||
|
||||
protected:
|
||||
|
||||
@ -464,11 +464,6 @@ Image* HTMLImageElement::imageContents()
|
||||
return imageLoader().image()->image();
|
||||
}
|
||||
|
||||
bool HTMLImageElement::isInteractiveContent() const
|
||||
{
|
||||
return hasAttribute(HTMLNames::usemapAttr);
|
||||
}
|
||||
|
||||
PassRefPtr<Image> HTMLImageElement::getSourceImageForCanvas(SourceImageMode, SourceImageStatus* status) const
|
||||
{
|
||||
if (!complete() || !cachedImage()) {
|
||||
|
||||
@ -111,7 +111,6 @@ private:
|
||||
|
||||
virtual InsertionNotificationRequest insertedInto(ContainerNode*) override;
|
||||
virtual void removedFrom(ContainerNode*) override;
|
||||
virtual bool isInteractiveContent() const override;
|
||||
virtual Image* imageContents() override;
|
||||
|
||||
ImageCandidate findBestFitImageFromPictureParent();
|
||||
|
||||
@ -2414,11 +2414,6 @@ void HTMLMediaElement::mediaPlayerMediaSourceOpened(blink::WebMediaSource* webMe
|
||||
m_mediaSource->setWebMediaSourceAndOpen(adoptPtr(webMediaSource));
|
||||
}
|
||||
|
||||
bool HTMLMediaElement::isInteractiveContent() const
|
||||
{
|
||||
return hasAttribute(HTMLNames::controlsAttr);
|
||||
}
|
||||
|
||||
void HTMLMediaElement::defaultEventHandler(Event* event)
|
||||
{
|
||||
HTMLElement::defaultEventHandler(event);
|
||||
|
||||
@ -209,7 +209,6 @@ private:
|
||||
virtual void removedFrom(ContainerNode*) override final;
|
||||
virtual void didRecalcStyle(StyleRecalcChange) override final;
|
||||
|
||||
virtual bool isInteractiveContent() const override final;
|
||||
virtual void defaultEventHandler(Event*) override final;
|
||||
|
||||
// ActiveDOMObject functions.
|
||||
|
||||
@ -1246,15 +1246,6 @@ void EventHandler::invalidateClick()
|
||||
m_clickNode = nullptr;
|
||||
}
|
||||
|
||||
static Node* parentForClickEvent(const Node& node)
|
||||
{
|
||||
// IE doesn't dispatch click events for mousedown/mouseup events across form
|
||||
// controls.
|
||||
if (node.isHTMLElement() && toHTMLElement(node).isInteractiveContent())
|
||||
return 0;
|
||||
return NodeRenderingTraversal::parent(&node);
|
||||
}
|
||||
|
||||
bool EventHandler::handleMouseReleaseEvent(const PlatformMouseEvent& mouseEvent)
|
||||
{
|
||||
TRACE_EVENT0("blink", "EventHandler::handleMouseReleaseEvent");
|
||||
@ -1293,7 +1284,7 @@ bool EventHandler::handleMouseReleaseEvent(const PlatformMouseEvent& mouseEvent)
|
||||
|
||||
bool swallowClickEvent = false;
|
||||
if (m_clickCount > 0 && mev.targetNode() && m_clickNode) {
|
||||
if (Node* clickTargetNode = mev.targetNode()->commonAncestor(*m_clickNode, parentForClickEvent))
|
||||
if (Node* clickTargetNode = NodeRenderingTraversal::commonAncestor(*mev.targetNode(), *m_clickNode))
|
||||
swallowClickEvent = !dispatchMouseEvent(EventTypeNames::click, clickTargetNode, m_clickCount, mouseEvent, true);
|
||||
}
|
||||
|
||||
@ -1770,7 +1761,7 @@ bool EventHandler::handleGestureTap(const GestureEventWithHitTestResults& target
|
||||
bool swallowClickEvent = false;
|
||||
if (m_clickNode) {
|
||||
if (currentHitTest.innerNode()) {
|
||||
Node* clickTargetNode = currentHitTest.innerNode()->commonAncestor(*m_clickNode, parentForClickEvent);
|
||||
Node* clickTargetNode = NodeRenderingTraversal::commonAncestor(*currentHitTest.innerNode(), *m_clickNode);
|
||||
swallowClickEvent = !dispatchMouseEvent(EventTypeNames::click, clickTargetNode, gestureEvent.tapCount(), fakeMouseUp, true);
|
||||
}
|
||||
m_clickNode = nullptr;
|
||||
@ -2270,7 +2261,9 @@ bool EventHandler::handleAccessKey(const PlatformKeyboardEvent& evt)
|
||||
Element* elem = m_frame->document()->getElementByAccessKey(key.lower());
|
||||
if (!elem)
|
||||
return false;
|
||||
elem->accessKeyAction(false);
|
||||
// FIXME(sky): We should probably pass SendMouseUpDownEvents here, not
|
||||
// firing mouseup and mousedown is IE legacy.
|
||||
elem->dispatchSimulatedClick(0, SendNoEvents);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user