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 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
285 #endif | 285 #endif |
286 | 286 |
287 #if !ENABLE(OILPAN) | 287 #if !ENABLE(OILPAN) |
288 #if DUMP_NODE_STATISTICS | 288 #if DUMP_NODE_STATISTICS |
289 liveNodeSet().remove(this); | 289 liveNodeSet().remove(this); |
290 #endif | 290 #endif |
291 | 291 |
292 if (hasRareData()) | 292 if (hasRareData()) |
293 clearRareData(); | 293 clearRareData(); |
294 | 294 |
295 RELEASE_ASSERT(!renderer()); | 295 RELEASE_ASSERT(!layoutObject()); |
296 | 296 |
297 if (!isContainerNode()) | 297 if (!isContainerNode()) |
298 willBeDeletedFromDocument(); | 298 willBeDeletedFromDocument(); |
299 | 299 |
300 if (m_previous) | 300 if (m_previous) |
301 m_previous->setNextSibling(nullptr); | 301 m_previous->setNextSibling(nullptr); |
302 if (m_next) | 302 if (m_next) |
303 m_next->setPreviousSibling(nullptr); | 303 m_next->setPreviousSibling(nullptr); |
304 | 304 |
305 if (m_treeScope) | 305 if (m_treeScope) |
306 m_treeScope->guardDeref(); | 306 m_treeScope->guardDeref(); |
307 | 307 |
308 if (getFlag(HasWeakReferencesFlag)) | 308 if (getFlag(HasWeakReferencesFlag)) |
309 WeakNodeMap::notifyNodeDestroyed(this); | 309 WeakNodeMap::notifyNodeDestroyed(this); |
310 | 310 |
311 // clearEventTargetData() must be always done, | 311 // clearEventTargetData() must be always done, |
312 // or eventTargetDataMap() may keep a raw pointer to a deleted object. | 312 // or eventTargetDataMap() may keep a raw pointer to a deleted object. |
313 ASSERT(!hasEventTargetData()); | 313 ASSERT(!hasEventTargetData()); |
314 #else | 314 #else |
315 // With Oilpan, the rare data finalizer also asserts for | 315 // With Oilpan, the rare data finalizer also asserts for |
316 // this condition (we cannot directly access it here.) | 316 // this condition (we cannot directly access it here.) |
317 RELEASE_ASSERT(hasRareData() || !renderer()); | 317 RELEASE_ASSERT(hasRareData() || !layoutObject()); |
318 #endif | 318 #endif |
319 | 319 |
320 InspectorCounters::decrementCounter(InspectorCounters::NodeCounter); | 320 InspectorCounters::decrementCounter(InspectorCounters::NodeCounter); |
321 } | 321 } |
322 | 322 |
323 #if !ENABLE(OILPAN) | 323 #if !ENABLE(OILPAN) |
324 // With Oilpan all of this is handled with weak processing of the document. | 324 // With Oilpan all of this is handled with weak processing of the document. |
325 void Node::willBeDeletedFromDocument() | 325 void Node::willBeDeletedFromDocument() |
326 { | 326 { |
327 if (hasEventTargetData()) | 327 if (hasEventTargetData()) |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
363 setFlag(HasRareDataFlag); | 363 setFlag(HasRareDataFlag); |
364 return *rareData(); | 364 return *rareData(); |
365 } | 365 } |
366 | 366 |
367 #if !ENABLE(OILPAN) | 367 #if !ENABLE(OILPAN) |
368 void Node::clearRareData() | 368 void Node::clearRareData() |
369 { | 369 { |
370 ASSERT(hasRareData()); | 370 ASSERT(hasRareData()); |
371 ASSERT(!transientMutationObserverRegistry() || transientMutationObserverRegi stry()->isEmpty()); | 371 ASSERT(!transientMutationObserverRegistry() || transientMutationObserverRegi stry()->isEmpty()); |
372 | 372 |
373 LayoutObject* renderer = m_data.m_rareData->renderer(); | 373 LayoutObject* renderer = m_data.m_rareData->layoutObject(); |
Julien - ping for review
2015/03/05 16:19:15
s/renderer/layoutObject/
Julien - ping for review
2015/03/05 16:19:15
s/renderer/layoutObject/
| |
374 if (isElementNode()) | 374 if (isElementNode()) |
375 delete static_cast<ElementRareData*>(m_data.m_rareData); | 375 delete static_cast<ElementRareData*>(m_data.m_rareData); |
376 else | 376 else |
377 delete static_cast<NodeRareData*>(m_data.m_rareData); | 377 delete static_cast<NodeRareData*>(m_data.m_rareData); |
378 m_data.m_renderer = renderer; | 378 m_data.m_renderer = renderer; |
379 clearFlag(HasRareDataFlag); | 379 clearFlag(HasRareDataFlag); |
380 } | 380 } |
381 #endif | 381 #endif |
382 | 382 |
383 Node* Node::toNode() | 383 Node* Node::toNode() |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
554 bool Node::hasEditableStyle(EditableLevel editableLevel, UserSelectAllTreatment treatment) const | 554 bool Node::hasEditableStyle(EditableLevel editableLevel, UserSelectAllTreatment treatment) const |
555 { | 555 { |
556 if (isPseudoElement()) | 556 if (isPseudoElement()) |
557 return false; | 557 return false; |
558 | 558 |
559 // Ideally we'd call ASSERT(!needsStyleRecalc()) here, but | 559 // Ideally we'd call ASSERT(!needsStyleRecalc()) here, but |
560 // ContainerNode::setFocus() calls setNeedsStyleRecalc(), so the assertion | 560 // ContainerNode::setFocus() calls setNeedsStyleRecalc(), so the assertion |
561 // would fire in the middle of Document::setFocusedNode(). | 561 // would fire in the middle of Document::setFocusedNode(). |
562 | 562 |
563 for (const Node* node = this; node; node = node->parentNode()) { | 563 for (const Node* node = this; node; node = node->parentNode()) { |
564 if ((node->isHTMLElement() || node->isDocumentNode()) && node->renderer( )) { | 564 if ((node->isHTMLElement() || node->isDocumentNode()) && node->layoutObj ect()) { |
565 // Elements with user-select: all style are considered atomic | 565 // Elements with user-select: all style are considered atomic |
566 // therefore non editable. | 566 // therefore non editable. |
567 if (Position::nodeIsUserSelectAll(node) && treatment == UserSelectAl lIsAlwaysNonEditable) | 567 if (Position::nodeIsUserSelectAll(node) && treatment == UserSelectAl lIsAlwaysNonEditable) |
568 return false; | 568 return false; |
569 switch (node->renderer()->style()->userModify()) { | 569 switch (node->layoutObject()->style()->userModify()) { |
570 case READ_ONLY: | 570 case READ_ONLY: |
571 return false; | 571 return false; |
572 case READ_WRITE: | 572 case READ_WRITE: |
573 return true; | 573 return true; |
574 case READ_WRITE_PLAINTEXT_ONLY: | 574 case READ_WRITE_PLAINTEXT_ONLY: |
575 return editableLevel != RichlyEditable; | 575 return editableLevel != RichlyEditable; |
576 } | 576 } |
577 ASSERT_NOT_REACHED(); | 577 ASSERT_NOT_REACHED(); |
578 return false; | 578 return false; |
579 } | 579 } |
(...skipping 15 matching lines...) Expand all Loading... | |
595 ASSERT(document().existingAXObjectCache()); | 595 ASSERT(document().existingAXObjectCache()); |
596 | 596 |
597 if (AXObjectCache* cache = document().existingAXObjectCache()) | 597 if (AXObjectCache* cache = document().existingAXObjectCache()) |
598 return cache->rootAXEditableElement(this); | 598 return cache->rootAXEditableElement(this); |
599 | 599 |
600 return false; | 600 return false; |
601 } | 601 } |
602 | 602 |
603 LayoutBox* Node::layoutBox() const | 603 LayoutBox* Node::layoutBox() const |
604 { | 604 { |
605 LayoutObject* renderer = this->renderer(); | 605 LayoutObject* renderer = this->layoutObject(); |
Julien - ping for review
2015/03/05 16:19:15
Ditto.
| |
606 return renderer && renderer->isBox() ? toLayoutBox(renderer) : nullptr; | 606 return renderer && renderer->isBox() ? toLayoutBox(renderer) : nullptr; |
607 } | 607 } |
608 | 608 |
609 LayoutBoxModelObject* Node::layoutBoxModelObject() const | 609 LayoutBoxModelObject* Node::layoutBoxModelObject() const |
610 { | 610 { |
611 LayoutObject* renderer = this->renderer(); | 611 LayoutObject* renderer = this->layoutObject(); |
612 return renderer && renderer->isBoxModelObject() ? toLayoutBoxModelObject(ren derer) : nullptr; | 612 return renderer && renderer->isBoxModelObject() ? toLayoutBoxModelObject(ren derer) : nullptr; |
Julien - ping for review
2015/03/05 16:19:15
Ditto.
| |
613 } | 613 } |
614 | 614 |
615 LayoutRect Node::boundingBox() const | 615 LayoutRect Node::boundingBox() const |
616 { | 616 { |
617 if (renderer()) | 617 if (layoutObject()) |
618 return LayoutRect(renderer()->absoluteBoundingBoxRect()); | 618 return LayoutRect(layoutObject()->absoluteBoundingBoxRect()); |
619 return LayoutRect(); | 619 return LayoutRect(); |
620 } | 620 } |
621 | 621 |
622 bool Node::hasNonEmptyBoundingBox() const | 622 bool Node::hasNonEmptyBoundingBox() const |
623 { | 623 { |
624 // Before calling absoluteRects, check for the common case where the rendere r | 624 // Before calling absoluteRects, check for the common case where the rendere r |
625 // is non-empty, since this is a faster check and almost always returns true . | 625 // is non-empty, since this is a faster check and almost always returns true . |
626 LayoutBoxModelObject* box = layoutBoxModelObject(); | 626 LayoutBoxModelObject* box = layoutBoxModelObject(); |
627 if (!box) | 627 if (!box) |
628 return false; | 628 return false; |
629 if (!box->borderBoundingBox().isEmpty()) | 629 if (!box->borderBoundingBox().isEmpty()) |
630 return true; | 630 return true; |
631 | 631 |
632 Vector<IntRect> rects; | 632 Vector<IntRect> rects; |
633 FloatPoint absPos = renderer()->localToAbsolute(); | 633 FloatPoint absPos = layoutObject()->localToAbsolute(); |
634 renderer()->absoluteRects(rects, flooredLayoutPoint(absPos)); | 634 layoutObject()->absoluteRects(rects, flooredLayoutPoint(absPos)); |
635 size_t n = rects.size(); | 635 size_t n = rects.size(); |
636 for (size_t i = 0; i < n; ++i) | 636 for (size_t i = 0; i < n; ++i) |
637 if (!rects[i].isEmpty()) | 637 if (!rects[i].isEmpty()) |
638 return true; | 638 return true; |
639 | 639 |
640 return false; | 640 return false; |
641 } | 641 } |
642 | 642 |
643 #ifndef NDEBUG | 643 #ifndef NDEBUG |
644 inline static ShadowRoot* oldestShadowRootFor(const Node* node) | 644 inline static ShadowRoot* oldestShadowRootFor(const Node* node) |
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
914 // We only need to detach if the node has already been through attach(). | 914 // We only need to detach if the node has already been through attach(). |
915 if (styleChangeType() < NeedsReattachStyleChange) | 915 if (styleChangeType() < NeedsReattachStyleChange) |
916 detach(reattachContext); | 916 detach(reattachContext); |
917 attach(reattachContext); | 917 attach(reattachContext); |
918 } | 918 } |
919 | 919 |
920 void Node::attach(const AttachContext&) | 920 void Node::attach(const AttachContext&) |
921 { | 921 { |
922 ASSERT(document().inStyleRecalc() || isDocumentNode()); | 922 ASSERT(document().inStyleRecalc() || isDocumentNode()); |
923 ASSERT(needsAttach()); | 923 ASSERT(needsAttach()); |
924 ASSERT(!renderer() || (renderer()->style() && (renderer()->parent() || rende rer()->isLayoutView()))); | 924 ASSERT(!layoutObject() || (layoutObject()->style() && (layoutObject()->paren t() || layoutObject()->isLayoutView()))); |
925 | 925 |
926 clearNeedsStyleRecalc(); | 926 clearNeedsStyleRecalc(); |
927 | 927 |
928 if (AXObjectCache* cache = document().axObjectCache()) | 928 if (AXObjectCache* cache = document().axObjectCache()) |
929 cache->updateCacheAfterNodeIsAttached(this); | 929 cache->updateCacheAfterNodeIsAttached(this); |
930 } | 930 } |
931 | 931 |
932 #if ENABLE(ASSERT) | 932 #if ENABLE(ASSERT) |
933 static Node* detachingNode; | 933 static Node* detachingNode; |
934 | 934 |
(...skipping 10 matching lines...) Expand all Loading... | |
945 | 945 |
946 #if ENABLE(ASSERT) | 946 #if ENABLE(ASSERT) |
947 // The detaching might trigger destruction of a popup menu window, | 947 // The detaching might trigger destruction of a popup menu window, |
948 // with ensuing detachment of its Nodes. In a separate document, so | 948 // with ensuing detachment of its Nodes. In a separate document, so |
949 // don't assert for these, but do set detachingNode to the most recent | 949 // don't assert for these, but do set detachingNode to the most recent |
950 // Node being detached. | 950 // Node being detached. |
951 ASSERT(!detachingNode || detachingNode->document() != document()); | 951 ASSERT(!detachingNode || detachingNode->document() != document()); |
952 detachingNode = this; | 952 detachingNode = this; |
953 #endif | 953 #endif |
954 | 954 |
955 if (renderer()) | 955 if (layoutObject()) |
956 renderer()->destroyAndCleanupAnonymousWrappers(); | 956 layoutObject()->destroyAndCleanupAnonymousWrappers(); |
957 setRenderer(nullptr); | 957 setRenderer(nullptr); |
958 | 958 |
959 // Do not remove the element's hovered and active status | 959 // Do not remove the element's hovered and active status |
960 // if performing a reattach. | 960 // if performing a reattach. |
961 if (!context.performingReattach) { | 961 if (!context.performingReattach) { |
962 Document& doc = document(); | 962 Document& doc = document(); |
963 if (isUserActionElement()) { | 963 if (isUserActionElement()) { |
964 if (hovered()) | 964 if (hovered()) |
965 doc.hoveredNodeDetached(this); | 965 doc.hoveredNodeDetached(this); |
966 if (inActiveChain()) | 966 if (inActiveChain()) |
(...skipping 13 matching lines...) Expand all Loading... | |
980 #if ENABLE(ASSERT) | 980 #if ENABLE(ASSERT) |
981 detachingNode = nullptr; | 981 detachingNode = nullptr; |
982 #endif | 982 #endif |
983 } | 983 } |
984 | 984 |
985 void Node::reattachWhitespaceSiblingsIfNeeded(Text* start) | 985 void Node::reattachWhitespaceSiblingsIfNeeded(Text* start) |
986 { | 986 { |
987 for (Node* sibling = start; sibling; sibling = sibling->nextSibling()) { | 987 for (Node* sibling = start; sibling; sibling = sibling->nextSibling()) { |
988 if (sibling->isTextNode() && toText(sibling)->containsOnlyWhitespace()) { | 988 if (sibling->isTextNode() && toText(sibling)->containsOnlyWhitespace()) { |
989 toText(sibling)->reattachIfNeeded(); | 989 toText(sibling)->reattachIfNeeded(); |
990 } else if (sibling->renderer()) { | 990 } else if (sibling->layoutObject()) { |
991 return; | 991 return; |
992 } | 992 } |
993 } | 993 } |
994 } | 994 } |
995 | 995 |
996 // FIXME: This code is used by editing. Seems like it could move over there and not pollute Node. | 996 // FIXME: This code is used by editing. Seems like it could move over there and not pollute Node. |
997 Node* Node::previousNodeConsideringAtomicNodes() const | 997 Node* Node::previousNodeConsideringAtomicNodes() const |
998 { | 998 { |
999 if (previousSibling()) { | 999 if (previousSibling()) { |
1000 Node* n = previousSibling(); | 1000 Node* n = previousSibling(); |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1057 return 0; | 1057 return 0; |
1058 } | 1058 } |
1059 | 1059 |
1060 // FIXME: Shouldn't these functions be in the editing code? Code that asks ques tions about HTML in the core DOM class | 1060 // FIXME: Shouldn't these functions be in the editing code? Code that asks ques tions about HTML in the core DOM class |
1061 // is obviously misplaced. | 1061 // is obviously misplaced. |
1062 bool Node::canStartSelection() const | 1062 bool Node::canStartSelection() const |
1063 { | 1063 { |
1064 if (hasEditableStyle()) | 1064 if (hasEditableStyle()) |
1065 return true; | 1065 return true; |
1066 | 1066 |
1067 if (renderer()) { | 1067 if (layoutObject()) { |
1068 LayoutStyle* style = renderer()->style(); | 1068 LayoutStyle* style = layoutObject()->style(); |
1069 // We allow selections to begin within an element that has -webkit-user- select: none set, | 1069 // We allow selections to begin within an element that has -webkit-user- select: none set, |
1070 // but if the element is draggable then dragging should take priority ov er selection. | 1070 // but if the element is draggable then dragging should take priority ov er selection. |
1071 if (style->userDrag() == DRAG_ELEMENT && style->userSelect() == SELECT_N ONE) | 1071 if (style->userDrag() == DRAG_ELEMENT && style->userSelect() == SELECT_N ONE) |
1072 return false; | 1072 return false; |
1073 } | 1073 } |
1074 return parentOrShadowHostNode() ? parentOrShadowHostNode()->canStartSelectio n() : true; | 1074 return parentOrShadowHostNode() ? parentOrShadowHostNode()->canStartSelectio n() : true; |
1075 } | 1075 } |
1076 | 1076 |
1077 bool Node::canParticipateInComposedTree() const | 1077 bool Node::canParticipateInComposedTree() const |
1078 { | 1078 { |
(...skipping 1085 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2164 if (mouseEvent->button() == MiddleButton) { | 2164 if (mouseEvent->button() == MiddleButton) { |
2165 if (enclosingLinkEventParentOrSelf()) | 2165 if (enclosingLinkEventParentOrSelf()) |
2166 return; | 2166 return; |
2167 | 2167 |
2168 // Avoid that canBeScrolledAndHasScrollableArea changes render tree | 2168 // Avoid that canBeScrolledAndHasScrollableArea changes render tree |
2169 // structure. | 2169 // structure. |
2170 // FIXME: We should avoid synchronous layout if possible. We can | 2170 // FIXME: We should avoid synchronous layout if possible. We can |
2171 // remove this synchronous layout if we avoid synchronous layout in | 2171 // remove this synchronous layout if we avoid synchronous layout in |
2172 // LayoutTextControlSingleLine::scrollHeight | 2172 // LayoutTextControlSingleLine::scrollHeight |
2173 document().updateLayoutIgnorePendingStylesheets(); | 2173 document().updateLayoutIgnorePendingStylesheets(); |
2174 LayoutObject* renderer = this->renderer(); | 2174 LayoutObject* renderer = this->layoutObject(); |
2175 while (renderer && (!renderer->isBox() || !toLayoutBox(renderer)->ca nBeScrolledAndHasScrollableArea())) | 2175 while (renderer && (!renderer->isBox() || !toLayoutBox(renderer)->ca nBeScrolledAndHasScrollableArea())) |
2176 renderer = renderer->parent(); | 2176 renderer = renderer->parent(); |
2177 | 2177 |
2178 if (renderer) { | 2178 if (renderer) { |
2179 if (LocalFrame* frame = document().frame()) | 2179 if (LocalFrame* frame = document().frame()) |
2180 frame->eventHandler().startPanScrolling(renderer); | 2180 frame->eventHandler().startPanScrolling(renderer); |
2181 } | 2181 } |
2182 } | 2182 } |
2183 #endif | 2183 #endif |
2184 } else if ((eventType == EventTypeNames::wheel || eventType == EventTypeName s::mousewheel) && event->hasInterface(EventNames::WheelEvent)) { | 2184 } else if ((eventType == EventTypeNames::wheel || eventType == EventTypeName s::mousewheel) && event->hasInterface(EventNames::WheelEvent)) { |
2185 WheelEvent* wheelEvent = toWheelEvent(event); | 2185 WheelEvent* wheelEvent = toWheelEvent(event); |
2186 | 2186 |
2187 // If we don't have a renderer, send the wheel event to the first node w e find with a renderer. | 2187 // If we don't have a renderer, send the wheel event to the first node w e find with a renderer. |
2188 // This is needed for <option> and <optgroup> elements so that <select>s get a wheel scroll. | 2188 // This is needed for <option> and <optgroup> elements so that <select>s get a wheel scroll. |
2189 Node* startNode = this; | 2189 Node* startNode = this; |
2190 while (startNode && !startNode->renderer()) | 2190 while (startNode && !startNode->layoutObject()) |
2191 startNode = startNode->parentOrShadowHostNode(); | 2191 startNode = startNode->parentOrShadowHostNode(); |
2192 | 2192 |
2193 if (startNode && startNode->renderer()) { | 2193 if (startNode && startNode->layoutObject()) { |
2194 if (LocalFrame* frame = document().frame()) | 2194 if (LocalFrame* frame = document().frame()) |
2195 frame->eventHandler().defaultWheelEventHandler(startNode, wheelE vent); | 2195 frame->eventHandler().defaultWheelEventHandler(startNode, wheelE vent); |
2196 } | 2196 } |
2197 } else if (event->type() == EventTypeNames::webkitEditableContentChanged) { | 2197 } else if (event->type() == EventTypeNames::webkitEditableContentChanged) { |
2198 dispatchInputEvent(); | 2198 dispatchInputEvent(); |
2199 } | 2199 } |
2200 } | 2200 } |
2201 | 2201 |
2202 void Node::willCallDefaultEventHandler(const Event&) | 2202 void Node::willCallDefaultEventHandler(const Event&) |
2203 { | 2203 { |
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2456 node->showTreeForThis(); | 2456 node->showTreeForThis(); |
2457 } | 2457 } |
2458 | 2458 |
2459 void showNodePath(const blink::Node* node) | 2459 void showNodePath(const blink::Node* node) |
2460 { | 2460 { |
2461 if (node) | 2461 if (node) |
2462 node->showNodePathForThis(); | 2462 node->showNodePathForThis(); |
2463 } | 2463 } |
2464 | 2464 |
2465 #endif | 2465 #endif |
OLD | NEW |