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*) {
m_callbackSelectorChangeTimer.startOneShot(0, BLINK_FROM_HERE);
return;
}
if (host()->frame()) {
if (supplementable()->frame()) {
Vector<String> addedSelectors;
Vector<String> removedSelectors;
copyToVector(m_addedSelectors, addedSelectors);
copyToVector(m_removedSelectors, removedSelectors);
host()->frame()->loader().client()->selectorMatchChanged(addedSelectors,
removedSelectors);
supplementable()->frame()->loader().client()->selectorMatchChanged(
addedSelectors, removedSelectors);
}
m_addedSelectors.clear();
m_removedSelectors.clear();
......@@ -164,7 +164,7 @@ void CSSSelectorWatch::watchCSSSelectors(const Vector<String>& selectors) {
m_watchedCallbackSelectors.push_back(
StyleRule::create(std::move(selectorList), callbackPropertySet));
}
host()->styleEngine().watchedSelectorsChanged();
supplementable()->styleEngine().watchedSelectorsChanged();
}
DEFINE_TRACE(CSSSelectorWatch) {
......
......@@ -72,8 +72,8 @@ DocumentParserTiming::DocumentParserTiming(Document& document)
: Supplement<Document>(document) {}
void DocumentParserTiming::notifyDocumentParserTimingChanged() {
if (host()->loader())
host()->loader()->didChangePerformanceTiming();
if (supplementable()->loader())
supplementable()->loader()->didChangePerformanceTiming();
}
} // namespace blink
......@@ -36,7 +36,7 @@ FirstMeaningfulPaintDetector::FirstMeaningfulPaintDetector(
&FirstMeaningfulPaintDetector::networkStableTimerFired) {}
Document* FirstMeaningfulPaintDetector::document() {
return m_paintTiming->host();
return m_paintTiming->supplementable();
}
// Computes "layout significance" (http://goo.gl/rytlPL) of a layout operation.
......
......@@ -123,12 +123,12 @@ PaintTiming::PaintTiming(Document& document)
m_fmpDetector(new FirstMeaningfulPaintDetector(this)) {}
LocalFrame* PaintTiming::frame() const {
return host()->frame();
return supplementable()->frame();
}
void PaintTiming::notifyPaintTimingChanged() {
if (host()->loader())
host()->loader()->didChangePerformanceTiming();
if (supplementable()->loader())
supplementable()->loader()->didChangePerformanceTiming();
}
void PaintTiming::setFirstPaint(double stamp) {
......
......@@ -41,7 +41,7 @@ Performance* DOMWindowPerformance::performance(DOMWindow& window) {
Performance* DOMWindowPerformance::performance() {
if (!m_performance)
m_performance = Performance::create(host()->frame());
m_performance = Performance::create(supplementable()->frame());
return m_performance.get();
}
......
......@@ -70,15 +70,15 @@ bool NavigatorBeacon::canSendBeacon(ExecutionContext* context,
}
// If detached from frame, do not allow sending a Beacon.
if (!host()->frame())
if (!supplementable()->frame())
return false;
return true;
}
int NavigatorBeacon::maxAllowance() const {
DCHECK(host()->frame());
const Settings* settings = host()->frame()->settings();
DCHECK(supplementable()->frame());
const Settings* settings = supplementable()->frame()->settings();
if (settings) {
int maxAllowed = settings->getMaxBeaconTransmission();
if (maxAllowed < m_transmittedBytes)
......@@ -118,7 +118,7 @@ bool NavigatorBeacon::sendBeaconImpl(
bool allowed;
if (data.isArrayBufferView()) {
allowed = PingLoader::sendBeacon(host()->frame(), allowance, url,
allowed = PingLoader::sendBeacon(supplementable()->frame(), allowance, url,
data.getAsArrayBufferView(), bytes);
} else if (data.isBlob()) {
Blob* blob = data.getAsBlob();
......@@ -134,17 +134,17 @@ bool NavigatorBeacon::sendBeaconImpl(
return false;
}
}
allowed =
PingLoader::sendBeacon(host()->frame(), allowance, url, blob, bytes);
allowed = PingLoader::sendBeacon(supplementable()->frame(), allowance, url,
blob, bytes);
} else if (data.isString()) {
allowed = PingLoader::sendBeacon(host()->frame(), allowance, url,
allowed = PingLoader::sendBeacon(supplementable()->frame(), allowance, url,
data.getAsString(), bytes);
} else if (data.isFormData()) {
allowed = PingLoader::sendBeacon(host()->frame(), allowance, url,
allowed = PingLoader::sendBeacon(supplementable()->frame(), allowance, url,
data.getAsFormData(), bytes);
} else {
allowed = PingLoader::sendBeacon(host()->frame(), allowance, url, String(),
bytes);
allowed = PingLoader::sendBeacon(supplementable()->frame(), allowance, url,
String(), bytes);
}
if (allowed) {
......
......@@ -34,8 +34,8 @@ Worklet* WindowPaintWorklet::paintWorklet(DOMWindow& window) {
}
PaintWorklet* WindowPaintWorklet::paintWorklet() {
if (!m_paintWorklet && host()->frame())
m_paintWorklet = PaintWorklet::create(host()->frame());
if (!m_paintWorklet && supplementable()->frame())
m_paintWorklet = PaintWorklet::create(supplementable()->frame());
return m_paintWorklet.get();
}
......
......@@ -62,7 +62,7 @@ String NavigatorDoNotTrack::doNotTrack(Navigator& navigator) {
}
String NavigatorDoNotTrack::doNotTrack() {
LocalFrame* frame = host()->frame();
LocalFrame* frame = supplementable()->frame();
if (!frame || !frame->loader().client())
return String();
return frame->loader().client()->doNotTrackValue();
......
......@@ -52,8 +52,8 @@ Geolocation* NavigatorGeolocation::geolocation(Navigator& navigator) {
}
Geolocation* NavigatorGeolocation::geolocation() {
if (!m_geolocation && host()->frame())
m_geolocation = Geolocation::create(host()->frame()->document());
if (!m_geolocation && supplementable()->frame())
m_geolocation = Geolocation::create(supplementable()->frame()->document());
return m_geolocation;
}
......
......@@ -88,10 +88,10 @@ ScriptPromise NavigatorInstalledApp::getInstalledRelatedApps(
}
InstalledAppController* NavigatorInstalledApp::controller() {
if (!host()->frame())
if (!supplementable()->frame())
return nullptr;
return InstalledAppController::from(*host()->frame());
return InstalledAppController::from(*supplementable()->frame());
}
const char* NavigatorInstalledApp::supplementName() {
......
......@@ -56,10 +56,10 @@ Storage* DOMWindowStorage::localStorage(DOMWindow& window,
Storage* DOMWindowStorage::sessionStorage(
ExceptionState& exceptionState) const {
if (!host()->frame())
if (!supplementable()->frame())
return nullptr;
Document* document = host()->frame()->document();
Document* document = supplementable()->frame()->document();
DCHECK(document);
String accessDeniedMessage = "Access is denied for this document.";
if (!document->getSecurityOrigin()->canAccessLocalStorage()) {
......@@ -99,10 +99,10 @@ Storage* DOMWindowStorage::sessionStorage(
}
Storage* DOMWindowStorage::localStorage(ExceptionState& exceptionState) const {
if (!host()->frame())
if (!supplementable()->frame())
return nullptr;
Document* document = host()->frame()->document();
Document* document = supplementable()->frame()->document();
DCHECK(document);
String accessDeniedMessage = "Access is denied for this document.";
if (!document->getSecurityOrigin()->canAccessLocalStorage()) {
......
......@@ -71,7 +71,7 @@ ScriptPromise NavigatorVR::getVRDisplays(ScriptState* scriptState) {
}
VRController* NavigatorVR::controller() {
if (!host()->frame())
if (!supplementable()->frame())
return 0;
if (!m_controller) {
......@@ -82,7 +82,8 @@ VRController* NavigatorVR::controller() {
}
Document* NavigatorVR::document() {
return host()->frame() ? host()->frame()->document() : nullptr;
return supplementable()->frame() ? supplementable()->frame()->document()
: nullptr;
}
DEFINE_TRACE(NavigatorVR) {
......@@ -104,17 +105,17 @@ const char* NavigatorVR::supplementName() {
}
void NavigatorVR::enqueueVREvent(VRDisplayEvent* event) {
if (host()->frame()) {
host()->frame()->domWindow()->enqueueWindowEvent(event);
if (supplementable()->frame()) {
supplementable()->frame()->domWindow()->enqueueWindowEvent(event);
}
}
void NavigatorVR::dispatchVRGestureEvent(VRDisplayEvent* event) {
if (!(host()->frame()))
if (!(supplementable()->frame()))
return;
UserGestureIndicator gestureIndicator(
DocumentUserGestureToken::create(document()));
LocalDOMWindow* window = host()->frame()->domWindow();
LocalDOMWindow* window = supplementable()->frame()->domWindow();
DCHECK(window);
event->setTarget(window);
window->dispatchEvent(event);
......
......@@ -99,31 +99,33 @@ class Supplement : public GarbageCollectedMixin {
// All Supplement objects should be instantiated with m_host.
Supplement() {}
explicit Supplement(T& host) : m_host(&host) {}
explicit Supplement(T& supplementable) : m_supplementable(&supplementable) {}
// 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).
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,
Supplement<T>* supplement) {
host.provideSupplement(key, supplement);
supplementable.provideSupplement(key, supplement);
}
static Supplement<T>* from(Supplementable<T>& host, const char* key) {
return host.requireSupplement(key);
static Supplement<T>* from(Supplementable<T>& supplementable,
const char* key) {
return supplementable.requireSupplement(key);
}
static Supplement<T>* from(Supplementable<T>* host, const char* key) {
return host ? host->requireSupplement(key) : 0;
static Supplement<T>* from(Supplementable<T>* supplementable,
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:
Member<T> m_host;
Member<T> m_supplementable;
};
// 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