Changeset 191451 in webkit
- Timestamp:
- Oct 22, 2015, 4:37:46 AM (10 years ago)
- Location:
- trunk
- Files:
-
- 1 added
- 16 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r191450 r191451 1 2015-10-22 Ryosuke Niwa <rniwa@webkit.org> 2 3 REGRESSION (r181972): Scroll position changes to top of youtube page when switching tabs 4 https://bugs.webkit.org/show_bug.cgi?id=150428 5 6 Reviewed by Antti Koivisto. 7 8 The bug was caused by updateFocusAppearance in WebPage::restoreSelectionInFocusedEditableElement 9 revealing the focused element which was added in r181972. Fixed the bug by adding an option to 10 suppress this behavior here. 11 12 * dom/Document.cpp: 13 (WebCore::Document::Document): 14 (WebCore::Document::updateFocusAppearanceSoon): 15 * dom/Document.h: 16 * dom/Element.cpp: 17 (WebCore::Element::focus): 18 (WebCore::Element::updateFocusAppearanceAfterAttachIfNeeded): 19 (WebCore::Element::updateFocusAppearance): 20 * dom/Element.h: 21 * history/CachedPage.cpp: 22 (WebCore::CachedPage::restore): 23 * html/HTMLAreaElement.cpp: 24 (WebCore::HTMLAreaElement::updateFocusAppearance): 25 * html/HTMLAreaElement.h: 26 * html/HTMLInputElement.cpp: 27 (WebCore::HTMLInputElement::updateFocusAppearance): 28 (WebCore::HTMLInputElement::runPostTypeUpdateTasks): 29 (WebCore::HTMLInputElement::didAttachRenderers): 30 * html/HTMLInputElement.h: 31 * html/HTMLTextAreaElement.cpp: 32 (WebCore::HTMLTextAreaElement::updateFocusAppearance): 33 * html/HTMLTextAreaElement.h: 34 1 35 2015-10-22 Joonghun Park <jh718.park@samsung.com> 2 36 -
trunk/Source/WebCore/dom/Document.cpp
r191262 r191451 456 456 , m_gotoAnchorNeededAfterStylesheetsLoad(false) 457 457 , m_frameElementsShouldIgnoreScrolling(false) 458 , m_updateFocusAppearanceRestoresSelection( false)458 , m_updateFocusAppearanceRestoresSelection(SelectionRestorationMode::SetDefault) 459 459 , m_ignoreDestructiveWriteCount(0) 460 460 , m_markers(std::make_unique<DocumentMarkerController>(*this)) … … 5080 5080 } 5081 5081 5082 void Document::updateFocusAppearanceSoon( bool restorePreviousSelection)5083 { 5084 m_updateFocusAppearanceRestoresSelection = restorePreviousSelection;5082 void Document::updateFocusAppearanceSoon(SelectionRestorationMode mode) 5083 { 5084 m_updateFocusAppearanceRestoresSelection = mode; 5085 5085 if (!m_updateFocusAppearanceTimer.isActive()) 5086 5086 m_updateFocusAppearanceTimer.startOneShot(0); -
trunk/Source/WebCore/dom/Document.h
r191262 r191451 275 275 enum DimensionsCheck { WidthDimensionsCheck = 1 << 0, HeightDimensionsCheck = 1 << 1, AllDimensionsCheck = 1 << 2 }; 276 276 277 enum class SelectionRestorationMode { 278 Restore, 279 SetDefault, 280 }; 281 282 enum class SelectionRevealMode { 283 Reveal, 284 DoNotReveal 285 }; 286 277 287 enum class HttpEquivPolicy { 278 288 Enabled, … … 967 977 void setHasNodesWithPlaceholderStyle() { m_hasNodesWithPlaceholderStyle = true; } 968 978 969 void updateFocusAppearanceSoon( bool restorePreviousSelection);979 void updateFocusAppearanceSoon(SelectionRestorationMode); 970 980 void cancelFocusAppearanceUpdate(); 971 981 … … 1493 1503 bool m_haveExplicitlyDisabledDNSPrefetch; 1494 1504 bool m_frameElementsShouldIgnoreScrolling; 1495 boolm_updateFocusAppearanceRestoresSelection;1505 SelectionRestorationMode m_updateFocusAppearanceRestoresSelection; 1496 1506 1497 1507 // http://www.whatwg.org/specs/web-apps/current-work/#ignore-destructive-writes-counter -
trunk/Source/WebCore/dom/Element.cpp
r191262 r191451 2220 2220 view->setProhibitsScrolling(true); 2221 2221 #endif 2222 updateFocusAppearance(restorePreviousSelection );2222 updateFocusAppearance(restorePreviousSelection ? SelectionRestorationMode::Restore : SelectionRestorationMode::SetDefault); 2223 2223 #if PLATFORM(IOS) 2224 2224 if (isFormControl) … … 2235 2235 return; 2236 2236 if (isFocusable() && document().focusedElement() == this) 2237 document().updateFocusAppearanceSoon( false /* don't restore selection */);2237 document().updateFocusAppearanceSoon(SelectionRestorationMode::SetDefault); 2238 2238 data->setNeedsFocusAppearanceUpdateSoonAfterAttach(false); 2239 2239 } 2240 2240 2241 void Element::updateFocusAppearance( bool /*restorePreviousSelection*/)2241 void Element::updateFocusAppearance(SelectionRestorationMode, SelectionRevealMode revealMode) 2242 2242 { 2243 2243 if (isRootEditableElement()) { … … 2255 2255 if (frame->selection().shouldChangeSelection(newSelection)) { 2256 2256 frame->selection().setSelection(newSelection, FrameSelection::defaultSetSelectionOptions(), Element::defaultFocusTextStateChangeIntent()); 2257 frame->selection().revealSelection(); 2257 if (revealMode == SelectionRevealMode::Reveal) 2258 frame->selection().revealSelection(); 2258 2259 } 2259 } else if (renderer() && !renderer()->isWidget() )2260 } else if (renderer() && !renderer()->isWidget() && revealMode == SelectionRevealMode::Reveal) 2260 2261 renderer()->scrollRectToVisible(renderer()->anchorRect()); 2261 2262 } -
trunk/Source/WebCore/dom/Element.h
r191262 r191451 328 328 void updateFocusAppearanceAfterAttachIfNeeded(); 329 329 virtual void focus(bool restorePreviousSelection = true, FocusDirection = FocusDirectionNone); 330 virtual void updateFocusAppearance( bool restorePreviousSelection);330 virtual void updateFocusAppearance(SelectionRestorationMode, SelectionRevealMode = SelectionRevealMode::Reveal); 331 331 virtual void blur(); 332 332 -
trunk/Source/WebCore/history/CachedPage.cpp
r184304 r191451 93 93 } 94 94 #endif 95 element->updateFocusAppearance( true);95 element->updateFocusAppearance(SelectionRestorationMode::Restore); 96 96 #if PLATFORM(IOS) 97 97 if (frameView) -
trunk/Source/WebCore/html/HTMLAreaElement.cpp
r182120 r191451 225 225 } 226 226 227 void HTMLAreaElement::updateFocusAppearance( bool restorePreviousSelection)227 void HTMLAreaElement::updateFocusAppearance(SelectionRestorationMode restorationMode, SelectionRevealMode revealMode) 228 228 { 229 229 if (!isFocusable()) … … 234 234 return; 235 235 236 imageElement->updateFocusAppearance(restor ePreviousSelection);236 imageElement->updateFocusAppearance(restorationMode, revealMode); 237 237 } 238 238 -
trunk/Source/WebCore/html/HTMLAreaElement.h
r177996 r191451 58 58 virtual bool isMouseFocusable() const override; 59 59 virtual bool isFocusable() const override; 60 virtual void updateFocusAppearance( bool /*restorePreviousSelection*/) override;60 virtual void updateFocusAppearance(SelectionRestorationMode, SelectionRevealMode) override; 61 61 virtual void setFocus(bool) override; 62 62 -
trunk/Source/WebCore/html/HTMLInputElement.cpp
r190845 r191451 403 403 } 404 404 405 void HTMLInputElement::updateFocusAppearance( bool restorePreviousSelection)405 void HTMLInputElement::updateFocusAppearance(SelectionRestorationMode restorationMode, SelectionRevealMode revealMode) 406 406 { 407 407 if (isTextField()) { 408 if ( !restorePreviousSelection|| !hasCachedSelection())408 if (restorationMode == SelectionRestorationMode::SetDefault || !hasCachedSelection()) 409 409 select(Element::defaultFocusTextStateChangeIntent()); 410 410 else 411 411 restoreCachedSelection(); 412 if (document().frame() )412 if (document().frame() && revealMode == SelectionRevealMode::Reveal) 413 413 document().frame()->selection().revealSelection(); 414 414 } else 415 HTMLTextFormControlElement::updateFocusAppearance(restor ePreviousSelection);415 HTMLTextFormControlElement::updateFocusAppearance(restorationMode, revealMode); 416 416 } 417 417 … … 529 529 530 530 if (document().focusedElement() == this) 531 updateFocusAppearance( true);531 updateFocusAppearance(SelectionRestorationMode::Restore, SelectionRevealMode::Reveal); 532 532 533 533 setChangedSinceLastFormControlChangeEvent(false); … … 786 786 787 787 if (document().focusedElement() == this) 788 document().updateFocusAppearanceSoon( true /* restore selection */);788 document().updateFocusAppearanceSoon(SelectionRestorationMode::Restore); 789 789 } 790 790 -
trunk/Source/WebCore/html/HTMLInputElement.h
r191327 r191451 344 344 virtual bool isEnumeratable() const override final; 345 345 virtual bool supportLabels() const override final; 346 virtual void updateFocusAppearance( bool restorePreviousSelection) override final;346 virtual void updateFocusAppearance(SelectionRestorationMode, SelectionRevealMode) override final; 347 347 virtual bool shouldUseInputMethod() override final; 348 348 -
trunk/Source/WebCore/html/HTMLTextAreaElement.cpp
r190613 r191451 252 252 } 253 253 254 void HTMLTextAreaElement::updateFocusAppearance( bool restorePreviousSelection)255 { 256 if ( !restorePreviousSelection|| !hasCachedSelection()) {254 void HTMLTextAreaElement::updateFocusAppearance(SelectionRestorationMode restorationMode, SelectionRevealMode revealMode) 255 { 256 if (restorationMode == SelectionRestorationMode::SetDefault || !hasCachedSelection()) { 257 257 // If this is the first focus, set a caret at the beginning of the text. 258 258 // This matches some browsers' behavior; see bug 11746 Comment #15. … … 262 262 restoreCachedSelection(Element::defaultFocusTextStateChangeIntent()); 263 263 264 if (document().frame() )264 if (document().frame() && revealMode == SelectionRevealMode::Reveal) 265 265 document().frame()->selection().revealSelection(); 266 266 } -
trunk/Source/WebCore/html/HTMLTextAreaElement.h
r189841 r191451 109 109 virtual bool isMouseFocusable() const override; 110 110 virtual bool isKeyboardFocusable(KeyboardEvent*) const override; 111 virtual void updateFocusAppearance( bool restorePreviousSelection) override;111 virtual void updateFocusAppearance(SelectionRestorationMode, SelectionRevealMode) override; 112 112 113 113 virtual void accessKeyAction(bool sendMouseEvents) override; -
trunk/Source/WebKit2/ChangeLog
r191449 r191451 1 2015-10-22 Ryosuke Niwa <rniwa@webkit.org> 2 3 REGRESSION (r181972): Scroll position changes to top of youtube page when switching tabs 4 https://bugs.webkit.org/show_bug.cgi?id=150428 5 6 Reviewed by Antti Koivisto. 7 8 Call updateFocusAppearance with RevealMode::DoNotReveal to avoid revealing the focused element. 9 10 * WebProcess/WebPage/WebPage.cpp: 11 (WebKit::WebPage::restoreSelectionInFocusedEditableElement): 12 1 13 2015-10-22 Carlos Garcia Campos <cgarcia@igalia.com> 2 14 -
trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp
r191408 r191451 3445 3445 if (auto document = frame.document()) { 3446 3446 if (auto element = document->focusedElement()) 3447 element->updateFocusAppearance( true /* restoreSelection */);3447 element->updateFocusAppearance(SelectionRestorationMode::Restore, SelectionRevealMode::DoNotReveal); 3448 3448 } 3449 3449 } -
trunk/Tools/ChangeLog
r191448 r191451 1 2015-10-22 Ryosuke Niwa <rniwa@webkit.org> 2 3 REGRESSION (r181972): Scroll position changes to top of youtube page when switching tabs 4 https://bugs.webkit.org/show_bug.cgi?id=150428 5 6 Reviewed by Antti Koivisto. 7 8 Added a regression test using WebKit API test. 9 10 * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj: 11 * TestWebKitAPI/Tests/mac/FirstResponderScrollingPosition.mm: Added. 12 (TestWebKitAPI::didFinishLoadForFrame): 13 (TestWebKitAPI::TEST): 14 1 15 2015-10-22 Carlos Garcia Campos <cgarcia@igalia.com> 2 16 -
trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj
r191183 r191451 266 266 9B26FCCA159D16DE00CC3765 /* HTMLFormCollectionNamedItem.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 9B26FCB4159D15E700CC3765 /* HTMLFormCollectionNamedItem.html */; }; 267 267 9B4F8FA7159D52DD002D9F94 /* HTMLCollectionNamedItem.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 9B4F8FA6159D52CA002D9F94 /* HTMLCollectionNamedItem.html */; }; 268 9B7916501BD89D0D00D50B8F /* FirstResponderScrollingPosition.mm in Sources */ = {isa = PBXBuildFile; fileRef = 9B79164F1BD89D0D00D50B8F /* FirstResponderScrollingPosition.mm */; settings = {ASSET_TAGS = (); }; }; 268 269 A13EBBAA1B87428D00097110 /* WebProcessPlugIn.mm in Sources */ = {isa = PBXBuildFile; fileRef = A13EBBA91B87428D00097110 /* WebProcessPlugIn.mm */; }; 269 270 A13EBBAB1B87434600097110 /* PlatformUtilitiesCocoa.mm in Sources */ = {isa = PBXBuildFile; fileRef = 0F139E721A423A2B00F590F5 /* PlatformUtilitiesCocoa.mm */; }; … … 639 640 9B4F8FA3159D52B1002D9F94 /* HTMLCollectionNamedItem.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = HTMLCollectionNamedItem.mm; sourceTree = "<group>"; }; 640 641 9B4F8FA6159D52CA002D9F94 /* HTMLCollectionNamedItem.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = HTMLCollectionNamedItem.html; sourceTree = "<group>"; }; 642 9B79164F1BD89D0D00D50B8F /* FirstResponderScrollingPosition.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = FirstResponderScrollingPosition.mm; sourceTree = "<group>"; }; 641 643 A13EBB491B87339E00097110 /* TestWebKitAPI.wkbundle */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = TestWebKitAPI.wkbundle; sourceTree = BUILT_PRODUCTS_DIR; }; 642 644 A13EBB521B87346600097110 /* WebProcessPlugIn.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = WebProcessPlugIn.xcconfig; sourceTree = "<group>"; }; … … 1314 1316 E19DB9781B32137C00DB38D4 /* NavigatorLanguage.mm */, 1315 1317 A57A34EF16AF677200C2501F /* PageVisibilityStateWithWindowChanges.mm */, 1318 9B79164F1BD89D0D00D50B8F /* FirstResponderScrollingPosition.mm */, 1316 1319 00BC16851680FE810065F1E5 /* PublicSuffix.mm */, 1317 1320 37C784DE197C8F2E0010A496 /* RenderedImageFromDOMNode.mm */, … … 1753 1756 7A5623111AD5AF3E0096B920 /* MenuTypesForMouseEvents.cpp in Sources */, 1754 1757 51CB4AD81B3A079C00C1B1C6 /* ModalAlertsSPI.cpp in Sources */, 1758 9B7916501BD89D0D00D50B8F /* FirstResponderScrollingPosition.mm in Sources */, 1755 1759 1CF0D3791BBF2F3D00B4EF54 /* WKRetainPtr.cpp in Sources */, 1756 1760 26F6E1F01ADC749B00DE696B /* DFAMinimizer.cpp in Sources */,
Note:
See TracChangeset
for help on using the changeset viewer.