Title: [255486] trunk/Source/WebCore
- Revision
- 255486
- Author
- [email protected]
- Date
- 2020-01-30 22:59:20 -0800 (Thu, 30 Jan 2020)
Log Message
[iOS] Page throttling reasons are not initialized with the device low power mode
https://bugs.webkit.org/show_bug.cgi?id=206860
Patch by Said Abou-Hallawa <[email protected]> on 2020-01-30
Reviewed by Simon Fraser.
Initialize m_throttlingReasons with the device current low power mode in
the constructor of Page.
Add m_throttlingReasonsOverridenForTesting to Page and use it to control
overriding the ThrottlingReasons of m_throttlingReasons.
* page/Page.cpp:
(WebCore::m_deviceOrientationUpdateProvider):
(WebCore::Page::setLowPowerModeEnabledOverrideForTesting):
(WebCore::Page::handleLowModePowerChange):
(WebCore::Page::isLowPowerModeEnabled const): Deleted.
* page/Page.h:
(WebCore::Page::isLowPowerModeEnabled const):
(WebCore::Page::canUpdateThrottlingReason const):
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (255485 => 255486)
--- trunk/Source/WebCore/ChangeLog 2020-01-31 05:35:42 UTC (rev 255485)
+++ trunk/Source/WebCore/ChangeLog 2020-01-31 06:59:20 UTC (rev 255486)
@@ -1,3 +1,25 @@
+2020-01-30 Said Abou-Hallawa <[email protected]>
+
+ [iOS] Page throttling reasons are not initialized with the device low power mode
+ https://bugs.webkit.org/show_bug.cgi?id=206860
+
+ Reviewed by Simon Fraser.
+
+ Initialize m_throttlingReasons with the device current low power mode in
+ the constructor of Page.
+
+ Add m_throttlingReasonsOverridenForTesting to Page and use it to control
+ overriding the ThrottlingReasons of m_throttlingReasons.
+
+ * page/Page.cpp:
+ (WebCore::m_deviceOrientationUpdateProvider):
+ (WebCore::Page::setLowPowerModeEnabledOverrideForTesting):
+ (WebCore::Page::handleLowModePowerChange):
+ (WebCore::Page::isLowPowerModeEnabled const): Deleted.
+ * page/Page.h:
+ (WebCore::Page::isLowPowerModeEnabled const):
+ (WebCore::Page::canUpdateThrottlingReason const):
+
2020-01-30 Doug Kelly <[email protected]>
Ensure non-initial values for CSS Font properties
Modified: trunk/Source/WebCore/page/Page.cpp (255485 => 255486)
--- trunk/Source/WebCore/page/Page.cpp 2020-01-31 05:35:42 UTC (rev 255485)
+++ trunk/Source/WebCore/page/Page.cpp 2020-01-31 06:59:20 UTC (rev 255486)
@@ -335,6 +335,9 @@
m_corsDisablingPatterns.uncheckedAppend(WTFMove(parsedPattern));
}
m_corsDisablingPatterns.shrinkToFit();
+
+ if (m_lowPowerModeNotifier->isLowPowerModeEnabled())
+ m_throttlingReasons.add(ThrottlingReason::LowPowerMode);
}
Page::~Page()
@@ -1160,18 +1163,20 @@
return !isUtilityPage() && nonUtilityPageCount == 1;
}
-bool Page::isLowPowerModeEnabled() const
+void Page::setLowPowerModeEnabledOverrideForTesting(Optional<bool> isEnabled)
{
- if (m_lowPowerModeEnabledOverrideForTesting)
- return m_lowPowerModeEnabledOverrideForTesting.value();
+ // Remove ThrottlingReason::LowPowerMode so handleLowModePowerChange() can do its work.
+ m_throttlingReasonsOverridenForTesting.remove(ThrottlingReason::LowPowerMode);
- return m_lowPowerModeNotifier->isLowPowerModeEnabled();
-}
+ // Use the current low power mode value of the device.
+ if (!isEnabled) {
+ handleLowModePowerChange(m_lowPowerModeNotifier->isLowPowerModeEnabled());
+ return;
+ }
-void Page::setLowPowerModeEnabledOverrideForTesting(Optional<bool> isEnabled)
-{
- m_lowPowerModeEnabledOverrideForTesting = isEnabled;
- handleLowModePowerChange(m_lowPowerModeEnabledOverrideForTesting.valueOr(false));
+ // Override the value and add ThrottlingReason::LowPowerMode so it won't change.
+ handleLowModePowerChange(isEnabled.value());
+ m_throttlingReasonsOverridenForTesting.add(ThrottlingReason::LowPowerMode);
}
void Page::setTopContentInset(float contentInset)
@@ -1410,6 +1415,9 @@
void Page::handleLowModePowerChange(bool isLowPowerModeEnabled)
{
+ if (!canUpdateThrottlingReason(ThrottlingReason::LowPowerMode))
+ return;
+
if (isLowPowerModeEnabled == m_throttlingReasons.contains(ThrottlingReason::LowPowerMode))
return;
Modified: trunk/Source/WebCore/page/Page.h (255485 => 255486)
--- trunk/Source/WebCore/page/Page.h 2020-01-31 05:35:42 UTC (rev 255485)
+++ trunk/Source/WebCore/page/Page.h 2020-01-31 06:59:20 UTC (rev 255486)
@@ -698,7 +698,7 @@
bool isOnlyNonUtilityPage() const;
bool isUtilityPage() const { return m_isUtilityPage; }
- bool isLowPowerModeEnabled() const;
+ bool isLowPowerModeEnabled() const { return m_throttlingReasons.contains(ThrottlingReason::LowPowerMode); }
WEBCORE_EXPORT void setLowPowerModeEnabledOverrideForTesting(Optional<bool>);
bool renderingUpdateThrottlingEnabled() const;
@@ -705,6 +705,7 @@
void renderingUpdateThrottlingEnabledChanged();
bool isRenderingUpdateThrottled() const;
Seconds preferredRenderingUpdateInterval() const;
+ bool canUpdateThrottlingReason(ThrottlingReason reason) const { return !m_throttlingReasonsOverridenForTesting.contains(reason); }
WEBCORE_EXPORT void applicationWillResignActive();
WEBCORE_EXPORT void applicationDidEnterBackground();
@@ -969,7 +970,6 @@
std::unique_ptr<PerformanceMonitor> m_performanceMonitor;
std::unique_ptr<LowPowerModeNotifier> m_lowPowerModeNotifier;
- Optional<bool> m_lowPowerModeEnabledOverrideForTesting;
Optional<Navigation> m_navigationToLogWhenVisible;
@@ -1004,6 +1004,7 @@
Vector<UserContentURLPattern> m_corsDisablingPatterns;
OptionSet<ThrottlingReason> m_throttlingReasons;
+ OptionSet<ThrottlingReason> m_throttlingReasonsOverridenForTesting;
};
inline PageGroup& Page::group()
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes