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

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

Issue 2905763003: Rollback ContextMenu (Closed)
Patch Set: Rebase Created 3 years, 6 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. 5 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved.
6 * (http://www.torchmobile.com/) 6 * (http://www.torchmobile.com/)
7 * Copyright (C) 2011 Motorola Mobility. All rights reserved. 7 * Copyright (C) 2011 Motorola Mobility. All rights reserved.
8 * 8 *
9 * This library is free software; you can redistribute it and/or 9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Library General Public 10 * modify it under the terms of the GNU Library General Public
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 #include "core/editing/spellcheck/SpellChecker.h" 50 #include "core/editing/spellcheck/SpellChecker.h"
51 #include "core/events/EventListener.h" 51 #include "core/events/EventListener.h"
52 #include "core/events/KeyboardEvent.h" 52 #include "core/events/KeyboardEvent.h"
53 #include "core/frame/Settings.h" 53 #include "core/frame/Settings.h"
54 #include "core/frame/UseCounter.h" 54 #include "core/frame/UseCounter.h"
55 #include "core/frame/csp/ContentSecurityPolicy.h" 55 #include "core/frame/csp/ContentSecurityPolicy.h"
56 #include "core/html/HTMLBRElement.h" 56 #include "core/html/HTMLBRElement.h"
57 #include "core/html/HTMLDimension.h" 57 #include "core/html/HTMLDimension.h"
58 #include "core/html/HTMLFormElement.h" 58 #include "core/html/HTMLFormElement.h"
59 #include "core/html/HTMLInputElement.h" 59 #include "core/html/HTMLInputElement.h"
60 #include "core/html/HTMLMenuElement.h"
61 #include "core/html/HTMLTemplateElement.h" 60 #include "core/html/HTMLTemplateElement.h"
62 #include "core/html/parser/HTMLParserIdioms.h" 61 #include "core/html/parser/HTMLParserIdioms.h"
63 #include "core/layout/LayoutBoxModelObject.h" 62 #include "core/layout/LayoutBoxModelObject.h"
64 #include "core/layout/LayoutObject.h" 63 #include "core/layout/LayoutObject.h"
65 #include "core/page/SpatialNavigation.h" 64 #include "core/page/SpatialNavigation.h"
66 #include "core/svg/SVGSVGElement.h" 65 #include "core/svg/SVGSVGElement.h"
67 #include "platform/Language.h" 66 #include "platform/Language.h"
68 #include "platform/text/BidiResolver.h" 67 #include "platform/text/BidiResolver.h"
69 #include "platform/text/BidiTextRun.h" 68 #include "platform/text/BidiTextRun.h"
70 #include "platform/text/TextRunIterator.h" 69 #include "platform/text/TextRunIterator.h"
(...skipping 990 matching lines...) Expand 10 before | Expand all | Expand 10 after
1061 if (!ParseColorWithLegacyRules(attribute_value, parsed_color)) 1060 if (!ParseColorWithLegacyRules(attribute_value, parsed_color))
1062 return; 1061 return;
1063 1062
1064 style->SetProperty(property_id, *CSSColorValue::Create(parsed_color.Rgb())); 1063 style->SetProperty(property_id, *CSSColorValue::Create(parsed_color.Rgb()));
1065 } 1064 }
1066 1065
1067 bool HTMLElement::IsInteractiveContent() const { 1066 bool HTMLElement::IsInteractiveContent() const {
1068 return false; 1067 return false;
1069 } 1068 }
1070 1069
1071 HTMLMenuElement* HTMLElement::AssignedContextMenu() const {
1072 if (HTMLMenuElement* menu = contextMenu())
1073 return menu;
1074
1075 return parentElement() && parentElement()->IsHTMLElement()
1076 ? ToHTMLElement(parentElement())->AssignedContextMenu()
1077 : nullptr;
1078 }
1079
1080 HTMLMenuElement* HTMLElement::contextMenu() const {
1081 const AtomicString& context_menu_id(FastGetAttribute(contextmenuAttr));
1082 if (context_menu_id.IsNull())
1083 return nullptr;
1084
1085 Element* element = GetTreeScope().getElementById(context_menu_id);
1086 // Not checking if the menu element is of type "popup".
1087 // Ignoring menu element type attribute is intentional according to the
1088 // standard.
1089 return isHTMLMenuElement(element) ? toHTMLMenuElement(element) : nullptr;
1090 }
1091
1092 void HTMLElement::setContextMenu(HTMLMenuElement* context_menu) {
1093 if (!context_menu) {
1094 setAttribute(contextmenuAttr, "");
1095 return;
1096 }
1097
1098 // http://www.whatwg.org/specs/web-apps/current-work/multipage/infrastructure. html#reflecting-content-attributes-in-idl-attributes
1099 // On setting, if the given element has an id attribute, and has the same home
1100 // subtree as the element of the attribute being set, and the given element is
1101 // the first element in that home subtree whose ID is the value of that id
1102 // attribute, then the content attribute must be set to the value of that id
1103 // attribute. Otherwise, the content attribute must be set to the empty
1104 // string.
1105 const AtomicString& context_menu_id(context_menu->FastGetAttribute(idAttr));
1106
1107 if (!context_menu_id.IsNull() &&
1108 context_menu == GetTreeScope().getElementById(context_menu_id))
1109 setAttribute(contextmenuAttr, context_menu_id);
1110 else
1111 setAttribute(contextmenuAttr, "");
1112 }
1113
1114 void HTMLElement::DefaultEventHandler(Event* event) { 1070 void HTMLElement::DefaultEventHandler(Event* event) {
1115 if (event->type() == EventTypeNames::keypress && event->IsKeyboardEvent()) { 1071 if (event->type() == EventTypeNames::keypress && event->IsKeyboardEvent()) {
1116 HandleKeypressEvent(ToKeyboardEvent(event)); 1072 HandleKeypressEvent(ToKeyboardEvent(event));
1117 if (event->DefaultHandled()) 1073 if (event->DefaultHandled())
1118 return; 1074 return;
1119 } 1075 }
1120 1076
1121 Element::DefaultEventHandler(event); 1077 Element::DefaultEventHandler(event);
1122 } 1078 }
1123 1079
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
1223 1179
1224 #ifndef NDEBUG 1180 #ifndef NDEBUG
1225 1181
1226 // For use in the debugger 1182 // For use in the debugger
1227 void dumpInnerHTML(blink::HTMLElement*); 1183 void dumpInnerHTML(blink::HTMLElement*);
1228 1184
1229 void dumpInnerHTML(blink::HTMLElement* element) { 1185 void dumpInnerHTML(blink::HTMLElement* element) {
1230 printf("%s\n", element->innerHTML().Ascii().data()); 1186 printf("%s\n", element->innerHTML().Ascii().data());
1231 } 1187 }
1232 #endif 1188 #endif
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/html/HTMLElement.h ('k') | third_party/WebKit/Source/core/html/HTMLElement.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698