Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(252)

Side by Side Diff: third_party/WebKit/Source/core/dom/IntersectionObserver.cpp

Issue 1773813007: blink: Rename modules/ method to prefix with get when they collide. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: clash-modules: rebase-fixes Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "core/dom/IntersectionObserver.h" 5 #include "core/dom/IntersectionObserver.h"
6 6
7 #include "bindings/core/v8/ExceptionState.h" 7 #include "bindings/core/v8/ExceptionState.h"
8 #include "core/css/parser/CSSParserTokenRange.h" 8 #include "core/css/parser/CSSParserTokenRange.h"
9 #include "core/css/parser/CSSTokenizer.h" 9 #include "core/css/parser/CSSTokenizer.h"
10 #include "core/dom/ExceptionCode.h" 10 #include "core/dom/ExceptionCode.h"
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 } 79 }
80 80
81 std::sort(thresholds.begin(), thresholds.end()); 81 std::sort(thresholds.begin(), thresholds.end());
82 } 82 }
83 83
84 IntersectionObserver* IntersectionObserver::create(const IntersectionObserverIni t& observerInit, IntersectionObserverCallback& callback, ExceptionState& excepti onState) 84 IntersectionObserver* IntersectionObserver::create(const IntersectionObserverIni t& observerInit, IntersectionObserverCallback& callback, ExceptionState& excepti onState)
85 { 85 {
86 RefPtrWillBeRawPtr<Node> root = observerInit.root(); 86 RefPtrWillBeRawPtr<Node> root = observerInit.root();
87 if (!root) { 87 if (!root) {
88 // TODO(szager): Use Document instead of document element for implicit r oot. (crbug.com/570538) 88 // TODO(szager): Use Document instead of document element for implicit r oot. (crbug.com/570538)
89 ExecutionContext* context = callback.executionContext(); 89 ExecutionContext* context = callback.getExecutionContext();
90 ASSERT(context->isDocument()); 90 ASSERT(context->isDocument());
91 Frame* mainFrame = toDocument(context)->frame()->tree().top(); 91 Frame* mainFrame = toDocument(context)->frame()->tree().top();
92 if (mainFrame && mainFrame->isLocalFrame()) 92 if (mainFrame && mainFrame->isLocalFrame())
93 root = toLocalFrame(mainFrame)->document(); 93 root = toLocalFrame(mainFrame)->document();
94 } 94 }
95 if (!root) { 95 if (!root) {
96 exceptionState.throwDOMException(HierarchyRequestError, "Unable to get r oot node in main frame to track."); 96 exceptionState.throwDOMException(HierarchyRequestError, "Unable to get r oot node in main frame to track.");
97 return nullptr; 97 return nullptr;
98 } 98 }
99 99
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 } 173 }
174 174
175 void IntersectionObserver::observe(Element* target) 175 void IntersectionObserver::observe(Element* target)
176 { 176 {
177 if (!m_root || !target || m_root.get() == target) 177 if (!m_root || !target || m_root.get() == target)
178 return; 178 return;
179 179
180 if (target->ensureIntersectionObserverData().getObservationFor(*this)) 180 if (target->ensureIntersectionObserverData().getObservationFor(*this))
181 return; 181 return;
182 182
183 bool shouldReportRootBounds = target->document().frame()->securityContext()- >securityOrigin()->canAccess(rootNode()->document().frame()->securityContext()-> securityOrigin()); 183 bool shouldReportRootBounds = target->document().frame()->securityContext()- >getSecurityOrigin()->canAccess(rootNode()->document().frame()->securityContext( )->getSecurityOrigin());
184 IntersectionObservation* observation = new IntersectionObservation(*this, *t arget, shouldReportRootBounds); 184 IntersectionObservation* observation = new IntersectionObservation(*this, *t arget, shouldReportRootBounds);
185 target->ensureIntersectionObserverData().addObservation(*observation); 185 target->ensureIntersectionObserverData().addObservation(*observation);
186 m_observations.add(observation); 186 m_observations.add(observation);
187 } 187 }
188 188
189 void IntersectionObserver::unobserve(Element* target) 189 void IntersectionObserver::unobserve(Element* target)
190 { 190 {
191 if (!target || !target->intersectionObserverData()) 191 if (!target || !target->intersectionObserverData())
192 return; 192 return;
193 // TODO(szager): unobserve callback 193 // TODO(szager): unobserve callback
194 if (IntersectionObservation* observation = target->intersectionObserverData( )->getObservationFor(*this)) 194 if (IntersectionObservation* observation = target->intersectionObserverData( )->getObservationFor(*this))
195 observation->disconnect(); 195 observation->disconnect();
196 } 196 }
197 197
198 void IntersectionObserver::computeIntersectionObservations() 198 void IntersectionObserver::computeIntersectionObservations()
199 { 199 {
200 if (!m_root || !m_root->inDocument()) 200 if (!m_root || !m_root->inDocument())
201 return; 201 return;
202 Document* callbackDocument = toDocument(m_callback->executionContext()); 202 Document* callbackDocument = toDocument(m_callback->getExecutionContext());
203 if (!callbackDocument) 203 if (!callbackDocument)
204 return; 204 return;
205 LocalDOMWindow* callbackDOMWindow = callbackDocument->domWindow(); 205 LocalDOMWindow* callbackDOMWindow = callbackDocument->domWindow();
206 if (!callbackDOMWindow) 206 if (!callbackDOMWindow)
207 return; 207 return;
208 DOMHighResTimeStamp timestamp = DOMWindowPerformance::performance(*callbackD OMWindow)->now(); 208 DOMHighResTimeStamp timestamp = DOMWindowPerformance::performance(*callbackD OMWindow)->now();
209 for (auto& observation : m_observations) 209 for (auto& observation : m_observations)
210 observation->computeIntersectionObservations(timestamp); 210 observation->computeIntersectionObservations(timestamp);
211 } 211 }
212 212
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
255 stringBuilder.append(' '); 255 stringBuilder.append(' ');
256 appendLength(stringBuilder, m_bottomMargin); 256 appendLength(stringBuilder, m_bottomMargin);
257 stringBuilder.append(' '); 257 stringBuilder.append(' ');
258 appendLength(stringBuilder, m_leftMargin); 258 appendLength(stringBuilder, m_leftMargin);
259 return stringBuilder.toString(); 259 return stringBuilder.toString();
260 } 260 }
261 261
262 void IntersectionObserver::enqueueIntersectionObserverEntry(IntersectionObserver Entry& entry) 262 void IntersectionObserver::enqueueIntersectionObserverEntry(IntersectionObserver Entry& entry)
263 { 263 {
264 m_entries.append(&entry); 264 m_entries.append(&entry);
265 toDocument(m_callback->executionContext())->ensureIntersectionObserverContro ller().scheduleIntersectionObserverForDelivery(*this); 265 toDocument(m_callback->getExecutionContext())->ensureIntersectionObserverCon troller().scheduleIntersectionObserverForDelivery(*this);
266 } 266 }
267 267
268 static LayoutUnit computeMargin(const Length& length, LayoutUnit referenceLength ) 268 static LayoutUnit computeMargin(const Length& length, LayoutUnit referenceLength )
269 { 269 {
270 if (length.type() == Percent) 270 if (length.type() == Percent)
271 return LayoutUnit(static_cast<int>(referenceLength.toFloat() * length.pe rcent() / 100.0)); 271 return LayoutUnit(static_cast<int>(referenceLength.toFloat() * length.pe rcent() / 100.0));
272 ASSERT(length.type() == Fixed); 272 ASSERT(length.type() == Fixed);
273 return LayoutUnit(length.intValue()); 273 return LayoutUnit(length.intValue());
274 } 274 }
275 275
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
318 { 318 {
319 #if ENABLE(OILPAN) 319 #if ENABLE(OILPAN)
320 visitor->template registerWeakMembers<IntersectionObserver, &IntersectionObs erver::clearWeakMembers>(this); 320 visitor->template registerWeakMembers<IntersectionObserver, &IntersectionObs erver::clearWeakMembers>(this);
321 #endif 321 #endif
322 visitor->trace(m_callback); 322 visitor->trace(m_callback);
323 visitor->trace(m_observations); 323 visitor->trace(m_observations);
324 visitor->trace(m_entries); 324 visitor->trace(m_entries);
325 } 325 }
326 326
327 } // namespace blink 327 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/dom/Fullscreen.cpp ('k') | third_party/WebKit/Source/core/dom/IntersectionObserverCallback.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698