Changeset 126069 in webkit
- Timestamp:
- Aug 20, 2012 2:16:51 PM (12 years ago)
- Location:
- trunk
- Files:
-
- 2 deleted
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r126067 r126069 1 2012-08-20 Kenneth Russell <kbr@google.com> 2 3 Unreviewed, rolling out r126026. 4 http://trac.webkit.org/changeset/126026 5 https://bugs.webkit.org/show_bug.cgi?id=94449 6 7 Caused assertion failure in layout test touchadjustment/context-menu.html 8 9 * touchadjustment/context-menu-select-text.html: 10 * touchadjustment/context-menu-text-subtargets-expected.txt: Removed. 11 * touchadjustment/context-menu-text-subtargets.html: Removed. 12 * touchadjustment/resources/touchadjustment.js: 13 1 14 2012-08-20 Christophe Dumez <christophe.dumez@intel.com> 2 15 -
trunk/LayoutTests/touchadjustment/context-menu-select-text.html
r126026 r126069 2 2 <html> 3 3 <head> 4 <title>Touch Adjustment : Adjust context-menu to selectable text- bug 94101</title>4 <title>Touch Adjustment : Adjust context-menu to selectable words - bug 94101</title> 5 5 <script src="../fast/js/resources/js-test-pre.js"></script> 6 6 <script src="resources/touchadjustment.js"></script> -
trunk/LayoutTests/touchadjustment/resources/touchadjustment.js
r126026 r126069 25 25 } 26 26 27 function boundsToString(bounds)28 {29 return "("+bounds.left+","+bounds.top+")x("+bounds.width+","+bounds.height+")";30 }31 32 function pointToString(point)33 {34 return "("+point.x+","+point.y+")";35 }36 37 38 27 function shouldBeNode(adjustedNode, targetNode) { 39 28 if (typeof targetNode == "string") { … … 54 43 } 55 44 } 56 57 function shouldBeWithin(adjustedPoint, targetArea) {58 if (adjustedPoint.x >= targetArea.left && adjustedPoint.y >= targetArea.top59 && adjustedPoint.x <= (targetArea.left + targetArea.width)60 && adjustedPoint.y <= (targetArea.top + targetArea.height)) {61 testPassed("adjusted point was within " + boundsToString(targetArea));62 } else {63 testFailed("adjusted node should be within " + boundsToString(targetArea) + ". Was " + pointToString(adjustedPoint));64 }65 }66 67 45 68 46 function testTouchPoint(touchpoint, targetNode, allowTextNodes) -
trunk/Source/WebCore/ChangeLog
r126068 r126069 1 2012-08-20 Kenneth Russell <kbr@google.com> 2 3 Unreviewed, rolling out r126026. 4 http://trac.webkit.org/changeset/126026 5 https://bugs.webkit.org/show_bug.cgi?id=94449 6 7 Caused assertion failure in layout test touchadjustment/context-menu.html 8 9 * page/TouchAdjustment.cpp: 10 (TouchAdjustment): 11 (WebCore::TouchAdjustment::providesContextMenuItems): 12 (WebCore::TouchAdjustment::appendSubtargetsForNodeToList): 13 (WebCore::TouchAdjustment::compileSubtargetList): 14 (WebCore::findBestClickableCandidate): 15 (WebCore::findBestContextMenuCandidate): 16 1 17 2012-08-20 Andrew Lo <anlo@rim.com> 2 18 -
trunk/Source/WebCore/page/TouchAdjustment.cpp
r126026 r126069 36 36 #include "RenderObject.h" 37 37 #include "RenderStyle.h" 38 #include "RenderText.h"39 38 #include "ShadowRoot.h" 40 #include "Text.h"41 #include "TextBreakIterator.h"42 39 43 40 namespace WebCore { … … 66 63 typedef Vector<SubtargetGeometry> SubtargetGeometryList; 67 64 typedef bool (*NodeFilter)(Node*); 68 typedef void (*AppendSubtargetsForNode)(Node*, SubtargetGeometryList&);69 65 typedef float (*DistanceFunction)(const IntPoint&, const IntRect&, const SubtargetGeometry&); 70 66 … … 106 102 return true; 107 103 if (node->renderer()->canBeSelectionLeaf()) { 108 // If the context menu gesture will trigger a selection all selectable nodes are valid targets. 104 // If the context menu gesture will trigger a selection all selectable nodes are targets. 105 // FIXME: To improve the adjusted point, each individual word should be a separate subtarget, 106 // see for example FatFingers::checkForText() in WebKit/blackberry. 109 107 if (node->renderer()->frame()->editor()->behavior().shouldSelectOnContextualMenuClick()) 110 108 return true; 111 // Only the selected part of the renderer is a valid target, but this will be corrected in112 // appendContextSubtargetsForNode.109 // FIXME: A selected text might only be partially selected, and we should only append 110 // the selected subtargets of it in appendSubtargetsForNodeToList(). 113 111 if (node->renderer()->selectionState() != RenderObject::SelectionNone) 114 112 return true; … … 117 115 } 118 116 119 static inline void appendQuadsToSubtargetList(Vector<FloatQuad>& quads, Node* node, SubtargetGeometryList& subtargets) 120 { 117 static inline void appendSubtargetsForNodeToList(Node* node, SubtargetGeometryList& subtargets) 118 { 119 // Since the node is a result of a hit test, we are already ensured it has a renderer. 120 ASSERT(node->renderer()); 121 122 Vector<FloatQuad> quads; 123 node->renderer()->absoluteQuads(quads); 124 121 125 Vector<FloatQuad>::const_iterator it = quads.begin(); 122 126 const Vector<FloatQuad>::const_iterator end = quads.end(); 123 127 for (; it != end; ++it) 124 128 subtargets.append(SubtargetGeometry(node, *it)); 125 }126 127 static inline void appendBasicSubtargetsForNode(Node* node, SubtargetGeometryList& subtargets)128 {129 // Since the node is a result of a hit test, we are already ensured it has a renderer.130 ASSERT(node->renderer());131 132 Vector<FloatQuad> quads;133 node->renderer()->absoluteQuads(quads);134 135 appendQuadsToSubtargetList(quads, node, subtargets);136 }137 138 static inline void appendContextSubtargetsForNode(Node* node, SubtargetGeometryList& subtargets)139 {140 // This is a variant of appendBasicSubtargetsForNode that adds special subtargets for141 // selected or auto-selectable parts of text nodes.142 ASSERT(node->renderer());143 144 if (!node->isTextNode())145 return appendBasicSubtargetsForNode(node, subtargets);146 147 Text* textNode = static_cast<WebCore::Text*>(node);148 RenderText* textRenderer = static_cast<RenderText*>(textNode->renderer());149 150 if (textRenderer->frame()->editor()->behavior().shouldSelectOnContextualMenuClick()) {151 // Make subtargets out of every word.152 String textValue = textNode->data();153 TextBreakIterator* wordIterator = wordBreakIterator(textValue.characters(), textValue.length());154 int lastOffset = textBreakFirst(wordIterator);155 if (lastOffset == -1)156 return;157 int offset;158 while ((offset = textBreakNext(wordIterator)) != -1) {159 if (isWordTextBreak(wordIterator)) {160 Vector<FloatQuad> quads;161 textRenderer->absoluteQuadsForRange(quads, lastOffset, offset);162 appendQuadsToSubtargetList(quads, textNode, subtargets);163 }164 lastOffset = offset;165 }166 } else {167 // Make subtargets out of only the selected part of the text.168 ASSERT(textRenderer->selectionState() != RenderObject::SelectionNone);169 int startPos, endPos;170 switch (textRenderer->selectionState()) {171 case RenderObject::SelectionInside:172 startPos = 0;173 endPos = textRenderer->textLength();174 break;175 case RenderObject::SelectionStart:176 textRenderer->selectionStartEnd(startPos, endPos);177 endPos = textRenderer->textLength();178 break;179 case RenderObject::SelectionEnd:180 textRenderer->selectionStartEnd(startPos, endPos);181 startPos = 0;182 break;183 case RenderObject::SelectionBoth:184 textRenderer->selectionStartEnd(startPos, endPos);185 break;186 default:187 appendBasicSubtargetsForNode(node, subtargets);188 return;189 }190 Vector<FloatQuad> quads;191 textRenderer->absoluteQuadsForRange(quads, startPos, endPos);192 appendQuadsToSubtargetList(quads, textNode, subtargets);193 }194 129 } 195 130 … … 214 149 215 150 // Compiles a list of subtargets of all the relevant target nodes. 216 void compileSubtargetList(const NodeList& intersectedNodes, SubtargetGeometryList& subtargets, NodeFilter nodeFilter , AppendSubtargetsForNode appendSubtargetsForNode)151 void compileSubtargetList(const NodeList& intersectedNodes, SubtargetGeometryList& subtargets, NodeFilter nodeFilter) 217 152 { 218 153 // Find candidates responding to tap gesture events in O(n) time. … … 267 202 if (ancestorsToRespondersSet.contains(respondingNode)) 268 203 continue; 269 appendSubtargetsForNode (candidate, subtargets);204 appendSubtargetsForNodeToList(candidate, subtargets); 270 205 } 271 206 } … … 474 409 IntRect targetArea; 475 410 TouchAdjustment::SubtargetGeometryList subtargets; 476 TouchAdjustment::compileSubtargetList(nodeList, subtargets, TouchAdjustment::nodeRespondsToTapGesture , TouchAdjustment::appendBasicSubtargetsForNode);411 TouchAdjustment::compileSubtargetList(nodeList, subtargets, TouchAdjustment::nodeRespondsToTapGesture); 477 412 return TouchAdjustment::findNodeWithLowestDistanceMetric(targetNode, targetPoint, targetArea, touchHotspot, touchArea, subtargets, TouchAdjustment::hybridDistanceFunction); 478 413 } … … 482 417 IntRect targetArea; 483 418 TouchAdjustment::SubtargetGeometryList subtargets; 484 TouchAdjustment::compileSubtargetList(nodeList, subtargets, TouchAdjustment::providesContextMenuItems , TouchAdjustment::appendContextSubtargetsForNode);419 TouchAdjustment::compileSubtargetList(nodeList, subtargets, TouchAdjustment::providesContextMenuItems); 485 420 return TouchAdjustment::findNodeWithLowestDistanceMetric(targetNode, targetPoint, targetArea, touchHotspot, touchArea, subtargets, TouchAdjustment::hybridDistanceFunction); 486 421 }
Note: See TracChangeset
for help on using the changeset viewer.