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

Side by Side Diff: third_party/WebKit/Source/core/dom/Node.cpp

Issue 1982973002: Add CustomElementState for Custom Elements v1 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix test Created 4 years, 7 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 * (C) 2001 Dirk Mueller (mueller@kde.org) 4 * (C) 2001 Dirk Mueller (mueller@kde.org)
5 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All r ights reserved. 5 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All r ights reserved.
6 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) 6 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
7 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmo bile.com/) 7 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmo bile.com/)
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 2285 matching lines...) Expand 10 before | Expand all | Expand 10 after
2296 DCHECK(isUserActionElement()); 2296 DCHECK(isUserActionElement());
2297 return document().userActionElements().isHovered(this); 2297 return document().userActionElements().isHovered(this);
2298 } 2298 }
2299 2299
2300 bool Node::isUserActionElementFocused() const 2300 bool Node::isUserActionElementFocused() const
2301 { 2301 {
2302 DCHECK(isUserActionElement()); 2302 DCHECK(isUserActionElement());
2303 return document().userActionElements().isFocused(this); 2303 return document().userActionElements().isFocused(this);
2304 } 2304 }
2305 2305
2306 void Node::setCustomElementState(CustomElementState newState)
2307 {
2308 CustomElementState oldState = getCustomElementState();
2309
2310 switch (newState) {
2311 case CustomElementState::Uncustomized:
2312 NOTREACHED(); // Everything starts in this state
2313 return;
2314
2315 case CustomElementState::Undefined:
2316 DCHECK(CustomElementState::Uncustomized == oldState);
2317 break;
2318
2319 case CustomElementState::Customized:
2320 DCHECK(CustomElementState::Undefined == oldState);
dominicc (has gone to gerrit) 2016/05/18 07:56:21 When upgrading, don't you go from undefined -> cus
kojii 2016/05/18 08:32:15 Do you mean uncustomized -> customized? From crea
2321 break;
2322 }
2323
2324 DCHECK(isHTMLElement());
2325 DCHECK(V0Upgraded != getV0CustomElementState());
2326
2327 setFlag(CustomElementFlag);
2328 if (newState == CustomElementState::Customized)
2329 setFlag(CustomElementCustomizedFlag);
2330 DCHECK(newState == getCustomElementState());
2331
2332 // TODO(kojii): Should fire pseudoStateChanged() when :defined selector is
2333 // ready.
2334 // toElement(this)->pseudoStateChanged(CSSSelector::PseudoDefined);
2335 }
2336
2306 void Node::setV0CustomElementState(V0CustomElementState newState) 2337 void Node::setV0CustomElementState(V0CustomElementState newState)
2307 { 2338 {
2308 V0CustomElementState oldState = getV0CustomElementState(); 2339 V0CustomElementState oldState = getV0CustomElementState();
2309 2340
2310 switch (newState) { 2341 switch (newState) {
2311 case V0NotCustomElement: 2342 case V0NotCustomElement:
2312 ASSERT_NOT_REACHED(); // Everything starts in this state 2343 ASSERT_NOT_REACHED(); // Everything starts in this state
2313 return; 2344 return;
2314 2345
2315 case V0WaitingForUpgrade: 2346 case V0WaitingForUpgrade:
2316 DCHECK_EQ(V0NotCustomElement, oldState); 2347 DCHECK_EQ(V0NotCustomElement, oldState);
2317 break; 2348 break;
2318 2349
2319 case V0Upgraded: 2350 case V0Upgraded:
2320 DCHECK_EQ(V0WaitingForUpgrade, oldState); 2351 DCHECK_EQ(V0WaitingForUpgrade, oldState);
2321 break; 2352 break;
2322 } 2353 }
2323 2354
2324 DCHECK(isHTMLElement() || isSVGElement()); 2355 DCHECK(isHTMLElement() || isSVGElement());
2356 DCHECK(CustomElementState::Customized != getCustomElementState());
2325 setFlag(V0CustomElementFlag); 2357 setFlag(V0CustomElementFlag);
2326 setFlag(newState == V0Upgraded, V0CustomElementUpgradedFlag); 2358 setFlag(newState == V0Upgraded, V0CustomElementUpgradedFlag);
2327 2359
2328 if (oldState == V0NotCustomElement || newState == V0Upgraded) 2360 if (oldState == V0NotCustomElement || newState == V0Upgraded)
2329 toElement(this)->pseudoStateChanged(CSSSelector::PseudoUnresolved); 2361 toElement(this)->pseudoStateChanged(CSSSelector::PseudoUnresolved);
2330 } 2362 }
2331 2363
2332 void Node::updateAssignmentForInsertedInto(ContainerNode* insertionPoint) 2364 void Node::updateAssignmentForInsertedInto(ContainerNode* insertionPoint)
2333 { 2365 {
2334 if (isShadowHost(insertionPoint)) { 2366 if (isShadowHost(insertionPoint)) {
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
2424 2456
2425 void showNodePath(const blink::Node* node) 2457 void showNodePath(const blink::Node* node)
2426 { 2458 {
2427 if (node) 2459 if (node)
2428 node->showNodePathForThis(); 2460 node->showNodePathForThis();
2429 else 2461 else
2430 fprintf(stderr, "Cannot showNodePath for (nil)\n"); 2462 fprintf(stderr, "Cannot showNodePath for (nil)\n");
2431 } 2463 }
2432 2464
2433 #endif 2465 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698