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

Side by Side Diff: Source/core/html/HTMLElement.cpp

Issue 464903002: Add contextmenu attribute for HTMLElement. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: 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
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 833 matching lines...) Expand 10 before | Expand all | Expand 10 after
894 parsedColor.setRGB(parseColorStringWithCrazyLegacyRules(colorString)); 895 parsedColor.setRGB(parseColorStringWithCrazyLegacyRules(colorString));
895 896
896 style->setProperty(propertyID, cssValuePool().createColorValue(parsedColor.r gb())); 897 style->setProperty(propertyID, cssValuePool().createColorValue(parsedColor.r gb()));
897 } 898 }
898 899
899 bool HTMLElement::isInteractiveContent() const 900 bool HTMLElement::isInteractiveContent() const
900 { 901 {
901 return false; 902 return false;
902 } 903 }
903 904
905
906 HTMLMenuElement* HTMLElement::contextMenu() const
907 {
908 const AtomicString& contextMenuId(fastGetAttribute(contextmenuAttr));
909 if (contextMenuId.isNull())
910 return nullptr;
911
912 Element* element = treeScope().getElementById(contextMenuId);
913 return isHTMLMenuElement(element) ? toHTMLMenuElement(element) : nullptr;
pals 2014/08/17 17:18:13 Specification http://www.whatwg.org/specs/web-apps
tkent 2014/08/18 02:24:52 Off topic: Please refer to multipage version URL.
pals 2014/08/18 14:23:24 Done.
914 }
915
916 void HTMLElement::setContextMenu(HTMLMenuElement* contextMenu)
917 {
918 if (!contextMenu)
919 return;
920
921 const AtomicString& contextMenuId(contextMenu->fastGetAttribute(idAttr));
922 const AtomicString& contextMenuType(contextMenu->fastGetAttribute(typeAttr)) ;
923
924 if (!contextMenuId.isNull() && equalIgnoringCase(contextMenuType, "popup") & & contextMenu->inDocument())
pals 2014/08/17 17:18:13 http://www.whatwg.org/specs/web-apps/current-work/
tkent 2014/08/18 02:24:52 You misread the specification. This paragraph is
tkent 2014/08/18 02:27:27 reject IDs of <menu type=popup> -> reject IDs of *
pals 2014/08/18 14:23:24 Done.
925 setAttribute(contextmenuAttr, contextMenuId);
926 else
927 setAttribute(contextmenuAttr, "");
pals 2014/08/17 17:18:13 Specification http://www.whatwg.org/specs/web-apps
tkent 2014/08/18 02:24:52 "same home subtree" means we need to check treeSco
pals 2014/08/18 14:23:24 Done. I was doing inDocument() check. Also added a
928 }
929
904 void HTMLElement::defaultEventHandler(Event* event) 930 void HTMLElement::defaultEventHandler(Event* event)
905 { 931 {
906 if (event->type() == EventTypeNames::keypress && event->isKeyboardEvent()) { 932 if (event->type() == EventTypeNames::keypress && event->isKeyboardEvent()) {
907 handleKeypressEvent(toKeyboardEvent(event)); 933 handleKeypressEvent(toKeyboardEvent(event));
908 if (event->defaultHandled()) 934 if (event->defaultHandled())
909 return; 935 return;
910 } 936 }
911 937
912 Element::defaultEventHandler(event); 938 Element::defaultEventHandler(event);
913 } 939 }
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
959 #ifndef NDEBUG 985 #ifndef NDEBUG
960 986
961 // For use in the debugger 987 // For use in the debugger
962 void dumpInnerHTML(blink::HTMLElement*); 988 void dumpInnerHTML(blink::HTMLElement*);
963 989
964 void dumpInnerHTML(blink::HTMLElement* element) 990 void dumpInnerHTML(blink::HTMLElement* element)
965 { 991 {
966 printf("%s\n", element->innerHTML().ascii().data()); 992 printf("%s\n", element->innerHTML().ascii().data());
967 } 993 }
968 #endif 994 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698