Changeset 122225 in webkit
- Timestamp:
- Jul 10, 2012 9:01:26 AM (12 years ago)
- Location:
- trunk
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r122224 r122225 1 2012-07-10 Leandro Gracia Gil <leandrogracia@chromium.org> 2 3 WebSurroundingText layout tests should use the same code path as the rest of the feature. 4 https://bugs.webkit.org/show_bug.cgi?id=90807 5 6 Reviewed by Adam Barth. 7 8 Make the textSurroundingNode method take a pair of point coordinates 9 instead of a node offset. 10 11 * platform/chromium/editing/surrounding-text/surrounding-text-expected.txt: 12 * platform/chromium/editing/surrounding-text/surrounding-text.html: 13 1 14 2012-07-10 Kevin Ellis <kevers@chromium.org> 2 15 -
trunk/LayoutTests/platform/chromium/editing/surrounding-text/surrounding-text-expected.txt
r122139 r122225 9 9 PASS surroundingText('<button>.</button>12345<p id="here">6789 12345</p>6789<button>.</button>', 5, 1) is "1" 10 10 PASS surroundingText('<button>.</button>12345<p id="here">6789 12345</p>6789<button>.</button>', 6, 2) is "12" 11 PASS surroundingText('<button>.</button>12345<p id="here">6789 12345</p>6789<button>.</button>', 100, 5) is ""12 11 PASS surroundingText('<select>.</select><div>57th Street and Lake Shore Drive</div> <span>Chicago</span> <span id="here">IL</span> <span>60637</span><select>.</select>', 0, 100) is "57th Street and Lake Shore Drive Chicago IL 60637" 13 12 PASS surroundingText('<fieldset>.</fieldset>12345<button>abc</button><p>6789<br id="here"/>12345</p>6789<textarea>abc</textarea>0123<fieldset>.</fieldset>', 0, 100) is "6789 12345 6789" -
trunk/LayoutTests/platform/chromium/editing/surrounding-text/surrounding-text.html
r122139 r122225 9 9 <script> 10 10 description('Test the extraction of the text surrounding an element.'); 11 12 function findOffsetCoordinates(node, offset) { 13 var nodeRange = document.createRange(); 14 nodeRange.selectNode(node); 15 16 var offsetRange = document.createRange(); 17 offsetRange.setStart(node, offset); 18 offsetRange.setEnd(node, offset + 1); 19 20 var nodeRect = nodeRange.getBoundingClientRect(); 21 var offsetRect = offsetRange.getBoundingClientRect(); 22 var x = (offsetRect.left + offsetRect.right) / 2 - nodeRect.left; 23 var y = (offsetRect.top + offsetRect.bottom) / 2 - nodeRect.top; 24 25 return { x: x, y: y }; 26 } 11 27 12 28 function surroundingText(html, offset, maxLength) { … … 21 37 throw 'No node after "here" element'; 22 38 23 var text = window.testRunner.textSurroundingNode(node, offset, maxLength); 39 var coords = findOffsetCoordinates(node, offset); 40 var text = window.testRunner.textSurroundingNode(node, coords.x, coords.y, maxLength); 24 41 return text.replace(/\s+/g, ' ').replace(/^\s*|\s*$/g, ''); 25 42 } … … 34 51 shouldBeEqualToString('surroundingText(\'<button>.</button>12345<p id="here">6789 12345</p>6789<button>.</button>\', 5, 1)', '1'); 35 52 shouldBeEqualToString('surroundingText(\'<button>.</button>12345<p id="here">6789 12345</p>6789<button>.</button>\', 6, 2)', '12'); 36 shouldBeEqualToString('surroundingText(\'<button>.</button>12345<p id="here">6789 12345</p>6789<button>.</button>\', 100, 5)', '');37 53 shouldBeEqualToString('surroundingText(\'<select>.</select><div>57th Street and Lake Shore Drive</div> <span>Chicago</span> <span id="here">IL</span> <span>60637</span><select>.</select>\', 0, 100)', '57th Street and Lake Shore Drive Chicago IL 60637'); 38 54 shouldBeEqualToString('surroundingText(\'<fieldset>.</fieldset>12345<button>abc</button><p>6789<br id="here"/>12345</p>6789<textarea>abc</textarea>0123<fieldset>.</fieldset>\', 0, 100)', '6789 12345 6789'); -
trunk/Source/WebKit/chromium/ChangeLog
r122220 r122225 1 2012-07-10 Leandro Gracia Gil <leandrogracia@chromium.org> 2 3 WebSurroundingText layout tests should use the same code path as the rest of the feature. 4 https://bugs.webkit.org/show_bug.cgi?id=90807 5 6 Reviewed by Adam Barth. 7 8 Replace the offset-based initialize method used only by LayoutTestController 9 with a point-based version to follow the same code path. 10 11 * public/WebSurroundingText.h: 12 (WebKit): 13 (WebSurroundingText): 14 * src/WebSurroundingText.cpp: 15 (WebKit::WebSurroundingText::initialize): 16 1 17 2012-07-10 Sheriff Bot <webkit.review.bot@gmail.com> 2 18 -
trunk/Source/WebKit/chromium/public/WebSurroundingText.h
r115472 r122225 38 38 39 39 class WebHitTestResult; 40 class WebNode; 41 class WebPoint; 40 42 41 43 class WebSurroundingText { … … 51 53 WEBKIT_EXPORT void initialize(const WebHitTestResult&, size_t maxLength); 52 54 53 // Initializes the object go get the surrounding text centered in the selected offset of the givennode.55 // Initializes the object to get the surrounding text centered in the position relative to a provided node. 54 56 // The maximum length of the contents retrieved is defined by maxLength. 55 WEBKIT_EXPORT void initialize( WebNode textNode, size_t offset, size_t maxLength);57 WEBKIT_EXPORT void initialize(const WebNode&, const WebPoint&, size_t maxLength); 56 58 57 59 // Surrounding text content retrieved. -
trunk/Source/WebKit/chromium/src/WebSurroundingText.cpp
r122139 r122225 41 41 namespace WebKit { 42 42 43 void WebSurroundingText::initialize(const WebHitTestResult& hitTest Info, size_t maxLength)43 void WebSurroundingText::initialize(const WebHitTestResult& hitTestResult, size_t maxLength) 44 44 { 45 Node* node = hitTest Info.node().unwrap<Node>();45 Node* node = hitTestResult.node().unwrap<Node>(); 46 46 if (!node || !node->renderer()) 47 47 return; 48 48 49 m_private.reset(new SurroundingText(VisiblePosition(node->renderer()->positionForPoint(static_cast<IntPoint>(hitTest Info.localPoint()))), maxLength));49 m_private.reset(new SurroundingText(VisiblePosition(node->renderer()->positionForPoint(static_cast<IntPoint>(hitTestResult.localPoint()))), maxLength)); 50 50 } 51 51 52 void WebSurroundingText::initialize( WebNode textNode, size_t offset, size_t maxLength)52 void WebSurroundingText::initialize(const WebNode& webNode, const WebPoint& nodePoint, size_t maxLength) 53 53 { 54 Node* node = textNode.unwrap<Node>();55 if (!node || !node-> isTextNode() || offset >= node->nodeValue().length())54 const Node* node = webNode.constUnwrap<Node>(); 55 if (!node || !node->renderer()) 56 56 return; 57 57 58 m_private.reset(new SurroundingText( VisiblePosition(Position(toText(node), offset).parentAnchoredEquivalent(), DOWNSTREAM), maxLength));58 m_private.reset(new SurroundingText(node->renderer()->positionForPoint(static_cast<IntPoint>(nodePoint)), maxLength)); 59 59 } 60 60 -
trunk/Tools/ChangeLog
r122219 r122225 1 2012-07-10 Leandro Gracia Gil <leandrogracia@chromium.org> 2 3 WebSurroundingText layout tests should use the same code path as the rest of the feature. 4 https://bugs.webkit.org/show_bug.cgi?id=90807 5 6 Reviewed by Adam Barth. 7 8 Make the textSurroundingNode method take a pair of point coordinates 9 instead of a node offset. 10 11 * DumpRenderTree/chromium/LayoutTestController.cpp: 12 (LayoutTestController::textSurroundingNode): 13 * DumpRenderTree/chromium/LayoutTestController.h: 14 (LayoutTestController): 15 1 16 2012-07-10 Csaba Osztrogonác <ossy@webkit.org> 2 17 -
trunk/Tools/DumpRenderTree/chromium/LayoutTestController.cpp
r122077 r122225 2350 2350 { 2351 2351 result->setNull(); 2352 if (arguments.size() < 3 || !arguments[0].isObject() || !arguments[1].isNumber() || !arguments[2].isNumber())2352 if (arguments.size() < 4 || !arguments[0].isObject() || !arguments[1].isNumber() || !arguments[2].isNumber() || !arguments[3].isNumber()) 2353 2353 return; 2354 2354 … … 2360 2360 return; 2361 2361 2362 unsigned offset = arguments[1].toInt32(); 2363 if (offset >= node.nodeValue().length()) { 2364 result->set(WebString().utf8()); 2365 return; 2366 } 2362 WebPoint point(arguments[1].toInt32(), arguments[2].toInt32()); 2363 unsigned maxLength = arguments[3].toInt32(); 2367 2364 2368 2365 WebSurroundingText surroundingText; 2369 unsigned maxLength = arguments[2].toInt32(); 2370 surroundingText.initialize(node, offset, maxLength); 2366 surroundingText.initialize(node, point, maxLength); 2367 if (surroundingText.isNull()) 2368 return; 2369 2371 2370 result->set(surroundingText.textContent().utf8()); 2372 2371 } -
trunk/Tools/DumpRenderTree/chromium/LayoutTestController.h
r122077 r122225 458 458 459 459 // Retrieves the text surrounding a position in a text node. 460 // Expects the first argument to be a text node, the second to be an offset 461 // in the node contents and the third the maximum text length to retrieve. 460 // Expects the first argument to be a text node, the second and third to be 461 // point coordinates relative to the node and the fourth the maximum text 462 // length to retrieve. 462 463 void textSurroundingNode(const CppArgumentList&, CppVariant*); 463 464
Note: See TracChangeset
for help on using the changeset viewer.