summaryrefslogtreecommitdiffstats
path: root/Source/WebCore/page/SpatialNavigation.cpp
diff options
context:
space:
mode:
authorBen Murdoch <benm@google.com>2011-05-24 11:24:40 +0100
committerBen Murdoch <benm@google.com>2011-06-02 09:53:15 +0100
commit81bc750723a18f21cd17d1b173cd2a4dda9cea6e (patch)
tree7a9e5ed86ff429fd347a25153107221543909b19 /Source/WebCore/page/SpatialNavigation.cpp
parent94088a6d336c1dd80a1e734af51e96abcbb689a7 (diff)
downloadexternal_webkit-81bc750723a18f21cd17d1b173cd2a4dda9cea6e.zip
external_webkit-81bc750723a18f21cd17d1b173cd2a4dda9cea6e.tar.gz
external_webkit-81bc750723a18f21cd17d1b173cd2a4dda9cea6e.tar.bz2
Merge WebKit at r80534: Intial merge by Git
Change-Id: Ia7a83357124c9e1cdb1debf55d9661ec0bd09a61
Diffstat (limited to 'Source/WebCore/page/SpatialNavigation.cpp')
-rw-r--r--Source/WebCore/page/SpatialNavigation.cpp36
1 files changed, 32 insertions, 4 deletions
diff --git a/Source/WebCore/page/SpatialNavigation.cpp b/Source/WebCore/page/SpatialNavigation.cpp
index 34a2c97..15d3639 100644
--- a/Source/WebCore/page/SpatialNavigation.cpp
+++ b/Source/WebCore/page/SpatialNavigation.cpp
@@ -39,6 +39,7 @@
#include "IntRect.h"
#include "Node.h"
#include "Page.h"
+#include "RenderInline.h"
#include "RenderLayer.h"
#include "Settings.h"
@@ -594,12 +595,39 @@ void entryAndExitPointsForDirection(FocusDirection direction, const IntRect& sta
}
}
+bool areElementsOnSameLine(const FocusCandidate& firstCandidate, const FocusCandidate& secondCandidate)
+{
+ if (firstCandidate.isNull() || secondCandidate.isNull())
+ return false;
+
+ if (!firstCandidate.visibleNode->renderer() || !secondCandidate.visibleNode->renderer())
+ return false;
+
+ if (!firstCandidate.rect.intersects(secondCandidate.rect))
+ return false;
+
+ if (firstCandidate.focusableNode->hasTagName(HTMLNames::areaTag) || secondCandidate.focusableNode->hasTagName(HTMLNames::areaTag))
+ return false;
+
+ if (!firstCandidate.visibleNode->renderer()->isRenderInline() || !secondCandidate.visibleNode->renderer()->isRenderInline())
+ return false;
+
+ if (firstCandidate.visibleNode->renderer()->containingBlock() != secondCandidate.visibleNode->renderer()->containingBlock())
+ return false;
+
+ return true;
+}
+
void distanceDataForNode(FocusDirection direction, const FocusCandidate& current, FocusCandidate& candidate)
{
- if (candidate.isNull())
- return;
- if (!candidate.visibleNode->renderer())
- return;
+ if (areElementsOnSameLine(current, candidate)) {
+ if ((direction == FocusDirectionUp && current.rect.y() > candidate.rect.y()) || (direction == FocusDirectionDown && candidate.rect.y() > current.rect.y())) {
+ candidate.distance = 0;
+ candidate.alignment = Full;
+ return;
+ }
+ }
+
IntRect nodeRect = candidate.rect;
IntRect currentRect = current.rect;
deflateIfOverlapped(currentRect, nodeRect);