summaryrefslogtreecommitdiff
path: root/Source/WebCore/style/StyleResolveForDocument.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Source/WebCore/style/StyleResolveForDocument.cpp')
-rw-r--r--Source/WebCore/style/StyleResolveForDocument.cpp89
1 files changed, 38 insertions, 51 deletions
diff --git a/Source/WebCore/style/StyleResolveForDocument.cpp b/Source/WebCore/style/StyleResolveForDocument.cpp
index c920829c2..1d5ac769b 100644
--- a/Source/WebCore/style/StyleResolveForDocument.cpp
+++ b/Source/WebCore/style/StyleResolveForDocument.cpp
@@ -36,6 +36,7 @@
#include "HTMLIFrameElement.h"
#include "LocaleToScriptMapping.h"
#include "NodeRenderStyle.h"
+#include "Page.h"
#include "RenderObject.h"
#include "RenderStyle.h"
#include "RenderView.h"
@@ -47,95 +48,81 @@ namespace WebCore {
namespace Style {
-PassRef<RenderStyle> resolveForDocument(const Document& document)
+RenderStyle resolveForDocument(const Document& document)
{
ASSERT(document.hasLivingRenderTree());
RenderView& renderView = *document.renderView();
- // HTML5 states that seamless iframes should replace default CSS values
- // with values inherited from the containing iframe element. However,
- // some values (such as the case of designMode = "on") still need to
- // be set by this "document style".
auto documentStyle = RenderStyle::create();
- bool seamlessWithParent = document.shouldDisplaySeamlesslyWithParent();
- if (seamlessWithParent) {
- RenderStyle* iframeStyle = document.seamlessParentIFrame()->renderStyle();
- if (iframeStyle)
- documentStyle.get().inheritFrom(iframeStyle);
- }
- // FIXME: It's not clear which values below we want to override in the seamless case!
- documentStyle.get().setDisplay(BLOCK);
- if (!seamlessWithParent) {
- documentStyle.get().setRTLOrdering(document.visuallyOrdered() ? VisualOrder : LogicalOrder);
- documentStyle.get().setZoom(!document.printing() ? renderView.frame().pageZoomFactor() : 1);
- documentStyle.get().setPageScaleTransform(renderView.frame().frameScaleFactor());
- documentStyle.get().setLocale(document.contentLanguage());
- }
+ documentStyle.setDisplay(BLOCK);
+ documentStyle.setRTLOrdering(document.visuallyOrdered() ? VisualOrder : LogicalOrder);
+ documentStyle.setZoom(!document.printing() ? renderView.frame().pageZoomFactor() : 1);
+ documentStyle.setPageScaleTransform(renderView.frame().frameScaleFactor());
+ FontCascadeDescription documentFontDescription = documentStyle.fontDescription();
+ documentFontDescription.setLocale(document.contentLanguage());
+ documentStyle.setFontDescription(WTFMove(documentFontDescription));
+
// This overrides any -webkit-user-modify inherited from the parent iframe.
- documentStyle.get().setUserModify(document.inDesignMode() ? READ_WRITE : READ_ONLY);
+ documentStyle.setUserModify(document.inDesignMode() ? READ_WRITE : READ_ONLY);
#if PLATFORM(IOS)
if (document.inDesignMode())
- documentStyle.get().setTextSizeAdjust(TextSizeAdjustment(NoTextSizeAdjustment));
+ documentStyle.setTextSizeAdjust(TextSizeAdjustment(NoTextSizeAdjustment));
#endif
Element* docElement = document.documentElement();
- RenderObject* docElementRenderer = docElement ? docElement->renderer() : 0;
+ RenderObject* docElementRenderer = docElement ? docElement->renderer() : nullptr;
if (docElementRenderer) {
// Use the direction and writing-mode of the body to set the
// viewport's direction and writing-mode unless the property is set on the document element.
// If there is no body, then use the document element.
- RenderObject* bodyRenderer = document.body() ? document.body()->renderer() : 0;
- if (bodyRenderer && !document.writingModeSetOnDocumentElement())
- documentStyle.get().setWritingMode(bodyRenderer->style().writingMode());
+ auto* body = document.bodyOrFrameset();
+ RenderObject* bodyRenderer = body ? body->renderer() : nullptr;
+ if (bodyRenderer && !docElementRenderer->style().hasExplicitlySetWritingMode())
+ documentStyle.setWritingMode(bodyRenderer->style().writingMode());
else
- documentStyle.get().setWritingMode(docElementRenderer->style().writingMode());
- if (bodyRenderer && !document.directionSetOnDocumentElement())
- documentStyle.get().setDirection(bodyRenderer->style().direction());
+ documentStyle.setWritingMode(docElementRenderer->style().writingMode());
+ if (bodyRenderer && !docElementRenderer->style().hasExplicitlySetDirection())
+ documentStyle.setDirection(bodyRenderer->style().direction());
else
- documentStyle.get().setDirection(docElementRenderer->style().direction());
+ documentStyle.setDirection(docElementRenderer->style().direction());
}
const Pagination& pagination = renderView.frameView().pagination();
if (pagination.mode != Pagination::Unpaginated) {
- documentStyle.get().setColumnStylesFromPaginationMode(pagination.mode);
- documentStyle.get().setColumnGap(pagination.gap);
- if (renderView.hasColumns() || renderView.multiColumnFlowThread())
- renderView.updateColumnProgressionFromStyle(&documentStyle.get());
+ documentStyle.setColumnStylesFromPaginationMode(pagination.mode);
+ documentStyle.setColumnGap(pagination.gap);
+ if (renderView.multiColumnFlowThread())
+ renderView.updateColumnProgressionFromStyle(documentStyle);
+ if (renderView.page().paginationLineGridEnabled()) {
+ documentStyle.setLineGrid("-webkit-default-pagination-grid");
+ documentStyle.setLineSnap(LineSnapContain);
+ }
}
- // Seamless iframes want to inherit their font from their parent iframe, so early return before setting the font.
- if (seamlessWithParent)
- return documentStyle;
-
const Settings& settings = renderView.frame().settings();
- FontDescription fontDescription;
- fontDescription.setScript(localeToScriptCodeForFontSelection(documentStyle.get().locale()));
- fontDescription.setUsePrinterFont(document.printing() || !settings.screenFontSubstitutionEnabled());
+ FontCascadeDescription fontDescription;
+ fontDescription.setLocale(document.contentLanguage());
fontDescription.setRenderingMode(settings.fontRenderingMode());
- const AtomicString& standardFont = settings.standardFontFamily(fontDescription.script());
- if (!standardFont.isEmpty()) {
- fontDescription.setGenericFamily(FontDescription::StandardFamily);
- fontDescription.setOneFamily(standardFont);
- }
- fontDescription.setKeywordSize(CSSValueMedium - CSSValueXxSmall + 1);
+ fontDescription.setOneFamily(standardFamily);
+
+ fontDescription.setKeywordSizeFromIdentifier(CSSValueMedium);
int size = fontSizeForKeyword(CSSValueMedium, false, document);
fontDescription.setSpecifiedSize(size);
bool useSVGZoomRules = document.isSVGDocument();
- fontDescription.setComputedSize(computedFontSizeFromSpecifiedSize(size, fontDescription.isAbsoluteSize(), useSVGZoomRules, &documentStyle.get(), document));
+ fontDescription.setComputedSize(computedFontSizeFromSpecifiedSize(size, fontDescription.isAbsoluteSize(), useSVGZoomRules, &documentStyle, document));
FontOrientation fontOrientation;
NonCJKGlyphOrientation glyphOrientation;
- documentStyle.get().getFontAndGlyphOrientation(fontOrientation, glyphOrientation);
+ std::tie(fontOrientation, glyphOrientation) = documentStyle.fontAndGlyphOrientation();
fontDescription.setOrientation(fontOrientation);
fontDescription.setNonCJKGlyphOrientation(glyphOrientation);
- documentStyle.get().setFontDescription(fontDescription);
+ documentStyle.setFontDescription(fontDescription);
- CSSFontSelector* fontSelector = document.styleResolverIfExists() ? document.styleResolverIfExists()->fontSelector() : 0;
- documentStyle.get().font().update(fontSelector);
+ documentStyle.fontCascade().update(&const_cast<Document&>(document).fontSelector());
return documentStyle;
}