Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(994)

Unified Diff: Source/core/page/EventHandler.cpp

Issue 1149373003: Remove Range.compareNode() as it is not in the spec (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: layout tests changed Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« Source/core/frame/UseCounter.cpp ('K') | « Source/core/frame/UseCounter.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/page/EventHandler.cpp
diff --git a/Source/core/page/EventHandler.cpp b/Source/core/page/EventHandler.cpp
index 17680fb568c943022b1296e3bf08c7893a8f51ad..bac91e47042a4fae8a4db4324f19d7f4d99e8b91 100644
--- a/Source/core/page/EventHandler.cpp
+++ b/Source/core/page/EventHandler.cpp
@@ -2054,10 +2054,14 @@ bool EventHandler::handleMouseFocus(const MouseEventWithHitTestResults& targeted
// mouseup will set a selection inside it, which will call
// FrameSelection::setFocusedNodeIfNeeded.
if (element
- && m_frame->selection().isRange()
- && m_frame->selection().toNormalizedRange()->compareNode(element, IGNORE_EXCEPTION) == Range::NODE_INSIDE
- && element->isDescendantOf(m_frame->document()->focusedElement()))
- return false;
+ && m_frame->selection().isRange()) {
+ RefPtrWillBeRawPtr<Range> selectedRange = m_frame->selection().toNormalizedRange();
+ bool nodeFullySelected = Range::compareBoundaryPoints(element->parentNode(), element->nodeIndex(), selectedRange->startContainer(), selectedRange->startOffset(), IGNORE_EXCEPTION) >= 0
+ && Range::compareBoundaryPoints(element->parentNode(), element->nodeIndex() + 1, selectedRange->endContainer(), selectedRange->endOffset(), IGNORE_EXCEPTION) <= 0;
+ if (nodeFullySelected && element->isDescendantOf(m_frame->document()->focusedElement()))
+ return false;
+ }
+
// Only change the focus when clicking scrollbars if it can transfered to a
// mouse focusable node.
« Source/core/frame/UseCounter.cpp ('K') | « Source/core/frame/UseCounter.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698