void RenderTextControl::hitInnerTextElement(HitTestResult& result, int xPos, int yPos, int tx, int ty) { result.setInnerNode(m_innerText.get()); result.setInnerNonSharedNode(m_innerText.get()); result.setLocalPoint(IntPoint(xPos - tx - x() - m_innerText->renderBox()->x(), yPos - ty - y() - m_innerText->renderBox()->y())); }
void RenderTextControl::hitInnerTextElement(HitTestResult& result, const LayoutPoint& pointInContainer, const LayoutPoint& accumulatedOffset) { LayoutPoint adjustedLocation = accumulatedOffset + location(); HTMLElement* innerText = innerTextElement(); result.setInnerNode(innerText); result.setInnerNonSharedNode(innerText); result.setLocalPoint(pointInContainer - toLayoutSize(adjustedLocation + innerText->renderBox()->location())); }
void RenderTextControl::hitInnerTextElement(HitTestResult& result, const LayoutPoint& pointInContainer, const LayoutPoint& accumulatedOffset) { TextControlInnerTextElement* innerText = innerTextElement(); if (!innerText->renderer()) return; LayoutPoint adjustedLocation = accumulatedOffset + location(); LayoutPoint localPoint = pointInContainer - toLayoutSize(adjustedLocation + innerText->renderBox()->location()) + scrolledContentOffset(); result.setInnerNode(innerText); result.setInnerNonSharedNode(innerText); result.setLocalPoint(localPoint); }
void RenderView::updateHitTestResult(HitTestResult& result, const IntPoint& point) { if (result.innerNode()) return; Node* node = document()->documentElement(); if (node) { result.setInnerNode(node); if (!result.innerNonSharedNode()) result.setInnerNonSharedNode(node); result.setLocalPoint(point); } }
void RenderTextControl::hitInnerEditorElement(HitTestResult& result, const LayoutPoint& pointInContainer, const LayoutPoint& accumulatedOffset) { HTMLElement* innerEditor = innerEditorElement(); if (!innerEditor->renderer()) return; LayoutPoint adjustedLocation = accumulatedOffset + location(); LayoutPoint localPoint = pointInContainer - toLayoutSize(adjustedLocation + innerEditor->renderBox()->location()); if (hasOverflowClip()) localPoint += scrolledContentOffset(); result.setInnerNode(innerEditor); result.setInnerNonSharedNode(innerEditor); result.setLocalPoint(localPoint); }
void RenderView::updateHitTestResult(HitTestResult& result, const LayoutPoint& point) { if (result.innerNode()) return; Node* node = document()->documentElement(); if (node) { result.setInnerNode(node); if (!result.innerNonSharedNode()) result.setInnerNonSharedNode(node); LayoutPoint adjustedPoint = point; offsetForContents(adjustedPoint); result.setLocalPoint(adjustedPoint); } }
bool RenderTextControlSingleLine::nodeAtPoint(const HitTestRequest& request, HitTestResult& result, int xPos, int yPos, int tx, int ty, HitTestAction hitTestAction) { // If we're within the text control, we want to act as if we've hit the inner text block element, in case the point // was on the control but not on the inner element (see Radar 4617841). // In a search field, we want to act as if we've hit the results block if we're to the left of the inner text block, // and act as if we've hit the close block if we're to the right of the inner text block. if (!RenderTextControl::nodeAtPoint(request, result, xPos, yPos, tx, ty, hitTestAction)) return false; // If we hit a node inside the inner text element, say that we hit that element, // and if we hit our node (e.g. we're over the border or padding), also say that we hit the // inner text element so that it gains focus. if (result.innerNode()->isDescendantOf(innerTextElement()) || result.innerNode() == node()) hitInnerTextElement(result, xPos, yPos, tx, ty); // If we're not a search field, or we already found the results or cancel buttons, we're done. if (!m_innerBlock || result.innerNode() == m_resultsButton || result.innerNode() == m_cancelButton) return true; Node* innerNode = 0; RenderBox* innerBlockRenderer = m_innerBlock->renderBox(); RenderBox* innerTextRenderer = innerTextElement()->renderBox(); IntPoint localPoint = result.localPoint(); localPoint.move(-innerBlockRenderer->x(), -innerBlockRenderer->y()); int textLeft = tx + x() + innerBlockRenderer->x() + innerTextRenderer->x(); if (m_resultsButton && m_resultsButton->renderer() && xPos < textLeft) innerNode = m_resultsButton.get(); if (!innerNode) { int textRight = textLeft + innerTextRenderer->width(); if (m_cancelButton && m_cancelButton->renderer() && xPos > textRight) innerNode = m_cancelButton.get(); } if (innerNode) { result.setInnerNode(innerNode); localPoint.move(-innerNode->renderBox()->x(), -innerNode->renderBox()->y()); } result.setLocalPoint(localPoint); return true; }
bool RenderTextControlSingleLine::nodeAtPoint(const HitTestRequest& request, HitTestResult& result, int xPos, int yPos, int tx, int ty, HitTestAction hitTestAction) { // If we're within the text control, we want to act as if we've hit the inner text block element, in case the point // was on the control but not on the inner element (see Radar 4617841). // In a search field, we want to act as if we've hit the results block if we're to the left of the inner text block, // and act as if we've hit the close block if we're to the right of the inner text block. if (!RenderTextControl::nodeAtPoint(request, result, xPos, yPos, tx, ty, hitTestAction)) return false; if (result.innerNode() != element() && result.innerNode() != m_innerBlock.get()) return false; hitInnerTextBlock(result, xPos, yPos, tx, ty); if (!m_innerBlock) return true; Node* innerNode = 0; RenderBox* innerBlockRenderer = m_innerBlock->renderBox(); RenderBox* innerTextRenderer = innerTextElement()->renderBox(); IntPoint localPoint = result.localPoint(); localPoint.move(-innerBlockRenderer->x(), -innerBlockRenderer->y()); int textLeft = tx + x() + innerBlockRenderer->x() + innerTextRenderer->x(); if (m_resultsButton && m_resultsButton->renderer() && xPos < textLeft) innerNode = m_resultsButton.get(); if (!innerNode) { int textRight = textLeft + innerTextRenderer->width(); if (m_cancelButton && m_cancelButton->renderer() && xPos > textRight) innerNode = m_cancelButton.get(); } if (innerNode) { result.setInnerNode(innerNode); localPoint.move(-innerNode->renderBox()->x(), -innerNode->renderBox()->y()); } result.setLocalPoint(localPoint); return true; }
bool RenderListBox::nodeAtPoint(const HitTestRequest& request, HitTestResult& result, int x, int y, int tx, int ty, HitTestAction hitTestAction) { if (!RenderBlock::nodeAtPoint(request, result, x, y, tx, ty, hitTestAction)) return false; const Vector<Element*>& listItems = toSelectElement(static_cast<Element*>(node()))->listItems(); int size = numItems(); tx += this->x(); ty += this->y(); for (int i = 0; i < size; ++i) { if (itemBoundingBoxRect(tx, ty, i).contains(x, y)) { if (Element* node = listItems[i]) { result.setInnerNode(node); if (!result.innerNonSharedNode()) result.setInnerNonSharedNode(node); result.setLocalPoint(IntPoint(x - tx, y - ty)); break; } } } return true; }
bool RenderListBox::nodeAtPoint(const HitTestRequest& request, HitTestResult& result, const LayoutPoint& pointInContainer, const LayoutPoint& accumulatedOffset, HitTestAction hitTestAction) { if (!RenderBlock::nodeAtPoint(request, result, pointInContainer, accumulatedOffset, hitTestAction)) return false; const Vector<HTMLElement*>& listItems = toHTMLSelectElement(node())->listItems(); int size = numItems(); LayoutPoint adjustedLocation = accumulatedOffset + location(); for (int i = 0; i < size; ++i) { if (itemBoundingBoxRect(adjustedLocation, i).contains(pointInContainer)) { if (Element* node = listItems[i]) { result.setInnerNode(node); if (!result.innerNonSharedNode()) result.setInnerNonSharedNode(node); result.setLocalPoint(pointInContainer - toLayoutSize(adjustedLocation)); break; } } } return true; }
bool RenderTextControlSingleLine::nodeAtPoint(const HitTestRequest& request, HitTestResult& result, const IntPoint& pointInContainer, const IntPoint& accumulatedOffset, HitTestAction hitTestAction) { // If we're within the text control, we want to act as if we've hit the inner text block element, in case the point // was on the control but not on the inner element (see Radar 4617841). // In a search field, we want to act as if we've hit the results block if we're to the left of the inner text block, // and act as if we've hit the close block if we're to the right of the inner text block. if (!RenderTextControl::nodeAtPoint(request, result, pointInContainer, accumulatedOffset, hitTestAction)) return false; // If we hit a node inside the inner text element, say that we hit that element, // and if we hit our node (e.g. we're over the border or padding), also say that we hit the // inner text element so that it gains focus. if (result.innerNode()->isDescendantOf(innerTextElement()) || result.innerNode() == node()) hitInnerTextElement(result, pointInContainer, accumulatedOffset); // If we found a spin button, we're done. HTMLElement* innerSpinButton = innerSpinButtonElement(); if (innerSpinButton && result.innerNode() == innerSpinButton) return true; #if ENABLE(INPUT_SPEECH) HTMLElement* speechButton = speechButtonElement(); if (speechButton && result.innerNode() == speechButton) return true; #endif // If we're not a search field, or we already found the speech, results or cancel buttons, we're done. HTMLElement* innerBlock = innerBlockElement(); HTMLElement* resultsButton = resultsButtonElement(); HTMLElement* cancelButton = cancelButtonElement(); if (!innerBlock || result.innerNode() == resultsButton || result.innerNode() == cancelButton) return true; Node* innerNode = 0; RenderBox* innerBlockRenderer = innerBlock->renderBox(); RenderBox* innerTextRenderer = innerTextElement()->renderBox(); IntPoint localPoint = result.localPoint(); localPoint.move(-innerBlockRenderer->location()); int textLeft = accumulatedOffset.x() + x() + innerBlockRenderer->x() + innerTextRenderer->x(); if (resultsButton && resultsButton->renderer() && pointInContainer.x() < textLeft) innerNode = resultsButton; #if ENABLE(INPUT_SPEECH) if (!innerNode && speechButtonElement() && speechButtonElement()->renderer()) { int buttonLeft = accumulatedOffset.x() + x() + innerBlockRenderer->x() + innerBlockRenderer->width() - speechButtonElement()->renderBox()->width(); if (pointInContainer.x() >= buttonLeft) innerNode = speechButtonElement(); } #endif if (!innerNode) { int textRight = textLeft + innerTextRenderer->width(); if (cancelButton && cancelButton->renderer() && pointInContainer.x() > textRight) innerNode = cancelButton; } if (innerNode) { result.setInnerNode(innerNode); localPoint.move(-innerNode->renderBox()->location()); } result.setLocalPoint(localPoint); return true; }