Changeset 88456 in webkit
- Timestamp:
- Jun 9, 2011, 9:15:29 AM (14 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r88452 r88456 1 2011-06-08 Abhishek Arya <inferno@chromium.org> 2 3 Reviewed by Ryosuke Niwa. 4 5 Tests that setting selection on a text control does not result in crash. 6 https://bugs.webkit.org/show_bug.cgi?id=62329 7 8 * fast/forms/text-control-selection-crash-expected.txt: Added. 9 * fast/forms/text-control-selection-crash.html: Added. 10 1 11 2011-06-09 Csaba Osztrogonác <ossy@webkit.org> 2 12 -
trunk/Source/WebCore/ChangeLog
r88454 r88456 1 2011-06-08 Abhishek Arya <inferno@chromium.org> 2 3 Reviewed by Ryosuke Niwa. 4 5 Make indexForVisiblePosition and isSelectableElement static. 6 https://bugs.webkit.org/show_bug.cgi?id=62329 7 8 This protects us when converting frame->selection->start() or end() 9 to VisiblePosition which blows away the RenderTextControl from 10 underneath (due to layout update). 11 12 Test: fast/forms/text-control-selection-crash.html 13 14 * accessibility/AccessibilityRenderObject.cpp: 15 (WebCore::AccessibilityRenderObject::indexForVisiblePosition): 16 * rendering/RenderTextControl.cpp: 17 (WebCore::RenderTextControl::selectionStart): 18 (WebCore::RenderTextControl::selectionEnd): 19 (WebCore::RenderTextControl::isSelectableElement): 20 (WebCore::RenderTextControl::indexForVisiblePosition): 21 * rendering/RenderTextControl.h: 22 1 23 2011-06-09 Ben Murdoch <benm@google.com> 2 24 -
trunk/Source/WebCore/accessibility/AccessibilityRenderObject.cpp
r87856 r88456 2500 2500 { 2501 2501 if (isNativeTextControl()) 2502 return toRenderTextControl(m_renderer)->indexForVisiblePosition(pos);2502 return RenderTextControl::indexForVisiblePosition(toRenderTextControl(m_renderer)->innerTextElement(), pos); 2503 2503 2504 2504 if (!isTextControl()) -
trunk/Source/WebCore/rendering/RenderTextControl.cpp
r88251 r88456 178 178 if (!frame) 179 179 return 0; 180 return indexForVisiblePosition(frame->selection()->start()); 180 181 HTMLElement* innerText = innerTextElement(); 182 // Do not call innerTextElement() in the function arguments as creating a VisiblePosition 183 // from frame->selection->start() can blow us from underneath. Also, function ordering is 184 // usually dependent on the compiler. 185 return RenderTextControl::indexForVisiblePosition(innerText, frame->selection()->start()); 181 186 } 182 187 … … 186 191 if (!frame) 187 192 return 0; 188 return indexForVisiblePosition(frame->selection()->end()); 193 194 HTMLElement* innerText = innerTextElement(); 195 // Do not call innerTextElement() in the function arguments as creating a VisiblePosition 196 // from frame->selection->end() can blow us from underneath. Also, function ordering is 197 // usually dependent on the compiler. 198 return RenderTextControl::indexForVisiblePosition(innerText, frame->selection()->end()); 189 199 } 190 200 … … 230 240 } 231 241 232 bool RenderTextControl::isSelectableElement( Node* node) const233 { 234 if (!node )242 bool RenderTextControl::isSelectableElement(HTMLElement* innerText, Node* node) 243 { 244 if (!node || !innerText) 235 245 return false; 236 246 237 HTMLElement* innerText = innerTextElement();238 if (!innerText)239 return false;240 241 247 if (node->rootEditableElement() == innerText) 242 248 return true; … … 313 319 } 314 320 315 int RenderTextControl::indexForVisiblePosition( const VisiblePosition& pos) const321 int RenderTextControl::indexForVisiblePosition(HTMLElement* innerTextElement, const VisiblePosition& pos) 316 322 { 317 323 Position indexPosition = pos.deepEquivalent(); 318 if (! isSelectableElement(indexPosition.deprecatedNode()))324 if (!RenderTextControl::isSelectableElement(innerTextElement, indexPosition.deprecatedNode())) 319 325 return 0; 320 326 ExceptionCode ec = 0; 321 RefPtr<Range> range = Range::create( document());322 range->setStart(innerTextElement (), 0, ec);327 RefPtr<Range> range = Range::create(indexPosition.document()); 328 range->setStart(innerTextElement, 0, ec); 323 329 ASSERT(!ec); 324 330 range->setEnd(indexPosition.deprecatedNode(), indexPosition.deprecatedEditingOffset(), ec); -
trunk/Source/WebCore/rendering/RenderTextControl.h
r88251 r88456 51 51 52 52 VisiblePosition visiblePositionForIndex(int index) const; 53 int indexForVisiblePosition(const VisiblePosition&) const;53 static int indexForVisiblePosition(HTMLElement*, const VisiblePosition&); 54 54 55 55 void updatePlaceholderVisibility(bool, bool); … … 103 103 bool hasVisibleTextArea() const; 104 104 friend void setSelectionRange(Node*, int start, int end); 105 bool isSelectableElement(Node*) const;105 static bool isSelectableElement(HTMLElement*, Node*); 106 106 107 107 virtual int textBlockInsetLeft() const = 0;
Note:
See TracChangeset
for help on using the changeset viewer.