void HitTestResult::append(const HitTestResult& other) { ASSERT(isRectBasedTest() && other.isRectBasedTest()); if (!m_innerNode && other.innerNode()) { m_innerNode = other.innerNode(); m_innerNonSharedNode = other.innerNonSharedNode(); m_localPoint = other.localPoint(); m_innerURLElement = other.URLElement(); m_scrollbar = other.scrollbar(); m_isOverWidget = other.isOverWidget(); } if (other.m_rectBasedTestResult) { NodeSet& set = mutableRectBasedTestResult(); for (NodeSet::const_iterator it = other.m_rectBasedTestResult->begin(), last = other.m_rectBasedTestResult->end(); it != last; ++it) set.add(it->get()); } }
HitTestResult::HitTestResult(const HitTestResult& other) : m_innerNode(other.innerNode()) , m_innerNonSharedNode(other.innerNonSharedNode()) , m_point(other.point()) , m_localPoint(other.localPoint()) , m_innerURLElement(other.URLElement()) , m_scrollbar(other.scrollbar()) , m_isOverWidget(other.isOverWidget()) { // Only copy the padding and ListHashSet in case of rect hit test. // Copying the later is rather expensive. if ((m_isRectBased = other.isRectBasedTest())) { m_topPadding = other.m_topPadding; m_rightPadding = other.m_rightPadding; m_bottomPadding = other.m_bottomPadding; m_leftPadding = other.m_leftPadding; m_rectBasedTestResult = other.rectBasedTestResult(); } else m_topPadding = m_rightPadding = m_bottomPadding = m_leftPadding = 0; }
void HitTestResult::append(const HitTestResult& other) { ASSERT(hitTestRequest().listBased()); if (!m_scrollbar && other.scrollbar()) { setScrollbar(other.scrollbar()); } if (!m_innerNode && other.innerNode()) { m_innerNode = other.innerNode(); m_innerPossiblyPseudoNode = other.innerPossiblyPseudoNode(); m_localPoint = other.localPoint(); m_pointInInnerNodeFrame = other.m_pointInInnerNodeFrame; m_innerURLElement = other.URLElement(); m_isOverWidget = other.isOverWidget(); } if (other.m_listBasedTestResult) { NodeSet& set = mutableListBasedTestResult(); for (NodeSet::const_iterator it = other.m_listBasedTestResult->begin(), last = other.m_listBasedTestResult->end(); it != last; ++it) set.add(it->get()); } }
// Helper function to get misspelled word on which context menu // is to be evolked. This function also sets the word on which context menu // has been evoked to be the selected word, as required. This function changes // the selection only when there were no selected characters on OS X. static String selectMisspelledWord(const ContextMenu* defaultMenu, Frame* selectedFrame) { // First select from selectedText to check for multiple word selection. String misspelledWord = selectedFrame->editor()->selectedText().stripWhiteSpace(); // If some texts were already selected, we don't change the selection. if (!misspelledWord.isEmpty()) { // Don't provide suggestions for multiple words. if (!isASingleWord(misspelledWord)) return String(); return misspelledWord; } // Selection is empty, so change the selection to the word under the cursor. HitTestResult hitTestResult = selectedFrame->eventHandler()-> hitTestResultAtPoint(defaultMenu->hitTestResult().point(), true); Node* innerNode = hitTestResult.innerNode(); VisiblePosition pos(innerNode->renderer()->positionForPoint( hitTestResult.localPoint())); if (pos.isNull()) return misspelledWord; // It is empty. WebFrameImpl::selectWordAroundPosition(selectedFrame, pos); misspelledWord = selectedFrame->editor()->selectedText().stripWhiteSpace(); #if OS(DARWIN) // If misspelled word is still empty, then that portion should not be // selected. Set the selection to that position only, and do not expand. if (misspelledWord.isEmpty()) selectedFrame->selection()->setSelection(VisibleSelection(pos)); #else // On non-Mac, right-click should not make a range selection in any case. selectedFrame->selection()->setSelection(VisibleSelection(pos)); #endif return misspelledWord; }
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; }
HitTestResult::HitTestResult(const HitTestResult& other) : m_hitTestLocation(other.m_hitTestLocation) , m_localPoint(other.localPoint()) { }