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 579 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 590 return false; | 590 return false; |
| 591 | 591 |
| 592 // FIXME(dmazzoni): support ScopedAXObjectCache (crbug/489851). | 592 // FIXME(dmazzoni): support ScopedAXObjectCache (crbug/489851). |
| 593 if (AXObjectCache* cache = node.document().existingAXObjectCache()) | 593 if (AXObjectCache* cache = node.document().existingAXObjectCache()) |
| 594 return cache->rootAXEditableElement(&node); | 594 return cache->rootAXEditableElement(&node); |
| 595 | 595 |
| 596 return false; | 596 return false; |
| 597 } | 597 } |
| 598 | 598 |
| 599 // TODO(yoichio): Move to core/editing | 599 // TODO(yoichio): Move to core/editing |
| 600 bool Node::hasEditableStyle(EditableType editableType) const | 600 bool hasEditableStyle(const Node& node, EditableType editableType) |
| 601 { | 601 { |
| 602 switch (editableType) { | 602 switch (editableType) { |
| 603 case ContentIsEditable: | 603 case ContentIsEditable: |
| 604 return blink::hasEditableStyle(*this, Editable); | 604 return blink::hasEditableStyle(node, Editable); |
| 605 case HasEditableAXRole: | 605 case HasEditableAXRole: |
| 606 return isEditableToAccessibility(*this, Editable); | 606 return isEditableToAccessibility(node, Editable); |
| 607 } | 607 } |
| 608 NOTREACHED(); | 608 NOTREACHED(); |
| 609 return false; | 609 return false; |
| 610 } | 610 } |
| 611 | 611 |
| 612 // TODO(yoichio): Move to core/editing | 612 // TODO(yoichio): Move to core/editing |
| 613 bool Node::layoutObjectIsRichlyEditable(EditableType editableType) const | 613 bool layoutObjectIsRichlyEditable(const Node& node, EditableType editableType) |
|
tkent
2016/07/21 09:26:40
Off topic: The names 'hasEditableStyle' and 'layou
| |
| 614 { | 614 { |
| 615 switch (editableType) { | 615 switch (editableType) { |
| 616 case ContentIsEditable: | 616 case ContentIsEditable: |
| 617 return blink::hasEditableStyle(*this, RichlyEditable); | 617 return blink::hasEditableStyle(node, RichlyEditable); |
| 618 case HasEditableAXRole: | 618 case HasEditableAXRole: |
| 619 return isEditableToAccessibility(*this, RichlyEditable); | 619 return isEditableToAccessibility(node, RichlyEditable); |
| 620 } | 620 } |
| 621 NOTREACHED(); | 621 NOTREACHED(); |
| 622 return false; | 622 return false; |
| 623 } | 623 } |
| 624 | 624 |
| 625 LayoutBox* Node::layoutBox() const | 625 LayoutBox* Node::layoutBox() const |
| 626 { | 626 { |
| 627 LayoutObject* layoutObject = this->layoutObject(); | 627 LayoutObject* layoutObject = this->layoutObject(); |
| 628 return layoutObject && layoutObject->isBox() ? toLayoutBox(layoutObject) : n ullptr; | 628 return layoutObject && layoutObject->isBox() ? toLayoutBox(layoutObject) : n ullptr; |
| 629 } | 629 } |
| (...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1006 return 0; | 1006 return 0; |
| 1007 } | 1007 } |
| 1008 | 1008 |
| 1009 // FIXME: Shouldn't these functions be in the editing code? Code that asks ques tions about HTML in the core DOM class | 1009 // FIXME: Shouldn't these functions be in the editing code? Code that asks ques tions about HTML in the core DOM class |
| 1010 // is obviously misplaced. | 1010 // is obviously misplaced. |
| 1011 bool Node::canStartSelection() const | 1011 bool Node::canStartSelection() const |
| 1012 { | 1012 { |
| 1013 if (isDisabledFormControl(this)) | 1013 if (isDisabledFormControl(this)) |
| 1014 return false; | 1014 return false; |
| 1015 | 1015 |
| 1016 if (hasEditableStyle()) | 1016 if (hasEditableStyle(*this)) |
| 1017 return true; | 1017 return true; |
| 1018 | 1018 |
| 1019 if (layoutObject()) { | 1019 if (layoutObject()) { |
| 1020 const ComputedStyle& style = layoutObject()->styleRef(); | 1020 const ComputedStyle& style = layoutObject()->styleRef(); |
| 1021 // We allow selections to begin within an element that has -webkit-user- select: none set, | 1021 // We allow selections to begin within an element that has -webkit-user- select: none set, |
| 1022 // but if the element is draggable then dragging should take priority ov er selection. | 1022 // but if the element is draggable then dragging should take priority ov er selection. |
| 1023 if (style.userDrag() == DRAG_ELEMENT && style.userSelect() == SELECT_NON E) | 1023 if (style.userDrag() == DRAG_ELEMENT && style.userSelect() == SELECT_NON E) |
| 1024 return false; | 1024 return false; |
| 1025 } | 1025 } |
| 1026 ContainerNode* parent = FlatTreeTraversal::parent(*this); | 1026 ContainerNode* parent = FlatTreeTraversal::parent(*this); |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1135 ContainerNode* Node::parentOrShadowHostOrTemplateHostNode() const | 1135 ContainerNode* Node::parentOrShadowHostOrTemplateHostNode() const |
| 1136 { | 1136 { |
| 1137 if (isDocumentFragment() && toDocumentFragment(this)->isTemplateContent()) | 1137 if (isDocumentFragment() && toDocumentFragment(this)->isTemplateContent()) |
| 1138 return static_cast<const TemplateContentDocumentFragment*>(this)->host() ; | 1138 return static_cast<const TemplateContentDocumentFragment*>(this)->host() ; |
| 1139 return parentOrShadowHostNode(); | 1139 return parentOrShadowHostNode(); |
| 1140 } | 1140 } |
| 1141 | 1141 |
| 1142 // TODO(yoichio): Move to core/editing | 1142 // TODO(yoichio): Move to core/editing |
| 1143 bool isRootEditableElement(const Node& node) | 1143 bool isRootEditableElement(const Node& node) |
| 1144 { | 1144 { |
| 1145 return node.hasEditableStyle() && node.isElementNode() && (!node.parentNode( ) || !node.parentNode()->hasEditableStyle() | 1145 return hasEditableStyle(node) && node.isElementNode() && (!node.parentNode() || !hasEditableStyle(*node.parentNode()) |
| 1146 || !node.parentNode()->isElementNode() || &node == node.document().body( )); | 1146 || !node.parentNode()->isElementNode() || &node == node.document().body( )); |
| 1147 } | 1147 } |
| 1148 | 1148 |
| 1149 // TODO(yoichio): Move to core/editing | 1149 // TODO(yoichio): Move to core/editing |
| 1150 Element* rootEditableElement(const Node& node, EditableType editableType) | 1150 Element* rootEditableElement(const Node& node, EditableType editableType) |
| 1151 { | 1151 { |
| 1152 if (editableType == HasEditableAXRole) { | 1152 if (editableType == HasEditableAXRole) { |
| 1153 if (AXObjectCache* cache = node.document().existingAXObjectCache()) | 1153 if (AXObjectCache* cache = node.document().existingAXObjectCache()) |
| 1154 return const_cast<Element*>(cache->rootAXEditableElement(&node)); | 1154 return const_cast<Element*>(cache->rootAXEditableElement(&node)); |
| 1155 } | 1155 } |
| 1156 | 1156 |
| 1157 return rootEditableElement(node); | 1157 return rootEditableElement(node); |
| 1158 } | 1158 } |
| 1159 | 1159 |
| 1160 // TODO(yoichio): Move to core/editing | 1160 // TODO(yoichio): Move to core/editing |
| 1161 Element* rootEditableElement(const Node& node) | 1161 Element* rootEditableElement(const Node& node) |
| 1162 { | 1162 { |
| 1163 const Node* result = nullptr; | 1163 const Node* result = nullptr; |
| 1164 for (const Node* n = &node; n && n->hasEditableStyle(); n = n->parentNode()) { | 1164 for (const Node* n = &node; n && hasEditableStyle(*n); n = n->parentNode()) { |
| 1165 if (n->isElementNode()) | 1165 if (n->isElementNode()) |
| 1166 result = n; | 1166 result = n; |
| 1167 if (node.document().body() == n) | 1167 if (node.document().body() == n) |
| 1168 break; | 1168 break; |
| 1169 } | 1169 } |
| 1170 return toElement(const_cast<Node*>(result)); | 1170 return toElement(const_cast<Node*>(result)); |
| 1171 } | 1171 } |
| 1172 | 1172 |
| 1173 // FIXME: End of obviously misplaced HTML editing functions. Try to move these out of Node. | 1173 // FIXME: End of obviously misplaced HTML editing functions. Try to move these out of Node. |
| 1174 | 1174 |
| (...skipping 475 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1650 WTFLogAlways("%s?%s\t%p\n", prefix, nodeName().utf8().data(), this); | 1650 WTFLogAlways("%s?%s\t%p\n", prefix, nodeName().utf8().data(), this); |
| 1651 } else if (isShadowRoot()) { | 1651 } else if (isShadowRoot()) { |
| 1652 // nodeName of ShadowRoot is #document-fragment. It's confused with | 1652 // nodeName of ShadowRoot is #document-fragment. It's confused with |
| 1653 // DocumentFragment. | 1653 // DocumentFragment. |
| 1654 WTFLogAlways("%s#shadow-root\t%p\n", prefix, this); | 1654 WTFLogAlways("%s#shadow-root\t%p\n", prefix, this); |
| 1655 } else { | 1655 } else { |
| 1656 StringBuilder attrs; | 1656 StringBuilder attrs; |
| 1657 appendAttributeDesc(this, attrs, idAttr, " ID"); | 1657 appendAttributeDesc(this, attrs, idAttr, " ID"); |
| 1658 appendAttributeDesc(this, attrs, classAttr, " CLASS"); | 1658 appendAttributeDesc(this, attrs, classAttr, " CLASS"); |
| 1659 appendAttributeDesc(this, attrs, styleAttr, " STYLE"); | 1659 appendAttributeDesc(this, attrs, styleAttr, " STYLE"); |
| 1660 if (hasEditableStyle()) | 1660 if (hasEditableStyle(*this)) |
| 1661 attrs.append(" (editable)"); | 1661 attrs.append(" (editable)"); |
| 1662 if (document().focusedElement() == this) | 1662 if (document().focusedElement() == this) |
| 1663 attrs.append(" (focused)"); | 1663 attrs.append(" (focused)"); |
| 1664 WTFLogAlways("%s%s\t%p%s\n", prefix, nodeName().utf8().data(), this, att rs.toString().utf8().data()); | 1664 WTFLogAlways("%s%s\t%p%s\n", prefix, nodeName().utf8().data(), this, att rs.toString().utf8().data()); |
| 1665 } | 1665 } |
| 1666 } | 1666 } |
| 1667 | 1667 |
| 1668 void Node::showTreeForThis() const | 1668 void Node::showTreeForThis() const |
| 1669 { | 1669 { |
| 1670 showTreeAndMark(this, "*"); | 1670 showTreeAndMark(this, "*"); |
| (...skipping 865 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2536 | 2536 |
| 2537 void showNodePath(const blink::Node* node) | 2537 void showNodePath(const blink::Node* node) |
| 2538 { | 2538 { |
| 2539 if (node) | 2539 if (node) |
| 2540 node->showNodePathForThis(); | 2540 node->showNodePathForThis(); |
| 2541 else | 2541 else |
| 2542 fprintf(stderr, "Cannot showNodePath for (nil)\n"); | 2542 fprintf(stderr, "Cannot showNodePath for (nil)\n"); |
| 2543 } | 2543 } |
| 2544 | 2544 |
| 2545 #endif | 2545 #endif |
| OLD | NEW |