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

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

Issue 2121313003: [Editing][DOM][CodeHealth] Make Node::isContentEditable and Node::isRichEditable global functions. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 5 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 521 matching lines...) Expand 10 before | Expand all | Expand 10 after
532 else 532 else
533 node = NodeTraversal::nextPostOrder(*node); 533 node = NodeTraversal::nextPostOrder(*node);
534 } 534 }
535 } 535 }
536 536
537 // TODO(yoichio): Move to core/editing 537 // TODO(yoichio): Move to core/editing
538 enum EditableLevel { Editable, RichlyEditable }; 538 enum EditableLevel { Editable, RichlyEditable };
539 static bool hasEditableStyle(const Node&, EditableLevel); 539 static bool hasEditableStyle(const Node&, EditableLevel);
540 static bool isEditableToAccessibility(const Node&, EditableLevel); 540 static bool isEditableToAccessibility(const Node&, EditableLevel);
541 541
542 bool Node::isContentEditable() const 542 // TODO(yoichio): Move to core/editing
543 bool isContentEditable(const Node& node)
543 { 544 {
544 document().updateStyleAndLayoutTree(); 545 node.document().updateStyleAndLayoutTree();
545 return blink::hasEditableStyle(*this, Editable); 546 return blink::hasEditableStyle(node, Editable);
546 }
547
548 bool Node::isContentRichlyEditable() const
549 {
550 document().updateStyleAndLayoutTree();
551 return blink::hasEditableStyle(*this, RichlyEditable);
552 } 547 }
553 548
554 // TODO(yoichio): Move to core/editing 549 // TODO(yoichio): Move to core/editing
550 bool isContentRichlyEditable(const Node& node)
551 {
552 node.document().updateStyleAndLayoutTree();
553 return blink::hasEditableStyle(node, RichlyEditable);
554 }
555
556 // TODO(yoichio): Move to core/editing
555 static bool hasEditableStyle(const Node& node, EditableLevel editableLevel) 557 static bool hasEditableStyle(const Node& node, EditableLevel editableLevel)
556 { 558 {
557 if (node.isPseudoElement()) 559 if (node.isPseudoElement())
558 return false; 560 return false;
559 561
560 // Ideally we'd call DCHECK(!needsStyleRecalc()) here, but 562 // Ideally we'd call DCHECK(!needsStyleRecalc()) here, but
561 // ContainerNode::setFocus() calls setNeedsStyleRecalc(), so the assertion 563 // ContainerNode::setFocus() calls setNeedsStyleRecalc(), so the assertion
562 // would fire in the middle of Document::setFocusedNode(). 564 // would fire in the middle of Document::setFocusedNode().
563 565
564 for (const Node& ancestor : NodeTraversal::inclusiveAncestorsOf(node)) { 566 for (const Node& ancestor : NodeTraversal::inclusiveAncestorsOf(node)) {
(...skipping 1665 matching lines...) Expand 10 before | Expand all | Expand 10 after
2230 { 2232 {
2231 if (isDisabledFormControl(this)) 2233 if (isDisabledFormControl(this))
2232 return false; 2234 return false;
2233 return hasEventListeners(EventTypeNames::mousemove) || hasEventListeners(Eve ntTypeNames::mouseover) || hasEventListeners(EventTypeNames::mouseout); 2235 return hasEventListeners(EventTypeNames::mousemove) || hasEventListeners(Eve ntTypeNames::mouseover) || hasEventListeners(EventTypeNames::mouseout);
2234 } 2236 }
2235 2237
2236 bool Node::willRespondToMouseClickEvents() 2238 bool Node::willRespondToMouseClickEvents()
2237 { 2239 {
2238 if (isDisabledFormControl(this)) 2240 if (isDisabledFormControl(this))
2239 return false; 2241 return false;
2240 return isContentEditable() || hasEventListeners(EventTypeNames::mouseup) || hasEventListeners(EventTypeNames::mousedown) || hasEventListeners(EventTypeNames ::click) || hasEventListeners(EventTypeNames::DOMActivate); 2242 return isContentEditable(*this) || hasEventListeners(EventTypeNames::mouseup ) || hasEventListeners(EventTypeNames::mousedown) || hasEventListeners(EventType Names::click) || hasEventListeners(EventTypeNames::DOMActivate);
2241 } 2243 }
2242 2244
2243 bool Node::willRespondToTouchEvents() 2245 bool Node::willRespondToTouchEvents()
2244 { 2246 {
2245 if (isDisabledFormControl(this)) 2247 if (isDisabledFormControl(this))
2246 return false; 2248 return false;
2247 return hasEventListeners(EventTypeNames::touchstart) || hasEventListeners(Ev entTypeNames::touchmove) || hasEventListeners(EventTypeNames::touchcancel) || ha sEventListeners(EventTypeNames::touchend); 2249 return hasEventListeners(EventTypeNames::touchstart) || hasEventListeners(Ev entTypeNames::touchmove) || hasEventListeners(EventTypeNames::touchcancel) || ha sEventListeners(EventTypeNames::touchend);
2248 } 2250 }
2249 2251
2250 unsigned Node::connectedSubframeCount() const 2252 unsigned Node::connectedSubframeCount() const
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after
2536 2538
2537 void showNodePath(const blink::Node* node) 2539 void showNodePath(const blink::Node* node)
2538 { 2540 {
2539 if (node) 2541 if (node)
2540 node->showNodePathForThis(); 2542 node->showNodePathForThis();
2541 else 2543 else
2542 fprintf(stderr, "Cannot showNodePath for (nil)\n"); 2544 fprintf(stderr, "Cannot showNodePath for (nil)\n");
2543 } 2545 }
2544 2546
2545 #endif 2547 #endif
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/dom/Node.h ('k') | third_party/WebKit/Source/core/editing/CaretBase.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698