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

Side by Side 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: Reflect HTMLMenuElement as per spec 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 unified diff | Download patch
« no previous file with comments | « Source/core/html/HTMLElement.h ('k') | Source/core/html/HTMLElement.idl » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) 3 * (C) 1999 Antti Koivisto (koivisto@kde.org)
4 * Copyright (C) 2004-2008, 2013, 2014 Apple Inc. All rights reserved. 4 * Copyright (C) 2004-2008, 2013, 2014 Apple Inc. All rights reserved.
5 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmo bile.com/) 5 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmo bile.com/)
6 * Copyright (C) 2011 Motorola Mobility. All rights reserved. 6 * Copyright (C) 2011 Motorola Mobility. All rights reserved.
7 * 7 *
8 * This library is free software; you can redistribute it and/or 8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Library General Public 9 * modify it under the terms of the GNU Library General Public
10 * License as published by the Free Software Foundation; either 10 * License as published by the Free Software Foundation; either
(...skipping 30 matching lines...) Expand all
41 #include "core/dom/Text.h" 41 #include "core/dom/Text.h"
42 #include "core/dom/shadow/ElementShadow.h" 42 #include "core/dom/shadow/ElementShadow.h"
43 #include "core/dom/shadow/ShadowRoot.h" 43 #include "core/dom/shadow/ShadowRoot.h"
44 #include "core/editing/markup.h" 44 #include "core/editing/markup.h"
45 #include "core/events/EventListener.h" 45 #include "core/events/EventListener.h"
46 #include "core/events/KeyboardEvent.h" 46 #include "core/events/KeyboardEvent.h"
47 #include "core/frame/Settings.h" 47 #include "core/frame/Settings.h"
48 #include "core/html/HTMLBRElement.h" 48 #include "core/html/HTMLBRElement.h"
49 #include "core/html/HTMLFormElement.h" 49 #include "core/html/HTMLFormElement.h"
50 #include "core/html/HTMLInputElement.h" 50 #include "core/html/HTMLInputElement.h"
51 #include "core/html/HTMLMenuElement.h"
51 #include "core/html/HTMLTemplateElement.h" 52 #include "core/html/HTMLTemplateElement.h"
52 #include "core/html/HTMLTextFormControlElement.h" 53 #include "core/html/HTMLTextFormControlElement.h"
53 #include "core/html/parser/HTMLParserIdioms.h" 54 #include "core/html/parser/HTMLParserIdioms.h"
54 #include "core/rendering/RenderObject.h" 55 #include "core/rendering/RenderObject.h"
55 #include "platform/text/BidiResolver.h" 56 #include "platform/text/BidiResolver.h"
56 #include "platform/text/BidiTextRun.h" 57 #include "platform/text/BidiTextRun.h"
57 #include "platform/text/TextRunIterator.h" 58 #include "platform/text/TextRunIterator.h"
58 #include "wtf/StdLibExtras.h" 59 #include "wtf/StdLibExtras.h"
59 #include "wtf/text/CString.h" 60 #include "wtf/text/CString.h"
60 61
(...skipping 832 matching lines...) Expand 10 before | Expand all | Expand 10 after
893 parsedColor.setRGB(parseColorStringWithCrazyLegacyRules(colorString)); 894 parsedColor.setRGB(parseColorStringWithCrazyLegacyRules(colorString));
894 895
895 style->setProperty(propertyID, cssValuePool().createColorValue(parsedColor.r gb())); 896 style->setProperty(propertyID, cssValuePool().createColorValue(parsedColor.r gb()));
896 } 897 }
897 898
898 bool HTMLElement::isInteractiveContent() const 899 bool HTMLElement::isInteractiveContent() const
899 { 900 {
900 return false; 901 return false;
901 } 902 }
902 903
904 HTMLMenuElement* HTMLElement::contextMenu() const
905 {
906 const AtomicString& contextMenuId(fastGetAttribute(contextmenuAttr));
907 if (contextMenuId.isNull())
908 return nullptr;
909
910 Element* element = treeScope().getElementById(contextMenuId);
911 return isHTMLMenuElement(element) ? toHTMLMenuElement(element) : nullptr;
912 }
913
914 void HTMLElement::setContextMenu(HTMLMenuElement* contextMenu)
915 {
916 const AtomicString& contextMenuId(contextMenu->fastGetAttribute(idAttr));
917 if (!contextMenuId.isNull() && contextMenu->inDocument())
918 setAttribute(contextmenuAttr, contextMenuId);
919 else
920 setAttribute(contextmenuAttr, "");
921 }
922
903 void HTMLElement::defaultEventHandler(Event* event) 923 void HTMLElement::defaultEventHandler(Event* event)
904 { 924 {
905 if (event->type() == EventTypeNames::keypress && event->isKeyboardEvent()) { 925 if (event->type() == EventTypeNames::keypress && event->isKeyboardEvent()) {
906 handleKeypressEvent(toKeyboardEvent(event)); 926 handleKeypressEvent(toKeyboardEvent(event));
907 if (event->defaultHandled()) 927 if (event->defaultHandled())
908 return; 928 return;
909 } 929 }
910 930
911 Element::defaultEventHandler(event); 931 Element::defaultEventHandler(event);
912 } 932 }
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
958 #ifndef NDEBUG 978 #ifndef NDEBUG
959 979
960 // For use in the debugger 980 // For use in the debugger
961 void dumpInnerHTML(blink::HTMLElement*); 981 void dumpInnerHTML(blink::HTMLElement*);
962 982
963 void dumpInnerHTML(blink::HTMLElement* element) 983 void dumpInnerHTML(blink::HTMLElement* element)
964 { 984 {
965 printf("%s\n", element->innerHTML().ascii().data()); 985 printf("%s\n", element->innerHTML().ascii().data());
966 } 986 }
967 #endif 987 #endif
OLDNEW
« no previous file with comments | « Source/core/html/HTMLElement.h ('k') | Source/core/html/HTMLElement.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698