Changeset 173857 in webkit
- Timestamp:
- Sep 22, 2014, 5:23:54 PM (11 years ago)
- Location:
- trunk
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r173856 r173857 1 2014-09-22 Simon Fraser <simon.fraser@apple.com> 2 3 Move nodeFromPoint() back to Document where it belongs 4 https://bugs.webkit.org/show_bug.cgi?id=137012 5 6 Reviewed by Zalan Bujtas. 7 8 All platforms use subpixel layout now, so remove the conditional behavior in this test. 9 Fix the test to account for scaling now being done in layout units. 10 11 * fast/dom/Document/CaretRangeFromPoint/hittest-relative-to-viewport-expected.txt: 12 * fast/dom/Document/CaretRangeFromPoint/hittest-relative-to-viewport.html: 13 * platform/mac/fast/dom/Document/CaretRangeFromPoint/hittest-relative-to-viewport-expected.txt: 14 1 15 2014-09-22 Benjamin Poulain <bpoulain@apple.com> 2 16 -
trunk/LayoutTests/fast/dom/Document/CaretRangeFromPoint/hittest-relative-to-viewport-expected.txt
r49990 r173857 25 25 PASS Range.startOffset check (got 1, expected 1) 26 26 PASS Range.startContainer check (got [object Text], expected [object Text]) 27 PASS Range.startOffset check (got 13, expected 13)27 PASS Range.startOffset check (got 6, expected 6) 28 28 PASS Range.startContainer check (got [object Text], expected [object Text]) 29 29 PASS Range.startOffset check (got 4, expected 4) 30 30 PASS Range.startContainer check (got [object Text], expected [object Text]) 31 PASS Range.startOffset check (got 1 6, expected 16)31 PASS Range.startOffset check (got 10, expected 10) 32 32 33 33 PASS successfullyParsed is true -
trunk/LayoutTests/fast/dom/Document/CaretRangeFromPoint/hittest-relative-to-viewport.html
r155265 r173857 27 27 28 28 <script> 29 var r = document.getElementById('subpixel-test').getBoundingClientRect();30 var hasSubpixelSupport = r.right - r.left == 4.5;31 32 29 if (window.testRunner) 33 30 testRunner.dumpAsText(); 34 31 35 description('This checks for proper behavior of caretRangeFromPoint before and after scrolling.'); 32 description('This checks for proper behavior of caretRangeFromPoint before and after scrolling.'); 36 33 37 34 var elementTop = document.getElementById('test-top'), … … 72 69 73 70 if (zoomOrNot == "zoom") { 74 test( hasSubpixelSupport ? 0 : 1, 0, 0);75 test( hasSubpixelSupport ? 12 : 13, 0, 25);71 test(0, 0, 0); 72 test(6, 0, 25); 76 73 test(4, 50, 0); 77 test(1 6, 50, 25);74 test(10, 50, 25); 78 75 } else { 79 76 test(0, 0, 0); -
trunk/LayoutTests/platform/mac/fast/dom/Document/CaretRangeFromPoint/hittest-relative-to-viewport-expected.txt
r161884 r173857 25 25 PASS Range.startOffset check (got 0, expected 0) 26 26 PASS Range.startContainer check (got [object Text], expected [object Text]) 27 PASS Range.startOffset check (got 12, expected 12)27 PASS Range.startOffset check (got 6, expected 6) 28 28 PASS Range.startContainer check (got [object Text], expected [object Text]) 29 29 PASS Range.startOffset check (got 4, expected 4) 30 30 PASS Range.startContainer check (got [object Text], expected [object Text]) 31 PASS Range.startOffset check (got 1 6, expected 16)31 PASS Range.startOffset check (got 10, expected 10) 32 32 33 33 PASS successfullyParsed is true -
trunk/Source/WebCore/ChangeLog
r173853 r173857 1 2014-09-22 Simon Fraser <simon.fraser@apple.com> 2 3 Move nodeFromPoint() back to Document where it belongs 4 https://bugs.webkit.org/show_bug.cgi?id=137012 5 6 Reviewed by Zalan Bujtas. 7 8 nodeFromPoint() was moved into TreeScope for ShadowDOM work, but now we can move 9 it back to its logical place. 10 11 Make versions of elementFromPoint and caretRangeFromPoint that take LayoutPoints, 12 and change the current scale/offset code to be in layout units (which results 13 in a small behavior change). 14 15 elementFromPoint(int, int) and caretRangeFromPoint(int, int) are still required 16 for bindings code. 17 18 * dom/Document.cpp: 19 (WebCore::Document::nodeFromPoint): 20 (WebCore::Document::elementFromPoint): 21 (WebCore::Document::caretRangeFromPoint): 22 * dom/Document.h: 23 (WebCore::Document::elementFromPoint): Move logic from TreeScope::elementFromPoint() 24 here. 25 * dom/TreeScope.cpp: 26 (WebCore::nodeFromPoint): Deleted. 27 (WebCore::TreeScope::elementFromPoint): Deleted. 28 * dom/TreeScope.h: 29 1 30 2014-09-22 Benjamin Poulain <bpoulain@apple.com> 2 31 -
trunk/Source/WebCore/dom/Document.cpp
r173765 r173857 1378 1378 } 1379 1379 1380 Element* Document::elementFromPoint(int x, int y) const 1380 Node* Document::nodeFromPoint(const LayoutPoint& clientPoint, LayoutPoint* localPoint) 1381 { 1382 if (!frame() || !view()) 1383 return nullptr; 1384 1385 Frame& frame = *this->frame(); 1386 1387 float scaleFactor = frame.pageZoomFactor() * frame.frameScaleFactor(); 1388 1389 LayoutPoint contentsPoint = clientPoint; 1390 contentsPoint.scale(scaleFactor, scaleFactor); 1391 contentsPoint.moveBy(view()->contentsScrollPosition()); 1392 1393 LayoutRect visibleRect; 1394 #if PLATFORM(IOS) 1395 visibleRect = view()->unobscuredContentRect(); 1396 #else 1397 visibleRect = view()->visibleContentRect(); 1398 #endif 1399 if (!visibleRect.contains(contentsPoint)) 1400 return nullptr; 1401 1402 HitTestResult result(contentsPoint); 1403 renderView()->hitTest(HitTestRequest(), result); 1404 1405 if (localPoint) 1406 *localPoint = result.localPoint(); 1407 1408 return result.innerNode(); 1409 } 1410 1411 Element* Document::elementFromPoint(const LayoutPoint& clientPoint) 1381 1412 { 1382 1413 if (!hasLivingRenderTree()) 1383 1414 return nullptr; 1384 1415 1385 return TreeScope::elementFromPoint(x, y); 1416 Node* node = nodeFromPoint(clientPoint); 1417 while (node && !node->isElementNode()) 1418 node = node->parentNode(); 1419 1420 if (node) 1421 node = ancestorInThisScope(node); 1422 1423 return toElement(node); 1386 1424 } 1387 1425 1388 1426 PassRefPtr<Range> Document::caretRangeFromPoint(int x, int y) 1427 { 1428 return caretRangeFromPoint(LayoutPoint(x, y)); 1429 } 1430 1431 PassRefPtr<Range> Document::caretRangeFromPoint(const LayoutPoint& clientPoint) 1389 1432 { 1390 1433 if (!hasLivingRenderTree()) 1391 1434 return nullptr; 1435 1392 1436 LayoutPoint localPoint; 1393 Node* node = nodeFromPoint( this, x, y, &localPoint);1437 Node* node = nodeFromPoint(clientPoint, &localPoint); 1394 1438 if (!node) 1395 1439 return nullptr; -
trunk/Source/WebCore/dom/Document.h
r173765 r173857 444 444 NamedFlowCollection& namedFlows(); 445 445 446 Element* elementFromPoint(int x, int y) const; 446 Element* elementFromPoint(int x, int y) { return elementFromPoint(LayoutPoint(x, y)); } 447 Element* elementFromPoint(const LayoutPoint& clientPoint); 448 447 449 PassRefPtr<Range> caretRangeFromPoint(int x, int y); 450 PassRefPtr<Range> caretRangeFromPoint(const LayoutPoint& clientPoint); 448 451 449 452 String readyState() const; … … 1345 1348 PageVisibilityState pageVisibilityState() const; 1346 1349 1350 Node* nodeFromPoint(const LayoutPoint& clientPoint, LayoutPoint* localPoint = nullptr); 1351 1347 1352 PassRefPtr<HTMLCollection> ensureCachedCollection(CollectionType); 1348 1353 -
trunk/Source/WebCore/dom/TreeScope.cpp
r173766 r173857 33 33 #include "FocusController.h" 34 34 #include "Frame.h" 35 #include "FrameView.h"36 35 #include "HTMLAnchorElement.h" 37 36 #include "HTMLFrameOwnerElement.h" … … 41 40 #include "IdTargetObserverRegistry.h" 42 41 #include "Page.h" 43 #include "RenderView.h"44 42 #include "RuntimeEnabledFeatures.h" 45 43 #include "ShadowRoot.h" … … 215 213 } 216 214 return m_imageMapsByName->getElementByMapName(*AtomicString(name).impl(), *this); 217 }218 219 Node* nodeFromPoint(Document* document, int x, int y, LayoutPoint* localPoint)220 {221 Frame* frame = document->frame();222 223 if (!frame)224 return nullptr;225 FrameView* frameView = frame->view();226 if (!frameView)227 return nullptr;228 229 float scaleFactor = frame->pageZoomFactor() * frame->frameScaleFactor();230 231 IntPoint scrollPosition = frameView->contentsScrollPosition();232 IntPoint point = roundedIntPoint(FloatPoint(x * scaleFactor + scrollPosition.x(), y * scaleFactor + scrollPosition.y()));233 234 IntRect visibleRect;235 #if PLATFORM(IOS)236 visibleRect = frameView->unobscuredContentRect();237 #else238 visibleRect = frameView->visibleContentRect();239 #endif240 if (!visibleRect.contains(point))241 return nullptr;242 243 HitTestResult result(point);244 document->renderView()->hitTest(HitTestRequest(), result);245 246 if (localPoint)247 *localPoint = result.localPoint();248 249 return result.innerNode();250 }251 252 Element* TreeScope::elementFromPoint(int x, int y) const253 {254 Node* node = nodeFromPoint(&m_rootNode.document(), x, y);255 while (node && !node->isElementNode())256 node = node->parentNode();257 if (node)258 node = ancestorInThisScope(node);259 return toElement(node);260 215 } 261 216 -
trunk/Source/WebCore/dom/TreeScope.h
r172849 r173857 78 78 HTMLMapElement* getImageMap(const String& url) const; 79 79 80 Element* elementFromPoint(int x, int y) const;81 82 80 // For accessibility. 83 81 bool shouldCacheLabelsByForAttribute() const { return !!m_labelsByForAttribute; } … … 149 147 } 150 148 151 Node* nodeFromPoint(Document*, int x, int y, LayoutPoint* localPoint = 0);152 149 TreeScope* commonTreeScope(Node*, Node*); 153 150 -
trunk/Source/WebCore/page/FrameView.cpp
r173785 r173857 3127 3127 frame().document()->enqueueOverflowEvent(overflowEvent.release()); 3128 3128 } 3129 3130 3129 } 3131 3130
Note:
See TracChangeset
for help on using the changeset viewer.