Changeset 220812 in webkit
- Timestamp:
- Aug 16, 2017 3:12:12 PM (7 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 20 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r220811 r220812 1 2017-08-16 Simon Fraser <simon.fraser@apple.com> 2 3 Add a log channel for media queries 4 https://bugs.webkit.org/show_bug.cgi?id=175591 5 6 Reviewed by Zalan Bujtas. 7 8 Add a "MediaQueries" log channel which logs data about media query evaluation. 9 10 * css/MediaList.cpp: 11 (WebCore::MediaQuerySet::MediaQuerySet): 12 (WebCore::operator<<): 13 * css/MediaList.h: 14 * css/MediaQuery.cpp: 15 (WebCore::operator<<): 16 * css/MediaQuery.h: 17 * css/MediaQueryEvaluator.cpp: 18 (WebCore::operator<<): 19 (WebCore::MediaQueryEvaluator::evaluate const): 20 (WebCore::aspectRatioValueAsString): 21 (WebCore::orientationEvaluate): 22 (WebCore::aspectRatioEvaluate): 23 (WebCore::deviceAspectRatioEvaluate): 24 (WebCore::evaluateResolution): 25 (WebCore::deviceHeightEvaluate): 26 (WebCore::deviceWidthEvaluate): 27 (WebCore::heightEvaluate): 28 (WebCore::widthEvaluate): 29 * css/MediaQueryExpression.cpp: 30 (WebCore::operator<<): 31 * css/MediaQueryExpression.h: 32 * css/MediaQueryMatcher.cpp: 33 (WebCore::MediaQueryMatcher::styleResolverChanged): 34 * css/StyleResolver.cpp: 35 (WebCore::StyleResolver::hasMediaQueriesAffectedByViewportChange const): 36 (WebCore::StyleResolver::hasMediaQueriesAffectedByAccessibilitySettingsChange const): 37 * dom/InlineStyleSheetOwner.cpp: 38 (WebCore::InlineStyleSheetOwner::createSheet): 39 * html/HTMLImageElement.cpp: 40 (WebCore::HTMLImageElement::bestFitSourceFromPictureElement): 41 * html/HTMLLinkElement.cpp: 42 (WebCore::HTMLLinkElement::process): 43 * html/HTMLMediaElement.cpp: 44 (WebCore::HTMLMediaElement::selectNextSourceChild): 45 * html/HTMLPictureElement.cpp: 46 (WebCore::HTMLPictureElement::viewportChangeAffectedPicture const): 47 * html/parser/HTMLPreloadScanner.cpp: 48 (WebCore::TokenPreloadScanner::StartTagScanner::processAttribute): 49 * page/FrameView.cpp: 50 (WebCore::FrameView::layout): 51 * platform/Logging.cpp: 52 (WebCore::initializeLogChannelsIfNecessary): 53 * platform/Logging.h: 54 * platform/URL.cpp: 55 (WebCore::isSchemeFirstChar): 56 (WebCore::operator<<): 57 * platform/URL.h: 58 1 59 2017-08-16 Sam Weinig <sam@webkit.org> 2 60 -
trunk/Source/WebCore/css/MediaList.cpp
r219856 r220812 30 30 #include <wtf/NeverDestroyed.h> 31 31 #include <wtf/text/StringBuilder.h> 32 #include <wtf/text/TextStream.h> 32 33 33 34 namespace WebCore { … … 70 71 71 72 MediaQuerySet::MediaQuerySet() 72 : m_lastLine(0)73 73 { 74 74 } … … 278 278 #endif 279 279 280 } 280 TextStream& operator<<(TextStream& ts, const MediaQuerySet& querySet) 281 { 282 ts << querySet.mediaText(); 283 return ts; 284 } 285 286 TextStream& operator<<(TextStream& ts, const MediaList& mediaList) 287 { 288 ts << mediaList.mediaText(); 289 return ts; 290 } 291 292 } // namespace WebCore 293 -
trunk/Source/WebCore/css/MediaList.h
r208847 r220812 25 25 #include <wtf/Forward.h> 26 26 #include <wtf/Vector.h> 27 28 namespace WTF { 29 class TextStream; 30 } 27 31 28 32 namespace WebCore { … … 67 71 MediaQuerySet(const MediaQuerySet&); 68 72 69 signed m_lastLine;73 int m_lastLine { 0 }; 70 74 Vector<MediaQuery> m_queries; 71 75 }; … … 122 126 #endif 123 127 128 WTF::TextStream& operator<<(WTF::TextStream&, const MediaQuerySet&); 129 WTF::TextStream& operator<<(WTF::TextStream&, const MediaList&); 130 124 131 } // namespace -
trunk/Source/WebCore/css/MediaQuery.cpp
r201441 r220812 31 31 32 32 #include <wtf/text/StringBuilder.h> 33 #include <wtf/text/TextStream.h> 33 34 34 35 namespace WebCore { … … 107 108 } 108 109 110 TextStream& operator<<(TextStream& ts, const MediaQuery& query) 111 { 112 ts << query.cssText(); 113 return ts; 114 } 115 109 116 } //namespace -
trunk/Source/WebCore/css/MediaQuery.h
r212252 r220812 62 62 }; 63 63 64 WTF::TextStream& operator<<(WTF::TextStream&, const MediaQuery&); 65 64 66 } // namespace -
trunk/Source/WebCore/css/MediaQueryEvaluator.cpp
r220730 r220812 35 35 #include "CSSValueKeywords.h" 36 36 #include "FrameView.h" 37 #include "Logging.h" 37 38 #include "MainFrame.h" 38 39 #include "MediaFeatureNames.h" … … 48 49 #include "Theme.h" 49 50 #include <wtf/HashMap.h> 51 #include <wtf/text/TextStream.h> 50 52 51 53 #if ENABLE(3D_TRANSFORMS) … … 56 58 57 59 enum MediaFeaturePrefix { MinPrefix, MaxPrefix, NoPrefix }; 60 61 static TextStream& operator<<(TextStream& ts, MediaFeaturePrefix op) 62 { 63 switch (op) { 64 case MinPrefix: ts << "min"; break; 65 case MaxPrefix: ts << "max"; break; 66 case NoPrefix: ts << ""; break; 67 } 68 return ts; 69 } 58 70 59 71 typedef bool (*MediaQueryFunction)(CSSValue*, const CSSToLengthConversionData&, Frame&, MediaFeaturePrefix); … … 124 136 bool MediaQueryEvaluator::evaluate(const MediaQuerySet& querySet, StyleResolver* styleResolver) const 125 137 { 138 LOG_WITH_STREAM(MediaQueries, stream << "MediaQueryEvaluator::evaluate on " << (m_frame && m_frame->document() ? m_frame->document()->url().string() : emptyString())); 139 126 140 auto& queries = querySet.queryVector(); 127 if (!queries.size()) 141 if (!queries.size()) { 142 LOG_WITH_STREAM(MediaQueries, stream << "MediaQueryEvaluator::evaluate " << querySet << " returning true"); 128 143 return true; // Empty query list evaluates to true. 144 } 129 145 130 146 // Iterate over queries, stop if any of them eval to true (OR semantics). … … 156 172 } 157 173 174 LOG_WITH_STREAM(MediaQueries, stream << "MediaQueryEvaluator::evaluate " << querySet << " returning " << result); 158 175 return result; 159 176 } … … 203 220 } 204 221 222 #if !LOG_DISABLED 223 static String aspectRatioValueAsString(CSSValue* value) 224 { 225 if (!is<CSSAspectRatioValue>(value)) 226 return emptyString(); 227 228 auto& aspectRatio = downcast<CSSAspectRatioValue>(*value); 229 return String::format("%f/%f", aspectRatio.numeratorValue(), aspectRatio.denominatorValue()); 230 } 231 #endif 232 205 233 static bool compareAspectRatioValue(CSSValue* value, int width, int height, MediaFeaturePrefix op) 206 234 { … … 312 340 313 341 auto keyword = downcast<CSSPrimitiveValue>(*value).valueID(); 342 bool result; 314 343 if (viewSize.width() > viewSize.height()) // Square viewport is portrait. 315 return keyword == CSSValueLandscape; 316 return keyword == CSSValuePortrait; 344 result = keyword == CSSValueLandscape; 345 else 346 result = keyword == CSSValuePortrait; 347 348 LOG_WITH_STREAM(MediaQueries, stream << " orientationEvaluate: view size " << viewSize.width() << "x" << viewSize.height() << " is " << value->cssText() << ": " << result); 349 return result; 317 350 } 318 351 … … 327 360 return true; 328 361 auto viewSize = view->layoutSizeForMediaQuery(); 329 return compareAspectRatioValue(value, viewSize.width(), viewSize.height(), op); 362 bool result = compareAspectRatioValue(value, viewSize.width(), viewSize.height(), op); 363 LOG_WITH_STREAM(MediaQueries, stream << " aspectRatioEvaluate: " << op << " " << aspectRatioValueAsString(value) << " actual view size " << viewSize << ": " << result); 364 return result; 330 365 } 331 366 … … 338 373 339 374 auto size = screenRect(frame.mainFrame().view()).size(); 340 return compareAspectRatioValue(value, size.width(), size.height(), op); 375 bool result = compareAspectRatioValue(value, size.width(), size.height(), op); 376 LOG_WITH_STREAM(MediaQueries, stream << " deviceAspectRatioEvaluate: " << op << " " << aspectRatioValueAsString(value) << " actual screen size " << size << ": " << result); 377 return result; 341 378 } 342 379 … … 371 408 372 409 auto& resolution = downcast<CSSPrimitiveValue>(*value); 373 return compareValue(deviceScaleFactor, resolution.isNumber() ? resolution.floatValue() : resolution.floatValue(CSSPrimitiveValue::CSS_DPPX), op); 410 float resolutionValue = resolution.isNumber() ? resolution.floatValue() : resolution.floatValue(CSSPrimitiveValue::CSS_DPPX); 411 bool result = compareValue(deviceScaleFactor, resolutionValue, op); 412 LOG_WITH_STREAM(MediaQueries, stream << " evaluateResolution: " << op << " " << resolutionValue << " device scale factor " << deviceScaleFactor << ": " << result); 413 return result; 374 414 } 375 415 … … 424 464 int length; 425 465 auto height = screenRect(frame.mainFrame().view()).height(); 426 return computeLength(value, !frame.document()->inQuirksMode(), conversionData, length) && compareValue(height, length, op); 466 if (!computeLength(value, !frame.document()->inQuirksMode(), conversionData, length)) 467 return false; 468 469 LOG_WITH_STREAM(MediaQueries, stream << " deviceHeightEvaluate: query " << op << " height " << length << ", actual height " << height << " result: " << compareValue(height, length, op)); 470 471 return compareValue(height, length, op); 427 472 } 428 473 … … 435 480 int length; 436 481 auto width = screenRect(frame.mainFrame().view()).width(); 437 return computeLength(value, !frame.document()->inQuirksMode(), conversionData, length) && compareValue(width, length, op); 482 if (!computeLength(value, !frame.document()->inQuirksMode(), conversionData, length)) 483 return false; 484 485 LOG_WITH_STREAM(MediaQueries, stream << " deviceWidthEvaluate: query " << op << " width " << length << ", actual width " << width << " result: " << compareValue(width, length, op)); 486 487 return compareValue(width, length, op); 438 488 } 439 489 … … 448 498 if (auto* renderView = frame.document()->renderView()) 449 499 height = adjustForAbsoluteZoom(height, *renderView); 500 450 501 int length; 451 return computeLength(value, !frame.document()->inQuirksMode(), conversionData, length) && compareValue(height, length, op); 502 if (!computeLength(value, !frame.document()->inQuirksMode(), conversionData, length)) 503 return false; 504 505 LOG_WITH_STREAM(MediaQueries, stream << " heightEvaluate: query " << op << " height " << length << ", actual height " << height << " result: " << compareValue(height, length, op)); 506 507 return compareValue(height, length, op); 452 508 } 453 509 … … 462 518 if (auto* renderView = frame.document()->renderView()) 463 519 width = adjustForAbsoluteZoom(width, *renderView); 520 464 521 int length; 465 return computeLength(value, !frame.document()->inQuirksMode(), conversionData, length) && compareValue(width, length, op); 522 if (!computeLength(value, !frame.document()->inQuirksMode(), conversionData, length)) 523 return false; 524 525 LOG_WITH_STREAM(MediaQueries, stream << " widthEvaluate: query " << op << " width " << length << ", actual width " << width << " result: " << compareValue(width, length, op)); 526 527 return compareValue(width, length, op); 466 528 } 467 529 -
trunk/Source/WebCore/css/MediaQueryExpression.cpp
r220730 r220812 33 33 #include "CSSPrimitiveValue.h" 34 34 #include "MediaFeatureNames.h" 35 #include <wtf/text/TextStream.h> 35 36 #include <wtf/text/StringBuilder.h> 36 37 … … 226 227 } 227 228 229 TextStream& operator<<(TextStream& ts, const MediaQueryExpression& expression) 230 { 231 ts << expression.serialize(); 232 return ts; 233 } 234 235 228 236 } // namespace -
trunk/Source/WebCore/css/MediaQueryExpression.h
r212252 r220812 31 31 #include "CSSValue.h" 32 32 #include <memory> 33 34 namespace WTF { 35 class TextStream; 36 } 33 37 34 38 namespace WebCore { … … 76 80 } 77 81 82 WTF::TextStream& operator<<(WTF::TextStream&, const MediaQueryExpression&); 83 78 84 } // namespace -
trunk/Source/WebCore/css/MediaQueryMatcher.cpp
r217134 r220812 24 24 #include "Frame.h" 25 25 #include "FrameView.h" 26 #include "Logging.h" 26 27 #include "MediaList.h" 27 28 #include "MediaQueryEvaluator.h" … … 32 33 #include "StyleResolver.h" 33 34 #include "StyleScope.h" 35 #include <wtf/text/TextStream.h> 34 36 35 37 namespace WebCore { … … 119 121 return; 120 122 123 LOG_WITH_STREAM(MediaQueries, stream << "MediaQueryMatcher::styleResolverChanged " << m_document->url()); 124 121 125 MediaQueryEvaluator evaluator { mediaType(), *m_document, style.get() }; 122 126 Vector<Listener> listeners; -
trunk/Source/WebCore/css/StyleResolver.cpp
r220706 r220812 68 68 #include "KeyframeList.h" 69 69 #include "LinkHash.h" 70 #include "Logging.h" 70 71 #include "MathMLElement.h" 71 72 #include "MathMLNames.h" … … 1873 1874 bool StyleResolver::hasMediaQueriesAffectedByViewportChange() const 1874 1875 { 1876 LOG(MediaQueries, "StyleResolver::hasMediaQueriesAffectedByViewportChange evaluating queries"); 1875 1877 for (auto& result : m_viewportDependentMediaQueryResults) { 1876 1878 if (m_mediaQueryEvaluator.evaluate(result.expression) != result.result) … … 1887 1889 bool StyleResolver::hasMediaQueriesAffectedByAccessibilitySettingsChange() const 1888 1890 { 1891 LOG(MediaQueries, "StyleResolver::hasMediaQueriesAffectedByAccessibilitySettingsChange evaluating queries"); 1889 1892 for (auto& result : m_accessibilitySettingsDependentMediaQueryResults) { 1890 1893 if (m_mediaQueryEvaluator.evaluate(result.expression) != result.result) -
trunk/Source/WebCore/dom/InlineStyleSheetOwner.cpp
r213446 r220812 24 24 #include "ContentSecurityPolicy.h" 25 25 #include "Element.h" 26 #include "Logging.h" 26 27 #include "MediaList.h" 27 28 #include "MediaQueryEvaluator.h" … … 175 176 MediaQueryEvaluator screenEval(ASCIILiteral("screen"), true); 176 177 MediaQueryEvaluator printEval(ASCIILiteral("print"), true); 178 LOG(MediaQueries, "InlineStyleSheetOwner::createSheet evaluating queries"); 177 179 if (!screenEval.evaluate(*mediaQueries) && !printEval.evaluate(*mediaQueries)) 178 180 return; -
trunk/Source/WebCore/html/HTMLImageElement.cpp
r219237 r220812 34 34 #include "HTMLSourceElement.h" 35 35 #include "HTMLSrcsetParser.h" 36 #include "Logging.h" 36 37 #include "MIMETypeRegistry.h" 37 38 #include "MediaList.h" … … 170 171 MediaQueryEvaluator evaluator { document().printing() ? "print" : "screen", document(), documentElement ? documentElement->computedStyle() : nullptr }; 171 172 auto* queries = source.parsedMediaAttribute(); 173 LOG(MediaQueries, "HTMLImageElement %p bestFitSourceFromPictureElement evaluating media queries", this); 172 174 auto evaluation = !queries || evaluator.evaluate(*queries, picture->viewportDependentResults()); 173 175 if (picture->hasViewportDependentResults()) -
trunk/Source/WebCore/html/HTMLLinkElement.cpp
r220760 r220812 45 45 #include "HTMLNames.h" 46 46 #include "HTMLParserIdioms.h" 47 #include "Logging.h" 47 48 #include "MediaList.h" 48 49 #include "MediaQueryEvaluator.h" … … 288 289 documentStyle = Style::resolveForDocument(document()); 289 290 auto media = MediaQuerySet::create(m_media); 291 LOG(MediaQueries, "HTMLLinkElement::process evaluating queries"); 290 292 mediaQueryMatches = MediaQueryEvaluator { document().frame()->view()->mediaType(), document(), documentStyle ? &*documentStyle : nullptr }.evaluate(media.get()); 291 293 } -
trunk/Source/WebCore/html/HTMLMediaElement.cpp
r220759 r220812 4297 4297 #endif 4298 4298 auto* renderer = this->renderer(); 4299 LOG(MediaQueries, "HTMLMediaElement %p selectNextSourceChild evaluating media queries", this); 4299 4300 if (!MediaQueryEvaluator { "screen", document(), renderer ? &renderer->style() : nullptr }.evaluate(*media)) 4300 4301 goto CheckAgain; -
trunk/Source/WebCore/html/HTMLPictureElement.cpp
r217876 r220812 29 29 #include "ElementChildIterator.h" 30 30 #include "HTMLImageElement.h" 31 #include "Logging.h" 31 32 32 33 namespace WebCore { … … 65 66 MediaQueryEvaluator evaluator { document().printing() ? "print" : "screen", document(), documentElement ? documentElement->computedStyle() : nullptr }; 66 67 for (auto& result : m_viewportDependentMediaQueryResults) { 68 LOG(MediaQueries, "HTMLPictureElement %p viewportChangeAffectedPicture evaluating media queries", this); 67 69 if (evaluator.evaluate(result.expression) != result.result) 68 70 return true; -
trunk/Source/WebCore/html/parser/HTMLPreloadScanner.cpp
r217247 r220812 36 36 #include "LinkLoader.h" 37 37 #include "LinkRelAttribute.h" 38 #include "Logging.h" 38 39 #include "MediaList.h" 39 40 #include "MediaQueryEvaluator.h" … … 216 217 auto mediaSet = MediaQuerySet::create(attributeValue); 217 218 auto* documentElement = document.documentElement(); 219 LOG(MediaQueries, "HTMLPreloadScanner %p processAttribute evaluating media queries", this); 218 220 m_mediaMatched = MediaQueryEvaluator { document.printing() ? "print" : "screen", document, documentElement ? documentElement->computedStyle() : nullptr }.evaluate(mediaSet.get()); 219 221 } -
trunk/Source/WebCore/page/FrameView.cpp
r220806 r220812 1317 1317 1318 1318 if (inChildFrameLayoutWithFrameFlattening) { 1319 if (!m_frameFlatteningViewSizeForMediaQuery) 1319 if (!m_frameFlatteningViewSizeForMediaQuery) { 1320 LOG_WITH_STREAM(MediaQueries, stream << "FrameView " << this << " snapshotting size " << ScrollView::layoutSize() << " for media queries"); 1320 1321 m_frameFlatteningViewSizeForMediaQuery = ScrollView::layoutSize(); 1322 } 1321 1323 startLayoutAtMainFrameViewIfNeeded(allowSubtree); 1322 1324 RenderElement* root = m_layoutRoot ? m_layoutRoot : frame().document()->renderView(); -
trunk/Source/WebCore/platform/Logging.h
r219301 r220812 63 63 M(Media) \ 64 64 M(MediaCaptureSamples) \ 65 M(MediaQueries) \ 65 66 M(MediaSource) \ 66 67 M(MediaStream) \ -
trunk/Source/WebCore/platform/URL.cpp
r219338 r220812 42 42 #include <wtf/text/StringBuilder.h> 43 43 #include <wtf/text/StringHash.h> 44 #include <wtf/text/TextStream.h> 44 45 45 46 // FIXME: This file makes too much use of the + operator on String. … … 1335 1336 } 1336 1337 1337 } 1338 TextStream& operator<<(TextStream& ts, const URL& url) 1339 { 1340 ts << url.string(); 1341 return ts; 1342 } 1343 1344 } // namespace WebCore -
trunk/Source/WebCore/platform/URL.h
r219338 r220812 43 43 #endif 44 44 45 namespace WTF { 46 class TextStream; 47 } 48 45 49 namespace WebCore { 46 50 … … 442 446 } 443 447 448 WTF::TextStream& operator<<(WTF::TextStream&, const URL&); 449 444 450 } // namespace WebCore 445 451
Note: See TracChangeset
for help on using the changeset viewer.