|
Lines 503-529
String Frame::matchLabelsAgainstElement(const Vector<String>& labels, Element* e
a/Source/WebCore/page/Frame.cpp_sec1
|
| 503 |
|
503 |
|
| 504 |
Color Frame::getDocumentBackgroundColor() const |
504 |
Color Frame::getDocumentBackgroundColor() const |
| 505 |
{ |
505 |
{ |
| 506 |
// FIXME: This is a basic implementation adopted originally from WebFrame, |
506 |
// <https://bugs.webkit.org/show_bug.cgi?id=59540> We blend the background color of |
| 507 |
// but ultimately is wrong. Body painting propagates up to the document (see |
507 |
// the document and the body against the base background color of the frame view. |
| 508 |
// RenderBox::paintRootBoxDecorations()), so code from that method should be |
508 |
// Background images are unfortunately impractical to include. |
| 509 |
// adopted here to get the style used to paint the root background. |
|
|
| 510 |
|
509 |
|
| 511 |
// Return invalid Color objects if we are not able to obtain the color |
510 |
// Return invalid Color objects whenever there is insufficient information. |
| 512 |
// for whatever reason. |
|
|
| 513 |
if (!m_doc) |
511 |
if (!m_doc) |
| 514 |
return Color(); |
512 |
return Color(); |
|
|
513 |
|
| 514 |
Element* htmlElement = m_doc->documentElement(); |
| 515 |
Element* bodyElement = m_doc->body(); |
| 516 |
|
| 517 |
// start as invalid colors |
| 518 |
Color htmlBackgroundColor; |
| 519 |
Color bodyBackgroundColor; |
| 520 |
if (htmlElement && htmlElement->renderer()) |
| 521 |
htmlBackgroundColor = htmlElement->renderer()->style()->visitedDependentColor(CSSPropertyBackgroundColor); |
| 522 |
if (bodyElement && bodyElement->renderer()) |
| 523 |
bodyBackgroundColor = bodyElement->renderer()->style()->visitedDependentColor(CSSPropertyBackgroundColor); |
| 515 |
|
524 |
|
| 516 |
Element* rootElementToUse = m_doc->body(); |
525 |
if (!bodyBackgroundColor.isValid()) { |
| 517 |
if (!rootElementToUse) |
526 |
if (!htmlBackgroundColor.isValid()) |
| 518 |
rootElementToUse = m_doc->documentElement(); |
527 |
return Color(); |
| 519 |
if (!rootElementToUse) |
528 |
return view()->baseBackgroundColor().blend(htmlBackgroundColor); |
| 520 |
return Color(); |
529 |
} |
| 521 |
|
530 |
|
| 522 |
RenderObject* renderer = rootElementToUse->renderer(); |
531 |
if (!htmlBackgroundColor.isValid()) |
| 523 |
if (!renderer) |
532 |
return view()->baseBackgroundColor().blend(bodyBackgroundColor); |
| 524 |
return Color(); |
|
|
| 525 |
|
533 |
|
| 526 |
return renderer->style()->visitedDependentColor(CSSPropertyBackgroundColor); |
534 |
// We take the aggregate of the base background color |
|
|
535 |
// the <html> background color, and the <body> |
| 536 |
// background color to find the document color. The |
| 537 |
// addition of the base background color is not |
| 538 |
// technically part of the document background, but it |
| 539 |
// otherwise poses problems when the aggregate is not |
| 540 |
// fully opaque. |
| 541 |
return view()->baseBackgroundColor().blend(htmlBackgroundColor).blend(bodyBackgroundColor); |
| 527 |
} |
542 |
} |
| 528 |
|
543 |
|
| 529 |
void Frame::setPrinting(bool printing, const FloatSize& pageSize, float maximumShrinkRatio, AdjustViewSizeOrNot shouldAdjustViewSize) |
544 |
void Frame::setPrinting(bool printing, const FloatSize& pageSize, float maximumShrinkRatio, AdjustViewSizeOrNot shouldAdjustViewSize) |