| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2006, 2008, 2011 Apple Inc. All rights reserved. | 2 * Copyright (C) 2006, 2008, 2011 Apple Inc. All rights reserved. |
| 3 * Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies) | 3 * Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies) |
| 4 * | 4 * |
| 5 * This library is free software; you can redistribute it and/or | 5 * This library is free software; you can redistribute it and/or |
| 6 * modify it under the terms of the GNU Library General Public | 6 * modify it under the terms of the GNU Library General Public |
| 7 * License as published by the Free Software Foundation; either | 7 * License as published by the Free Software Foundation; either |
| 8 * version 2 of the License, or (at your option) any later version. | 8 * version 2 of the License, or (at your option) any later version. |
| 9 * | 9 * |
| 10 * This library is distributed in the hope that it will be useful, | 10 * This library is distributed in the hope that it will be useful, |
| (...skipping 25 matching lines...) Expand all Loading... |
| 36 #include "core/html/HTMLInputElement.h" | 36 #include "core/html/HTMLInputElement.h" |
| 37 #include "core/html/HTMLMediaElement.h" | 37 #include "core/html/HTMLMediaElement.h" |
| 38 #include "core/html/HTMLTextAreaElement.h" | 38 #include "core/html/HTMLTextAreaElement.h" |
| 39 #include "core/html/HTMLVideoElement.h" | 39 #include "core/html/HTMLVideoElement.h" |
| 40 #include "core/html/parser/HTMLParserIdioms.h" | 40 #include "core/html/parser/HTMLParserIdioms.h" |
| 41 #include "core/page/Frame.h" | 41 #include "core/page/Frame.h" |
| 42 #include "core/page/FrameTree.h" | 42 #include "core/page/FrameTree.h" |
| 43 #include "core/platform/Scrollbar.h" | 43 #include "core/platform/Scrollbar.h" |
| 44 #include "core/rendering/HitTestLocation.h" | 44 #include "core/rendering/HitTestLocation.h" |
| 45 #include "core/rendering/RenderImage.h" | 45 #include "core/rendering/RenderImage.h" |
| 46 #include "core/rendering/RenderTextFragment.h" |
| 46 | 47 |
| 47 namespace WebCore { | 48 namespace WebCore { |
| 48 | 49 |
| 49 using namespace HTMLNames; | 50 using namespace HTMLNames; |
| 50 | 51 |
| 51 HitTestResult::HitTestResult() | 52 HitTestResult::HitTestResult() |
| 52 : m_isOverWidget(false) | 53 : m_isOverWidget(false) |
| 53 , m_allowPseudoElements(false) | 54 , m_allowPseudoElements(false) |
| 55 , m_isFirstLetter(false) |
| 54 { | 56 { |
| 55 } | 57 } |
| 56 | 58 |
| 57 HitTestResult::HitTestResult(const LayoutPoint& point) | 59 HitTestResult::HitTestResult(const LayoutPoint& point) |
| 58 : m_hitTestLocation(point) | 60 : m_hitTestLocation(point) |
| 59 , m_pointInInnerNodeFrame(point) | 61 , m_pointInInnerNodeFrame(point) |
| 60 , m_isOverWidget(false) | 62 , m_isOverWidget(false) |
| 61 , m_allowPseudoElements(false) | 63 , m_allowPseudoElements(false) |
| 64 , m_isFirstLetter(false) |
| 62 { | 65 { |
| 63 } | 66 } |
| 64 | 67 |
| 65 HitTestResult::HitTestResult(const LayoutPoint& centerPoint, unsigned topPadding
, unsigned rightPadding, unsigned bottomPadding, unsigned leftPadding) | 68 HitTestResult::HitTestResult(const LayoutPoint& centerPoint, unsigned topPadding
, unsigned rightPadding, unsigned bottomPadding, unsigned leftPadding) |
| 66 : m_hitTestLocation(centerPoint, topPadding, rightPadding, bottomPadding, le
ftPadding) | 69 : m_hitTestLocation(centerPoint, topPadding, rightPadding, bottomPadding, le
ftPadding) |
| 67 , m_pointInInnerNodeFrame(centerPoint) | 70 , m_pointInInnerNodeFrame(centerPoint) |
| 71 , m_isFirstLetter(false) |
| 68 , m_isOverWidget(false) | 72 , m_isOverWidget(false) |
| 69 , m_allowPseudoElements(false) | 73 , m_allowPseudoElements(false) |
| 70 { | 74 { |
| 71 } | 75 } |
| 72 | 76 |
| 73 HitTestResult::HitTestResult(const HitTestLocation& other) | 77 HitTestResult::HitTestResult(const HitTestLocation& other) |
| 74 : m_hitTestLocation(other) | 78 : m_hitTestLocation(other) |
| 75 , m_pointInInnerNodeFrame(m_hitTestLocation.point()) | 79 , m_pointInInnerNodeFrame(m_hitTestLocation.point()) |
| 80 , m_isFirstLetter(false) |
| 76 , m_isOverWidget(false) | 81 , m_isOverWidget(false) |
| 77 , m_allowPseudoElements(false) | 82 , m_allowPseudoElements(false) |
| 78 { | 83 { |
| 79 } | 84 } |
| 80 | 85 |
| 81 HitTestResult::HitTestResult(const HitTestResult& other) | 86 HitTestResult::HitTestResult(const HitTestResult& other) |
| 82 : m_hitTestLocation(other.m_hitTestLocation) | 87 : m_hitTestLocation(other.m_hitTestLocation) |
| 83 , m_innerNode(other.m_innerNode) | 88 , m_innerNode(other.m_innerNode) |
| 84 , m_innerNonSharedNode(other.m_innerNonSharedNode) | 89 , m_innerNonSharedNode(other.m_innerNonSharedNode) |
| 85 , m_pointInInnerNodeFrame(other.m_pointInInnerNodeFrame) | 90 , m_pointInInnerNodeFrame(other.m_pointInInnerNodeFrame) |
| 86 , m_localPoint(other.localPoint()) | 91 , m_localPoint(other.localPoint()) |
| 87 , m_innerURLElement(other.URLElement()) | 92 , m_innerURLElement(other.URLElement()) |
| 88 , m_scrollbar(other.scrollbar()) | 93 , m_scrollbar(other.scrollbar()) |
| 94 , m_isFirstLetter(other.m_isFirstLetter) |
| 89 , m_isOverWidget(other.isOverWidget()) | 95 , m_isOverWidget(other.isOverWidget()) |
| 90 , m_allowPseudoElements(other.m_allowPseudoElements) | 96 , m_allowPseudoElements(other.m_allowPseudoElements) |
| 91 { | 97 { |
| 92 // Only copy the NodeSet in case of rect hit test. | 98 // Only copy the NodeSet in case of rect hit test. |
| 93 m_rectBasedTestResult = adoptPtr(other.m_rectBasedTestResult ? new NodeSet(*
other.m_rectBasedTestResult) : 0); | 99 m_rectBasedTestResult = adoptPtr(other.m_rectBasedTestResult ? new NodeSet(*
other.m_rectBasedTestResult) : 0); |
| 94 } | 100 } |
| 95 | 101 |
| 96 HitTestResult::~HitTestResult() | 102 HitTestResult::~HitTestResult() |
| 97 { | 103 { |
| 98 } | 104 } |
| 99 | 105 |
| 100 HitTestResult& HitTestResult::operator=(const HitTestResult& other) | 106 HitTestResult& HitTestResult::operator=(const HitTestResult& other) |
| 101 { | 107 { |
| 102 m_hitTestLocation = other.m_hitTestLocation; | 108 m_hitTestLocation = other.m_hitTestLocation; |
| 103 m_innerNode = other.m_innerNode; | 109 m_innerNode = other.m_innerNode; |
| 104 m_innerNonSharedNode = other.m_innerNonSharedNode; | 110 m_innerNonSharedNode = other.m_innerNonSharedNode; |
| 105 m_pointInInnerNodeFrame = other.m_pointInInnerNodeFrame; | 111 m_pointInInnerNodeFrame = other.m_pointInInnerNodeFrame; |
| 106 m_localPoint = other.localPoint(); | 112 m_localPoint = other.localPoint(); |
| 107 m_innerURLElement = other.URLElement(); | 113 m_innerURLElement = other.URLElement(); |
| 108 m_scrollbar = other.scrollbar(); | 114 m_scrollbar = other.scrollbar(); |
| 115 m_isFirstLetter = other.m_isFirstLetter; |
| 109 m_isOverWidget = other.isOverWidget(); | 116 m_isOverWidget = other.isOverWidget(); |
| 110 m_allowPseudoElements |= other.m_allowPseudoElements; // Do not lose the pse
udo element tracking if allowed. | 117 m_allowPseudoElements |= other.m_allowPseudoElements; // Do not lose the pse
udo element tracking if allowed. |
| 111 | 118 |
| 112 // Only copy the NodeSet in case of rect hit test. | 119 // Only copy the NodeSet in case of rect hit test. |
| 113 m_rectBasedTestResult = adoptPtr(other.m_rectBasedTestResult ? new NodeSet(*
other.m_rectBasedTestResult) : 0); | 120 m_rectBasedTestResult = adoptPtr(other.m_rectBasedTestResult ? new NodeSet(*
other.m_rectBasedTestResult) : 0); |
| 114 | 121 |
| 115 return *this; | 122 return *this; |
| 116 } | 123 } |
| 117 | 124 |
| 125 RenderObject* HitTestResult::renderer() const |
| 126 { |
| 127 if (!m_innerNode) |
| 128 return 0; |
| 129 RenderObject* renderer = m_innerNode->renderer(); |
| 130 if (!m_isFirstLetter || !renderer || !renderer->isText() || !toRenderText(re
nderer)->isTextFragment()) |
| 131 return renderer; |
| 132 return toRenderTextFragment(renderer)->firstRenderTextInFirstLetter(); |
| 133 } |
| 134 |
| 118 void HitTestResult::setToNodesInDocumentTreeScope() | 135 void HitTestResult::setToNodesInDocumentTreeScope() |
| 119 { | 136 { |
| 120 if (Node* node = innerNode()) { | 137 if (Node* node = innerNode()) { |
| 121 node = node->document().ancestorInThisScope(node); | 138 node = node->document().ancestorInThisScope(node); |
| 122 setInnerNode(node); | 139 setInnerNode(node); |
| 123 } | 140 } |
| 124 | 141 |
| 125 if (Node* node = innerNonSharedNode()) { | 142 if (Node* node = innerNonSharedNode()) { |
| 126 node = node->document().ancestorInThisScope(node); | 143 node = node->document().ancestorInThisScope(node); |
| 127 setInnerNonSharedNode(node); | 144 setInnerNonSharedNode(node); |
| (...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 498 Element* HitTestResult::innerElement() const | 515 Element* HitTestResult::innerElement() const |
| 499 { | 516 { |
| 500 for (Node* node = m_innerNode.get(); node; node = NodeRenderingTraversal::pa
rent(node)) | 517 for (Node* node = m_innerNode.get(); node; node = NodeRenderingTraversal::pa
rent(node)) |
| 501 if (node->isElementNode()) | 518 if (node->isElementNode()) |
| 502 return toElement(node); | 519 return toElement(node); |
| 503 | 520 |
| 504 return 0; | 521 return 0; |
| 505 } | 522 } |
| 506 | 523 |
| 507 } // namespace WebCore | 524 } // namespace WebCore |
| OLD | NEW |