Changeset 266887 in webkit
- Timestamp:
- Sep 10, 2020, 12:56:07 PM (6 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 4 edited
-
LayoutTests/ChangeLog (modified) (1 diff)
-
LayoutTests/fast/forms/programmatic-focus-after-display-expected.txt (added)
-
LayoutTests/fast/forms/programmatic-focus-after-display.html (added)
-
Source/WebCore/ChangeLog (modified) (1 diff)
-
Source/WebCore/dom/Element.cpp (modified) (4 diffs)
-
Source/WebCore/dom/Node.h (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r266886 r266887 1 2020-09-10 Wenson Hsieh <wenson_hsieh@apple.com> 2 3 REGRESSION (r257839): clickpay.com - password placeholder text cannot be replaced 4 https://bugs.webkit.org/show_bug.cgi?id=216257 5 <rdar://problem/68150686> 6 7 Reviewed by Antti Koivisto. 8 9 Add a new layout test to verify that the bug does not occur. See WebCore/ChangeLog for more details. 10 11 * fast/forms/programmatic-focus-after-display-expected.txt: Added. 12 * fast/forms/programmatic-focus-after-display.html: Added. 13 1 14 2020-09-10 Hector Lopez <hector_i_lopez@apple.com> 2 15 -
trunk/Source/WebCore/ChangeLog
r266885 r266887 1 2020-09-10 Wenson Hsieh <wenson_hsieh@apple.com> 2 3 REGRESSION (r257839): clickpay.com - password placeholder text cannot be replaced 4 https://bugs.webkit.org/show_bug.cgi?id=216257 5 <rdar://problem/68150686> 6 7 Reviewed by Antti Koivisto. 8 9 On clickpay.com, the field in the login form that contains the text "Password" is actually a plain text input, 10 referred to by the site's script as the "null text input". The page adds a focus event listener to this null 11 text input, and inside of this focus event listener, it reveals a hidden password field by removing an inline 12 `display: none;` style rule on the real password input element, programmatically focuses it, and then hides the 13 null text input by setting it to `display: none;` via inline style. 14 15 However, after the changes in r257839, we no longer attempt to do a style update upon programmatic focus in the 16 case where the programmatically focused element does not have a renderer yet (this applies to the password field 17 in this scenario, because it previously had `display: none;`). When we determine whether the newly displayed 18 password field is focusable using `Element::isVisibleWithoutResolvingFullStyle`, we then attempt to use either 19 the existing computed `RenderStyle` on the element, or perform a partial computed style resolution using the 20 `ResolveComputedStyleMode::RenderedOnly` flag. 21 22 But in the case where `ElementRareData`'s computed style exists, it is not guaranteed to be up to date if the 23 inline style changed since the computed style was last set. In the context of this bug, it's actually Safari's 24 AutoFill logic (embedded in the injected bundle) that ends up asking for the computed style of the password 25 input, forcing it to be created and set (though, as demonstrated in the layout test, simply grabbing the 26 computed style is sufficient to replicate the bug outside of Safari). 27 28 The end result is that we'll use this stale computed style, which still believes that the password input is not 29 displayed, and we end up not focusing the element due to believing that the password input is hidden. To fix 30 this, we would need to either check whether the element has an invalid style (i.e. `needsStyleRecalc()`) before 31 attempting to use the existing computed style, or clear out the `ElementRareData` computed style anytime the 32 element's style is invalidated. However, both of these approaches will cause us to perform partial style 33 resolution much more aggressively, leading to a 2-3% regression in Speedometer. 34 35 To address the bug without hampering our performance wins from r257839, we add a new node flag so that we can 36 remember when computed styles are no longer valid due to style invalidation, and consult this flag in 37 `Element::isVisibleWithoutResolvingFullStyle` to avoid using the existing computed style. 38 39 Test: fast/forms/programmatic-focus-after-display.html 40 41 * dom/Element.cpp: 42 (WebCore::Element::invalidateStyle): 43 (WebCore::Element::resolveComputedStyle): 44 (WebCore::Element::isVisibleWithoutResolvingFullStyle const): 45 * dom/Node.h: 46 (WebCore::Node::setHasValidStyle): 47 1 48 2020-09-10 Devin Rousso <drousso@apple.com> 2 49 -
trunk/Source/WebCore/dom/Element.cpp
r266776 r266887 1970 1970 Node::invalidateStyle(Style::Validity::ElementInvalid); 1971 1971 invalidateSiblingsIfNeeded(*this); 1972 1973 // FIXME: This flag should be set whenever styles are invalidated while computed styles are present, 1974 // not just in this codepath. 1975 if (hasRareData() && elementRareData()->computedStyle()) 1976 setNodeFlag(NodeFlag::IsComputedStyleInvalidFlag); 1972 1977 } 1973 1978 … … 3364 3369 { 3365 3370 ASSERT(isConnected()); 3366 ASSERT(!existingComputedStyle() );3371 ASSERT(!existingComputedStyle() || hasNodeFlag(NodeFlag::IsComputedStyleInvalidFlag)); 3367 3372 3368 3373 Deque<RefPtr<Element>, 32> elementsRequiringComputedStyle({ this }); … … 3384 3389 ElementRareData& rareData = element->ensureElementRareData(); 3385 3390 rareData.setComputedStyle(WTFMove(style)); 3391 element->clearNodeFlag(NodeFlag::IsComputedStyleInvalidFlag); 3386 3392 3387 3393 if (mode == ResolveComputedStyleMode::RenderedOnly && computedStyle->display() == DisplayType::None) … … 3413 3419 3414 3420 // Compute style in yet unstyled subtree. 3415 auto* style = existingComputedStyle();3421 auto* style = hasNodeFlag(NodeFlag::IsComputedStyleInvalidFlag) ? nullptr : existingComputedStyle(); 3416 3422 if (!style) 3417 3423 style = const_cast<Element&>(*this).resolveComputedStyle(ResolveComputedStyleMode::RenderedOnly); -
trunk/Source/WebCore/dom/Node.h
r266776 r266887 553 553 ContainsFullScreenElement = 1 << 26, 554 554 #endif 555 556 // Bits 27-31 are free. 555 IsComputedStyleInvalidFlag = 1 << 27, 556 557 // Bits 28-31 are free. 557 558 }; 558 559 … … 874 875 bitfields.clearFlag(NodeStyleFlag::StyleResolutionShouldRecompositeLayer); 875 876 setStyleBitfields(bitfields); 877 clearNodeFlag(NodeFlag::IsComputedStyleInvalidFlag); 876 878 } 877 879
Note:
See TracChangeset
for help on using the changeset viewer.