Fat fingers - Add a clearer way to distinguish the node we want (shadow or non-shadow)
https://bugs.webkit.org/show_bug.cgi?id=79256
PR #127814 / MKS_2587410
Reviewed by Rob Buis.
Patch adds a cleaner way for call sites of FatFingersResult to
query for the appropriated target node: shadow or non-shadow DOM nodes.
It also renames FatFingersResults::validNode to ::node, assuming
that "invalid" nodes are not applicable in any context.
* Api/WebPage.cpp:
(BlackBerry::WebKit::WebPagePrivate::clearDocumentData):
(BlackBerry::WebKit::WebPagePrivate::contextNode):
(BlackBerry::WebKit::WebPagePrivate::handleMouseEvent):
* WebKitSupport/FatFingers.h:
(FatFingersResult):
(BlackBerry::WebKit::FatFingersResult::node):
(BlackBerry::WebKit::FatFingersResult::nodeAsElementIfApplicable):
* WebKitSupport/SelectionHandler.cpp:
(BlackBerry::WebKit::SelectionHandler::selectAtPoint):
* WebKitSupport/TouchEventHandler.cpp:
(BlackBerry::WebKit::TouchEventHandler::touchHoldEvent):
(BlackBerry::WebKit::TouchEventHandler::handleTouchPoint):
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@108721
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
// Check for text input.
if (isTouching && lastFatFingersResult.isTextInput())
- return lastFatFingersResult.node(ShadowContentNotAllowed);
+ return lastFatFingersResult.node(FatFingersResult::ShadowContentNotAllowed);
IntPoint contentPos;
if (isTouching)
if (strategy == RectBased) {
FatFingersResult result = FatFingers(this, lastFatFingersResult.adjustedPosition(), FatFingers::Text).findBestPoint();
- return result.node(ShadowContentNotAllowed);
+ return result.node(FatFingersResult::ShadowContentNotAllowed);
}
HitTestResult result = eventHandler->hitTestResultAtPoint(contentPos, false /*allowShadowContent*/);
const FatFingersResult lastFatFingersResult = m_touchEventHandler->lastFatFingersResult();
// Fat fingers can deal with shadow content.
- node = lastFatFingersResult.node(ShadowContentNotAllowed);
+ node = lastFatFingersResult.node(FatFingersResult::ShadowContentNotAllowed);
}
if (!node) {
+2012-02-19 Antonio Gomes <agomes@rim.com>
+
+ Fat fingers - Add a clearer way to distinguish the node we want (shadow or non-shadow)
+ https://bugs.webkit.org/show_bug.cgi?id=79256
+ PR #127814 / MKS_2587410
+
+ Reviewed by Rob Buis.
+
+ Patch adds a cleaner way for call sites of FatFingersResult to
+ query for the appropriated target node: shadow or non-shadow DOM nodes.
+
+ It also renames FatFingersResults::validNode to ::node, assuming
+ that "invalid" nodes are not applicable in any context.
+
+ * Api/WebPage.cpp:
+ (BlackBerry::WebKit::WebPagePrivate::clearDocumentData):
+ (BlackBerry::WebKit::WebPagePrivate::contextNode):
+ (BlackBerry::WebKit::WebPagePrivate::handleMouseEvent):
+ * WebKitSupport/FatFingers.h:
+ (FatFingersResult):
+ (BlackBerry::WebKit::FatFingersResult::node):
+ (BlackBerry::WebKit::FatFingersResult::nodeAsElementIfApplicable):
+ * WebKitSupport/SelectionHandler.cpp:
+ (BlackBerry::WebKit::SelectionHandler::selectAtPoint):
+ * WebKitSupport/TouchEventHandler.cpp:
+ (BlackBerry::WebKit::TouchEventHandler::touchHoldEvent):
+ (BlackBerry::WebKit::TouchEventHandler::handleTouchPoint):
+
2012-02-23 Jacky Jiang <zhajiang@rim.com>
[BlackBerry] Upstream BlackBerry API web page related files
class FatFingersResult {
public:
+
FatFingersResult(const WebCore::IntPoint& p = WebCore::IntPoint::zero())
: m_originalPosition(p)
, m_adjustedPosition(p)
bool positionWasAdjusted() const { return m_isValid && m_positionWasAdjusted; }
bool isTextInput() const { return m_isValid && !!m_nodeUnderFatFinger && m_isTextInput; }
bool isValid() const { return m_isValid; }
- WebCore::Node* validNode() const { return m_nodeUnderFatFinger && m_nodeUnderFatFinger->inDocument() ? m_nodeUnderFatFinger.get() : 0; }
- WebCore::Element* nodeAsElementIfApplicable() const
+
+ enum ContentType { ShadowContentAllowed, ShadowContentNotAllowed };
+
+ WebCore::Node* node(ContentType type = ShadowContentAllowed) const
{
- return static_cast<WebCore::Element*>(m_nodeUnderFatFinger && m_nodeUnderFatFinger->inDocument() && m_nodeUnderFatFinger->isElementNode() ? m_nodeUnderFatFinger.get() : 0);
+ if (!m_nodeUnderFatFinger || !m_nodeUnderFatFinger->inDocument())
+ return 0;
+
+ WebCore::Node* result = m_nodeUnderFatFinger.get();
+
+ if (type == ShadowContentAllowed)
+ return result;
+
+ // Shadow trees can be nested.
+ while (result->isInShadowTree())
+ result = toElement(result->shadowAncestorNode());
+
+ return result;
+ }
+
+ WebCore::Element* nodeAsElementIfApplicable(ContentType type = ShadowContentAllowed) const
+ {
+ WebCore::Node* result = node(type);
+ if (!result || !result->isElementNode())
+ return 0;
+
+ return static_cast<WebCore::Element*>(result);
}
private:
// FIXME: Factory this get right fat finger code into a helper.
const FatFingersResult lastFatFingersResult = m_webPage->m_touchEventHandler->lastFatFingersResult();
if (lastFatFingersResult.positionWasAdjusted() && lastFatFingersResult.nodeAsElementIfApplicable()) {
- targetNode = lastFatFingersResult.validNode();
+ targetNode = lastFatFingersResult.node(FatFingersResult::ShadowContentNotAllowed);
targetPosition = lastFatFingersResult.adjustedPosition();
} else {
FatFingersResult newFatFingersResult = FatFingers(m_webPage, location, FatFingers::Text).findBestPoint();
return;
targetPosition = newFatFingersResult.adjustedPosition();
- targetNode = newFatFingersResult.validNode();
+ targetNode = newFatFingersResult.node(FatFingersResult::ShadowContentNotAllowed);
}
ASSERT(targetNode);
handleFatFingerPressed();
// Clear the focus ring indication if tap-and-hold'ing on a link.
- if (m_lastFatFingersResult.validNode() && m_lastFatFingersResult.validNode()->isLink())
+ if (m_lastFatFingersResult.node() && m_lastFatFingersResult.node()->isLink())
m_webPage->clearFocusNode();
}
m_lastFatFingersResult = FatFingers(m_webPage, contentPos, FatFingers::ClickableElement).findBestPoint();
Element* elementUnderFatFinger = 0;
- if (m_lastFatFingersResult.positionWasAdjusted() && m_lastFatFingersResult.validNode()) {
- ASSERT(m_lastFatFingersResult.validNode()->isElementNode());
+ if (m_lastFatFingersResult.positionWasAdjusted() && m_lastFatFingersResult.node()) {
+ ASSERT(m_lastFatFingersResult.node()->isElementNode());
elementUnderFatFinger = m_lastFatFingersResult.nodeAsElementIfApplicable();
}
// Set or reset the touch mode.
- Element* possibleTargetNodeForMouseMoveEvents = static_cast<Element*>(m_lastFatFingersResult.positionWasAdjusted() ? elementUnderFatFinger : m_lastFatFingersResult.validNode());
+ Element* possibleTargetNodeForMouseMoveEvents = static_cast<Element*>(m_lastFatFingersResult.positionWasAdjusted() ? elementUnderFatFinger : m_lastFatFingersResult.node());
m_convertTouchToMouse = shouldConvertTouchToMouse(possibleTargetNodeForMouseMoveEvents);
if (elementUnderFatFinger)