Changeset 164156 in webkit
- Timestamp:
- Feb 14, 2014, 8:52:38 PM (12 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 3 edited
-
ChangeLog (modified) (1 diff)
-
editing/FrameSelection.cpp (modified) (2 diffs)
-
html/HTMLTextFormControlElement.cpp (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r164145 r164156 1 2014-02-14 Ryosuke Niwa <rniwa@webkit.org> 2 3 setSelectionRange shouldn't trigger a synchronous layout to check focusability when text field is already focused 4 https://bugs.webkit.org/show_bug.cgi?id=128804 5 6 Reviewed by Enrica Casucci. 7 8 Don't trigger a synchronous layout at the beginning of setSelectionRange if the element is already focused 9 since we don't have to check the size of render box in that case. 10 11 We should be able to get rid of this synchronous layout entirely once we fix https://webkit.org/b/128797 12 but that's somewhat risky behavioral change so we'll do that in a separate patch. 13 14 * editing/FrameSelection.cpp: 15 (WebCore::FrameSelection::selectAll): Fixed the bug where selectAll selects the entire document even if the text 16 form contol is focused if the selection is none (i.e. not anchored to any node). 17 * html/HTMLTextFormControlElement.cpp: 18 (WebCore::HTMLTextFormControlElement::setSelectionRange): Only update the layout if the element is not focused 19 already. Also pass in DoNotSetFocus option to setSelection since we already have the focus in that case. 20 1 21 2014-02-14 Dan Bernstein <mitz@apple.com> 2 22 -
trunk/Source/WebCore/editing/FrameSelection.cpp
r164133 r164156 1641 1641 Document* document = m_frame->document(); 1642 1642 1643 if (document->focusedElement() && document->focusedElement()->hasTagName(selectTag)) { 1643 Element* focusedElement = document->focusedElement(); 1644 if (focusedElement && focusedElement->hasTagName(selectTag)) { 1644 1645 HTMLSelectElement* selectElement = toHTMLSelectElement(document->focusedElement()); 1645 1646 if (selectElement->canSelectAll()) { … … 1658 1659 selectStartTarget = root.get(); 1659 1660 } else { 1660 root = m_selection.nonBoundaryShadowTreeRootNode(); 1661 if (m_selection.isNone() && focusedElement) { 1662 if (focusedElement->isTextFormControl()) { 1663 toHTMLTextFormControlElement(focusedElement)->select(); 1664 return; 1665 } 1666 root = focusedElement->nonBoundaryShadowTreeRootNode(); 1667 } else 1668 root = m_selection.nonBoundaryShadowTreeRootNode(); 1669 1661 1670 if (root) 1662 1671 selectStartTarget = root->shadowHost(); -
trunk/Source/WebCore/html/HTMLTextFormControlElement.cpp
r163846 r164156 214 214 } 215 215 216 static inline bool hasVisibleTextArea(RenderElement& textControl, TextControlInnerTextElement* innerText)217 {218 return textControl.style().visibility() != HIDDEN && innerText && innerText->renderer() && innerText->renderBox()->height();219 }220 221 216 void HTMLTextFormControlElement::setRangeText(const String& replacement, ExceptionCode& ec) 222 217 { … … 291 286 void HTMLTextFormControlElement::setSelectionRange(int start, int end, TextFieldSelectionDirection direction) 292 287 { 293 document().updateLayoutIgnorePendingStylesheets(); 294 295 if (!renderer() || !renderer()->isTextControl()) 288 if (!isTextFormControl()) 296 289 return; 297 290 … … 300 293 301 294 TextControlInnerTextElement* innerText = innerTextElement(); 302 if (!hasVisibleTextArea(*renderer(), innerText)) { 303 cacheSelection(start, end, direction); 304 return; 305 } 295 bool hasFocus = document().focusedElement() == this; 296 if (!hasFocus && innerText) { 297 // FIXME: Removing this synchronous layout requires fixing <https://webkit.org/b/128797> 298 document().updateLayoutIgnorePendingStylesheets(); 299 if (RenderElement* rendererTextControl = renderer()) { 300 if (rendererTextControl->style().visibility() == HIDDEN || !innerText->renderBox()->height()) { 301 cacheSelection(start, end, direction); 302 return; 303 } 304 } 305 } 306 306 307 Position startPosition = positionForIndex(innerText, start); 307 308 Position endPosition; … … 318 319 newSelection.setIsDirectional(direction != SelectionHasNoDirection); 319 320 321 FrameSelection::SetSelectionOptions options = FrameSelection::defaultSetSelectionOptions(); 322 if (hasFocus) 323 options |= FrameSelection::DoNotSetFocus; 320 324 if (Frame* frame = document().frame()) 321 frame->selection().setSelection(newSelection );325 frame->selection().setSelection(newSelection, options); 322 326 } 323 327
Note:
See TracChangeset
for help on using the changeset viewer.