Changeset 168660 in webkit
- Timestamp:
- May 12, 2014 5:13:58 PM (10 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r168658 r168660 1 2014-05-12 Simon Fraser <simon.fraser@apple.com> 2 3 Add debug dumping for ViewportConfiguration 4 https://bugs.webkit.org/show_bug.cgi?id=132843 5 6 Reviewed by Benjamin Poulain. 7 8 Add some TextStream-based dumping for ViewportConfiguration. 9 10 * page/ViewportConfiguration.cpp: 11 (WebCore::ViewportConfiguration::updateConfiguration): 12 (WebCore::ViewportConfigurationTextStream::ViewportConfigurationTextStream): 13 (WebCore::ViewportConfigurationTextStream::increaseIndent): 14 (WebCore::ViewportConfigurationTextStream::decreaseIndent): 15 (WebCore::dumpProperty): 16 (WebCore::ViewportConfigurationTextStream::writeIndent): 17 (WebCore::ViewportConfigurationTextStream::operator<<): 18 (WebCore::ViewportConfiguration::description): 19 (WebCore::ViewportConfiguration::dump): 20 * page/ViewportConfiguration.h: 21 1 22 2014-05-12 Brady Eidson <beidson@apple.com> 2 23 -
trunk/Source/WebCore/page/ViewportConfiguration.cpp
r168136 r168660 27 27 #include "ViewportConfiguration.h" 28 28 29 #include <WebCore/TextStream.h> 29 30 #include <wtf/Assertions.h> 30 31 #include <wtf/MathExtras.h> 32 #include <wtf/text/CString.h> 31 33 32 34 #if PLATFORM(IOS) … … 314 316 } 315 317 318 #ifndef NDEBUG 319 class ViewportConfigurationTextStream : public TextStream { 320 public: 321 ViewportConfigurationTextStream() 322 : m_indent(0) 323 { 324 } 325 326 using TextStream::operator<<; 327 328 ViewportConfigurationTextStream& operator<<(const ViewportConfiguration::Parameters&); 329 ViewportConfigurationTextStream& operator<<(const ViewportArguments&); 330 331 void increaseIndent() { ++m_indent; } 332 void decreaseIndent() { --m_indent; ASSERT(m_indent >= 0); } 333 334 void writeIndent(); 335 336 private: 337 int m_indent; 338 }; 339 340 template <typename T> 341 static void dumpProperty(ViewportConfigurationTextStream& ts, String name, T value) 342 { 343 ts << "\n"; 344 ts.increaseIndent(); 345 ts.writeIndent(); 346 ts << "(" << name << " "; 347 ts << value << ")"; 348 ts.decreaseIndent(); 349 } 350 351 void ViewportConfigurationTextStream::writeIndent() 352 { 353 for (int i = 0; i < m_indent; ++i) 354 *this << " "; 355 } 356 357 ViewportConfigurationTextStream& ViewportConfigurationTextStream::operator<<(const ViewportConfiguration::Parameters& parameters) 358 { 359 ViewportConfigurationTextStream& ts = *this; 360 361 ts.increaseIndent(); 362 ts << "\n"; 363 ts.writeIndent(); 364 ts << "(width " << parameters.width << ", set: " << (parameters.widthIsSet ? "true" : "false") << ")"; 365 366 ts << "\n"; 367 ts.writeIndent(); 368 ts << "(height " << parameters.height << ", set: " << (parameters.heightIsSet ? "true" : "false") << ")"; 369 370 ts << "\n"; 371 ts.writeIndent(); 372 ts << "(initialScale " << parameters.width << ", set: " << (parameters.initialScaleIsSet ? "true" : "false") << ")"; 373 ts.decreaseIndent(); 374 375 dumpProperty(ts, "minimumScale", parameters.minimumScale); 376 dumpProperty(ts, "maximumScale", parameters.maximumScale); 377 dumpProperty(ts, "allowsUserScaling", parameters.allowsUserScaling); 378 379 return ts; 380 } 381 382 ViewportConfigurationTextStream& ViewportConfigurationTextStream::operator<<(const ViewportArguments& viewportArguments) 383 { 384 ViewportConfigurationTextStream& ts = *this; 385 386 ts.increaseIndent(); 387 388 ts << "\n"; 389 ts.writeIndent(); 390 ts << "(width " << viewportArguments.width << ", minWidth " << viewportArguments.minWidth << ", maxWidth " << viewportArguments.maxWidth << ")"; 391 392 ts << "\n"; 393 ts.writeIndent(); 394 ts << "(height " << viewportArguments.height << ", minHeight " << viewportArguments.minHeight << ", maxHeight " << viewportArguments.maxHeight << ")"; 395 396 ts << "\n"; 397 ts.writeIndent(); 398 ts << "(zoom " << viewportArguments.zoom << ", minZoom " << viewportArguments.minZoom << ", maxZoom " << viewportArguments.maxZoom << ")"; 399 ts.decreaseIndent(); 400 401 #if PLATFORM(IOS) 402 dumpProperty(ts, "minimalUI", viewportArguments.minimalUI); 403 #endif 404 return ts; 405 } 406 407 CString ViewportConfiguration::description() const 408 { 409 ViewportConfigurationTextStream ts; 410 411 ts << "(viewport-configuration " << (void*)this; 412 ts << "\n"; 413 ts.increaseIndent(); 414 ts.writeIndent(); 415 ts << "(viewport arguments"; 416 ts << m_viewportArguments; 417 ts << ")"; 418 ts.decreaseIndent(); 419 420 ts << "\n"; 421 ts.increaseIndent(); 422 ts.writeIndent(); 423 ts << "(configuration"; 424 ts << m_configuration; 425 ts << ")"; 426 ts.decreaseIndent(); 427 428 ts << "\n"; 429 ts.increaseIndent(); 430 ts.writeIndent(); 431 ts << "(default configuration"; 432 ts << m_defaultConfiguration; 433 ts << ")"; 434 ts.decreaseIndent(); 435 436 dumpProperty(ts, "contentSize", m_contentSize); 437 dumpProperty(ts, "minimumLayoutSize", m_minimumLayoutSize); 438 439 ts << "\n"; 440 ts.increaseIndent(); 441 ts.writeIndent(); 442 ts << "(computed initial scale " << initialScale() << ")\n"; 443 ts.writeIndent(); 444 ts << "(computed minimum scale " << minimumScale() << ")\n"; 445 ts.writeIndent(); 446 ts << "(computed layout size " << layoutSize() << ")"; 447 ts.decreaseIndent(); 448 449 ts << ")\n"; 450 451 return ts.release().utf8(); 452 } 453 454 void ViewportConfiguration::dump() const 455 { 456 fprintf(stderr, "%s", description().data()); 457 } 458 459 #endif 460 316 461 } // namespace WebCore -
trunk/Source/WebCore/page/ViewportConfiguration.h
r167735 r168660 88 88 static Parameters imageDocumentParameters(); 89 89 static Parameters xhtmlMobileParameters(); 90 90 91 #ifndef NDEBUG 92 WTF::CString description() const; 93 void dump() const; 94 #endif 95 91 96 private: 92 97 void updateConfiguration();
Note: See TracChangeset
for help on using the changeset viewer.