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

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

Issue 2155623002: [DOM][Editing][CodeHealth] Make private Node::hasEditableStyle static local (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: init 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
« no previous file with comments | « third_party/WebKit/Source/core/dom/Node.h ('k') | no next file » | 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 * (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 516 matching lines...) Expand 10 before | Expand all | Expand 10 after
527 if (node == this) 527 if (node == this)
528 break; 528 break;
529 529
530 if (node->getNodeType() == TEXT_NODE) 530 if (node->getNodeType() == TEXT_NODE)
531 node = toText(node)->mergeNextSiblingNodesIfPossible(); 531 node = toText(node)->mergeNextSiblingNodesIfPossible();
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
538 enum EditableLevel { Editable, RichlyEditable };
539 static bool hasEditableStyle(const Node&, EditableLevel);
540 static bool isEditableToAccessibility(const Node&, EditableLevel);
541
537 bool Node::isContentEditable() const 542 bool Node::isContentEditable() const
538 { 543 {
539 document().updateStyleAndLayoutTree(); 544 document().updateStyleAndLayoutTree();
540 return hasEditableStyle(Editable); 545 return blink::hasEditableStyle(*this, Editable);
541 } 546 }
542 547
543 bool Node::isContentRichlyEditable() const 548 bool Node::isContentRichlyEditable() const
544 { 549 {
545 document().updateStyleAndLayoutTree(); 550 document().updateStyleAndLayoutTree();
546 return hasEditableStyle(RichlyEditable); 551 return blink::hasEditableStyle(*this, RichlyEditable);
547 } 552 }
548 553
549 bool Node::hasEditableStyle(EditableLevel editableLevel) const 554 // TODO(yoichio): Move to core/editing
555 static bool hasEditableStyle(const Node& node, EditableLevel editableLevel)
550 { 556 {
551 if (isPseudoElement()) 557 if (node.isPseudoElement())
552 return false; 558 return false;
553 559
554 // Ideally we'd call DCHECK(!needsStyleRecalc()) here, but 560 // Ideally we'd call DCHECK(!needsStyleRecalc()) here, but
555 // ContainerNode::setFocus() calls setNeedsStyleRecalc(), so the assertion 561 // ContainerNode::setFocus() calls setNeedsStyleRecalc(), so the assertion
556 // would fire in the middle of Document::setFocusedNode(). 562 // would fire in the middle of Document::setFocusedNode().
557 563
558 for (const Node& node : NodeTraversal::inclusiveAncestorsOf(*this)) { 564 for (const Node& ancestor : NodeTraversal::inclusiveAncestorsOf(node)) {
559 if ((node.isHTMLElement() || node.isDocumentNode()) && node.layoutObject ()) { 565 if ((ancestor.isHTMLElement() || ancestor.isDocumentNode()) && ancestor. layoutObject()) {
560 switch (node.layoutObject()->style()->userModify()) { 566 switch (ancestor.layoutObject()->style()->userModify()) {
561 case READ_ONLY: 567 case READ_ONLY:
562 return false; 568 return false;
563 case READ_WRITE: 569 case READ_WRITE:
564 return true; 570 return true;
565 case READ_WRITE_PLAINTEXT_ONLY: 571 case READ_WRITE_PLAINTEXT_ONLY:
566 return editableLevel != RichlyEditable; 572 return editableLevel != RichlyEditable;
567 } 573 }
568 ASSERT_NOT_REACHED(); 574 ASSERT_NOT_REACHED();
569 return false; 575 return false;
570 } 576 }
571 } 577 }
572 578
573 return false; 579 return false;
574 } 580 }
575 581
576 bool Node::isEditableToAccessibility(EditableLevel editableLevel) const 582 // TODO(yoichio): Move to core/editing
583 static bool isEditableToAccessibility(const Node& node, EditableLevel editableLe vel)
577 { 584 {
578 if (hasEditableStyle(editableLevel)) 585 if (blink::hasEditableStyle(node, editableLevel))
579 return true; 586 return true;
580 587
581 // FIXME: Respect editableLevel for ARIA editable elements. 588 // FIXME: Respect editableLevel for ARIA editable elements.
582 if (editableLevel == RichlyEditable) 589 if (editableLevel == RichlyEditable)
583 return false; 590 return false;
584 591
585 // FIXME(dmazzoni): support ScopedAXObjectCache (crbug/489851). 592 // FIXME(dmazzoni): support ScopedAXObjectCache (crbug/489851).
586 if (AXObjectCache* cache = document().existingAXObjectCache()) 593 if (AXObjectCache* cache = node.document().existingAXObjectCache())
587 return cache->rootAXEditableElement(this); 594 return cache->rootAXEditableElement(&node);
588 595
589 return false; 596 return false;
590 } 597 }
591 598
599 // TODO(yoichio): Move to core/editing
600 bool Node::hasEditableStyle(EditableType editableType) const
601 {
602 switch (editableType) {
603 case ContentIsEditable:
604 return blink::hasEditableStyle(*this, Editable);
605 case HasEditableAXRole:
606 return isEditableToAccessibility(*this, Editable);
607 }
608 NOTREACHED();
609 return false;
610 }
611
612 // TODO(yoichio): Move to core/editing
613 bool Node::layoutObjectIsRichlyEditable(EditableType editableType) const
614 {
615 switch (editableType) {
616 case ContentIsEditable:
617 return blink::hasEditableStyle(*this, RichlyEditable);
618 case HasEditableAXRole:
619 return isEditableToAccessibility(*this, RichlyEditable);
620 }
621 NOTREACHED();
622 return false;
623 }
624
592 LayoutBox* Node::layoutBox() const 625 LayoutBox* Node::layoutBox() const
593 { 626 {
594 LayoutObject* layoutObject = this->layoutObject(); 627 LayoutObject* layoutObject = this->layoutObject();
595 return layoutObject && layoutObject->isBox() ? toLayoutBox(layoutObject) : n ullptr; 628 return layoutObject && layoutObject->isBox() ? toLayoutBox(layoutObject) : n ullptr;
596 } 629 }
597 630
598 LayoutBoxModelObject* Node::layoutBoxModelObject() const 631 LayoutBoxModelObject* Node::layoutBoxModelObject() const
599 { 632 {
600 LayoutObject* layoutObject = this->layoutObject(); 633 LayoutObject* layoutObject = this->layoutObject();
601 return layoutObject && layoutObject->isBoxModelObject() ? toLayoutBoxModelOb ject(layoutObject) : nullptr; 634 return layoutObject && layoutObject->isBoxModelObject() ? toLayoutBoxModelOb ject(layoutObject) : nullptr;
(...skipping 1901 matching lines...) Expand 10 before | Expand all | Expand 10 after
2503 2536
2504 void showNodePath(const blink::Node* node) 2537 void showNodePath(const blink::Node* node)
2505 { 2538 {
2506 if (node) 2539 if (node)
2507 node->showNodePathForThis(); 2540 node->showNodePathForThis();
2508 else 2541 else
2509 fprintf(stderr, "Cannot showNodePath for (nil)\n"); 2542 fprintf(stderr, "Cannot showNodePath for (nil)\n");
2510 } 2543 }
2511 2544
2512 #endif 2545 #endif
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/dom/Node.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698