Changeset 243305 in webkit
- Timestamp:
- Mar 21, 2019, 11:38:39 AM (7 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 3 edited
-
ChangeLog (modified) (1 diff)
-
page/ios/ContentChangeObserver.cpp (modified) (4 diffs)
-
page/ios/ContentChangeObserver.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r243304 r243305 1 2019-03-21 Zalan Bujtas <zalan@apple.com> 2 3 [ContentChangeObserver] Track hidden elements only while transitioning. 4 https://bugs.webkit.org/show_bug.cgi?id=196050 5 <rdar://problem/49092037> 6 7 Reviewed by Simon Fraser. 8 9 Use the existing isConsideredHidden() logic to decide whether the current transition should be tracked. 10 11 * page/ios/ContentChangeObserver.cpp: 12 (WebCore::isConsideredHidden): 13 (WebCore::ContentChangeObserver::didAddTransition): 14 (WebCore::ContentChangeObserver::StyleChangeScope::StyleChangeScope): 15 (WebCore::ContentChangeObserver::StyleChangeScope::~StyleChangeScope): 16 (WebCore::ContentChangeObserver::StyleChangeScope::isConsideredHidden const): Deleted. 17 * page/ios/ContentChangeObserver.h: 18 1 19 2019-03-21 Zalan Bujtas <zalan@apple.com> 2 20 -
trunk/Source/WebCore/page/ios/ContentChangeObserver.cpp
r243304 r243305 43 43 static const Seconds maximumDelayForTransitions { 300_ms }; 44 44 45 static bool isConsideredHidden(const Element& element) 46 { 47 if (!element.renderStyle()) 48 return true; 49 50 auto& style = *element.renderStyle(); 51 if (style.display() == DisplayType::None) 52 return true; 53 54 if (style.visibility() == Visibility::Hidden) 55 return true; 56 57 auto width = style.logicalWidth(); 58 auto height = style.logicalHeight(); 59 if ((width.isFixed() && !width.value()) || (height.isFixed() && !height.value())) 60 return true; 61 62 auto top = style.logicalTop(); 63 auto left = style.logicalLeft(); 64 // FIXME: This is trying to check if the element is outside of the viewport. This is incorrect for many reasons. 65 if (left.isFixed() && width.isFixed() && -left.value() >= width.value()) 66 return true; 67 if (top.isFixed() && height.isFixed() && -top.value() >= height.value()) 68 return true; 69 70 // It's a common technique used to position content offscreen. 71 if (style.hasOutOfFlowPosition() && left.isFixed() && left.value() <= -999) 72 return true; 73 74 // FIXME: Check for other cases like zero height with overflow hidden. 75 auto maxHeight = style.maxHeight(); 76 if (maxHeight.isFixed() && !maxHeight.value()) 77 return true; 78 79 return false; 80 } 81 45 82 ContentChangeObserver::ContentChangeObserver(Document& document) 46 83 : m_document(document) … … 99 136 auto transitionEnd = Seconds { transition.duration() + std::max<double>(0, transition.isDelaySet() ? transition.delay() : 0) }; 100 137 if (transitionEnd > maximumDelayForTransitions) 138 return; 139 if (!isConsideredHidden(element)) 101 140 return; 102 141 LOG_WITH_STREAM(ContentObservation, stream << "didAddTransition: transition created on " << &element << " (" << transitionEnd.milliseconds() << "ms)."); … … 385 424 { 386 425 if (m_contentChangeObserver.isObservingContentChanges() && !m_contentChangeObserver.hasVisibleChangeState()) 387 m_wasHidden = isConsideredHidden( );426 m_wasHidden = isConsideredHidden(m_element); 388 427 } 389 428 … … 391 430 { 392 431 auto changedFromHiddenToVisible = [&] { 393 return m_wasHidden && !isConsideredHidden( );432 return m_wasHidden && !isConsideredHidden(m_element); 394 433 }; 395 434 396 435 if (changedFromHiddenToVisible() && isConsideredClickable()) 397 436 m_contentChangeObserver.contentVisibilityDidChange(); 398 }399 400 bool ContentChangeObserver::StyleChangeScope::isConsideredHidden() const401 {402 if (!m_element.renderStyle())403 return true;404 405 auto& style = *m_element.renderStyle();406 if (style.display() == DisplayType::None)407 return true;408 409 if (style.visibility() == Visibility::Hidden)410 return true;411 412 auto width = style.logicalWidth();413 auto height = style.logicalHeight();414 if ((width.isFixed() && !width.value()) || (height.isFixed() && !height.value()))415 return true;416 417 auto top = style.logicalTop();418 auto left = style.logicalLeft();419 // FIXME: This is trying to check if the element is outside of the viewport. This is incorrect for many reasons.420 if (left.isFixed() && width.isFixed() && -left.value() >= width.value())421 return true;422 if (top.isFixed() && height.isFixed() && -top.value() >= height.value())423 return true;424 425 // It's a common technique used to position content offscreen.426 if (style.hasOutOfFlowPosition() && left.isFixed() && left.value() <= -999)427 return true;428 429 // FIXME: Check for other cases like zero height with overflow hidden.430 auto maxHeight = style.maxHeight();431 if (maxHeight.isFixed() && !maxHeight.value())432 return true;433 434 return false;435 437 } 436 438 -
trunk/Source/WebCore/page/ios/ContentChangeObserver.h
r243304 r243305 67 67 68 68 private: 69 bool isConsideredHidden() const;70 69 bool isConsideredClickable() const; 71 70
Note:
See TracChangeset
for help on using the changeset viewer.