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

Unified Diff: Source/core/html/HTMLElement.cpp

Issue 243403006: Implement contextmenu attribute with basic support of <menu> (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Added test for RelatedEvent constructors Created 6 years, 4 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
Index: Source/core/html/HTMLElement.cpp
diff --git a/Source/core/html/HTMLElement.cpp b/Source/core/html/HTMLElement.cpp
index 27946c5916c246c3fad01ed76b68b23c42353bb5..0773516c173607e1d9d9db5ab7b21d818a937894 100644
--- a/Source/core/html/HTMLElement.cpp
+++ b/Source/core/html/HTMLElement.cpp
@@ -48,6 +48,7 @@
#include "core/html/HTMLBRElement.h"
#include "core/html/HTMLFormElement.h"
#include "core/html/HTMLInputElement.h"
+#include "core/html/HTMLMenuElement.h"
#include "core/html/HTMLTemplateElement.h"
#include "core/html/HTMLTextFormControlElement.h"
#include "core/html/parser/HTMLParserIdioms.h"
@@ -900,6 +901,24 @@ bool HTMLElement::isInteractiveContent() const
return false;
}
+HTMLMenuElement* HTMLElement::contextMenu() const
+{
+ const AtomicString& contextMenuId(fastGetAttribute(contextmenuAttr));
+ if (!contextMenuId.isNull()) {
+ Element* element = treeScope().getElementById(contextMenuId);
+ return isHTMLMenuElement(element) ? toHTMLMenuElement(element) : nullptr;
+ }
+
+ return nullptr;
+}
+
+void HTMLElement::setContextMenu(HTMLMenuElement* contextMenu)
+{
+ const AtomicString& contextMenuId(contextMenu->fastGetAttribute(idAttr));
+ if (!contextMenuId.isNull() && contextMenu->inDocument())
+ setAttribute(contextmenuAttr, contextMenuId);
+}
+
void HTMLElement::defaultEventHandler(Event* event)
{
if (event->type() == EventTypeNames::keypress && event->isKeyboardEvent()) {

Powered by Google App Engine
This is Rietveld 408576698