Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 519 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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 bool Node::isContentEditable(UserSelectAllTreatment treatment) const | 537 bool Node::isContentEditable(UserSelectAllTreatment treatment) const |
| 538 { | 538 { |
| 539 document().updateStyleAndLayoutTree(); | 539 document().updateStyleAndLayoutTree(); |
| 540 return hasEditableStyle(Editable, treatment); | 540 return hasEditableStyle(this, Editable, treatment); |
| 541 } | 541 } |
| 542 | 542 |
| 543 bool Node::isContentRichlyEditable() const | 543 bool Node::isContentRichlyEditable() const |
| 544 { | 544 { |
| 545 document().updateStyleAndLayoutTree(); | 545 document().updateStyleAndLayoutTree(); |
| 546 return hasEditableStyle(RichlyEditable, UserSelectAllIsAlwaysNonEditable); | 546 return hasEditableStyle(this, RichlyEditable, UserSelectAllIsAlwaysNonEditab le); |
| 547 } | 547 } |
| 548 | 548 |
| 549 bool Node::hasEditableStyle(EditableLevel editableLevel, UserSelectAllTreatment treatment) const | 549 // TODO(yoichio): Move this to core/editing |
| 550 bool Node::hasEditableStyle(const Node* node, EditableLevel editableLevel, UserS electAllTreatment treatment) | |
|
yosin_UTC9
2016/07/07 09:34:54
s/const Node*/const Node&/
| |
| 550 { | 551 { |
| 551 if (isPseudoElement()) | 552 if (node->isPseudoElement()) |
| 552 return false; | 553 return false; |
| 553 | 554 |
| 554 // Ideally we'd call DCHECK(!needsStyleRecalc()) here, but | 555 // Ideally we'd call DCHECK(!needsStyleRecalc()) here, but |
| 555 // ContainerNode::setFocus() calls setNeedsStyleRecalc(), so the assertion | 556 // ContainerNode::setFocus() calls setNeedsStyleRecalc(), so the assertion |
| 556 // would fire in the middle of Document::setFocusedNode(). | 557 // would fire in the middle of Document::setFocusedNode(). |
| 557 | 558 |
| 558 for (const Node& node : NodeTraversal::inclusiveAncestorsOf(*this)) { | 559 for (const Node& ancestor : NodeTraversal::inclusiveAncestorsOf(*node)) { |
| 559 if ((node.isHTMLElement() || node.isDocumentNode()) && node.layoutObject ()) { | 560 if ((ancestor.isHTMLElement() || ancestor.isDocumentNode()) && ancestor. layoutObject()) { |
| 560 // Elements with user-select: all style are considered atomic | 561 // Elements with user-select: all style are considered atomic |
| 561 // therefore non editable. | 562 // therefore non editable. |
| 562 if (nodeIsUserSelectAll(&node) && treatment == UserSelectAllIsAlways NonEditable) | 563 if (nodeIsUserSelectAll(&ancestor) && treatment == UserSelectAllIsAl waysNonEditable) |
| 563 return false; | 564 return false; |
| 564 switch (node.layoutObject()->style()->userModify()) { | 565 switch (ancestor.layoutObject()->style()->userModify()) { |
| 565 case READ_ONLY: | 566 case READ_ONLY: |
| 566 return false; | 567 return false; |
| 567 case READ_WRITE: | 568 case READ_WRITE: |
| 568 return true; | 569 return true; |
| 569 case READ_WRITE_PLAINTEXT_ONLY: | 570 case READ_WRITE_PLAINTEXT_ONLY: |
| 570 return editableLevel != RichlyEditable; | 571 return editableLevel != RichlyEditable; |
| 571 } | 572 } |
| 572 ASSERT_NOT_REACHED(); | 573 ASSERT_NOT_REACHED(); |
| 573 return false; | 574 return false; |
| 574 } | 575 } |
| 575 } | 576 } |
| 576 | 577 |
| 577 return false; | 578 return false; |
| 578 } | 579 } |
| 579 | 580 |
| 580 bool Node::isEditableToAccessibility(EditableLevel editableLevel) const | 581 // TODO(yoichio): Move this to core/editing |
| 582 bool Node::isEditableToAccessibility(const Node* node, EditableLevel editableLev el) | |
|
yosin_UTC9
2016/07/07 09:34:54
s/const Node*/const Node&/
| |
| 581 { | 583 { |
| 582 if (hasEditableStyle(editableLevel)) | 584 if (hasEditableStyle(node, editableLevel)) |
| 583 return true; | 585 return true; |
| 584 | 586 |
| 585 // FIXME: Respect editableLevel for ARIA editable elements. | 587 // FIXME: Respect editableLevel for ARIA editable elements. |
| 586 if (editableLevel == RichlyEditable) | 588 if (editableLevel == RichlyEditable) |
| 587 return false; | 589 return false; |
| 588 | 590 |
| 589 // FIXME(dmazzoni): support ScopedAXObjectCache (crbug/489851). | 591 // FIXME(dmazzoni): support ScopedAXObjectCache (crbug/489851). |
| 590 if (AXObjectCache* cache = document().existingAXObjectCache()) | 592 if (AXObjectCache* cache = node->document().existingAXObjectCache()) |
| 591 return cache->rootAXEditableElement(this); | 593 return cache->rootAXEditableElement(node); |
| 592 | 594 |
| 593 return false; | 595 return false; |
| 594 } | 596 } |
| 595 | 597 |
| 596 LayoutBox* Node::layoutBox() const | 598 LayoutBox* Node::layoutBox() const |
| 597 { | 599 { |
| 598 LayoutObject* layoutObject = this->layoutObject(); | 600 LayoutObject* layoutObject = this->layoutObject(); |
| 599 return layoutObject && layoutObject->isBox() ? toLayoutBox(layoutObject) : n ullptr; | 601 return layoutObject && layoutObject->isBox() ? toLayoutBox(layoutObject) : n ullptr; |
| 600 } | 602 } |
| 601 | 603 |
| (...skipping 1899 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2501 | 2503 |
| 2502 void showNodePath(const blink::Node* node) | 2504 void showNodePath(const blink::Node* node) |
| 2503 { | 2505 { |
| 2504 if (node) | 2506 if (node) |
| 2505 node->showNodePathForThis(); | 2507 node->showNodePathForThis(); |
| 2506 else | 2508 else |
| 2507 fprintf(stderr, "Cannot showNodePath for (nil)\n"); | 2509 fprintf(stderr, "Cannot showNodePath for (nil)\n"); |
| 2508 } | 2510 } |
| 2509 | 2511 |
| 2510 #endif | 2512 #endif |
| OLD | NEW |