- Revision
- 221464
- Author
- akl...@apple.com
- Date
- 2017-08-31 18:17:16 -0700 (Thu, 31 Aug 2017)
Log Message
Element focus appearance update should be either immediate or a post-layout task
https://bugs.webkit.org/show_bug.cgi?id=176193
Reviewed by Antti Koivisto.
This change removes an old mechanism for avoiding element focus appearance updates
while we might be in the middle of attaching a renderer.
Focus appearance updates depend on a clean layout, since they want to be able to
scroll the element into the visible viewport if needed.
We now simply do the updates either immediately after layout in Element::focus(),
or as a post-layout callback when needed for HTMLInputElement::didAttachRenderers().
* dom/Document.cpp:
(WebCore::Document::Document):
(WebCore::Document::updateFocusAppearanceSoon): Deleted.
(WebCore::Document::cancelFocusAppearanceUpdate): Deleted.
(WebCore::Document::updateFocusAppearanceTimerFired): Deleted.
* dom/Document.h:
* dom/Element.cpp:
(WebCore::Element::focus):
(WebCore::Element::blur):
(WebCore::Element::clearStyleDerivedDataBeforeDetachingRenderer):
(WebCore::Element::updateFocusAppearanceAfterAttachIfNeeded): Deleted.
(WebCore::Element::cancelFocusAppearanceUpdate): Deleted.
* dom/Element.h:
* dom/ElementRareData.h:
(WebCore::ElementRareData::ElementRareData):
(WebCore::ElementRareData::needsFocusAppearanceUpdateSoonAfterAttach const): Deleted.
(WebCore::ElementRareData::setNeedsFocusAppearanceUpdateSoonAfterAttach): Deleted.
* html/HTMLInputElement.cpp:
(WebCore::HTMLInputElement::didAttachRenderers):
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (221463 => 221464)
--- trunk/Source/WebCore/ChangeLog 2017-09-01 00:36:53 UTC (rev 221463)
+++ trunk/Source/WebCore/ChangeLog 2017-09-01 01:17:16 UTC (rev 221464)
@@ -1,3 +1,38 @@
+2017-08-31 Andreas Kling <akl...@apple.com>
+
+ Element focus appearance update should be either immediate or a post-layout task
+ https://bugs.webkit.org/show_bug.cgi?id=176193
+
+ Reviewed by Antti Koivisto.
+
+ This change removes an old mechanism for avoiding element focus appearance updates
+ while we might be in the middle of attaching a renderer.
+
+ Focus appearance updates depend on a clean layout, since they want to be able to
+ scroll the element into the visible viewport if needed.
+ We now simply do the updates either immediately after layout in Element::focus(),
+ or as a post-layout callback when needed for HTMLInputElement::didAttachRenderers().
+
+ * dom/Document.cpp:
+ (WebCore::Document::Document):
+ (WebCore::Document::updateFocusAppearanceSoon): Deleted.
+ (WebCore::Document::cancelFocusAppearanceUpdate): Deleted.
+ (WebCore::Document::updateFocusAppearanceTimerFired): Deleted.
+ * dom/Document.h:
+ * dom/Element.cpp:
+ (WebCore::Element::focus):
+ (WebCore::Element::blur):
+ (WebCore::Element::clearStyleDerivedDataBeforeDetachingRenderer):
+ (WebCore::Element::updateFocusAppearanceAfterAttachIfNeeded): Deleted.
+ (WebCore::Element::cancelFocusAppearanceUpdate): Deleted.
+ * dom/Element.h:
+ * dom/ElementRareData.h:
+ (WebCore::ElementRareData::ElementRareData):
+ (WebCore::ElementRareData::needsFocusAppearanceUpdateSoonAfterAttach const): Deleted.
+ (WebCore::ElementRareData::setNeedsFocusAppearanceUpdateSoonAfterAttach): Deleted.
+ * html/HTMLInputElement.cpp:
+ (WebCore::HTMLInputElement::didAttachRenderers):
+
2017-08-31 Don Olmstead <don.olmst...@sony.com>
[CMake] Make USE_CF conditional within Windows
Modified: trunk/Source/WebCore/dom/Document.cpp (221463 => 221464)
--- trunk/Source/WebCore/dom/Document.cpp 2017-09-01 00:36:53 UTC (rev 221463)
+++ trunk/Source/WebCore/dom/Document.cpp 2017-09-01 01:17:16 UTC (rev 221464)
@@ -461,7 +461,6 @@
, m_visitedLinkState(std::make_unique<VisitedLinkState>(*this))
, m_markers(std::make_unique<DocumentMarkerController>(*this))
, m_styleRecalcTimer([this] { updateStyleIfNeeded(); })
- , m_updateFocusAppearanceTimer(*this, &Document::updateFocusAppearanceTimerFired)
, m_documentCreationTime(MonotonicTime::now())
, m_scriptRunner(std::make_unique<ScriptRunner>(*this))
, m_moduleLoader(std::make_unique<ScriptModuleLoader>(*this))
@@ -5480,29 +5479,6 @@
m_pendingStateObject = WTFMove(stateObject);
}
-void Document::updateFocusAppearanceSoon(SelectionRestorationMode mode)
-{
- m_updateFocusAppearanceRestoresSelection = mode;
- if (!m_updateFocusAppearanceTimer.isActive())
- m_updateFocusAppearanceTimer.startOneShot(0_s);
-}
-
-void Document::cancelFocusAppearanceUpdate()
-{
- m_updateFocusAppearanceTimer.stop();
-}
-
-void Document::updateFocusAppearanceTimerFired()
-{
- Element* element = focusedElement();
- if (!element)
- return;
-
- updateLayout();
- if (element->isFocusable())
- element->updateFocusAppearance(m_updateFocusAppearanceRestoresSelection);
-}
-
void Document::attachRange(Range* range)
{
ASSERT(!m_ranges.contains(range));
Modified: trunk/Source/WebCore/dom/Document.h (221463 => 221464)
--- trunk/Source/WebCore/dom/Document.h 2017-09-01 00:36:53 UTC (rev 221463)
+++ trunk/Source/WebCore/dom/Document.h 2017-09-01 01:17:16 UTC (rev 221464)
@@ -966,9 +966,6 @@
bool hasNodesWithMissingStyle() const { return m_hasNodesWithMissingStyle; }
void setHasNodesWithMissingStyle() { m_hasNodesWithMissingStyle = true; }
- void updateFocusAppearanceSoon(SelectionRestorationMode);
- void cancelFocusAppearanceUpdate();
-
// Extension for manipulating canvas drawing contexts for use in CSS
std::optional<RenderingContext> getCSSCanvasContext(const String& type, const String& name, int width, int height);
HTMLCanvasElement* getCSSCanvasElement(const String& name);
@@ -1412,7 +1409,6 @@
void updateTitleFromTitleElement();
void updateTitle(const StringWithDirection&);
- void updateFocusAppearanceTimerFired();
void updateBaseURL();
void buildAccessKeyMap(TreeScope* root);
@@ -1537,7 +1533,6 @@
const std::unique_ptr<DocumentMarkerController> m_markers;
Timer m_styleRecalcTimer;
- Timer m_updateFocusAppearanceTimer;
Element* m_cssTarget { nullptr };
@@ -1732,7 +1727,6 @@
PageCacheState m_pageCacheState { NotInPageCache };
ReferrerPolicy m_referrerPolicy { ReferrerPolicy::NoReferrerWhenDowngrade };
ReadyState m_readyState { Complete };
- SelectionRestorationMode m_updateFocusAppearanceRestoresSelection { SelectionRestorationMode::SetDefault };
MutationObserverOptions m_mutationObserverTypes { 0 };
Modified: trunk/Source/WebCore/dom/Element.cpp (221463 => 221464)
--- trunk/Source/WebCore/dom/Element.cpp 2017-09-01 00:36:53 UTC (rev 221463)
+++ trunk/Source/WebCore/dom/Element.cpp 2017-09-01 01:17:16 UTC (rev 221464)
@@ -2458,13 +2458,6 @@
// Setting the focused node above might have invalidated the layout due to scripts.
document().updateLayoutIgnorePendingStylesheets();
- if (!isFocusable()) {
- ensureElementRareData().setNeedsFocusAppearanceUpdateSoonAfterAttach(true);
- return;
- }
-
- cancelFocusAppearanceUpdate();
-
SelectionRevealMode revealMode = SelectionRevealMode::Reveal;
#if PLATFORM(IOS)
// Focusing a form element triggers animation in UIKit to scroll to the right position.
@@ -2478,18 +2471,6 @@
updateFocusAppearance(restorePreviousSelection ? SelectionRestorationMode::Restore : SelectionRestorationMode::SetDefault, revealMode);
}
-void Element::updateFocusAppearanceAfterAttachIfNeeded()
-{
- if (!hasRareData())
- return;
- ElementRareData* data = ""
- if (!data->needsFocusAppearanceUpdateSoonAfterAttach())
- return;
- if (isFocusable() && document().focusedElement() == this)
- document().updateFocusAppearanceSoon(SelectionRestorationMode::SetDefault);
- data->setNeedsFocusAppearanceUpdateSoonAfterAttach(false);
-}
-
void Element::updateFocusAppearance(SelectionRestorationMode, SelectionRevealMode revealMode)
{
if (isRootEditableElement()) {
@@ -2518,7 +2499,6 @@
void Element::blur()
{
- cancelFocusAppearanceUpdate();
if (treeScope().focusedElementInScope() == this) {
if (Frame* frame = document().frame())
frame->page()->focusController().setFocusedElement(nullptr, *frame);
@@ -2927,14 +2907,6 @@
return document().getCachedLocale(computeInheritedLanguage());
}
-void Element::cancelFocusAppearanceUpdate()
-{
- if (hasRareData())
- elementRareData()->setNeedsFocusAppearanceUpdateSoonAfterAttach(false);
- if (document().focusedElement() == this)
- document().cancelFocusAppearanceUpdate();
-}
-
void Element::normalizeAttributes()
{
if (!hasAttributes())
@@ -3528,7 +3500,6 @@
void Element::clearStyleDerivedDataBeforeDetachingRenderer()
{
unregisterNamedFlowContentElement();
- cancelFocusAppearanceUpdate();
clearBeforePseudoElement();
clearAfterPseudoElement();
}
Modified: trunk/Source/WebCore/dom/Element.h (221463 => 221464)
--- trunk/Source/WebCore/dom/Element.h 2017-09-01 00:36:53 UTC (rev 221463)
+++ trunk/Source/WebCore/dom/Element.h 2017-09-01 01:17:16 UTC (rev 221464)
@@ -639,8 +639,6 @@
void formatForDebugger(char* buffer, unsigned length) const override;
#endif
- void cancelFocusAppearanceUpdate();
-
// The cloneNode function is private so that non-virtual cloneElementWith/WithoutChildren are used instead.
Ref<Node> cloneNodeInternal(Document&, CloningOperation) override;
virtual Ref<Element> cloneElementWithoutAttributesAndChildren(Document&);
Modified: trunk/Source/WebCore/dom/ElementRareData.h (221463 => 221464)
--- trunk/Source/WebCore/dom/ElementRareData.h 2017-09-01 00:36:53 UTC (rev 221463)
+++ trunk/Source/WebCore/dom/ElementRareData.h 2017-09-01 01:17:16 UTC (rev 221464)
@@ -51,9 +51,6 @@
bool tabIndexSetExplicitly() const { return m_tabIndexWasSetExplicitly; }
void clearTabIndexExplicitly() { m_tabIndex = 0; m_tabIndexWasSetExplicitly = false; }
- bool needsFocusAppearanceUpdateSoonAfterAttach() const { return m_needsFocusAppearanceUpdateSoonAfterAttach; }
- void setNeedsFocusAppearanceUpdateSoonAfterAttach(bool needs) { m_needsFocusAppearanceUpdateSoonAfterAttach = needs; }
-
bool styleAffectedByActive() const { return m_styleAffectedByActive; }
void setStyleAffectedByActive(bool value) { m_styleAffectedByActive = value; }
@@ -120,7 +117,6 @@
int m_tabIndex;
unsigned short m_childIndex;
unsigned m_tabIndexWasSetExplicitly : 1;
- unsigned m_needsFocusAppearanceUpdateSoonAfterAttach : 1;
unsigned m_styleAffectedByActive : 1;
unsigned m_styleAffectedByEmpty : 1;
unsigned m_styleAffectedByFocusWithin : 1;
@@ -166,7 +162,6 @@
, m_tabIndex(0)
, m_childIndex(0)
, m_tabIndexWasSetExplicitly(false)
- , m_needsFocusAppearanceUpdateSoonAfterAttach(false)
, m_styleAffectedByActive(false)
, m_styleAffectedByEmpty(false)
, m_styleAffectedByFocusWithin(false)
Modified: trunk/Source/WebCore/html/HTMLInputElement.cpp (221463 => 221464)
--- trunk/Source/WebCore/html/HTMLInputElement.cpp 2017-09-01 00:36:53 UTC (rev 221463)
+++ trunk/Source/WebCore/html/HTMLInputElement.cpp 2017-09-01 01:17:16 UTC (rev 221464)
@@ -817,8 +817,11 @@
m_inputType->attach();
- if (document().focusedElement() == this)
- document().updateFocusAppearanceSoon(SelectionRestorationMode::Restore);
+ if (document().focusedElement() == this) {
+ document().view()->queuePostLayoutCallback([protectedThis = makeRef(*this)] {
+ protectedThis->updateFocusAppearance(SelectionRestorationMode::Restore, SelectionRevealMode::Reveal);
+ });
+ }
}
void HTMLInputElement::didDetachRenderers()