Commit 71d04138 authored by haraken's avatar haraken Committed by Commit bot

Rename Supplement::host() to Supplement::supplementable()

Supplement::host() is confusing with FrameHost since it's sometimes used
as host()->frame() etc. Hence this CL renames it to something clearer.

BUG=610176
CQ_INCLUDE_TRYBOTS=master.tryserver.chromium.linux:linux_layout_tests_slimming_paint_v2

Review-Url: https://codereview.chromium.org/2630703002
Cr-Commit-Position: refs/heads/master@{#443528}
parent 035f36c3
...@@ -76,13 +76,13 @@ void CSSSelectorWatch::callbackSelectorChangeTimerFired(TimerBase*) { ...@@ -76,13 +76,13 @@ void CSSSelectorWatch::callbackSelectorChangeTimerFired(TimerBase*) {
m_callbackSelectorChangeTimer.startOneShot(0, BLINK_FROM_HERE); m_callbackSelectorChangeTimer.startOneShot(0, BLINK_FROM_HERE);
return; return;
} }
if (host()->frame()) { if (supplementable()->frame()) {
Vector<String> addedSelectors; Vector<String> addedSelectors;
Vector<String> removedSelectors; Vector<String> removedSelectors;
copyToVector(m_addedSelectors, addedSelectors); copyToVector(m_addedSelectors, addedSelectors);
copyToVector(m_removedSelectors, removedSelectors); copyToVector(m_removedSelectors, removedSelectors);
host()->frame()->loader().client()->selectorMatchChanged(addedSelectors, supplementable()->frame()->loader().client()->selectorMatchChanged(
removedSelectors); addedSelectors, removedSelectors);
} }
m_addedSelectors.clear(); m_addedSelectors.clear();
m_removedSelectors.clear(); m_removedSelectors.clear();
...@@ -164,7 +164,7 @@ void CSSSelectorWatch::watchCSSSelectors(const Vector<String>& selectors) { ...@@ -164,7 +164,7 @@ void CSSSelectorWatch::watchCSSSelectors(const Vector<String>& selectors) {
m_watchedCallbackSelectors.push_back( m_watchedCallbackSelectors.push_back(
StyleRule::create(std::move(selectorList), callbackPropertySet)); StyleRule::create(std::move(selectorList), callbackPropertySet));
} }
host()->styleEngine().watchedSelectorsChanged(); supplementable()->styleEngine().watchedSelectorsChanged();
} }
DEFINE_TRACE(CSSSelectorWatch) { DEFINE_TRACE(CSSSelectorWatch) {
......
...@@ -72,8 +72,8 @@ DocumentParserTiming::DocumentParserTiming(Document& document) ...@@ -72,8 +72,8 @@ DocumentParserTiming::DocumentParserTiming(Document& document)
: Supplement<Document>(document) {} : Supplement<Document>(document) {}
void DocumentParserTiming::notifyDocumentParserTimingChanged() { void DocumentParserTiming::notifyDocumentParserTimingChanged() {
if (host()->loader()) if (supplementable()->loader())
host()->loader()->didChangePerformanceTiming(); supplementable()->loader()->didChangePerformanceTiming();
} }
} // namespace blink } // namespace blink
...@@ -36,7 +36,7 @@ FirstMeaningfulPaintDetector::FirstMeaningfulPaintDetector( ...@@ -36,7 +36,7 @@ FirstMeaningfulPaintDetector::FirstMeaningfulPaintDetector(
&FirstMeaningfulPaintDetector::networkStableTimerFired) {} &FirstMeaningfulPaintDetector::networkStableTimerFired) {}
Document* FirstMeaningfulPaintDetector::document() { Document* FirstMeaningfulPaintDetector::document() {
return m_paintTiming->host(); return m_paintTiming->supplementable();
} }
// Computes "layout significance" (http://goo.gl/rytlPL) of a layout operation. // Computes "layout significance" (http://goo.gl/rytlPL) of a layout operation.
......
...@@ -123,12 +123,12 @@ PaintTiming::PaintTiming(Document& document) ...@@ -123,12 +123,12 @@ PaintTiming::PaintTiming(Document& document)
m_fmpDetector(new FirstMeaningfulPaintDetector(this)) {} m_fmpDetector(new FirstMeaningfulPaintDetector(this)) {}
LocalFrame* PaintTiming::frame() const { LocalFrame* PaintTiming::frame() const {
return host()->frame(); return supplementable()->frame();
} }
void PaintTiming::notifyPaintTimingChanged() { void PaintTiming::notifyPaintTimingChanged() {
if (host()->loader()) if (supplementable()->loader())
host()->loader()->didChangePerformanceTiming(); supplementable()->loader()->didChangePerformanceTiming();
} }
void PaintTiming::setFirstPaint(double stamp) { void PaintTiming::setFirstPaint(double stamp) {
......
...@@ -41,7 +41,7 @@ Performance* DOMWindowPerformance::performance(DOMWindow& window) { ...@@ -41,7 +41,7 @@ Performance* DOMWindowPerformance::performance(DOMWindow& window) {
Performance* DOMWindowPerformance::performance() { Performance* DOMWindowPerformance::performance() {
if (!m_performance) if (!m_performance)
m_performance = Performance::create(host()->frame()); m_performance = Performance::create(supplementable()->frame());
return m_performance.get(); return m_performance.get();
} }
......
...@@ -70,15 +70,15 @@ bool NavigatorBeacon::canSendBeacon(ExecutionContext* context, ...@@ -70,15 +70,15 @@ bool NavigatorBeacon::canSendBeacon(ExecutionContext* context,
} }
// If detached from frame, do not allow sending a Beacon. // If detached from frame, do not allow sending a Beacon.
if (!host()->frame()) if (!supplementable()->frame())
return false; return false;
return true; return true;
} }
int NavigatorBeacon::maxAllowance() const { int NavigatorBeacon::maxAllowance() const {
DCHECK(host()->frame()); DCHECK(supplementable()->frame());
const Settings* settings = host()->frame()->settings(); const Settings* settings = supplementable()->frame()->settings();
if (settings) { if (settings) {
int maxAllowed = settings->getMaxBeaconTransmission(); int maxAllowed = settings->getMaxBeaconTransmission();
if (maxAllowed < m_transmittedBytes) if (maxAllowed < m_transmittedBytes)
...@@ -118,7 +118,7 @@ bool NavigatorBeacon::sendBeaconImpl( ...@@ -118,7 +118,7 @@ bool NavigatorBeacon::sendBeaconImpl(
bool allowed; bool allowed;
if (data.isArrayBufferView()) { if (data.isArrayBufferView()) {
allowed = PingLoader::sendBeacon(host()->frame(), allowance, url, allowed = PingLoader::sendBeacon(supplementable()->frame(), allowance, url,
data.getAsArrayBufferView(), bytes); data.getAsArrayBufferView(), bytes);
} else if (data.isBlob()) { } else if (data.isBlob()) {
Blob* blob = data.getAsBlob(); Blob* blob = data.getAsBlob();
...@@ -134,17 +134,17 @@ bool NavigatorBeacon::sendBeaconImpl( ...@@ -134,17 +134,17 @@ bool NavigatorBeacon::sendBeaconImpl(
return false; return false;
} }
} }
allowed = allowed = PingLoader::sendBeacon(supplementable()->frame(), allowance, url,
PingLoader::sendBeacon(host()->frame(), allowance, url, blob, bytes); blob, bytes);
} else if (data.isString()) { } else if (data.isString()) {
allowed = PingLoader::sendBeacon(host()->frame(), allowance, url, allowed = PingLoader::sendBeacon(supplementable()->frame(), allowance, url,
data.getAsString(), bytes); data.getAsString(), bytes);
} else if (data.isFormData()) { } else if (data.isFormData()) {
allowed = PingLoader::sendBeacon(host()->frame(), allowance, url, allowed = PingLoader::sendBeacon(supplementable()->frame(), allowance, url,
data.getAsFormData(), bytes); data.getAsFormData(), bytes);
} else { } else {
allowed = PingLoader::sendBeacon(host()->frame(), allowance, url, String(), allowed = PingLoader::sendBeacon(supplementable()->frame(), allowance, url,
bytes); String(), bytes);
} }
if (allowed) { if (allowed) {
......
...@@ -34,8 +34,8 @@ Worklet* WindowPaintWorklet::paintWorklet(DOMWindow& window) { ...@@ -34,8 +34,8 @@ Worklet* WindowPaintWorklet::paintWorklet(DOMWindow& window) {
} }
PaintWorklet* WindowPaintWorklet::paintWorklet() { PaintWorklet* WindowPaintWorklet::paintWorklet() {
if (!m_paintWorklet && host()->frame()) if (!m_paintWorklet && supplementable()->frame())
m_paintWorklet = PaintWorklet::create(host()->frame()); m_paintWorklet = PaintWorklet::create(supplementable()->frame());
return m_paintWorklet.get(); return m_paintWorklet.get();
} }
......
...@@ -62,7 +62,7 @@ String NavigatorDoNotTrack::doNotTrack(Navigator& navigator) { ...@@ -62,7 +62,7 @@ String NavigatorDoNotTrack::doNotTrack(Navigator& navigator) {
} }
String NavigatorDoNotTrack::doNotTrack() { String NavigatorDoNotTrack::doNotTrack() {
LocalFrame* frame = host()->frame(); LocalFrame* frame = supplementable()->frame();
if (!frame || !frame->loader().client()) if (!frame || !frame->loader().client())
return String(); return String();
return frame->loader().client()->doNotTrackValue(); return frame->loader().client()->doNotTrackValue();
......
...@@ -52,8 +52,8 @@ Geolocation* NavigatorGeolocation::geolocation(Navigator& navigator) { ...@@ -52,8 +52,8 @@ Geolocation* NavigatorGeolocation::geolocation(Navigator& navigator) {
} }
Geolocation* NavigatorGeolocation::geolocation() { Geolocation* NavigatorGeolocation::geolocation() {
if (!m_geolocation && host()->frame()) if (!m_geolocation && supplementable()->frame())
m_geolocation = Geolocation::create(host()->frame()->document()); m_geolocation = Geolocation::create(supplementable()->frame()->document());
return m_geolocation; return m_geolocation;
} }
......
...@@ -88,10 +88,10 @@ ScriptPromise NavigatorInstalledApp::getInstalledRelatedApps( ...@@ -88,10 +88,10 @@ ScriptPromise NavigatorInstalledApp::getInstalledRelatedApps(
} }
InstalledAppController* NavigatorInstalledApp::controller() { InstalledAppController* NavigatorInstalledApp::controller() {
if (!host()->frame()) if (!supplementable()->frame())
return nullptr; return nullptr;
return InstalledAppController::from(*host()->frame()); return InstalledAppController::from(*supplementable()->frame());
} }
const char* NavigatorInstalledApp::supplementName() { const char* NavigatorInstalledApp::supplementName() {
......
...@@ -56,10 +56,10 @@ Storage* DOMWindowStorage::localStorage(DOMWindow& window, ...@@ -56,10 +56,10 @@ Storage* DOMWindowStorage::localStorage(DOMWindow& window,
Storage* DOMWindowStorage::sessionStorage( Storage* DOMWindowStorage::sessionStorage(
ExceptionState& exceptionState) const { ExceptionState& exceptionState) const {
if (!host()->frame()) if (!supplementable()->frame())
return nullptr; return nullptr;
Document* document = host()->frame()->document(); Document* document = supplementable()->frame()->document();
DCHECK(document); DCHECK(document);
String accessDeniedMessage = "Access is denied for this document."; String accessDeniedMessage = "Access is denied for this document.";
if (!document->getSecurityOrigin()->canAccessLocalStorage()) { if (!document->getSecurityOrigin()->canAccessLocalStorage()) {
...@@ -99,10 +99,10 @@ Storage* DOMWindowStorage::sessionStorage( ...@@ -99,10 +99,10 @@ Storage* DOMWindowStorage::sessionStorage(
} }
Storage* DOMWindowStorage::localStorage(ExceptionState& exceptionState) const { Storage* DOMWindowStorage::localStorage(ExceptionState& exceptionState) const {
if (!host()->frame()) if (!supplementable()->frame())
return nullptr; return nullptr;
Document* document = host()->frame()->document(); Document* document = supplementable()->frame()->document();
DCHECK(document); DCHECK(document);
String accessDeniedMessage = "Access is denied for this document."; String accessDeniedMessage = "Access is denied for this document.";
if (!document->getSecurityOrigin()->canAccessLocalStorage()) { if (!document->getSecurityOrigin()->canAccessLocalStorage()) {
......
...@@ -71,7 +71,7 @@ ScriptPromise NavigatorVR::getVRDisplays(ScriptState* scriptState) { ...@@ -71,7 +71,7 @@ ScriptPromise NavigatorVR::getVRDisplays(ScriptState* scriptState) {
} }
VRController* NavigatorVR::controller() { VRController* NavigatorVR::controller() {
if (!host()->frame()) if (!supplementable()->frame())
return 0; return 0;
if (!m_controller) { if (!m_controller) {
...@@ -82,7 +82,8 @@ VRController* NavigatorVR::controller() { ...@@ -82,7 +82,8 @@ VRController* NavigatorVR::controller() {
} }
Document* NavigatorVR::document() { Document* NavigatorVR::document() {
return host()->frame() ? host()->frame()->document() : nullptr; return supplementable()->frame() ? supplementable()->frame()->document()
: nullptr;
} }
DEFINE_TRACE(NavigatorVR) { DEFINE_TRACE(NavigatorVR) {
...@@ -104,17 +105,17 @@ const char* NavigatorVR::supplementName() { ...@@ -104,17 +105,17 @@ const char* NavigatorVR::supplementName() {
} }
void NavigatorVR::enqueueVREvent(VRDisplayEvent* event) { void NavigatorVR::enqueueVREvent(VRDisplayEvent* event) {
if (host()->frame()) { if (supplementable()->frame()) {
host()->frame()->domWindow()->enqueueWindowEvent(event); supplementable()->frame()->domWindow()->enqueueWindowEvent(event);
} }
} }
void NavigatorVR::dispatchVRGestureEvent(VRDisplayEvent* event) { void NavigatorVR::dispatchVRGestureEvent(VRDisplayEvent* event) {
if (!(host()->frame())) if (!(supplementable()->frame()))
return; return;
UserGestureIndicator gestureIndicator( UserGestureIndicator gestureIndicator(
DocumentUserGestureToken::create(document())); DocumentUserGestureToken::create(document()));
LocalDOMWindow* window = host()->frame()->domWindow(); LocalDOMWindow* window = supplementable()->frame()->domWindow();
DCHECK(window); DCHECK(window);
event->setTarget(window); event->setTarget(window);
window->dispatchEvent(event); window->dispatchEvent(event);
......
...@@ -99,31 +99,33 @@ class Supplement : public GarbageCollectedMixin { ...@@ -99,31 +99,33 @@ class Supplement : public GarbageCollectedMixin {
// All Supplement objects should be instantiated with m_host. // All Supplement objects should be instantiated with m_host.
Supplement() {} Supplement() {}
explicit Supplement(T& host) : m_host(&host) {} explicit Supplement(T& supplementable) : m_supplementable(&supplementable) {}
// Supplementable and its supplements live and die together. // Supplementable and its supplements live and die together.
// Thus host() should never return null (if the default constructor // Thus supplementable() should never return null (if the default constructor
// is completely removed). // is completely removed).
T* host() const { return m_host; } T* supplementable() const { return m_supplementable; }
static void provideTo(Supplementable<T>& host, static void provideTo(Supplementable<T>& supplementable,
const char* key, const char* key,
Supplement<T>* supplement) { Supplement<T>* supplement) {
host.provideSupplement(key, supplement); supplementable.provideSupplement(key, supplement);
} }
static Supplement<T>* from(Supplementable<T>& host, const char* key) { static Supplement<T>* from(Supplementable<T>& supplementable,
return host.requireSupplement(key); const char* key) {
return supplementable.requireSupplement(key);
} }
static Supplement<T>* from(Supplementable<T>* host, const char* key) { static Supplement<T>* from(Supplementable<T>* supplementable,
return host ? host->requireSupplement(key) : 0; const char* key) {
return supplementable ? supplementable->requireSupplement(key) : 0;
} }
DEFINE_INLINE_VIRTUAL_TRACE() { visitor->trace(m_host); } DEFINE_INLINE_VIRTUAL_TRACE() { visitor->trace(m_supplementable); }
private: private:
Member<T> m_host; Member<T> m_supplementable;
}; };
// Supplementable<T> inherits from GarbageCollectedMixin virtually // Supplementable<T> inherits from GarbageCollectedMixin virtually
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment