From 28010af899d96024c7336363687873144f4f2a82 Mon Sep 17 00:00:00 2001 From: Konstantin Tokarev Date: Sat, 6 Aug 2016 19:25:36 +0300 Subject: Dashed and dotted borders having radius have overlong dash lengths WebKit assumes FlatCap as default, while Qt uses SquareCap. In case of dotted borders, they are rendered as solid, because gaps are completely filled by dash caps. Task-number: QTBUG-55171 QTBUG-55175 Change-Id: Ie18f3c9b9a92db55aa716792316d9b0e9263f223 Reviewed-by: Allan Sandfeld Jensen --- Source/WebCore/platform/graphics/qt/GraphicsContextQt.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/Source/WebCore/platform/graphics/qt/GraphicsContextQt.cpp b/Source/WebCore/platform/graphics/qt/GraphicsContextQt.cpp index 65b93535a..b11e05d8b 100644 --- a/Source/WebCore/platform/graphics/qt/GraphicsContextQt.cpp +++ b/Source/WebCore/platform/graphics/qt/GraphicsContextQt.cpp @@ -356,6 +356,7 @@ void GraphicsContext::platformInit(PlatformGraphicsContext* painter) QPen pen(painter->pen()); pen.setColor(strokeColor()); pen.setJoinStyle(toQtLineJoin(MiterJoin)); + pen.setCapStyle(Qt::FlatCap); painter->setPen(pen); } -- cgit v1.2.3 From bad5ece677263b1fd025ae2305896abbcb0b94a6 Mon Sep 17 00:00:00 2001 From: Topi Reinio Date: Fri, 12 Aug 2016 11:07:24 +0200 Subject: Doc: Change instances of 'OS X' to 'macOS' As of version 10.12 (Sierra), the name of Apple's desktop operating system will be macOS. Change all occurrences where the platform is discussed to use the macro \macos (defined in the documentation configuration in qtbase). Change-Id: I47a83c520dc57f77666d8a40de30d3bb9fd724f9 Reviewed-by: Konstantin Tokarev Reviewed-by: Leena Miettinen --- Source/WebKit/qt/docs/qtwebkit.qdoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/WebKit/qt/docs/qtwebkit.qdoc b/Source/WebKit/qt/docs/qtwebkit.qdoc index f8f22fbd9..f72d39a32 100644 --- a/Source/WebKit/qt/docs/qtwebkit.qdoc +++ b/Source/WebKit/qt/docs/qtwebkit.qdoc @@ -175,7 +175,7 @@ \endtable \table - \header \li Mac OS X + \header \li \macos \row \li \list \li \c{Library/Internet Plug-Ins} in the user's home directory -- cgit v1.2.3 From bb43bca1664721401c3a2c25b585913bb5e8cb4f Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Mon, 22 Aug 2016 10:02:51 +0200 Subject: Prospective build fix for Windows Similar to commit 770a0c91f3fadcdb132d9eb96d085aafbe1bacd0 in qtbase we may need a heuristic for the COPIES assignment for the qmldir file to protect against copying the same file twice to the same location on debug-and-release builds on Windows. Change-Id: I60d34d218856a70c242824b9253d229d2d33d48d Reviewed-by: Oswald Buddenhagen --- Source/WebKit/qt/declarative/experimental/experimental.pri | 8 +++++--- Source/WebKit/qt/declarative/public.pri | 8 +++++--- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/Source/WebKit/qt/declarative/experimental/experimental.pri b/Source/WebKit/qt/declarative/experimental/experimental.pri index c59f4569e..c4d7002e4 100644 --- a/Source/WebKit/qt/declarative/experimental/experimental.pri +++ b/Source/WebKit/qt/declarative/experimental/experimental.pri @@ -11,9 +11,11 @@ TARGET.module_name = QtWebKit/experimental CONFIG += plugin -cpqmldir.files = $${_PRO_FILE_PWD_}/qmldir -cpqmldir.path = $${ROOT_BUILD_DIR}/imports/$${TARGET.module_name} -COPIES += cpqmldir +!debug_and_release|!build_all|CONFIG(release, debug|release) { + cpqmldir.files = $${_PRO_FILE_PWD_}/qmldir + cpqmldir.path = $${ROOT_BUILD_DIR}/imports/$${TARGET.module_name} + COPIES += cpqmldir +} contains(QT_CONFIG, reduce_exports):CONFIG += hide_symbols diff --git a/Source/WebKit/qt/declarative/public.pri b/Source/WebKit/qt/declarative/public.pri index bdef38045..3c7d07a05 100644 --- a/Source/WebKit/qt/declarative/public.pri +++ b/Source/WebKit/qt/declarative/public.pri @@ -11,9 +11,11 @@ TARGET.module_name = QtWebKit CONFIG += plugin -cpqmldir.files = $${_PRO_FILE_PWD_}/qmldir -cpqmldir.path = $${ROOT_BUILD_DIR}/imports/$${TARGET.module_name} -COPIES += cpqmldir +!debug_and_release|!build_all|CONFIG(release, debug|release) { + cpqmldir.files = $${_PRO_FILE_PWD_}/qmldir + cpqmldir.path = $${ROOT_BUILD_DIR}/imports/$${TARGET.module_name} + COPIES += cpqmldir +} contains(QT_CONFIG, reduce_exports):CONFIG += hide_symbols -- cgit v1.2.3 From d685987807e5c1ae1466593525a6bd213f53b887 Mon Sep 17 00:00:00 2001 From: Konstantin Tokarev Date: Mon, 5 Sep 2016 16:35:44 +0300 Subject: Fixed documentation of QWebSettings::JavascriptCanOpenWindows MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I1e22cba3fb1807302ad2fa868e875d762a369ac0 Reviewed-by: Florian Bruhin Reviewed-by: Michael Brüning --- Source/WebKit/qt/Api/qwebsettings.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/WebKit/qt/Api/qwebsettings.cpp b/Source/WebKit/qt/Api/qwebsettings.cpp index 363f58f78..d3a864262 100644 --- a/Source/WebKit/qt/Api/qwebsettings.cpp +++ b/Source/WebKit/qt/Api/qwebsettings.cpp @@ -455,7 +455,7 @@ QWebSettings* QWebSettings::globalSettings() \value PrivateBrowsingEnabled Private browsing prevents WebKit from recording visited pages in the history and storing web page icons. This is disabled by default. \value JavascriptCanOpenWindows Specifies whether JavaScript programs - can open new windows. This is disabled by default. + can open popup windows without user interaction. This is disabled by default. \value JavascriptCanCloseWindows Specifies whether JavaScript programs can close windows. This is disabled by default. \value JavascriptCanAccessClipboard Specifies whether JavaScript programs -- cgit v1.2.3 From b35917bcb44d7f200af0f4ac68a126fa0aa8d93d Mon Sep 17 00:00:00 2001 From: Konstantin Tokarev Date: Thu, 8 Sep 2016 13:50:29 +0300 Subject: Changes for 5.6.2 Change-Id: If817b994f89ede46fb1b20e5f54bc9027b2022f9 Reviewed-by: Allan Sandfeld Jensen --- dist/changes-5.6.2 | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 dist/changes-5.6.2 diff --git a/dist/changes-5.6.2 b/dist/changes-5.6.2 new file mode 100644 index 000000000..07cd4d2e3 --- /dev/null +++ b/dist/changes-5.6.2 @@ -0,0 +1,40 @@ +Qt 5.6.2 is a bug-fix release. It maintains both forward and backward +compatibility (source and binary) with Qt 5.6.1. + +For more details, refer to the online documentation included in this +distribution. The documentation is also available online: + + http://doc.qt.io/qt-5.6 + +The Qt version 5.6 series is binary compatible with the 5.5.x series. +Applications compiled for 5.5 will continue to run with 5.6. + +Some of the changes listed in this file include issue tracking numbers +corresponding to tasks in the Qt Bug Tracker: + + http://bugreports.qt.io/ + +Each of these identifiers can be entered in the bug tracker to obtain more +information about a particular change. + + +**************************************************************************** +* Library * +**************************************************************************** + +QtWebkit +-------- + - [QTBUG-53532] Fixed drawing of zoomed border-image with repeat mode + - [QTBUG-53989] Suppressed warnings about image format being blocked for + invalid images + - [QTBUG-55171] Dotted borders having radius are painted as solid + - [QTBUG-55175] Border dashes have wrong length + + +**************************************************************************** +* Platform Specific Changes * +**************************************************************************** + +- Fixed compilation on macOS when targeting 10.9 or higher +- Fixed compilation on OpenBSD in C++11 mode +- Various other build fixes -- cgit v1.2.3 From 47c9af1dc624e9417f261265bd31f5819f5df304 Mon Sep 17 00:00:00 2001 From: Frederik Gladhorn Date: Fri, 27 May 2016 00:51:47 +0200 Subject: Fix generator scripts to work with python3 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: Ic3f70861e3bbd69821d75527f1206a564ab69e2c Reviewed-by: Jędrzej Nowacki --- Source/JavaScriptCore/disassembler/udis86/ud_opcode.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Source/JavaScriptCore/disassembler/udis86/ud_opcode.py b/Source/JavaScriptCore/disassembler/udis86/ud_opcode.py index f82738062..20ecb7fe5 100644 --- a/Source/JavaScriptCore/disassembler/udis86/ud_opcode.py +++ b/Source/JavaScriptCore/disassembler/udis86/ud_opcode.py @@ -115,9 +115,9 @@ class UdOpcodeTables: '/mod' : lambda v: '00' if v == '!11' else '01', # Mode extensions: # (16, 32, 64) => (00, 01, 02) - '/o' : lambda v: "%02x" % (int(v) / 32), - '/a' : lambda v: "%02x" % (int(v) / 32), - '/m' : lambda v: "%02x" % (int(v) / 32), + '/o' : lambda v: "%02x" % (int(v) // 32), + '/a' : lambda v: "%02x" % (int(v) // 32), + '/m' : lambda v: "%02x" % (int(v) // 32), '/sse' : lambda v: UdOpcodeTables.OpcExtIndex['sse'][v] } -- cgit v1.2.3 From 490b7b65edbd06da0818c0ac765ca6ebd219dce3 Mon Sep 17 00:00:00 2001 From: Vitaliy Slobodin Date: Sun, 11 Sep 2016 12:35:18 +0300 Subject: Adjust the size of native popups When WebKit renders a native control without appearance (-webkit-appearance: none;) for the menu list, it uses the width of the element for the popup size. We need to manually adjust the width of the popup to the longest name. Change-Id: I5883095ab0199c3360ed3fe45d2e2dace416cc4a Reviewed-by: Konstantin Tokarev Reviewed-by: Allan Sandfeld Jensen --- Source/WebKit/qt/WidgetSupport/QtFallbackWebPopup.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Source/WebKit/qt/WidgetSupport/QtFallbackWebPopup.cpp b/Source/WebKit/qt/WidgetSupport/QtFallbackWebPopup.cpp index 61ddacaa8..e6c83197e 100644 --- a/Source/WebKit/qt/WidgetSupport/QtFallbackWebPopup.cpp +++ b/Source/WebKit/qt/WidgetSupport/QtFallbackWebPopup.cpp @@ -71,6 +71,9 @@ void QtFallbackWebPopup::show(const QWebSelectData& data) m_combo->setGeometry(QRect(rect.left(), rect.top(), rect.width(), m_combo->sizeHint().height())); } + // adjust the size of combo box to the longest name + m_combo->adjustSize(); + m_combo->showPopupAtCursorPosition(); } -- cgit v1.2.3 From a7a5227e2ca154172d19cdde023ca6ea76070369 Mon Sep 17 00:00:00 2001 From: Gurpreet Kaur Date: Mon, 28 Mar 2016 20:08:16 +0300 Subject: CSS Unit vw in border-width maps to 0px https://bugs.webkit.org/show_bug.cgi?id=109229 Patch by Gurpreet Kaur on 2013-09-12 Reviewed by Darin Adler. Source/WebCore: Border and outline properties were not applied incase its values were given in vh/vw units. Tests: fast/css/viewport-height-border.html fast/css/viewport-height-outline.html fast/css/viewport-width-border.html fast/css/viewport-width-outline.html * css/CSSPrimitiveValue.cpp: (WebCore::CSSPrimitiveValue::computeLengthDouble): Added case CSS_VH and CSS_VW. * css/CSSPrimitiveValue.h: (WebCore::CSSPrimitiveValue::isViewportPercentageWidth): (WebCore::CSSPrimitiveValue::isViewportPercentageHeight): Added APIs to check the unit type(CSS_VW and CSS_VH). * css/DeprecatedStyleBuilder.cpp: (WebCore::ApplyPropertyComputeLength::applyValue): Calculating the border values which has been specified in vh/vw units.The vh/vw units are calcultated as percent of viewport height and viewport width respectively. LayoutTests: * fast/css/viewport-height-border-expected.txt: Added. * fast/css/viewport-height-border.html: Added. * fast/css/viewport-height-outline-expected.txt: Added. * fast/css/viewport-height-outline.html: Added. * fast/css/viewport-width-border-expected.txt: Added. * fast/css/viewport-width-border.html: Added. * fast/css/viewport-width-outline-expected.txt: Added. * fast/css/viewport-width-outline.html: Added. Added new tests for verifying that border and outline properties are applied when its values are given in vh/vw units. * resources/js-test-pre.js: (shouldNotBeEqualToString): Added this API so that can compare two strings.Similiar to shouldBeEqualToString. git-svn-id: http://svn.webkit.org/repository/webkit/trunk@155624 268f45cc-cd09-0410-ab3c-d52691b4dbfc Change-Id: I77c04e5ace2d16158502295622132551a8b866fd Reviewed-by: Allan Sandfeld Jensen --- Source/WebCore/css/CSSPrimitiveValue.cpp | 4 ++++ Source/WebCore/css/CSSPrimitiveValue.h | 2 ++ Source/WebCore/css/DeprecatedStyleBuilder.cpp | 6 +++++- 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/Source/WebCore/css/CSSPrimitiveValue.cpp b/Source/WebCore/css/CSSPrimitiveValue.cpp index f3902c7be..3ee8cdf53 100644 --- a/Source/WebCore/css/CSSPrimitiveValue.cpp +++ b/Source/WebCore/css/CSSPrimitiveValue.cpp @@ -600,6 +600,10 @@ double CSSPrimitiveValue::computeLengthDouble(const RenderStyle* style, const Re case CSS_CALC_PERCENTAGE_WITH_NUMBER: ASSERT_NOT_REACHED(); return -1.0; + case CSS_VH: + case CSS_VW: + factor = 1.0; + break; default: ASSERT_NOT_REACHED(); return -1.0; diff --git a/Source/WebCore/css/CSSPrimitiveValue.h b/Source/WebCore/css/CSSPrimitiveValue.h index 28ae4e882..88acf041c 100644 --- a/Source/WebCore/css/CSSPrimitiveValue.h +++ b/Source/WebCore/css/CSSPrimitiveValue.h @@ -202,6 +202,8 @@ public: bool isVariableName() const { return primitiveType() == CSS_VARIABLE_NAME; } #endif bool isViewportPercentageLength() const { return m_primitiveUnitType >= CSS_VW && m_primitiveUnitType <= CSS_VMAX; } + bool isViewportPercentageWidth() const { return m_primitiveUnitType == CSS_VW; } + bool isViewportPercentageHeight() const { return m_primitiveUnitType == CSS_VH; } bool isValueID() const { return m_primitiveUnitType == CSS_VALUE_ID; } static PassRefPtr createIdentifier(CSSValueID valueID) { return adoptRef(new CSSPrimitiveValue(valueID)); } diff --git a/Source/WebCore/css/DeprecatedStyleBuilder.cpp b/Source/WebCore/css/DeprecatedStyleBuilder.cpp index 68bb3bcb7..7c6105285 100644 --- a/Source/WebCore/css/DeprecatedStyleBuilder.cpp +++ b/Source/WebCore/css/DeprecatedStyleBuilder.cpp @@ -31,6 +31,7 @@ #include "CSSAspectRatioValue.h" #include "CSSCalculationValue.h" #include "CSSCursorImageValue.h" +#include "CSSPrimitiveValue.h" #include "CSSPrimitiveValueMappings.h" #include "CSSToStyleMap.h" #include "CSSValueList.h" @@ -612,7 +613,10 @@ public: if (originalLength >= 1.0) length = 1.0; } - + if (primitiveValue->isViewportPercentageHeight()) + length = styleResolver->document()->renderView()->viewportSize().height() * length / 100.0f; + else if (primitiveValue->isViewportPercentageWidth()) + length = styleResolver->document()->renderView()->viewportSize().width() * length / 100.0f; } else { ASSERT_NOT_REACHED(); length = 0; -- cgit v1.2.3 From 3bb3f4e49fec10dfe1bd58e3466384317d71ffbe Mon Sep 17 00:00:00 2001 From: Gurpreet Kaur Date: Thu, 19 Sep 2013 11:03:32 +0000 Subject: CSS Unit vmax and vmin in border-width not handled https://bugs.webkit.org/show_bug.cgi?id=121421 Patch by Gurpreet Kaur on 2013-09-19 Reviewed by Darin Adler. Source/WebCore: Border properties were not applied incase its values were given in vmax/vmin units. Tests: fast/css/viewport-vmax-border.html fast/css/viewport-vmin-border.html * css/CSSPrimitiveValue.cpp: (WebCore::CSSPrimitiveValue::computeLengthDouble): * css/CSSPrimitiveValue.h: (WebCore::CSSPrimitiveValue::isViewportPercentageMax): (WebCore::CSSPrimitiveValue::isViewportPercentageMin): * css/DeprecatedStyleBuilder.cpp: (WebCore::ApplyPropertyComputeLength::applyValue): Calculating the border values which has been specified in vmax/vmin units. 1vmax: 1vw or 1vh, whatever is largest. 1vmin: 1vw or 1vh, whatever is smallest. The vh/vw units are calcultated as percent of viewport height and viewport width respectively. LayoutTests: * fast/css/viewport-vmax-border-expected.txt: Added. * fast/css/viewport-vmax-border.html: Added. * fast/css/viewport-vmin-border-expected.txt: Added. * fast/css/viewport-vmin-border.html: Added. Added new tests for verifying that border properties are applied when its values are given in vmax/vmin units. git-svn-id: http://svn.webkit.org/repository/webkit/trunk@156091 268f45cc-cd09-0410-ab3c-d52691b4dbfc Change-Id: I90501069a30cc57be3483c6048aa88568c6570f1 Reviewed-by: Allan Sandfeld Jensen --- Source/WebCore/css/CSSPrimitiveValue.cpp | 2 ++ Source/WebCore/css/CSSPrimitiveValue.h | 2 ++ Source/WebCore/css/DeprecatedStyleBuilder.cpp | 16 ++++++++++++---- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/Source/WebCore/css/CSSPrimitiveValue.cpp b/Source/WebCore/css/CSSPrimitiveValue.cpp index 3ee8cdf53..d0c852465 100644 --- a/Source/WebCore/css/CSSPrimitiveValue.cpp +++ b/Source/WebCore/css/CSSPrimitiveValue.cpp @@ -602,6 +602,8 @@ double CSSPrimitiveValue::computeLengthDouble(const RenderStyle* style, const Re return -1.0; case CSS_VH: case CSS_VW: + case CSS_VMAX: + case CSS_VMIN: factor = 1.0; break; default: diff --git a/Source/WebCore/css/CSSPrimitiveValue.h b/Source/WebCore/css/CSSPrimitiveValue.h index 88acf041c..6bf437ac5 100644 --- a/Source/WebCore/css/CSSPrimitiveValue.h +++ b/Source/WebCore/css/CSSPrimitiveValue.h @@ -204,6 +204,8 @@ public: bool isViewportPercentageLength() const { return m_primitiveUnitType >= CSS_VW && m_primitiveUnitType <= CSS_VMAX; } bool isViewportPercentageWidth() const { return m_primitiveUnitType == CSS_VW; } bool isViewportPercentageHeight() const { return m_primitiveUnitType == CSS_VH; } + bool isViewportPercentageMax() const { return m_primitiveUnitType == CSS_VMAX; } + bool isViewportPercentageMin() const { return m_primitiveUnitType == CSS_VMIN; } bool isValueID() const { return m_primitiveUnitType == CSS_VALUE_ID; } static PassRefPtr createIdentifier(CSSValueID valueID) { return adoptRef(new CSSPrimitiveValue(valueID)); } diff --git a/Source/WebCore/css/DeprecatedStyleBuilder.cpp b/Source/WebCore/css/DeprecatedStyleBuilder.cpp index 7c6105285..1d52de322 100644 --- a/Source/WebCore/css/DeprecatedStyleBuilder.cpp +++ b/Source/WebCore/css/DeprecatedStyleBuilder.cpp @@ -613,10 +613,18 @@ public: if (originalLength >= 1.0) length = 1.0; } - if (primitiveValue->isViewportPercentageHeight()) - length = styleResolver->document()->renderView()->viewportSize().height() * length / 100.0f; - else if (primitiveValue->isViewportPercentageWidth()) - length = styleResolver->document()->renderView()->viewportSize().width() * length / 100.0f; + if (primitiveValue->isViewportPercentageLength()) { + int viewPortHeight = styleResolver->document()->renderView()->viewportSize().height() * length / 100.0f; + int viewPortWidth = styleResolver->document()->renderView()->viewportSize().width() * length / 100.0f; + if (primitiveValue->isViewportPercentageHeight()) + length = viewPortHeight; + else if (primitiveValue->isViewportPercentageWidth()) + length = viewPortWidth; + else if (primitiveValue->isViewportPercentageMax()) + length = max(viewPortWidth, viewPortHeight); + else if (primitiveValue->isViewportPercentageMin()) + length = min(viewPortWidth, viewPortHeight); + } } else { ASSERT_NOT_REACHED(); length = 0; -- cgit v1.2.3 From 7cdd855e3287492093749a833b8b56c67e8db800 Mon Sep 17 00:00:00 2001 From: "hmuller@adobe.com" Date: Fri, 27 Sep 2013 23:17:34 +0000 Subject: Crash on shape-outside when using calc() https://bugs.webkit.org/show_bug.cgi?id=121020 Reviewed by Dirk Schulze. Source/WebCore: This change prevents a crash caused by specifying a CSS Shape geometry Length attribute with a calc() expression. It adds support for converting Lengths to CSSPrimitive Values, in large part by migrating Blink changes made to the calc classes since the split. Doing so required a few supporting changes in some related classes, notably CSSPrimitiveValue. Tests: fast/shapes/shape-inside/shape-inside-calc-crash.html css3/calc/simplification.html * css/BasicShapeFunctions.cpp: (WebCore::convertToCSSPrimitiveValue): Effectively use the new CSSPrimtiveValue(length,style) constructor to convert Lengths to CSSValues. (WebCore::valueForBasicShape): Use the convertToCSSPrimitiveValue() function. (WebCore::convertToLength): Added the CalculatedConversion convertToLength() flag to enable support for calc() valued Length Shape attributes. * css/BasicShapeFunctions.h: * css/CSSCalculationValue.cpp: (WebCore::hasDoubleValue): (WebCore::buildCssText): (WebCore::CSSCalcValue::clampToPermittedRange): (WebCore::CSSCalcValue::doubleValue): (WebCore::CSSCalcExpressionNode::~CSSCalcExpressionNode): (WebCore::CSSCalcPrimitiveValue::create): (WebCore::CSSCalcPrimitiveValue::toCalcValue): (WebCore::CSSCalcPrimitiveValue::doubleValue): (WebCore::CSSCalcPrimitiveValue::computeLengthPx): (WebCore::CSSCalcPrimitiveValue::primitiveType): (WebCore::CSSCalcPrimitiveValue::CSSCalcPrimitiveValue): (WebCore::determineCategory): (WebCore::isIntegerResult): (WebCore::CSSCalcBinaryOperation::create): (WebCore::CSSCalcBinaryOperation::createSimplified): (WebCore::CSSCalcBinaryOperation::doubleValue): (WebCore::CSSCalcBinaryOperation::buildCssText): (WebCore::CSSCalcBinaryOperation::primitiveType): (WebCore::CSSCalcBinaryOperation::CSSCalcBinaryOperation): (WebCore::CSSCalcBinaryOperation::getNumberSide): (WebCore::CSSCalcBinaryOperation::evaluate): (WebCore::CSSCalcBinaryOperation::evaluateOperator): (WebCore::CSSCalcExpressionNodeParser::parseValue): (WebCore::CSSCalcExpressionNodeParser::parseValueTerm): (WebCore::CSSCalcExpressionNodeParser::parseValueMultiplicativeExpression): (WebCore::CSSCalcExpressionNodeParser::parseAdditiveValueExpression): (WebCore::CSSCalcValue::createExpressionNode): (WebCore::CSSCalcValue::create): * css/CSSCalculationValue.h: (WebCore::CSSCalcExpressionNode::category): (WebCore::CSSCalcValue::create): (WebCore::CSSCalcValue::isInt): (WebCore::CSSCalcValue::permittedValueRange): (WebCore::CSSCalcValue::expressionNode): (WebCore::CSSCalcValue::CSSCalcValue): (WebCore::toCSSCalcValue): * css/CSSComputedStyleDeclaration.cpp: (WebCore::ComputedStyleExtractor::propertyValue): Pass the style along to the new valueForBasicShape() function. * css/CSSPrimitiveValue.cpp: (WebCore::CSSPrimitiveValue::unitCategory): Made this function public so that CSSCalculationValue could use it. (WebCore::CSSPrimitiveValue::conversionToCanonicalUnitsScaleFactor): Ditto. (WebCore::CSSPrimitiveValue::primitiveType): Cleared trailing whitespace. (WebCore::CSSPrimitiveValue::CSSPrimitiveValue): Construct a CSSPrimitiveValue from a Length and a RenderStyle*. (WebCore::CSSPrimitiveValue::init): The common part of the two Length CSSPrimitiveValue constructors. (WebCore::CSSPrimitiveValue::computeLengthDouble): Moved the case labels to the left per check-webkit-style. (WebCore::CSSPrimitiveValue::getStringValue): Ditto. (WebCore::CSSPrimitiveValue::getDoubleValue): Removed trailing whitespace. * css/CSSPrimitiveValue.h: (WebCore::CSSPrimitiveValue::create): Construct a CSSPrimitiveValue from a Length and a RenderStyle*. (WebCore::toCSSPrimitiveValue): Check the CSSValue*'s validity with ASSERT_WITH_SECURITY_IMPLICATION before casting to CSSPrimitiveValue*. * css/CSSValuePool.h: (WebCore::CSSValuePool::createValue): A new overload that delegates to the new CSSPrimitiveValue(length,style) constructor. * platform/CalculationValue.h: (WebCore::CalculationValue::operator==): (WebCore::CalculationValue::isNonNegative): (WebCore::CalculationValue::expression): (WebCore::CalcExpressionNumber::value): (WebCore::toCalcExpressionNumber): (WebCore::CalcExpressionLength::CalcExpressionLength): (WebCore::CalcExpressionLength::length): (WebCore::toCalcExpressionLength): (WebCore::CalcExpressionBinaryOperation::leftSide): (WebCore::CalcExpressionBinaryOperation::rightSide): (WebCore::CalcExpressionBinaryOperation::getOperator): (WebCore::toCalcExpressionBinaryOperation): (WebCore::CalcExpressionBlendLength::CalcExpressionBlendLength): (WebCore::CalcExpressionBlendLength::from): (WebCore::CalcExpressionBlendLength::to): (WebCore::CalcExpressionBlendLength::progress): (WebCore::toCalcExpressionBlendLength): LayoutTests: Specifying a CSS Shape geometry Length attribute with a calc() expression or looking up the value with getComputedStyle(), caused crashes. * fast/shapes/shape-inside/shape-inside-calc-crash-expected.txt: Added. * fast/shapes/shape-inside/shape-inside-calc-crash.html: Added. * css3/calc/simplification-expected.txt: Added * css3/calc/simplification.html: Added * LayoutTests/css3/calc/cssom-expected.txt: git-svn-id: http://svn.webkit.org/repository/webkit/trunk@156586 268f45cc-cd09-0410-ab3c-d52691b4dbfc Change-Id: I38216be400bd7024999444d9c1c7e5ad79cce2de Reviewed-by: Allan Sandfeld Jensen --- Source/WebCore/css/BasicShapeFunctions.cpp | 44 +- Source/WebCore/css/BasicShapeFunctions.h | 2 +- Source/WebCore/css/CSSCalculationValue.cpp | 390 ++++++++++++++--- Source/WebCore/css/CSSCalculationValue.h | 58 ++- Source/WebCore/css/CSSComputedStyleDeclaration.cpp | 6 +- Source/WebCore/css/CSSPrimitiveValue.cpp | 467 +++++++++++---------- Source/WebCore/css/CSSPrimitiveValue.h | 27 +- Source/WebCore/css/CSSValuePool.h | 3 +- Source/WebCore/platform/CalculationValue.h | 98 +++-- 9 files changed, 741 insertions(+), 354 deletions(-) diff --git a/Source/WebCore/css/BasicShapeFunctions.cpp b/Source/WebCore/css/BasicShapeFunctions.cpp index c5885095e..a99739a78 100644 --- a/Source/WebCore/css/BasicShapeFunctions.cpp +++ b/Source/WebCore/css/BasicShapeFunctions.cpp @@ -38,7 +38,7 @@ namespace WebCore { -PassRefPtr valueForBasicShape(const BasicShape* basicShape) +PassRefPtr valueForBasicShape(const RenderStyle* style, const BasicShape* basicShape) { RefPtr basicShapeValue; switch (basicShape->type()) { @@ -46,12 +46,12 @@ PassRefPtr valueForBasicShape(const BasicShape* basicShape) const BasicShapeRectangle* rectangle = static_cast(basicShape); RefPtr rectangleValue = CSSBasicShapeRectangle::create(); - rectangleValue->setX(cssValuePool().createValue(rectangle->x())); - rectangleValue->setY(cssValuePool().createValue(rectangle->y())); - rectangleValue->setWidth(cssValuePool().createValue(rectangle->width())); - rectangleValue->setHeight(cssValuePool().createValue(rectangle->height())); - rectangleValue->setRadiusX(cssValuePool().createValue(rectangle->cornerRadiusX())); - rectangleValue->setRadiusY(cssValuePool().createValue(rectangle->cornerRadiusY())); + rectangleValue->setX(cssValuePool().createValue(rectangle->x(), style)); + rectangleValue->setY(cssValuePool().createValue(rectangle->y(), style)); + rectangleValue->setWidth(cssValuePool().createValue(rectangle->width(), style)); + rectangleValue->setHeight(cssValuePool().createValue(rectangle->height(), style)); + rectangleValue->setRadiusX(cssValuePool().createValue(rectangle->cornerRadiusX(), style)); + rectangleValue->setRadiusY(cssValuePool().createValue(rectangle->cornerRadiusY(), style)); basicShapeValue = rectangleValue.release(); break; @@ -60,9 +60,9 @@ PassRefPtr valueForBasicShape(const BasicShape* basicShape) const BasicShapeCircle* circle = static_cast(basicShape); RefPtr circleValue = CSSBasicShapeCircle::create(); - circleValue->setCenterX(cssValuePool().createValue(circle->centerX())); - circleValue->setCenterY(cssValuePool().createValue(circle->centerY())); - circleValue->setRadius(cssValuePool().createValue(circle->radius())); + circleValue->setCenterX(cssValuePool().createValue(circle->centerX(), style)); + circleValue->setCenterY(cssValuePool().createValue(circle->centerY(), style)); + circleValue->setRadius(cssValuePool().createValue(circle->radius(), style)); basicShapeValue = circleValue.release(); break; @@ -71,10 +71,10 @@ PassRefPtr valueForBasicShape(const BasicShape* basicShape) const BasicShapeEllipse* ellipse = static_cast(basicShape); RefPtr ellipseValue = CSSBasicShapeEllipse::create(); - ellipseValue->setCenterX(cssValuePool().createValue(ellipse->centerX())); - ellipseValue->setCenterY(cssValuePool().createValue(ellipse->centerY())); - ellipseValue->setRadiusX(cssValuePool().createValue(ellipse->radiusX())); - ellipseValue->setRadiusY(cssValuePool().createValue(ellipse->radiusY())); + ellipseValue->setCenterX(cssValuePool().createValue(ellipse->centerX(), style)); + ellipseValue->setCenterY(cssValuePool().createValue(ellipse->centerY(), style)); + ellipseValue->setRadiusX(cssValuePool().createValue(ellipse->radiusX(), style)); + ellipseValue->setRadiusY(cssValuePool().createValue(ellipse->radiusY(), style)); basicShapeValue = ellipseValue.release(); break; @@ -86,7 +86,7 @@ PassRefPtr valueForBasicShape(const BasicShape* basicShape) polygonValue->setWindRule(polygon->windRule()); const Vector& values = polygon->values(); for (unsigned i = 0; i < values.size(); i += 2) - polygonValue->appendPoint(cssValuePool().createValue(values.at(i)), cssValuePool().createValue(values.at(i + 1))); + polygonValue->appendPoint(cssValuePool().createValue(values.at(i), style), cssValuePool().createValue(values.at(i + 1), style)); basicShapeValue = polygonValue.release(); break; @@ -95,12 +95,12 @@ PassRefPtr valueForBasicShape(const BasicShape* basicShape) const BasicShapeInsetRectangle* rectangle = static_cast(basicShape); RefPtr rectangleValue = CSSBasicShapeInsetRectangle::create(); - rectangleValue->setTop(cssValuePool().createValue(rectangle->top())); - rectangleValue->setRight(cssValuePool().createValue(rectangle->right())); - rectangleValue->setBottom(cssValuePool().createValue(rectangle->bottom())); - rectangleValue->setLeft(cssValuePool().createValue(rectangle->left())); - rectangleValue->setRadiusX(cssValuePool().createValue(rectangle->cornerRadiusX())); - rectangleValue->setRadiusY(cssValuePool().createValue(rectangle->cornerRadiusY())); + rectangleValue->setTop(cssValuePool().createValue(rectangle->top(), style)); + rectangleValue->setRight(cssValuePool().createValue(rectangle->right(), style)); + rectangleValue->setBottom(cssValuePool().createValue(rectangle->bottom(), style)); + rectangleValue->setLeft(cssValuePool().createValue(rectangle->left(), style)); + rectangleValue->setRadiusX(cssValuePool().createValue(rectangle->cornerRadiusX(), style)); + rectangleValue->setRadiusY(cssValuePool().createValue(rectangle->cornerRadiusY(), style)); basicShapeValue = rectangleValue.release(); break; @@ -113,7 +113,7 @@ PassRefPtr valueForBasicShape(const BasicShape* basicShape) static Length convertToLength(const RenderStyle* style, const RenderStyle* rootStyle, CSSPrimitiveValue* value) { - return value->convertToLength(style, rootStyle, style->effectiveZoom()); + return value->convertToLength(style, rootStyle, style->effectiveZoom()); } PassRefPtr basicShapeForValue(const RenderStyle* style, const RenderStyle* rootStyle, const CSSBasicShape* basicShapeValue) diff --git a/Source/WebCore/css/BasicShapeFunctions.h b/Source/WebCore/css/BasicShapeFunctions.h index 9bbc7c762..ddf7659a2 100644 --- a/Source/WebCore/css/BasicShapeFunctions.h +++ b/Source/WebCore/css/BasicShapeFunctions.h @@ -39,7 +39,7 @@ class CSSBasicShape; class CSSValue; class RenderStyle; -PassRefPtr valueForBasicShape(const BasicShape*); +PassRefPtr valueForBasicShape(const RenderStyle*, const BasicShape*); PassRefPtr basicShapeForValue(const RenderStyle*, const RenderStyle* rootStyle, const CSSBasicShape*); } diff --git a/Source/WebCore/css/CSSCalculationValue.cpp b/Source/WebCore/css/CSSCalculationValue.cpp index dca177991..b42a520c2 100644 --- a/Source/WebCore/css/CSSCalculationValue.cpp +++ b/Source/WebCore/css/CSSCalculationValue.cpp @@ -31,10 +31,12 @@ #include "config.h" #include "CSSCalculationValue.h" +#include "CSSPrimitiveValueMappings.h" #include "CSSValueList.h" #include "Length.h" #include "StyleResolver.h" +#include #include #include #include @@ -77,6 +79,72 @@ static CalculationCategory unitCategory(CSSPrimitiveValue::UnitTypes type) } } +static bool hasDoubleValue(CSSPrimitiveValue::UnitTypes type) +{ + switch (type) { + case CSSPrimitiveValue::CSS_NUMBER: + case CSSPrimitiveValue::CSS_PARSER_INTEGER: + case CSSPrimitiveValue::CSS_PERCENTAGE: + case CSSPrimitiveValue::CSS_EMS: + case CSSPrimitiveValue::CSS_EXS: + case CSSPrimitiveValue::CSS_CHS: + case CSSPrimitiveValue::CSS_REMS: + case CSSPrimitiveValue::CSS_PX: + case CSSPrimitiveValue::CSS_CM: + case CSSPrimitiveValue::CSS_MM: + case CSSPrimitiveValue::CSS_IN: + case CSSPrimitiveValue::CSS_PT: + case CSSPrimitiveValue::CSS_PC: + case CSSPrimitiveValue::CSS_DEG: + case CSSPrimitiveValue::CSS_RAD: + case CSSPrimitiveValue::CSS_GRAD: + case CSSPrimitiveValue::CSS_MS: + case CSSPrimitiveValue::CSS_S: + case CSSPrimitiveValue::CSS_HZ: + case CSSPrimitiveValue::CSS_KHZ: + case CSSPrimitiveValue::CSS_DIMENSION: + case CSSPrimitiveValue::CSS_VW: + case CSSPrimitiveValue::CSS_VH: + case CSSPrimitiveValue::CSS_VMIN: + case CSSPrimitiveValue::CSS_VMAX: + case CSSPrimitiveValue::CSS_DPPX: + case CSSPrimitiveValue::CSS_DPI: + case CSSPrimitiveValue::CSS_DPCM: + return true; + case CSSPrimitiveValue::CSS_UNKNOWN: + case CSSPrimitiveValue::CSS_STRING: + case CSSPrimitiveValue::CSS_URI: + case CSSPrimitiveValue::CSS_IDENT: + case CSSPrimitiveValue::CSS_ATTR: + case CSSPrimitiveValue::CSS_COUNTER: + case CSSPrimitiveValue::CSS_RECT: + case CSSPrimitiveValue::CSS_RGBCOLOR: + case CSSPrimitiveValue::CSS_PAIR: + case CSSPrimitiveValue::CSS_UNICODE_RANGE: + case CSSPrimitiveValue::CSS_PARSER_OPERATOR: + case CSSPrimitiveValue::CSS_PARSER_HEXCOLOR: + case CSSPrimitiveValue::CSS_PARSER_IDENTIFIER: + case CSSPrimitiveValue::CSS_TURN: + case CSSPrimitiveValue::CSS_COUNTER_NAME: + case CSSPrimitiveValue::CSS_SHAPE: + case CSSPrimitiveValue::CSS_QUAD: + case CSSPrimitiveValue::CSS_CALC: + case CSSPrimitiveValue::CSS_CALC_PERCENTAGE_WITH_NUMBER: + case CSSPrimitiveValue::CSS_CALC_PERCENTAGE_WITH_LENGTH: +#if ENABLE(CSS_VARIABLES) + case CSSPrimitiveValue::CSS_VARIABLE_NAME: +#endif + case CSSPrimitiveValue::CSS_PROPERTY_ID: + case CSSPrimitiveValue::CSS_VALUE_ID: +#if ENABLE(DASHBOARD_SUPPORT) + case CSSPrimitiveValue::CSS_DASHBOARD_REGION: +#endif + return false; + }; + ASSERT_NOT_REACHED(); + return false; +} + static String buildCssText(const String& expression) { StringBuilder result; @@ -87,7 +155,7 @@ static String buildCssText(const String& expression) result.append(expression); if (expressionHasSingleTerm) result.append(')'); - return result.toString(); + return result.toString(); } String CSSCalcValue::customCssText() const @@ -115,10 +183,10 @@ bool CSSCalcValue::hasVariableReference() const double CSSCalcValue::clampToPermittedRange(double value) const { return m_nonNegative && value < 0 ? 0 : value; -} - -double CSSCalcValue::doubleValue() const -{ +} + +double CSSCalcValue::doubleValue() const +{ return clampToPermittedRange(m_expression->doubleValue()); } @@ -126,20 +194,27 @@ double CSSCalcValue::computeLengthPx(const RenderStyle* currentStyle, const Rend { return clampToPermittedRange(m_expression->computeLengthPx(currentStyle, rootStyle, multiplier, computingFontSize)); } - -CSSCalcExpressionNode::~CSSCalcExpressionNode() + +CSSCalcExpressionNode::~CSSCalcExpressionNode() { } - + class CSSCalcPrimitiveValue : public CSSCalcExpressionNode { WTF_MAKE_FAST_ALLOCATED; public: - static PassRefPtr create(CSSPrimitiveValue* value, bool isInteger) + static PassRefPtr create(PassRefPtr value, bool isInteger) { return adoptRef(new CSSCalcPrimitiveValue(value, isInteger)); } - + + static PassRefPtr create(double value, CSSPrimitiveValue::UnitTypes type, bool isInteger) + { + if (std::isnan(value) || std::isinf(value)) + return 0; + return adoptRef(new CSSCalcPrimitiveValue(CSSPrimitiveValue::create(value, type).get(), isInteger)); + } + virtual bool isZero() const { return !m_value->getDoubleValue(); @@ -155,7 +230,7 @@ public: { return m_value->customSerializeResolvingVariables(variables); } - + virtual bool hasVariableReference() const { return m_value->isVariableName(); @@ -170,8 +245,12 @@ public: case CalcLength: return adoptPtr(new CalcExpressionNumber(m_value->computeLength(style, rootStyle, zoom))); case CalcPercent: - case CalcPercentLength: - return adoptPtr(new CalcExpressionLength(StyleResolver::convertToFloatLength(m_value.get(), style, rootStyle, zoom))); + case CalcPercentLength: { + CSSPrimitiveValue* primitiveValue = m_value.get(); + return adoptPtr(new CalcExpressionLength(primitiveValue + ? primitiveValue->convertToLength(style, rootStyle, zoom) + : Length(Undefined))); + } // Only types that could be part of a Length expression can be converted // to a CalcExpressionNode. CalcPercentNumber makes no sense as a Length. case CalcPercentNumber: @@ -186,23 +265,12 @@ public: virtual double doubleValue() const { - switch (m_category) { - case CalcNumber: - case CalcPercent: + if (hasDoubleValue(primitiveType())) return m_value->getDoubleValue(); - case CalcLength: - case CalcPercentLength: - case CalcPercentNumber: -#if ENABLE(CSS_VARIABLES) - case CalcVariable: -#endif - case CalcOther: - ASSERT_NOT_REACHED(); - break; - } + ASSERT_NOT_REACHED(); return 0; } - + virtual double computeLengthPx(const RenderStyle* currentStyle, const RenderStyle* rootStyle, double multiplier, bool computingFontSize) const { switch (m_category) { @@ -220,7 +288,8 @@ public: ASSERT_NOT_REACHED(); break; } - return 0; + ASSERT_NOT_REACHED(); + return 0; } virtual bool equals(const CSSCalcExpressionNode& other) const @@ -232,9 +301,13 @@ public: } virtual Type type() const { return CssCalcPrimitiveValue; } - + virtual CSSPrimitiveValue::UnitTypes primitiveType() const + { + return CSSPrimitiveValue::UnitTypes(m_value->primitiveType()); + } + private: - explicit CSSCalcPrimitiveValue(CSSPrimitiveValue* value, bool isInteger) + explicit CSSCalcPrimitiveValue(PassRefPtr value, bool isInteger) : CSSCalcExpressionNode(unitCategory((CSSPrimitiveValue::UnitTypes)value->primitiveType()), isInteger) , m_value(value) { @@ -244,12 +317,13 @@ private: }; static const CalculationCategory addSubtractResult[CalcOther][CalcOther] = { - { CalcNumber, CalcOther, CalcPercentNumber, CalcPercentNumber, CalcOther }, - { CalcOther, CalcLength, CalcPercentLength, CalcOther, CalcPercentLength }, - { CalcPercentNumber, CalcPercentLength, CalcPercent, CalcPercentNumber, CalcPercentLength }, - { CalcPercentNumber, CalcOther, CalcPercentNumber, CalcPercentNumber, CalcOther }, - { CalcOther, CalcPercentLength, CalcPercentLength, CalcOther, CalcPercentLength }, -}; +// CalcNumber CalcLength CalcPercent CalcPercentNumber CalcPercentLength + { CalcNumber, CalcOther, CalcPercentNumber, CalcPercentNumber, CalcOther }, // CalcNumber + { CalcOther, CalcLength, CalcPercentLength, CalcOther, CalcPercentLength }, // CalcLength + { CalcPercentNumber, CalcPercentLength, CalcPercent, CalcPercentNumber, CalcPercentLength }, // CalcPercent + { CalcPercentNumber, CalcOther, CalcPercentNumber, CalcPercentNumber, CalcOther }, // CalcPercentNumber + { CalcOther, CalcPercentLength, CalcPercentLength, CalcOther, CalcPercentLength }, // CalcPercentLength +}; static CalculationCategory determineCategory(const CSSCalcExpressionNode& leftSide, const CSSCalcExpressionNode& rightSide, CalcOperator op) { @@ -266,10 +340,10 @@ static CalculationCategory determineCategory(const CSSCalcExpressionNode& leftSi switch (op) { case CalcAdd: - case CalcSubtract: + case CalcSubtract: return addSubtractResult[leftCategory][rightCategory]; case CalcMultiply: - if (leftCategory != CalcNumber && rightCategory != CalcNumber) + if (leftCategory != CalcNumber && rightCategory != CalcNumber) return CalcOther; return leftCategory == CalcNumber ? rightCategory : leftCategory; case CalcDivide: @@ -277,18 +351,25 @@ static CalculationCategory determineCategory(const CSSCalcExpressionNode& leftSi return CalcOther; return leftCategory; } - + ASSERT_NOT_REACHED(); return CalcOther; } +static bool isIntegerResult(const CSSCalcExpressionNode* leftSide, const CSSCalcExpressionNode* rightSide, CalcOperator op) +{ + // Performs W3C spec's type checking for calc integers. + // http://www.w3.org/TR/css3-values/#calc-type-checking + return op != CalcDivide && leftSide->isInteger() && rightSide->isInteger(); +} + class CSSCalcBinaryOperation : public CSSCalcExpressionNode { public: - static PassRefPtr create(PassRefPtr leftSide, PassRefPtr rightSide, CalcOperator op) + static PassRefPtr create(PassRefPtr leftSide, PassRefPtr rightSide, CalcOperator op) { ASSERT(leftSide->category() != CalcOther && rightSide->category() != CalcOther); - + CalculationCategory newCategory = determineCategory(*leftSide, *rightSide, op); if (newCategory == CalcOther) @@ -296,7 +377,64 @@ public: return adoptRef(new CSSCalcBinaryOperation(leftSide, rightSide, op, newCategory)); } - + + static PassRefPtr createSimplified(PassRefPtr leftSide, PassRefPtr rightSide, CalcOperator op) + { + CalculationCategory leftCategory = leftSide->category(); + CalculationCategory rightCategory = rightSide->category(); + ASSERT(leftCategory != CalcOther && rightCategory != CalcOther); + + bool isInteger = isIntegerResult(leftSide.get(), rightSide.get(), op); + + // Simplify numbers. + if (leftCategory == CalcNumber && rightCategory == CalcNumber) { + CSSPrimitiveValue::UnitTypes evaluationType = isInteger ? CSSPrimitiveValue::CSS_PARSER_INTEGER : CSSPrimitiveValue::CSS_NUMBER; + return CSSCalcPrimitiveValue::create(evaluateOperator(leftSide->doubleValue(), rightSide->doubleValue(), op), evaluationType, isInteger); + } + + // Simplify addition and subtraction between same types. + if (op == CalcAdd || op == CalcSubtract) { + if (leftCategory == rightSide->category()) { + CSSPrimitiveValue::UnitTypes leftType = leftSide->primitiveType(); + if (hasDoubleValue(leftType)) { + CSSPrimitiveValue::UnitTypes rightType = rightSide->primitiveType(); + if (leftType == rightType) + return CSSCalcPrimitiveValue::create(evaluateOperator(leftSide->doubleValue(), rightSide->doubleValue(), op), leftType, isInteger); + CSSPrimitiveValue::UnitCategory leftUnitCategory = CSSPrimitiveValue::unitCategory(leftType); + if (leftUnitCategory != CSSPrimitiveValue::UOther && leftUnitCategory == CSSPrimitiveValue::unitCategory(rightType)) { + CSSPrimitiveValue::UnitTypes canonicalType = CSSPrimitiveValue::canonicalUnitTypeForCategory(leftUnitCategory); + if (canonicalType != CSSPrimitiveValue::CSS_UNKNOWN) { + double leftValue = leftSide->doubleValue() * CSSPrimitiveValue::conversionToCanonicalUnitsScaleFactor(leftType); + double rightValue = rightSide->doubleValue() * CSSPrimitiveValue::conversionToCanonicalUnitsScaleFactor(rightType); + return CSSCalcPrimitiveValue::create(evaluateOperator(leftValue, rightValue, op), canonicalType, isInteger); + } + } + } + } + } else { + // Simplify multiplying or dividing by a number for simplifiable types. + ASSERT(op == CalcMultiply || op == CalcDivide); + CSSCalcExpressionNode* numberSide = getNumberSide(leftSide.get(), rightSide.get()); + if (!numberSide) + return create(leftSide, rightSide, op); + if (numberSide == leftSide && op == CalcDivide) + return 0; + CSSCalcExpressionNode* otherSide = leftSide == numberSide ? rightSide.get() : leftSide.get(); + + double number = numberSide->doubleValue(); + if (std::isnan(number) || std::isinf(number)) + return 0; + if (op == CalcDivide && !number) + return 0; + + CSSPrimitiveValue::UnitTypes otherType = otherSide->primitiveType(); + if (hasDoubleValue(otherType)) + return CSSCalcPrimitiveValue::create(evaluateOperator(otherSide->doubleValue(), number, op), otherType, isInteger); + } + + return create(leftSide, rightSide, op); + } + virtual bool isZero() const { return !doubleValue(); @@ -313,11 +451,11 @@ public: return adoptPtr(new CalcExpressionBinaryOperation(left.release(), right.release(), m_operator)); } - virtual double doubleValue() const + virtual double doubleValue() const { return evaluate(m_leftSide->doubleValue(), m_rightSide->doubleValue()); } - + virtual double computeLengthPx(const RenderStyle* currentStyle, const RenderStyle* rootStyle, double multiplier, bool computingFontSize) const { const double leftValue = m_leftSide->computeLengthPx(currentStyle, rootStyle, multiplier, computingFontSize); @@ -335,8 +473,8 @@ public: result.append(' '); result.append(rightExpression); result.append(')'); - - return result.toString(); + + return result.toString(); } virtual String customCssText() const @@ -369,18 +507,64 @@ public: virtual Type type() const { return CssCalcBinaryOperation; } + virtual CSSPrimitiveValue::UnitTypes primitiveType() const + { + switch (m_category) { + case CalcNumber: + ASSERT(m_leftSide->category() == CalcNumber && m_rightSide->category() == CalcNumber); + if (m_isInteger) + return CSSPrimitiveValue::CSS_PARSER_INTEGER; + return CSSPrimitiveValue::CSS_NUMBER; + case CalcLength: + case CalcPercent: { + if (m_leftSide->category() == CalcNumber) + return m_rightSide->primitiveType(); + if (m_rightSide->category() == CalcNumber) + return m_leftSide->primitiveType(); + CSSPrimitiveValue::UnitTypes leftType = m_leftSide->primitiveType(); + if (leftType == m_rightSide->primitiveType()) + return leftType; + return CSSPrimitiveValue::CSS_UNKNOWN; + } +#if ENABLE(CSS_VARIABLES) + case CalcVariable: + return CSSPrimitiveValue::CSS_VARIABLE_NAME; +#endif + case CalcPercentLength: + case CalcPercentNumber: + case CalcOther: + return CSSPrimitiveValue::CSS_UNKNOWN; + } + ASSERT_NOT_REACHED(); + return CSSPrimitiveValue::CSS_UNKNOWN; + } + private: CSSCalcBinaryOperation(PassRefPtr leftSide, PassRefPtr rightSide, CalcOperator op, CalculationCategory category) - : CSSCalcExpressionNode(category, leftSide->isInteger() && rightSide->isInteger()) + : CSSCalcExpressionNode(category, isIntegerResult(leftSide.get(), rightSide.get(), op)) , m_leftSide(leftSide) , m_rightSide(rightSide) , m_operator(op) { } - - double evaluate(double leftValue, double rightValue) const + + static CSSCalcExpressionNode* getNumberSide(CSSCalcExpressionNode* leftSide, CSSCalcExpressionNode* rightSide) + { + if (leftSide->category() == CalcNumber) + return leftSide; + if (rightSide->category() == CalcNumber) + return rightSide; + return 0; + } + + double evaluate(double leftSide, double rightSide) const + { + return evaluateOperator(leftSide, rightSide, m_operator); + } + + static double evaluateOperator(double leftValue, double rightValue, CalcOperator op) { - switch (m_operator) { + switch (op) { case CalcAdd: return leftValue + rightValue; case CalcSubtract: @@ -394,7 +578,7 @@ private: } return 0; } - + const RefPtr m_leftSide; const RefPtr m_rightSide; const CalcOperator m_operator; @@ -449,7 +633,7 @@ private: if (!value || !value->isPrimitiveValue()) return false; - CSSPrimitiveValue* primitiveValue = static_cast(value.get()); + CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value.get()); result->value = CSSCalcPrimitiveValue::create(primitiveValue, parserValue->isInt); ++*index; @@ -459,8 +643,8 @@ private: bool parseValueTerm(CSSParserValueList* tokens, int depth, unsigned* index, Value* result) { if (checkDepthAndIndex(&depth, *index, tokens) != OK) - return false; - + return false; + if (operatorValue(tokens, *index) == '(') { unsigned currentIndex = *index + 1; if (!parseValueExpression(tokens, depth, ¤tIndex, result)) @@ -478,7 +662,7 @@ private: bool parseValueMultiplicativeExpression(CSSParserValueList* tokens, int depth, unsigned* index, Value* result) { if (checkDepthAndIndex(&depth, *index, tokens) != OK) - return false; + return false; if (!parseValueTerm(tokens, depth, index, result)) return false; @@ -493,7 +677,7 @@ private: if (!parseValueTerm(tokens, depth, index, &rhs)) return false; - result->value = CSSCalcBinaryOperation::create(result->value, rhs.value, static_cast(operatorCharacter)); + result->value = CSSCalcBinaryOperation::createSimplified(result->value, rhs.value, static_cast(operatorCharacter)); if (!result->value) return false; } @@ -505,7 +689,7 @@ private: bool parseAdditiveValueExpression(CSSParserValueList* tokens, int depth, unsigned* index, Value* result) { if (checkDepthAndIndex(&depth, *index, tokens) != OK) - return false; + return false; if (!parseValueMultiplicativeExpression(tokens, depth, index, result)) return false; @@ -520,7 +704,7 @@ private: if (!parseValueMultiplicativeExpression(tokens, depth, index, &rhs)) return false; - result->value = CSSCalcBinaryOperation::create(result->value, rhs.value, static_cast(operatorCharacter)); + result->value = CSSCalcBinaryOperation::createSimplified(result->value, rhs.value, static_cast(operatorCharacter)); if (!result->value) return false; } @@ -535,16 +719,96 @@ private: } }; +PassRefPtr CSSCalcValue::createExpressionNode(PassRefPtr value, bool isInteger) +{ + return CSSCalcPrimitiveValue::create(value, isInteger); +} + +PassRefPtr CSSCalcValue::createExpressionNode(PassRefPtr leftSide, PassRefPtr rightSide, CalcOperator op) +{ + return CSSCalcBinaryOperation::create(leftSide, rightSide, op); +} + +PassRefPtr CSSCalcValue::createExpressionNode(const CalcExpressionNode* node, const RenderStyle* style) +{ + switch (node->type()) { + case CalcExpressionNodeNumber: { + float value = toCalcExpressionNumber(node)->value(); + return createExpressionNode(CSSPrimitiveValue::create(value, CSSPrimitiveValue::CSS_NUMBER), value == trunc(value)); + } + case CalcExpressionNodeLength: + return createExpressionNode(toCalcExpressionLength(node)->length(), style); + case CalcExpressionNodeBinaryOperation: { + const CalcExpressionBinaryOperation* binaryNode = toCalcExpressionBinaryOperation(node); + return createExpressionNode(createExpressionNode(binaryNode->leftSide(), style), createExpressionNode(binaryNode->rightSide(), style), binaryNode->getOperator()); + } + case CalcExpressionNodeBlendLength: { + // FIXME: (http://webkit.org/b/122036) Create a CSSCalcExpressionNode equivalent of CalcExpressionBlendLength. + const CalcExpressionBlendLength* blendNode = toCalcExpressionBlendLength(node); + const double progress = blendNode->progress(); + const bool isInteger = !progress || (progress == 1); + return createExpressionNode( + createExpressionNode( + createExpressionNode(blendNode->from(), style), + createExpressionNode(CSSPrimitiveValue::create(1 - progress, CSSPrimitiveValue::CSS_NUMBER), isInteger), + CalcMultiply), + createExpressionNode( + createExpressionNode(blendNode->to(), style), + createExpressionNode(CSSPrimitiveValue::create(progress, CSSPrimitiveValue::CSS_NUMBER), isInteger), + CalcMultiply), + CalcAdd); + } + case CalcExpressionNodeUndefined: + ASSERT_NOT_REACHED(); + return 0; + } + ASSERT_NOT_REACHED(); + return 0; +} + +PassRefPtr CSSCalcValue::createExpressionNode(const Length& length, const RenderStyle* style) +{ + switch (length.type()) { + case Percent: + case ViewportPercentageWidth: + case ViewportPercentageHeight: + case ViewportPercentageMin: + case ViewportPercentageMax: + case Fixed: + return createExpressionNode(CSSPrimitiveValue::create(length, style), length.value() == trunc(length.value())); + case Calculated: + return createExpressionNode(length.calculationValue()->expression(), style); + case Auto: + case Intrinsic: + case MinIntrinsic: + case MinContent: + case MaxContent: + case FillAvailable: + case FitContent: + case Relative: + case Undefined: + ASSERT_NOT_REACHED(); + return 0; + } + ASSERT_NOT_REACHED(); + return 0; +} + PassRefPtr CSSCalcValue::create(CSSParserString name, CSSParserValueList* parserValueList, CalculationPermittedValueRange range) -{ - CSSCalcExpressionNodeParser parser; +{ + CSSCalcExpressionNodeParser parser; RefPtr expression; - + if (equalIgnoringCase(name, "calc(") || equalIgnoringCase(name, "-webkit-calc(")) - expression = parser.parseCalc(parserValueList); - // FIXME calc (http://webkit.org/b/16662) Add parsing for min and max here + expression = parser.parseCalc(parserValueList); + // FIXME: calc (http://webkit.org/b/16662) Add parsing for min and max here return expression ? adoptRef(new CSSCalcValue(expression, range)) : 0; } +PassRefPtr CSSCalcValue::create(PassRefPtr expression, CalculationPermittedValueRange range) +{ + return adoptRef(new CSSCalcValue(expression, range)); +} + } // namespace WebCore diff --git a/Source/WebCore/css/CSSCalculationValue.h b/Source/WebCore/css/CSSCalculationValue.h index 266e8f76c..13a17a3b7 100644 --- a/Source/WebCore/css/CSSCalculationValue.h +++ b/Source/WebCore/css/CSSCalculationValue.h @@ -32,6 +32,7 @@ #define CSSCalculationValue_h #include "CSSParserValues.h" +#include "CSSPrimitiveValue.h" #include "CSSValue.h" #include "CalculationValue.h" #include @@ -42,9 +43,10 @@ namespace WebCore { class CSSParserValueList; class CSSValueList; -class RenderStyle; class CalculationValue; class CalcExpressionNode; +class RenderStyle; +struct Length; enum CalculationCategory { CalcNumber = 0, @@ -57,7 +59,7 @@ enum CalculationCategory { #endif CalcOther }; - + class CSSCalcExpressionNode : public RefCounted { public: enum Type { @@ -67,7 +69,7 @@ public: virtual ~CSSCalcExpressionNode() = 0; virtual bool isZero() const = 0; - virtual PassOwnPtr toCalcValue(const RenderStyle*, const RenderStyle* rootStyle, double zoom = 1.0) const = 0; + virtual PassOwnPtr toCalcValue(const RenderStyle*, const RenderStyle* rootStyle, double zoom = 1.0) const = 0; virtual double doubleValue() const = 0; virtual double computeLengthPx(const RenderStyle* currentStyle, const RenderStyle* rootStyle, double multiplier = 1.0, bool computingFontSize = false) const = 0; virtual String customCssText() const = 0; @@ -78,56 +80,84 @@ public: virtual bool equals(const CSSCalcExpressionNode& other) const { return m_category == other.m_category && m_isInteger == other.m_isInteger; } virtual Type type() const = 0; - CalculationCategory category() const { return m_category; } + CalculationCategory category() const { return m_category; } + virtual CSSPrimitiveValue::UnitTypes primitiveType() const = 0; bool isInteger() const { return m_isInteger; } - + protected: CSSCalcExpressionNode(CalculationCategory category, bool isInteger) : m_category(category) , m_isInteger(isInteger) { } - + CalculationCategory m_category; bool m_isInteger; }; - + class CSSCalcValue : public CSSValue { public: static PassRefPtr create(CSSParserString name, CSSParserValueList*, CalculationPermittedValueRange); - static PassRefPtr create(CalculationValue*); + static PassRefPtr create(PassRefPtr, CalculationPermittedValueRange = CalculationRangeAll); + static PassRefPtr create(const CalculationValue* value, const RenderStyle* style) { return adoptRef(new CSSCalcValue(value, style)); } + + static PassRefPtr createExpressionNode(PassRefPtr, bool isInteger = false); + static PassRefPtr createExpressionNode(PassRefPtr, PassRefPtr, CalcOperator); + static PassRefPtr createExpressionNode(const CalcExpressionNode*, const RenderStyle*); + static PassRefPtr createExpressionNode(const Length&, const RenderStyle*); PassRefPtr toCalcValue(const RenderStyle* style, const RenderStyle* rootStyle, double zoom = 1.0) const { return CalculationValue::create(m_expression->toCalcValue(style, rootStyle, zoom), m_nonNegative ? CalculationRangeNonNegative : CalculationRangeAll); } CalculationCategory category() const { return m_expression->category(); } - bool isInt() const { return m_expression->isInteger(); } + bool isInt() const { return m_expression->isInteger(); } double doubleValue() const; bool isNegative() const { return m_expression->doubleValue() < 0; } + CalculationPermittedValueRange permittedValueRange() { return m_nonNegative ? CalculationRangeNonNegative : CalculationRangeAll; } double computeLengthPx(const RenderStyle* currentStyle, const RenderStyle* rootStyle, double multiplier = 1.0, bool computingFontSize = false) const; - + + CSSCalcExpressionNode* expressionNode() const { return m_expression.get(); } + String customCssText() const; bool equals(const CSSCalcValue&) const; #if ENABLE(CSS_VARIABLES) String customSerializeResolvingVariables(const HashMap&) const; bool hasVariableReference() const; #endif - -private: + +private: CSSCalcValue(PassRefPtr expression, CalculationPermittedValueRange range) : CSSValue(CalculationClass) , m_expression(expression) , m_nonNegative(range == CalculationRangeNonNegative) { } - + CSSCalcValue(const CalculationValue* value, const RenderStyle* style) + : CSSValue(CalculationClass) + , m_expression(createExpressionNode(value->expression(), style)) + , m_nonNegative(value->isNonNegative()) + { + } + double clampToPermittedRange(double) const; const RefPtr m_expression; const bool m_nonNegative; }; - + +inline CSSCalcValue* toCSSCalcValue(CSSValue* value) +{ + ASSERT_WITH_SECURITY_IMPLICATION(!value || value->isCalculationValue()); + return static_cast(value); +} + +inline const CSSCalcValue* toCSSCalcValue(const CSSValue* value) +{ + ASSERT_WITH_SECURITY_IMPLICATION(!value || value->isCalculationValue()); + return static_cast(value); +} + } // namespace WebCore #endif // CSSCalculationValue_h diff --git a/Source/WebCore/css/CSSComputedStyleDeclaration.cpp b/Source/WebCore/css/CSSComputedStyleDeclaration.cpp index f645ace2c..621cdf038 100644 --- a/Source/WebCore/css/CSSComputedStyleDeclaration.cpp +++ b/Source/WebCore/css/CSSComputedStyleDeclaration.cpp @@ -2707,7 +2707,7 @@ PassRefPtr ComputedStyleExtractor::propertyValue(CSSPropertyID propert case CSSPropertyWebkitClipPath: if (ClipPathOperation* operation = style->clipPath()) { if (operation->getOperationType() == ClipPathOperation::SHAPE) - return valueForBasicShape(static_cast(operation)->basicShape()); + return valueForBasicShape(style.get(), static_cast(operation)->basicShape()); #if ENABLE(SVG) else if (operation->getOperationType() == ClipPathOperation::REFERENCE) { ReferenceClipPathOperation* referenceOperation = static_cast(operation); @@ -2750,7 +2750,7 @@ PassRefPtr ComputedStyleExtractor::propertyValue(CSSPropertyID propert return cssValuePool().createIdentifierValue(CSSValueNone); } ASSERT(style->shapeInside()->type() == ShapeValue::Shape); - return valueForBasicShape(style->shapeInside()->shape()); + return valueForBasicShape(style.get(), style->shapeInside()->shape()); case CSSPropertyWebkitShapeOutside: if (!style->shapeOutside()) return cssValuePool().createIdentifierValue(CSSValueAuto); @@ -2760,7 +2760,7 @@ PassRefPtr ComputedStyleExtractor::propertyValue(CSSPropertyID propert return cssValuePool().createIdentifierValue(CSSValueNone); } ASSERT(style->shapeOutside()->type() == ShapeValue::Shape); - return valueForBasicShape(style->shapeOutside()->shape()); + return valueForBasicShape(style.get(), style->shapeOutside()->shape()); #endif #if ENABLE(CSS_FILTERS) case CSSPropertyWebkitFilter: diff --git a/Source/WebCore/css/CSSPrimitiveValue.cpp b/Source/WebCore/css/CSSPrimitiveValue.cpp index d0c852465..bd544aab5 100644 --- a/Source/WebCore/css/CSSPrimitiveValue.cpp +++ b/Source/WebCore/css/CSSPrimitiveValue.cpp @@ -52,7 +52,7 @@ using namespace WTF; namespace WebCore { - + // Max/min values for CSS, needs to slightly smaller/larger than the true max/min values to allow for rounding without overflowing. // Subtract two (rather than one) to allow for values to be converted to float and back without exceeding the LayoutUnit::max. const int maxValueForCssLength = INT_MAX / kFixedPointDenominator - 2; @@ -132,46 +132,46 @@ static inline bool isValidCSSUnitTypeForDoubleConversion(CSSPrimitiveValue::Unit return false; } -static CSSPrimitiveValue::UnitCategory unitCategory(CSSPrimitiveValue::UnitTypes type) +CSSPrimitiveValue::UnitCategory CSSPrimitiveValue::unitCategory(CSSPrimitiveValue::UnitTypes type) { // Here we violate the spec (http://www.w3.org/TR/DOM-Level-2-Style/css.html#CSS-CSSPrimitiveValue) and allow conversions // between CSS_PX and relative lengths (see cssPixelsPerInch comment in CSSHelper.h for the topic treatment). switch (type) { - case CSSPrimitiveValue::CSS_NUMBER: - return CSSPrimitiveValue::UNumber; - case CSSPrimitiveValue::CSS_PERCENTAGE: - return CSSPrimitiveValue::UPercent; - case CSSPrimitiveValue::CSS_PX: - case CSSPrimitiveValue::CSS_CM: - case CSSPrimitiveValue::CSS_MM: - case CSSPrimitiveValue::CSS_IN: - case CSSPrimitiveValue::CSS_PT: - case CSSPrimitiveValue::CSS_PC: - return CSSPrimitiveValue::ULength; - case CSSPrimitiveValue::CSS_MS: - case CSSPrimitiveValue::CSS_S: - return CSSPrimitiveValue::UTime; - case CSSPrimitiveValue::CSS_DEG: - case CSSPrimitiveValue::CSS_RAD: - case CSSPrimitiveValue::CSS_GRAD: - case CSSPrimitiveValue::CSS_TURN: - return CSSPrimitiveValue::UAngle; - case CSSPrimitiveValue::CSS_HZ: - case CSSPrimitiveValue::CSS_KHZ: - return CSSPrimitiveValue::UFrequency; - case CSSPrimitiveValue::CSS_VW: - case CSSPrimitiveValue::CSS_VH: - case CSSPrimitiveValue::CSS_VMIN: - case CSSPrimitiveValue::CSS_VMAX: - return CSSPrimitiveValue::UViewportPercentageLength; + case CSS_NUMBER: + return UNumber; + case CSS_PERCENTAGE: + return UPercent; + case CSS_PX: + case CSS_CM: + case CSS_MM: + case CSS_IN: + case CSS_PT: + case CSS_PC: + return ULength; + case CSS_MS: + case CSS_S: + return UTime; + case CSS_DEG: + case CSS_RAD: + case CSS_GRAD: + case CSS_TURN: + return UAngle; + case CSS_HZ: + case CSS_KHZ: + return UFrequency; + case CSS_VW: + case CSS_VH: + case CSS_VMIN: + case CSS_VMAX: + return UViewportPercentageLength; #if ENABLE(CSS_IMAGE_RESOLUTION) || ENABLE(RESOLUTION_MEDIA_QUERY) - case CSSPrimitiveValue::CSS_DPPX: - case CSSPrimitiveValue::CSS_DPI: - case CSSPrimitiveValue::CSS_DPCM: - return CSSPrimitiveValue::UResolution; + case CSS_DPPX: + case CSS_DPI: + case CSS_DPCM: + return UResolution; #endif default: - return CSSPrimitiveValue::UOther; + return UOther; } } @@ -182,14 +182,14 @@ static CSSTextCache& cssTextCache() return cache; } -unsigned short CSSPrimitiveValue::primitiveType() const +unsigned short CSSPrimitiveValue::primitiveType() const { if (m_primitiveUnitType == CSS_PROPERTY_ID || m_primitiveUnitType == CSS_VALUE_ID) return CSS_IDENT; if (m_primitiveUnitType != CSSPrimitiveValue::CSS_CALC) - return m_primitiveUnitType; - + return m_primitiveUnitType; + switch (m_value.calc->category()) { case CalcNumber: return CSSPrimitiveValue::CSS_NUMBER; @@ -284,66 +284,103 @@ CSSPrimitiveValue::CSSPrimitiveValue(RGBA32 color) CSSPrimitiveValue::CSSPrimitiveValue(const Length& length) : CSSValue(PrimitiveClass) +{ + init(length); +} + +CSSPrimitiveValue::CSSPrimitiveValue(const Length& length, const RenderStyle* style) + : CSSValue(PrimitiveClass) { switch (length.type()) { - case Auto: - m_primitiveUnitType = CSS_VALUE_ID; - m_value.valueID = CSSValueAuto; - break; - case WebCore::Fixed: - m_primitiveUnitType = CSS_PX; - m_value.num = length.value(); - break; - case Intrinsic: - m_primitiveUnitType = CSS_VALUE_ID; - m_value.valueID = CSSValueIntrinsic; - break; - case MinIntrinsic: - m_primitiveUnitType = CSS_VALUE_ID; - m_value.valueID = CSSValueMinIntrinsic; - break; - case MinContent: - m_primitiveUnitType = CSS_VALUE_ID; - m_value.valueID = CSSValueWebkitMinContent; - break; - case MaxContent: - m_primitiveUnitType = CSS_VALUE_ID; - m_value.valueID = CSSValueWebkitMaxContent; - break; - case FillAvailable: - m_primitiveUnitType = CSS_VALUE_ID; - m_value.valueID = CSSValueWebkitFillAvailable; - break; - case FitContent: - m_primitiveUnitType = CSS_VALUE_ID; - m_value.valueID = CSSValueWebkitFitContent; - break; - case Percent: - m_primitiveUnitType = CSS_PERCENTAGE; - ASSERT(std::isfinite(length.percent())); - m_value.num = length.percent(); - break; - case ViewportPercentageWidth: - m_primitiveUnitType = CSS_VW; - m_value.num = length.viewportPercentageLength(); - break; - case ViewportPercentageHeight: - m_primitiveUnitType = CSS_VH; - m_value.num = length.viewportPercentageLength(); - break; - case ViewportPercentageMin: - m_primitiveUnitType = CSS_VMIN; - m_value.num = length.viewportPercentageLength(); - break; - case ViewportPercentageMax: - m_primitiveUnitType = CSS_VMAX; - m_value.num = length.viewportPercentageLength(); - break; - case Calculated: - case Relative: - case Undefined: - ASSERT_NOT_REACHED(); - break; + case Auto: + case Intrinsic: + case MinIntrinsic: + case MinContent: + case MaxContent: + case FillAvailable: + case FitContent: + case Percent: + case ViewportPercentageWidth: + case ViewportPercentageHeight: + case ViewportPercentageMin: + case ViewportPercentageMax: + init(length); + return; + case Fixed: + m_primitiveUnitType = CSS_PX; + m_value.num = adjustFloatForAbsoluteZoom(length.value(), style); + return; + case Calculated: + init(CSSCalcValue::create(length.calculationValue().get(), style)); + return; + case Relative: + case Undefined: + ASSERT_NOT_REACHED(); + break; + } +} + +void CSSPrimitiveValue::init(const Length& length) +{ + switch (length.type()) { + case Auto: + m_primitiveUnitType = CSS_VALUE_ID; + m_value.valueID = CSSValueAuto; + break; + case WebCore::Fixed: + m_primitiveUnitType = CSS_PX; + m_value.num = length.value(); + break; + case Intrinsic: + m_primitiveUnitType = CSS_VALUE_ID; + m_value.valueID = CSSValueIntrinsic; + break; + case MinIntrinsic: + m_primitiveUnitType = CSS_VALUE_ID; + m_value.valueID = CSSValueMinIntrinsic; + break; + case MinContent: + m_primitiveUnitType = CSS_VALUE_ID; + m_value.valueID = CSSValueWebkitMinContent; + break; + case MaxContent: + m_primitiveUnitType = CSS_VALUE_ID; + m_value.valueID = CSSValueWebkitMaxContent; + break; + case FillAvailable: + m_primitiveUnitType = CSS_VALUE_ID; + m_value.valueID = CSSValueWebkitFillAvailable; + break; + case FitContent: + m_primitiveUnitType = CSS_VALUE_ID; + m_value.valueID = CSSValueWebkitFitContent; + break; + case Percent: + m_primitiveUnitType = CSS_PERCENTAGE; + ASSERT(std::isfinite(length.percent())); + m_value.num = length.percent(); + break; + case ViewportPercentageWidth: + m_primitiveUnitType = CSS_VW; + m_value.num = length.viewportPercentageLength(); + break; + case ViewportPercentageHeight: + m_primitiveUnitType = CSS_VH; + m_value.num = length.viewportPercentageLength(); + break; + case ViewportPercentageMin: + m_primitiveUnitType = CSS_VMIN; + m_value.num = length.viewportPercentageLength(); + break; + case ViewportPercentageMax: + m_primitiveUnitType = CSS_VMAX; + m_value.num = length.viewportPercentageLength(); + break; + case Calculated: + case Relative: + case Undefined: + ASSERT_NOT_REACHED(); + break; } } @@ -552,63 +589,63 @@ double CSSPrimitiveValue::computeLengthDouble(const RenderStyle* style, const Re if (m_primitiveUnitType == CSS_CALC) // The multiplier and factor is applied to each value in the calc expression individually return m_value.calc->computeLengthPx(style, rootStyle, multiplier, computingFontSize); - + double factor; switch (primitiveType()) { - case CSS_EMS: - factor = computingFontSize ? style->fontDescription().specifiedSize() : style->fontDescription().computedSize(); - break; - case CSS_EXS: - // FIXME: We have a bug right now where the zoom will be applied twice to EX units. - // We really need to compute EX using fontMetrics for the original specifiedSize and not use - // our actual constructed rendering font. - if (style->fontMetrics().hasXHeight()) - factor = style->fontMetrics().xHeight(); - else - factor = (computingFontSize ? style->fontDescription().specifiedSize() : style->fontDescription().computedSize()) / 2.0; - break; - case CSS_REMS: - if (rootStyle) - factor = computingFontSize ? rootStyle->fontDescription().specifiedSize() : rootStyle->fontDescription().computedSize(); - else - factor = 1.0; - break; - case CSS_CHS: - factor = style->fontMetrics().zeroWidth(); - break; - case CSS_PX: - factor = 1.0; - break; - case CSS_CM: - factor = cssPixelsPerInch / 2.54; // (2.54 cm/in) - break; - case CSS_MM: - factor = cssPixelsPerInch / 25.4; - break; - case CSS_IN: - factor = cssPixelsPerInch; - break; - case CSS_PT: - factor = cssPixelsPerInch / 72.0; - break; - case CSS_PC: - // 1 pc == 12 pt - factor = cssPixelsPerInch * 12.0 / 72.0; - break; - case CSS_CALC_PERCENTAGE_WITH_LENGTH: - case CSS_CALC_PERCENTAGE_WITH_NUMBER: - ASSERT_NOT_REACHED(); - return -1.0; - case CSS_VH: - case CSS_VW: - case CSS_VMAX: - case CSS_VMIN: + case CSS_EMS: + factor = computingFontSize ? style->fontDescription().specifiedSize() : style->fontDescription().computedSize(); + break; + case CSS_EXS: + // FIXME: We have a bug right now where the zoom will be applied twice to EX units. + // We really need to compute EX using fontMetrics for the original specifiedSize and not use + // our actual constructed rendering font. + if (style->fontMetrics().hasXHeight()) + factor = style->fontMetrics().xHeight(); + else + factor = (computingFontSize ? style->fontDescription().specifiedSize() : style->fontDescription().computedSize()) / 2.0; + break; + case CSS_REMS: + if (rootStyle) + factor = computingFontSize ? rootStyle->fontDescription().specifiedSize() : rootStyle->fontDescription().computedSize(); + else factor = 1.0; - break; - default: - ASSERT_NOT_REACHED(); - return -1.0; + break; + case CSS_CHS: + factor = style->fontMetrics().zeroWidth(); + break; + case CSS_PX: + factor = 1.0; + break; + case CSS_CM: + factor = cssPixelsPerInch / 2.54; // (2.54 cm/in) + break; + case CSS_MM: + factor = cssPixelsPerInch / 25.4; + break; + case CSS_IN: + factor = cssPixelsPerInch; + break; + case CSS_PT: + factor = cssPixelsPerInch / 72.0; + break; + case CSS_PC: + // 1 pc == 12 pt + factor = cssPixelsPerInch * 12.0 / 72.0; + break; + case CSS_CALC_PERCENTAGE_WITH_LENGTH: + case CSS_CALC_PERCENTAGE_WITH_NUMBER: + ASSERT_NOT_REACHED(); + return -1.0; + case CSS_VH: + case CSS_VW: + case CSS_VMAX: + case CSS_VMIN: + factor = 1.0; + break; + default: + ASSERT_NOT_REACHED(); + return -1.0; } // We do not apply the zoom factor when we are computing the value of the font-size property. The zooming @@ -629,53 +666,53 @@ void CSSPrimitiveValue::setFloatValue(unsigned short, double, ExceptionCode& ec) ec = NO_MODIFICATION_ALLOWED_ERR; } -static double conversionToCanonicalUnitsScaleFactor(unsigned short unitType) +double CSSPrimitiveValue::conversionToCanonicalUnitsScaleFactor(unsigned short unitType) { double factor = 1.0; // FIXME: the switch can be replaced by an array of scale factors. switch (unitType) { - // These are "canonical" units in their respective categories. - case CSSPrimitiveValue::CSS_PX: - case CSSPrimitiveValue::CSS_DEG: - case CSSPrimitiveValue::CSS_MS: - case CSSPrimitiveValue::CSS_HZ: - break; - case CSSPrimitiveValue::CSS_CM: - factor = cssPixelsPerInch / 2.54; // (2.54 cm/in) - break; - case CSSPrimitiveValue::CSS_DPCM: - factor = 2.54 / cssPixelsPerInch; // (2.54 cm/in) - break; - case CSSPrimitiveValue::CSS_MM: - factor = cssPixelsPerInch / 25.4; - break; - case CSSPrimitiveValue::CSS_IN: - factor = cssPixelsPerInch; - break; - case CSSPrimitiveValue::CSS_DPI: - factor = 1 / cssPixelsPerInch; - break; - case CSSPrimitiveValue::CSS_PT: - factor = cssPixelsPerInch / 72.0; - break; - case CSSPrimitiveValue::CSS_PC: - factor = cssPixelsPerInch * 12.0 / 72.0; // 1 pc == 12 pt - break; - case CSSPrimitiveValue::CSS_RAD: - factor = 180 / piDouble; - break; - case CSSPrimitiveValue::CSS_GRAD: - factor = 0.9; - break; - case CSSPrimitiveValue::CSS_TURN: - factor = 360; - break; - case CSSPrimitiveValue::CSS_S: - case CSSPrimitiveValue::CSS_KHZ: - factor = 1000; - break; - default: - break; + // These are "canonical" units in their respective categories. + case CSS_PX: + case CSS_DEG: + case CSS_MS: + case CSS_HZ: + break; + case CSS_CM: + factor = cssPixelsPerInch / 2.54; // (2.54 cm/in) + break; + case CSS_DPCM: + factor = 2.54 / cssPixelsPerInch; // (2.54 cm/in) + break; + case CSS_MM: + factor = cssPixelsPerInch / 25.4; + break; + case CSS_IN: + factor = cssPixelsPerInch; + break; + case CSS_DPI: + factor = 1 / cssPixelsPerInch; + break; + case CSS_PT: + factor = cssPixelsPerInch / 72.0; + break; + case CSS_PC: + factor = cssPixelsPerInch * 12.0 / 72.0; // 1 pc == 12 pt + break; + case CSS_RAD: + factor = 180 / piDouble; + break; + case CSS_GRAD: + factor = 0.9; + break; + case CSS_TURN: + factor = 360; + break; + case CSS_S: + case CSS_KHZ: + factor = 1000; + break; + default: + break; } return factor; @@ -702,7 +739,7 @@ double CSSPrimitiveValue::getDoubleValue(unsigned short unitType) const } double CSSPrimitiveValue::getDoubleValue() const -{ +{ return m_primitiveUnitType != CSS_CALC ? m_value.num : m_value.calc->doubleValue(); } @@ -796,20 +833,20 @@ String CSSPrimitiveValue::getStringValue(ExceptionCode& ec) const { ec = 0; switch (m_primitiveUnitType) { - case CSS_STRING: - case CSS_ATTR: - case CSS_URI: + case CSS_STRING: + case CSS_ATTR: + case CSS_URI: #if ENABLE(CSS_VARIABLES) - case CSS_VARIABLE_NAME: + case CSS_VARIABLE_NAME: #endif - return m_value.string; - case CSS_VALUE_ID: - return valueName(m_value.valueID); - case CSS_PROPERTY_ID: - return propertyName(m_value.propertyID); - default: - ec = INVALID_ACCESS_ERR; - break; + return m_value.string; + case CSS_VALUE_ID: + return valueName(m_value.valueID); + case CSS_PROPERTY_ID: + return propertyName(m_value.propertyID); + default: + ec = INVALID_ACCESS_ERR; + break; } return String(); @@ -818,19 +855,19 @@ String CSSPrimitiveValue::getStringValue(ExceptionCode& ec) const String CSSPrimitiveValue::getStringValue() const { switch (m_primitiveUnitType) { - case CSS_STRING: - case CSS_ATTR: - case CSS_URI: + case CSS_STRING: + case CSS_ATTR: + case CSS_URI: #if ENABLE(CSS_VARIABLES) - case CSS_VARIABLE_NAME: + case CSS_VARIABLE_NAME: #endif - return m_value.string; - case CSS_VALUE_ID: - return valueName(m_value.valueID); - case CSS_PROPERTY_ID: - return propertyName(m_value.propertyID); - default: - break; + return m_value.string; + case CSS_VALUE_ID: + return valueName(m_value.valueID); + case CSS_PROPERTY_ID: + return propertyName(m_value.propertyID); + default: + break; } return String(); diff --git a/Source/WebCore/css/CSSPrimitiveValue.h b/Source/WebCore/css/CSSPrimitiveValue.h index 6bf437ac5..9ccb1eeb3 100644 --- a/Source/WebCore/css/CSSPrimitiveValue.h +++ b/Source/WebCore/css/CSSPrimitiveValue.h @@ -154,6 +154,7 @@ public: #endif UOther }; + static UnitCategory unitCategory(CSSPrimitiveValue::UnitTypes); bool isAngle() const { @@ -207,7 +208,7 @@ public: bool isViewportPercentageMax() const { return m_primitiveUnitType == CSS_VMAX; } bool isViewportPercentageMin() const { return m_primitiveUnitType == CSS_VMIN; } bool isValueID() const { return m_primitiveUnitType == CSS_VALUE_ID; } - + static PassRefPtr createIdentifier(CSSValueID valueID) { return adoptRef(new CSSPrimitiveValue(valueID)); } static PassRefPtr createIdentifier(CSSPropertyID propertyID) { return adoptRef(new CSSPrimitiveValue(propertyID)); } static PassRefPtr createParserOperator(int parserOperator) { return adoptRef(new CSSPrimitiveValue(parserOperator)); } @@ -215,6 +216,7 @@ public: static PassRefPtr createColor(unsigned rgbValue) { return adoptRef(new CSSPrimitiveValue(rgbValue)); } static PassRefPtr create(double value, UnitTypes type) { return adoptRef(new CSSPrimitiveValue(value, type)); } static PassRefPtr create(const String& value, UnitTypes type) { return adoptRef(new CSSPrimitiveValue(value, type)); } + static PassRefPtr create(const Length& value, const RenderStyle* style) { return adoptRef(new CSSPrimitiveValue(value, style)); } template static PassRefPtr create(T value) { @@ -314,7 +316,7 @@ public: #endif CSSBasicShape* getShapeValue() const { return m_primitiveUnitType != CSS_SHAPE ? 0 : m_value.shape; } - + CSSCalcValue* cssCalcValue() const { return m_primitiveUnitType != CSS_CALC ? 0 : m_value.calc; } CSSPropertyID getPropertyID() const { return m_primitiveUnitType == CSS_PROPERTY_ID ? m_value.propertyID : CSSPropertyInvalid; } @@ -333,12 +335,15 @@ public: void addSubresourceStyleURLs(ListHashSet&, const StyleSheetContents*) const; Length viewportPercentageLength() const; - + PassRefPtr cloneForCSSOM() const; void setCSSOMSafe() { m_isCSSOMSafe = true; } bool equals(const CSSPrimitiveValue&) const; + static UnitTypes canonicalUnitTypeForCategory(UnitCategory); + static double conversionToCanonicalUnitsScaleFactor(unsigned short unitType); + private: CSSPrimitiveValue(CSSValueID); CSSPrimitiveValue(CSSPropertyID); @@ -346,6 +351,7 @@ private: CSSPrimitiveValue(int parserOperator); CSSPrimitiveValue(unsigned color); // RGB value CSSPrimitiveValue(const Length&); + CSSPrimitiveValue(const Length&, const RenderStyle*); CSSPrimitiveValue(const String&, UnitTypes); CSSPrimitiveValue(double, UnitTypes); @@ -366,8 +372,7 @@ private: static void create(unsigned); // compile-time guard template operator T*(); // compile-time guard - static UnitTypes canonicalUnitTypeForCategory(UnitCategory category); - + void init(const Length&); void init(PassRefPtr); void init(PassRefPtr); void init(PassRefPtr); @@ -396,6 +401,18 @@ private: } m_value; }; +inline CSSPrimitiveValue* toCSSPrimitiveValue(CSSValue* value) +{ + ASSERT_WITH_SECURITY_IMPLICATION(!value || value->isPrimitiveValue()); + return static_cast(value); +} + +inline const CSSPrimitiveValue* toCSSPrimitiveValue(const CSSValue* value) +{ + ASSERT_WITH_SECURITY_IMPLICATION(!value || value->isPrimitiveValue()); + return static_cast(value); +} + } // namespace WebCore #endif // CSSPrimitiveValue_h diff --git a/Source/WebCore/css/CSSValuePool.h b/Source/WebCore/css/CSSValuePool.h index 421d74d6e..e2ceb6e4c 100644 --- a/Source/WebCore/css/CSSValuePool.h +++ b/Source/WebCore/css/CSSValuePool.h @@ -31,9 +31,9 @@ #include "CSSPrimitiveValue.h" #include "CSSPropertyNames.h" #include "CSSValueKeywords.h" -#include #include #include +#include namespace WebCore { @@ -52,6 +52,7 @@ public: PassRefPtr createColorValue(unsigned rgbValue); PassRefPtr createValue(double value, CSSPrimitiveValue::UnitTypes); PassRefPtr createValue(const String& value, CSSPrimitiveValue::UnitTypes type) { return CSSPrimitiveValue::create(value, type); } + PassRefPtr createValue(const Length& value, const RenderStyle* style) { return CSSPrimitiveValue::create(value, style); } template static PassRefPtr createValue(T value) { return CSSPrimitiveValue::create(value); } void drain(); diff --git a/Source/WebCore/platform/CalculationValue.h b/Source/WebCore/platform/CalculationValue.h index 72543ff60..3dcbf1b78 100644 --- a/Source/WebCore/platform/CalculationValue.h +++ b/Source/WebCore/platform/CalculationValue.h @@ -59,7 +59,7 @@ enum CalcExpressionNodeType { CalcExpressionNodeBinaryOperation, CalcExpressionNodeBlendLength, }; - + class CalcExpressionNode { WTF_MAKE_FAST_ALLOCATED; public: @@ -67,37 +67,40 @@ public: : m_type(CalcExpressionNodeUndefined) { } - + virtual ~CalcExpressionNode() { } - + virtual float evaluate(float maxValue) const = 0; virtual bool operator==(const CalcExpressionNode&) const = 0; CalcExpressionNodeType type() const { return m_type; } - + protected: CalcExpressionNodeType m_type; }; - + class CalculationValue : public RefCounted { public: static PassRefPtr create(PassOwnPtr value, CalculationPermittedValueRange); float evaluate(float maxValue) const; - bool operator==(const CalculationValue& o) const - { + bool operator==(const CalculationValue& o) const + { return *(m_value.get()) == *(o.m_value.get()); } - + + bool isNonNegative() const { return m_isNonNegative; } + const CalcExpressionNode* expression() const { return m_value.get(); } + private: CalculationValue(PassOwnPtr value, CalculationPermittedValueRange range) : m_value(value) , m_isNonNegative(range == CalculationRangeNonNegative) { } - + OwnPtr m_value; bool m_isNonNegative; }; @@ -115,20 +118,28 @@ public: return m_value == o.m_value; } - virtual bool operator==(const CalcExpressionNode& o) const + virtual bool operator==(const CalcExpressionNode& o) const OVERRIDE { return type() == o.type() && *this == static_cast(o); } - - virtual float evaluate(float) const + + virtual float evaluate(float) const OVERRIDE { return m_value; } - + + float value() const { return m_value; } + private: float m_value; }; +inline const CalcExpressionNumber* toCalcExpressionNumber(const CalcExpressionNode* value) +{ + ASSERT_WITH_SECURITY_IMPLICATION(!value || value->type() == CalcExpressionNodeNumber); + return static_cast(value); +} + class CalcExpressionLength : public CalcExpressionNode { public: explicit CalcExpressionLength(Length length) @@ -141,21 +152,29 @@ public: { return m_length == o.m_length; } - - virtual bool operator==(const CalcExpressionNode& o) const + + virtual bool operator==(const CalcExpressionNode& o) const OVERRIDE { return type() == o.type() && *this == static_cast(o); } - - virtual float evaluate(float maxValue) const + + virtual float evaluate(float maxValue) const OVERRIDE { return floatValueForLength(m_length, maxValue); } - + + const Length& length() const { return m_length; } + private: Length m_length; }; +inline const CalcExpressionLength* toCalcExpressionLength(const CalcExpressionNode* value) +{ + ASSERT_WITH_SECURITY_IMPLICATION(!value || value->type() == CalcExpressionNodeLength); + return static_cast(value); +} + class CalcExpressionBinaryOperation : public CalcExpressionNode { public: CalcExpressionBinaryOperation(PassOwnPtr leftSide, PassOwnPtr rightSide, CalcOperator op) @@ -171,13 +190,16 @@ public: return m_operator == o.m_operator && *m_leftSide == *o.m_leftSide && *m_rightSide == *o.m_rightSide; } - virtual bool operator==(const CalcExpressionNode& o) const + virtual bool operator==(const CalcExpressionNode& o) const OVERRIDE { return type() == o.type() && *this == static_cast(o); } - - - virtual float evaluate(float) const; + + virtual float evaluate(float) const OVERRIDE; + + const CalcExpressionNode* leftSide() const { return m_leftSide.get(); } + const CalcExpressionNode* rightSide() const { return m_rightSide.get(); } + CalcOperator getOperator() const { return m_operator; } private: OwnPtr m_leftSide; @@ -185,6 +207,12 @@ private: CalcOperator m_operator; }; +inline const CalcExpressionBinaryOperation* toCalcExpressionBinaryOperation(const CalcExpressionNode* value) +{ + ASSERT_WITH_SECURITY_IMPLICATION(!value || value->type() == CalcExpressionNodeBinaryOperation); + return static_cast(value); +} + class CalcExpressionBlendLength : public CalcExpressionNode { public: CalcExpressionBlendLength(Length from, Length to, float progress) @@ -194,28 +222,38 @@ public: { m_type = CalcExpressionNodeBlendLength; } - + bool operator==(const CalcExpressionBlendLength& o) const { return m_progress == o.m_progress && m_from == o.m_from && m_to == o.m_to; } - - virtual bool operator==(const CalcExpressionNode& o) const + + virtual bool operator==(const CalcExpressionNode& o) const OVERRIDE { return type() == o.type() && *this == static_cast(o); } - - virtual float evaluate(float maxValue) const + + virtual float evaluate(float maxValue) const OVERRIDE { return (1.0f - m_progress) * floatValueForLength(m_from, maxValue) + m_progress * floatValueForLength(m_to, maxValue); } - -private: + + const Length& from() const { return m_from; } + const Length& to() const { return m_to; } + float progress() const { return m_progress; } + +private: Length m_from; Length m_to; float m_progress; }; - + +inline const CalcExpressionBlendLength* toCalcExpressionBlendLength(const CalcExpressionNode* value) +{ + ASSERT_WITH_SECURITY_IMPLICATION(!value || value->type() == CalcExpressionNodeBlendLength); + return static_cast(value); +} + } // namespace WebCore #endif // CalculationValue_h -- cgit v1.2.3 From ac20ee9ffda40fd1c1714ec3a000bbf27c3eee33 Mon Sep 17 00:00:00 2001 From: Martin Hodovan Date: Tue, 13 May 2014 17:08:43 +0000 Subject: ASSERTION FAILED: leftCategory != CalcOther && rightCategory != CalcOther in WebCore::CSSCalcBinaryOperation::createSimplified https://bugs.webkit.org/show_bug.cgi?id=132870 Source/WebCore: According to the standard, calc() should be able to handle angle, time and frequency values as well: http://www.w3.org/TR/css3-values/#calc Patch by Martin Hodovan on 2014-05-13 Reviewed by Darin Adler. Test: fast/css/calc-with-angle-time-frequency.html * css/CSSCalculationValue.cpp: (WebCore::unitCategory): (WebCore::CSSCalcPrimitiveValue::createCalcExpression): (WebCore::CSSCalcPrimitiveValue::computeLengthPx): (WebCore::CSSCalcPrimitiveValue::addSubtractResult): (WebCore::CSSCalcPrimitiveValue::determineCategory): (WebCore::CSSCalcBinaryOperation::primitiveType) * css/CSSCalculationValue.h: extending CalculationCategory * css/CSSParser.cpp: (WebCore::CSSParser::validCalculationUnit): * css/CSSPrimitiveValue.cpp: (WebCore::CSSPrimitiveValue::primitiveType): LayoutTests: Added test contains calc() expressions with angle, time and frequency values, covering all the newly introduced unit types, each of which used to fail. Patch by Martin Hodovan on 2014-05-13 Reviewed by Darin Adler. * fast/css/calc-with-angle-time-frequency-expected.txt: Added. * fast/css/calc-with-angle-time-frequency.html: Added. git-svn-id: http://svn.webkit.org/repository/webkit/trunk@168685 268f45cc-cd09-0410-ab3c-d52691b4dbfc Change-Id: Id342e513bef2aa147dbfc94d2fc5a72e51fd0f57 Reviewed-by: Allan Sandfeld Jensen --- Source/WebCore/css/CSSCalculationValue.cpp | 35 ++++++++++++++++++++++++++---- Source/WebCore/css/CSSCalculationValue.h | 3 +++ Source/WebCore/css/CSSParser.cpp | 23 ++++++++++++++------ Source/WebCore/css/CSSPrimitiveValue.cpp | 10 +++++++-- 4 files changed, 58 insertions(+), 13 deletions(-) diff --git a/Source/WebCore/css/CSSCalculationValue.cpp b/Source/WebCore/css/CSSCalculationValue.cpp index b42a520c2..60fd22adf 100644 --- a/Source/WebCore/css/CSSCalculationValue.cpp +++ b/Source/WebCore/css/CSSCalculationValue.cpp @@ -57,8 +57,6 @@ static CalculationCategory unitCategory(CSSPrimitiveValue::UnitTypes type) case CSSPrimitiveValue::CSS_NUMBER: case CSSPrimitiveValue::CSS_PARSER_INTEGER: return CalcNumber; - case CSSPrimitiveValue::CSS_PERCENTAGE: - return CalcPercent; case CSSPrimitiveValue::CSS_EMS: case CSSPrimitiveValue::CSS_EXS: case CSSPrimitiveValue::CSS_PX: @@ -70,6 +68,19 @@ static CalculationCategory unitCategory(CSSPrimitiveValue::UnitTypes type) case CSSPrimitiveValue::CSS_REMS: case CSSPrimitiveValue::CSS_CHS: return CalcLength; + case CSSPrimitiveValue::CSS_PERCENTAGE: + return CalcPercent; + case CSSPrimitiveValue::CSS_DEG: + case CSSPrimitiveValue::CSS_RAD: + case CSSPrimitiveValue::CSS_GRAD: + case CSSPrimitiveValue::CSS_TURN: + return CalcAngle; + case CSSPrimitiveValue::CSS_MS: + case CSSPrimitiveValue::CSS_S: + return CalcTime; + case CSSPrimitiveValue::CSS_HZ: + case CSSPrimitiveValue::CSS_KHZ: + return CalcFrequency; #if ENABLE(CSS_VARIABLES) case CSSPrimitiveValue::CSS_VARIABLE_NAME: return CalcVariable; @@ -254,6 +265,9 @@ public: // Only types that could be part of a Length expression can be converted // to a CalcExpressionNode. CalcPercentNumber makes no sense as a Length. case CalcPercentNumber: + case CalcAngle: + case CalcTime: + case CalcFrequency: #if ENABLE(CSS_VARIABLES) case CalcVariable: #endif @@ -281,6 +295,9 @@ public: return m_value->getDoubleValue(); case CalcPercentLength: case CalcPercentNumber: + case CalcAngle: + case CalcTime: + case CalcFrequency: #if ENABLE(CSS_VARIABLES) case CalcVariable: #endif @@ -316,7 +333,7 @@ private: RefPtr m_value; }; -static const CalculationCategory addSubtractResult[CalcOther][CalcOther] = { +static const CalculationCategory addSubtractResult[CalcAngle][CalcAngle] = { // CalcNumber CalcLength CalcPercent CalcPercentNumber CalcPercentLength { CalcNumber, CalcOther, CalcPercentNumber, CalcPercentNumber, CalcOther }, // CalcNumber { CalcOther, CalcLength, CalcPercentLength, CalcOther, CalcPercentLength }, // CalcLength @@ -341,7 +358,11 @@ static CalculationCategory determineCategory(const CSSCalcExpressionNode& leftSi switch (op) { case CalcAdd: case CalcSubtract: - return addSubtractResult[leftCategory][rightCategory]; + if (leftCategory < CalcAngle || rightCategory < CalcAngle) + return addSubtractResult[leftCategory][rightCategory]; + if (leftCategory == rightCategory) + return leftCategory; + return CalcOther; case CalcMultiply: if (leftCategory != CalcNumber && rightCategory != CalcNumber) return CalcOther; @@ -532,6 +553,12 @@ public: #endif case CalcPercentLength: case CalcPercentNumber: + case CalcAngle: + return CSSPrimitiveValue::CSS_DEG; + case CalcTime: + return CSSPrimitiveValue::CSS_MS; + case CalcFrequency: + return CSSPrimitiveValue::CSS_HZ; case CalcOther: return CSSPrimitiveValue::CSS_UNKNOWN; } diff --git a/Source/WebCore/css/CSSCalculationValue.h b/Source/WebCore/css/CSSCalculationValue.h index 13a17a3b7..27ff176f1 100644 --- a/Source/WebCore/css/CSSCalculationValue.h +++ b/Source/WebCore/css/CSSCalculationValue.h @@ -54,6 +54,9 @@ enum CalculationCategory { CalcPercent, CalcPercentNumber, CalcPercentLength, + CalcAngle, + CalcTime, + CalcFrequency, #if ENABLE(CSS_VARIABLES) CalcVariable, #endif diff --git a/Source/WebCore/css/CSSParser.cpp b/Source/WebCore/css/CSSParser.cpp index 54fd5e238..99ee8043a 100644 --- a/Source/WebCore/css/CSSParser.cpp +++ b/Source/WebCore/css/CSSParser.cpp @@ -1609,6 +1609,13 @@ bool CSSParser::validCalculationUnit(CSSParserValue* value, Units unitflags, Rel bool b = false; switch (m_parsedCalculation->category()) { + case CalcNumber: + b = (unitflags & FNumber); + if (!b && (unitflags & FInteger) && m_parsedCalculation->isInt()) + b = true; + if (b && mustBeNonNegative && m_parsedCalculation->isNegative()) + b = false; + break; case CalcLength: b = (unitflags & FLength); break; @@ -1617,19 +1624,21 @@ bool CSSParser::validCalculationUnit(CSSParserValue* value, Units unitflags, Rel if (b && mustBeNonNegative && m_parsedCalculation->isNegative()) b = false; break; - case CalcNumber: - b = (unitflags & FNumber); - if (!b && (unitflags & FInteger) && m_parsedCalculation->isInt()) - b = true; - if (b && mustBeNonNegative && m_parsedCalculation->isNegative()) - b = false; - break; case CalcPercentLength: b = (unitflags & FPercent) && (unitflags & FLength); break; case CalcPercentNumber: b = (unitflags & FPercent) && (unitflags & FNumber); break; + case CalcAngle: + b = (unitflags & FAngle); + break; + case CalcTime: + b = (unitflags & FTime); + break; + case CalcFrequency: + b = (unitflags & FFrequency); + break; #if ENABLE(CSS_VARIABLES) case CalcVariable: b = true; diff --git a/Source/WebCore/css/CSSPrimitiveValue.cpp b/Source/WebCore/css/CSSPrimitiveValue.cpp index bd544aab5..32f0121b6 100644 --- a/Source/WebCore/css/CSSPrimitiveValue.cpp +++ b/Source/WebCore/css/CSSPrimitiveValue.cpp @@ -193,14 +193,20 @@ unsigned short CSSPrimitiveValue::primitiveType() const switch (m_value.calc->category()) { case CalcNumber: return CSSPrimitiveValue::CSS_NUMBER; - case CalcPercent: - return CSSPrimitiveValue::CSS_PERCENTAGE; case CalcLength: return CSSPrimitiveValue::CSS_PX; + case CalcPercent: + return CSSPrimitiveValue::CSS_PERCENTAGE; case CalcPercentNumber: return CSSPrimitiveValue::CSS_CALC_PERCENTAGE_WITH_NUMBER; case CalcPercentLength: return CSSPrimitiveValue::CSS_CALC_PERCENTAGE_WITH_LENGTH; + case CalcAngle: + return CSSPrimitiveValue::CSS_DEG; + case CalcTime: + return CSSPrimitiveValue::CSS_MS; + case CalcFrequency: + return CSSPrimitiveValue::CSS_HZ; #if ENABLE(CSS_VARIABLES) case CalcVariable: return CSSPrimitiveValue::CSS_UNKNOWN; // The type of a calculation containing a variable cannot be known until the value of the variable is determined. -- cgit v1.2.3 From 502b4a55ac778d036a33c32fec51eecbbc73e1a9 Mon Sep 17 00:00:00 2001 From: "mhodovan.u-szeged@partner.samsung.com" Date: Fri, 27 Jun 2014 18:55:46 +0000 Subject: REGRESSION (r168685): css calc() expression fails https://bugs.webkit.org/show_bug.cgi?id=134059 Source/WebCore: The expression 'calc((100% - 20px) / 3' did not work properly after r168685, because primitiveType() function in CSSCalculationValue.cpp has handled CalcPercentLength and CalcPercentNumber categories as if they were angles. The patch fixes this incorrect behavior. Reviewed by Simon Fraser. Test: fast/css/calc-percentage-pixel.html * css/CSSCalculationValue.cpp: LayoutTests: Added test demonstrates that expressions like 'calc((100% - 20px) / 3' work correctly again. Reviewed by Simon Fraser. * fast/css/calc-percentage-pixel-expected.html: Added. * fast/css/calc-percentage-pixel.html: Added. git-svn-id: http://svn.webkit.org/repository/webkit/trunk@170544 268f45cc-cd09-0410-ab3c-d52691b4dbfc Change-Id: I2cebbb43b511c8c3634c55a97598d362ae0a1ab3 Reviewed-by: Allan Sandfeld Jensen --- Source/WebCore/css/CSSCalculationValue.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/WebCore/css/CSSCalculationValue.cpp b/Source/WebCore/css/CSSCalculationValue.cpp index 60fd22adf..b7072e5e4 100644 --- a/Source/WebCore/css/CSSCalculationValue.cpp +++ b/Source/WebCore/css/CSSCalculationValue.cpp @@ -551,14 +551,14 @@ public: case CalcVariable: return CSSPrimitiveValue::CSS_VARIABLE_NAME; #endif - case CalcPercentLength: - case CalcPercentNumber: case CalcAngle: return CSSPrimitiveValue::CSS_DEG; case CalcTime: return CSSPrimitiveValue::CSS_MS; case CalcFrequency: return CSSPrimitiveValue::CSS_HZ; + case CalcPercentLength: + case CalcPercentNumber: case CalcOther: return CSSPrimitiveValue::CSS_UNKNOWN; } -- cgit v1.2.3 From 6ca6514fa0caae5bf1df1aae126c51efb618d757 Mon Sep 17 00:00:00 2001 From: Antti Koivisto Date: Wed, 10 Dec 2014 20:46:15 +0000 Subject: Crash when creating CSSCalcBinaryOperation https://bugs.webkit.org/show_bug.cgi?id=134886 rdar://problem/17663561 Reviewed by Chris Dumez. Source/WebCore: Test: fast/css/calc-binary-operation-crash.html * css/CSSCalculationValue.cpp: (WebCore::determineCategory): Ensure that both axis are within the addSubtractResult table. Remove unneeded CalcOther test. The call site guarantees it doesn't happen and the normal cases would handle it anyway. Also strengthen some asserts. LayoutTests: * fast/css/calc-binary-operation-crash-expected.txt: Added. * fast/css/calc-binary-operation-crash.html: Added. git-svn-id: http://svn.webkit.org/repository/webkit/trunk@177089 268f45cc-cd09-0410-ab3c-d52691b4dbfc Change-Id: Iaf7199800b78c1397da9335bb3420ab6784f9227 Reviewed-by: Allan Sandfeld Jensen --- Source/WebCore/css/CSSCalculationValue.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/Source/WebCore/css/CSSCalculationValue.cpp b/Source/WebCore/css/CSSCalculationValue.cpp index b7072e5e4..9864abd64 100644 --- a/Source/WebCore/css/CSSCalculationValue.cpp +++ b/Source/WebCore/css/CSSCalculationValue.cpp @@ -274,6 +274,7 @@ public: case CalcOther: ASSERT_NOT_REACHED(); } + ASSERT_NOT_REACHED(); return nullptr; } @@ -346,9 +347,8 @@ static CalculationCategory determineCategory(const CSSCalcExpressionNode& leftSi { CalculationCategory leftCategory = leftSide.category(); CalculationCategory rightCategory = rightSide.category(); - - if (leftCategory == CalcOther || rightCategory == CalcOther) - return CalcOther; + ASSERT(leftCategory < CalcOther); + ASSERT(rightCategory < CalcOther); #if ENABLE(CSS_VARIABLES) if (leftCategory == CalcVariable || rightCategory == CalcVariable) @@ -358,7 +358,7 @@ static CalculationCategory determineCategory(const CSSCalcExpressionNode& leftSi switch (op) { case CalcAdd: case CalcSubtract: - if (leftCategory < CalcAngle || rightCategory < CalcAngle) + if (leftCategory < CalcAngle && rightCategory < CalcAngle) return addSubtractResult[leftCategory][rightCategory]; if (leftCategory == rightCategory) return leftCategory; @@ -389,7 +389,8 @@ class CSSCalcBinaryOperation : public CSSCalcExpressionNode { public: static PassRefPtr create(PassRefPtr leftSide, PassRefPtr rightSide, CalcOperator op) { - ASSERT(leftSide->category() != CalcOther && rightSide->category() != CalcOther); + ASSERT(leftSide->category() < CalcOther); + ASSERT(rightSide->category() < CalcOther); CalculationCategory newCategory = determineCategory(*leftSide, *rightSide, op); @@ -403,7 +404,8 @@ public: { CalculationCategory leftCategory = leftSide->category(); CalculationCategory rightCategory = rightSide->category(); - ASSERT(leftCategory != CalcOther && rightCategory != CalcOther); + ASSERT(leftCategory < CalcOther); + ASSERT(rightCategory < CalcOther); bool isInteger = isIntegerResult(leftSide.get(), rightSide.get(), op); -- cgit v1.2.3 From dd3b76df6531a6305f35e847192ce2b3638683d7 Mon Sep 17 00:00:00 2001 From: Dean Jackson Date: Fri, 12 Sep 2014 20:46:05 +0000 Subject: Unprefix the flexbox CSS properties https://bugs.webkit.org/show_bug.cgi?id=98420 Reviewed by Benjamin Poulain. Source/WebCore: Remove the need for a "-webkit-" prefix on flexbox and related properties. This includes: - align-content - align-items - align-self - flex-basis - flex-direction - flex-wrap - flex-grow - flex-shrink - flex - flex-flow - justify - order ... as well as the display keyword values "flex" and "inline-flex". * css/CSSComputedStyleDeclaration.cpp: Change names. (WebCore::ComputedStyleExtractor::propertyValue): * css/CSSParser.cpp: Ditto. (WebCore::isValidKeywordPropertyAndValue): (WebCore::isKeywordPropertyID): (WebCore::CSSParser::parseValue): (WebCore::CSSParser::parseFlex): * css/CSSPrimitiveValueMappings.h: Since we need to still handle the old keywords for display, this has added two new keywords. (WebCore::CSSPrimitiveValue::CSSPrimitiveValue): (WebCore::CSSPrimitiveValue::operator EDisplay): If the older keywords were used in content, map them to the new value names. * css/CSSPropertyNames.in: Add aliases for the prefixed properties. * css/CSSValueKeywords.in: Add "flex" and "inline-flex". * css/DeprecatedStyleBuilder.cpp: Change names. (WebCore::DeprecatedStyleBuilder::DeprecatedStyleBuilder): * css/StyleProperties.cpp: Change names. (WebCore::StyleProperties::getPropertyValue): (WebCore::StyleProperties::asText): * css/StylePropertyShorthand.cpp: Rename shorthand methods to remove the prefix. (WebCore::flexFlowShorthand): (WebCore::flexShorthand): (WebCore::shorthandForProperty): (WebCore::matchingShorthandsForLonghand): (WebCore::webkitFlexFlowShorthand): Deleted. (WebCore::webkitFlexShorthand): Deleted. * css/StylePropertyShorthand.h: * css/StyleResolver.cpp: (WebCore::equivalentBlockDisplay): (WebCore::StyleResolver::applyProperty): * page/animation/CSSPropertyAnimation.cpp: Change names. (WebCore::PropertyWrapperFlex::PropertyWrapperFlex): * rendering/RenderElement.cpp: (WebCore::RenderElement::createFor): Handle the two new display values (the same way as the old values). * rendering/style/RenderStyleConstants.h: Add constants for the new display values. LayoutTests: Now that we return "flex" instead of "-webkit-flex" (and similar changes) update the tests that rely on this. Other than that, we're still testing the prefixed content. A followup patch will add tests for non-prefixed content. * css3/flexbox/display-flexbox-set-get-expected.txt: * css3/flexbox/display-flexbox-set-get.html: * css3/flexbox/flexitem.html: * fast/css-grid-layout/grid-item-display.html: * fast/css/getComputedStyle/computed-style-expected.txt: * fast/css/getComputedStyle/computed-style-without-renderer-expected.txt: * fast/css/getComputedStyle/resources/property-names.js: * fast/css/inherit-initial-shorthand-values-expected.txt: * fast/css/inherit-initial-shorthand-values.html: * svg/css/getComputedStyle-basic-expected.txt: * transitions/flex-transitions-expected.txt: * transitions/flex-transitions.html: git-svn-id: http://svn.webkit.org/repository/webkit/trunk@173572 268f45cc-cd09-0410-ab3c-d52691b4dbfc Change-Id: If273fd32d5165e8fa504cdfd5b591a17d61f4bbc Reviewed-by: Allan Sandfeld Jensen --- Source/WebCore/css/CSSComputedStyleDeclaration.cpp | 48 ++++++++-------- Source/WebCore/css/CSSParser.cpp | 64 +++++++++++----------- Source/WebCore/css/CSSPrimitiveValueMappings.h | 10 +++- Source/WebCore/css/CSSProperty.cpp | 24 ++++---- Source/WebCore/css/CSSPropertyNames.in | 36 ++++++++---- Source/WebCore/css/CSSValueKeywords.in | 2 + Source/WebCore/css/DeprecatedStyleBuilder.cpp | 20 +++---- Source/WebCore/css/StylePropertySet.cpp | 22 ++++---- Source/WebCore/css/StylePropertyShorthand.cpp | 24 ++++---- Source/WebCore/css/StylePropertyShorthand.h | 4 +- Source/WebCore/css/StyleResolver.cpp | 26 +++++---- .../page/animation/CSSPropertyAnimation.cpp | 3 +- Source/WebCore/rendering/RenderObject.cpp | 2 + .../WebCore/rendering/style/RenderStyleConstants.h | 2 +- 14 files changed, 156 insertions(+), 131 deletions(-) diff --git a/Source/WebCore/css/CSSComputedStyleDeclaration.cpp b/Source/WebCore/css/CSSComputedStyleDeclaration.cpp index 621cdf038..f4c25e435 100644 --- a/Source/WebCore/css/CSSComputedStyleDeclaration.cpp +++ b/Source/WebCore/css/CSSComputedStyleDeclaration.cpp @@ -276,15 +276,15 @@ static const CSSPropertyID computedProperties[] = { #if ENABLE(CSS_FILTERS) CSSPropertyWebkitFilter, #endif - CSSPropertyWebkitAlignContent, - CSSPropertyWebkitAlignItems, - CSSPropertyWebkitAlignSelf, - CSSPropertyWebkitFlexBasis, - CSSPropertyWebkitFlexGrow, - CSSPropertyWebkitFlexShrink, - CSSPropertyWebkitFlexDirection, - CSSPropertyWebkitFlexWrap, - CSSPropertyWebkitJustifyContent, + CSSPropertyAlignContent, + CSSPropertyAlignItems, + CSSPropertyAlignSelf, + CSSPropertyFlexBasis, + CSSPropertyFlexGrow, + CSSPropertyFlexShrink, + CSSPropertyFlexDirection, + CSSPropertyFlexWrap, + CSSPropertyJustifyContent, CSSPropertyWebkitFontKerning, CSSPropertyWebkitFontSmoothing, CSSPropertyWebkitFontVariantLigatures, @@ -330,7 +330,7 @@ static const CSSPropertyID computedProperties[] = { CSSPropertyWebkitMaskRepeat, CSSPropertyWebkitMaskSize, CSSPropertyWebkitNbspMode, - CSSPropertyWebkitOrder, + CSSPropertyOrder, #if ENABLE(ACCELERATED_OVERFLOW_SCROLLING) CSSPropertyWebkitOverflowScrolling, #endif @@ -1958,11 +1958,11 @@ PassRefPtr ComputedStyleExtractor::propertyValue(CSSPropertyID propert return cssValuePool().createValue(style->display()); case CSSPropertyEmptyCells: return cssValuePool().createValue(style->emptyCells()); - case CSSPropertyWebkitAlignContent: + case CSSPropertyAlignContent: return cssValuePool().createValue(style->alignContent()); - case CSSPropertyWebkitAlignItems: + case CSSPropertyAlignItems: return cssValuePool().createValue(style->alignItems()); - case CSSPropertyWebkitAlignSelf: + case CSSPropertyAlignSelf: if (style->alignSelf() == AlignAuto) { Node* parent = styledNode->parentNode(); if (parent && parent->computedStyle()) @@ -1970,23 +1970,23 @@ PassRefPtr ComputedStyleExtractor::propertyValue(CSSPropertyID propert return cssValuePool().createValue(AlignStretch); } return cssValuePool().createValue(style->alignSelf()); - case CSSPropertyWebkitFlex: - return getCSSPropertyValuesForShorthandProperties(webkitFlexShorthand()); - case CSSPropertyWebkitFlexBasis: + case CSSPropertyFlex: + return getCSSPropertyValuesForShorthandProperties(flexShorthand()); + case CSSPropertyFlexBasis: return cssValuePool().createValue(style->flexBasis()); - case CSSPropertyWebkitFlexDirection: + case CSSPropertyFlexDirection: return cssValuePool().createValue(style->flexDirection()); - case CSSPropertyWebkitFlexFlow: - return getCSSPropertyValuesForShorthandProperties(webkitFlexFlowShorthand()); - case CSSPropertyWebkitFlexGrow: + case CSSPropertyFlexFlow: + return getCSSPropertyValuesForShorthandProperties(flexFlowShorthand()); + case CSSPropertyFlexGrow: return cssValuePool().createValue(style->flexGrow()); - case CSSPropertyWebkitFlexShrink: + case CSSPropertyFlexShrink: return cssValuePool().createValue(style->flexShrink()); - case CSSPropertyWebkitFlexWrap: + case CSSPropertyFlexWrap: return cssValuePool().createValue(style->flexWrap()); - case CSSPropertyWebkitJustifyContent: + case CSSPropertyJustifyContent: return cssValuePool().createValue(style->justifyContent()); - case CSSPropertyWebkitOrder: + case CSSPropertyOrder: return cssValuePool().createValue(style->order(), CSSPrimitiveValue::CSS_NUMBER); case CSSPropertyFloat: if (style->display() != NONE && style->hasOutOfFlowPosition()) diff --git a/Source/WebCore/css/CSSParser.cpp b/Source/WebCore/css/CSSParser.cpp index 99ee8043a..eabbd5024 100644 --- a/Source/WebCore/css/CSSParser.cpp +++ b/Source/WebCore/css/CSSParser.cpp @@ -703,7 +703,7 @@ static inline bool isValidKeywordPropertyAndValue(CSSPropertyID propertyId, int // inline | block | list-item | run-in | inline-block | table | // inline-table | table-row-group | table-header-group | table-footer-group | table-row | // table-column-group | table-column | table-cell | table-caption | -webkit-box | -webkit-inline-box | none | inherit - // -webkit-flex | -webkit-inline-flex | -webkit-grid | -webkit-inline-grid + // flex | -webkit-flex | inline-flex | -webkit-inline-flex | -webkit-grid | -webkit-inline-grid if ((valueID >= CSSValueInline && valueID <= CSSValueWebkitInlineFlex) || valueID == CSSValueNone) return true; if (parserContext.isCSSGridLayoutEnabled && (valueID == CSSValueWebkitGrid || valueID == CSSValueWebkitInlineGrid)) @@ -872,27 +872,27 @@ static inline bool isValidKeywordPropertyAndValue(CSSPropertyID propertyId, int if (valueID == CSSValueSrgb || valueID == CSSValueDefault) return true; break; - case CSSPropertyWebkitAlignContent: + case CSSPropertyAlignContent: if (valueID == CSSValueFlexStart || valueID == CSSValueFlexEnd || valueID == CSSValueCenter || valueID == CSSValueSpaceBetween || valueID == CSSValueSpaceAround || valueID == CSSValueStretch) return true; break; - case CSSPropertyWebkitAlignItems: + case CSSPropertyAlignItems: if (valueID == CSSValueFlexStart || valueID == CSSValueFlexEnd || valueID == CSSValueCenter || valueID == CSSValueBaseline || valueID == CSSValueStretch) return true; break; - case CSSPropertyWebkitAlignSelf: + case CSSPropertyAlignSelf: if (valueID == CSSValueAuto || valueID == CSSValueFlexStart || valueID == CSSValueFlexEnd || valueID == CSSValueCenter || valueID == CSSValueBaseline || valueID == CSSValueStretch) return true; break; - case CSSPropertyWebkitFlexDirection: + case CSSPropertyFlexDirection: if (valueID == CSSValueRow || valueID == CSSValueRowReverse || valueID == CSSValueColumn || valueID == CSSValueColumnReverse) return true; break; - case CSSPropertyWebkitFlexWrap: + case CSSPropertyFlexWrap: if (valueID == CSSValueNowrap || valueID == CSSValueWrap || valueID == CSSValueWrapReverse) return true; break; - case CSSPropertyWebkitJustifyContent: + case CSSPropertyJustifyContent: if (valueID == CSSValueFlexStart || valueID == CSSValueFlexEnd || valueID == CSSValueCenter || valueID == CSSValueSpaceBetween || valueID == CSSValueSpaceAround) return true; break; @@ -1119,12 +1119,12 @@ static inline bool isKeywordPropertyID(CSSPropertyID propertyId) case CSSPropertyWebkitColumnBreakBefore: case CSSPropertyWebkitColumnBreakInside: case CSSPropertyWebkitColumnRuleStyle: - case CSSPropertyWebkitAlignContent: - case CSSPropertyWebkitAlignItems: - case CSSPropertyWebkitAlignSelf: - case CSSPropertyWebkitFlexDirection: - case CSSPropertyWebkitFlexWrap: - case CSSPropertyWebkitJustifyContent: + case CSSPropertyAlignContent: + case CSSPropertyAlignItems: + case CSSPropertyAlignSelf: + case CSSPropertyFlexDirection: + case CSSPropertyFlexWrap: + case CSSPropertyJustifyContent: case CSSPropertyWebkitFontKerning: case CSSPropertyWebkitFontSmoothing: case CSSPropertyWebkitHyphens: @@ -2509,28 +2509,28 @@ bool CSSParser::parseValue(CSSPropertyID propId, bool important) validPrimitive = true; break; #endif - case CSSPropertyWebkitFlex: { + case CSSPropertyFlex: { ShorthandScope scope(this, propId); if (id == CSSValueNone) { - addProperty(CSSPropertyWebkitFlexGrow, cssValuePool().createValue(0, CSSPrimitiveValue::CSS_NUMBER), important); - addProperty(CSSPropertyWebkitFlexShrink, cssValuePool().createValue(0, CSSPrimitiveValue::CSS_NUMBER), important); - addProperty(CSSPropertyWebkitFlexBasis, cssValuePool().createIdentifierValue(CSSValueAuto), important); + addProperty(CSSPropertyFlexGrow, cssValuePool().createValue(0, CSSPrimitiveValue::CSS_NUMBER), important); + addProperty(CSSPropertyFlexShrink, cssValuePool().createValue(0, CSSPrimitiveValue::CSS_NUMBER), important); + addProperty(CSSPropertyFlexBasis, cssValuePool().createIdentifierValue(CSSValueAuto), important); return true; } return parseFlex(m_valueList.get(), important); } - case CSSPropertyWebkitFlexBasis: + case CSSPropertyFlexBasis: // FIXME: Support intrinsic dimensions too. if (id == CSSValueAuto) validPrimitive = true; else validPrimitive = (!id && validUnit(value, FLength | FPercent | FNonNeg)); break; - case CSSPropertyWebkitFlexGrow: - case CSSPropertyWebkitFlexShrink: + case CSSPropertyFlexGrow: + case CSSPropertyFlexShrink: validPrimitive = validUnit(value, FNumber | FNonNeg); break; - case CSSPropertyWebkitOrder: + case CSSPropertyOrder: if (validUnit(value, FInteger, CSSStrictMode)) { // We restrict the smallest value to int min + 2 because we use int min and int min + 1 as special values in a hash set. parsedValue = cssValuePool().createValue(max(static_cast(std::numeric_limits::min() + 2), value->fValue), @@ -2883,8 +2883,8 @@ bool CSSParser::parseValue(CSSPropertyID propId, bool important) case CSSPropertyPadding: // {1,4} | inherit return parse4Values(propId, paddingShorthand().properties(), important); - case CSSPropertyWebkitFlexFlow: - return parseShorthand(propId, webkitFlexFlowShorthand(), important); + case CSSPropertyFlexFlow: + return parseShorthand(propId, flexFlowShorthand(), important); case CSSPropertyFont: // [ [ 'font-style' || 'font-variant' || 'font-weight' ]? 'font-size' [ / 'line-height' ]? // 'font-family' ] | caption | icon | menu | message-box | small-caption | status-bar | inherit @@ -3056,12 +3056,12 @@ bool CSSParser::parseValue(CSSPropertyID propId, bool important) case CSSPropertyWebkitColumnBreakBefore: case CSSPropertyWebkitColumnBreakInside: case CSSPropertyWebkitColumnRuleStyle: - case CSSPropertyWebkitAlignContent: - case CSSPropertyWebkitAlignItems: - case CSSPropertyWebkitAlignSelf: - case CSSPropertyWebkitFlexDirection: - case CSSPropertyWebkitFlexWrap: - case CSSPropertyWebkitJustifyContent: + case CSSPropertyAlignContent: + case CSSPropertyAlignItems: + case CSSPropertyAlignSelf: + case CSSPropertyFlexDirection: + case CSSPropertyFlexWrap: + case CSSPropertyJustifyContent: case CSSPropertyWebkitFontKerning: case CSSPropertyWebkitFontSmoothing: case CSSPropertyWebkitHyphens: @@ -6607,9 +6607,9 @@ bool CSSParser::parseFlex(CSSParserValueList* args, bool important) if (!flexBasis) flexBasis = cssValuePool().createValue(0, CSSPrimitiveValue::CSS_PX); - addProperty(CSSPropertyWebkitFlexGrow, cssValuePool().createValue(clampToFloat(flexGrow), CSSPrimitiveValue::CSS_NUMBER), important); - addProperty(CSSPropertyWebkitFlexShrink, cssValuePool().createValue(clampToFloat(flexShrink), CSSPrimitiveValue::CSS_NUMBER), important); - addProperty(CSSPropertyWebkitFlexBasis, flexBasis, important); + addProperty(CSSPropertyFlexGrow, cssValuePool().createValue(clampToFloat(flexGrow), CSSPrimitiveValue::CSS_NUMBER), important); + addProperty(CSSPropertyFlexShrink, cssValuePool().createValue(clampToFloat(flexShrink), CSSPrimitiveValue::CSS_NUMBER), important); + addProperty(CSSPropertyFlexBasis, flexBasis, important); return true; } diff --git a/Source/WebCore/css/CSSPrimitiveValueMappings.h b/Source/WebCore/css/CSSPrimitiveValueMappings.h index b331504d7..c6273d7e7 100644 --- a/Source/WebCore/css/CSSPrimitiveValueMappings.h +++ b/Source/WebCore/css/CSSPrimitiveValueMappings.h @@ -1289,10 +1289,12 @@ template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EDisplay e) m_value.valueID = CSSValueWebkitInlineBox; break; case FLEX: - m_value.valueID = CSSValueWebkitFlex; + case WEBKIT_FLEX: + m_value.valueID = CSSValueFlex; break; case INLINE_FLEX: - m_value.valueID = CSSValueWebkitInlineFlex; + case WEBKIT_INLINE_FLEX: + m_value.valueID = CSSValueInlineFlex; break; case GRID: m_value.valueID = CSSValueWebkitGrid; @@ -1313,6 +1315,10 @@ template<> inline CSSPrimitiveValue::operator EDisplay() const EDisplay display = static_cast(m_value.valueID - CSSValueInline); ASSERT(display >= INLINE && display <= NONE); + if (display == WEBKIT_FLEX) + return FLEX; + if (display == WEBKIT_INLINE_FLEX) + return INLINE_FLEX; return display; } diff --git a/Source/WebCore/css/CSSProperty.cpp b/Source/WebCore/css/CSSProperty.cpp index 13a4d7e7f..63a4edfb7 100644 --- a/Source/WebCore/css/CSSProperty.cpp +++ b/Source/WebCore/css/CSSProperty.cpp @@ -573,18 +573,18 @@ bool CSSProperty::isInheritedProperty(CSSPropertyID propertyID) #if ENABLE(CSS_COMPOSITING) case CSSPropertyWebkitBlendMode: #endif - case CSSPropertyWebkitAlignContent: - case CSSPropertyWebkitAlignItems: - case CSSPropertyWebkitAlignSelf: - case CSSPropertyWebkitFlex: - case CSSPropertyWebkitFlexBasis: - case CSSPropertyWebkitFlexDirection: - case CSSPropertyWebkitFlexFlow: - case CSSPropertyWebkitFlexGrow: - case CSSPropertyWebkitFlexShrink: - case CSSPropertyWebkitFlexWrap: - case CSSPropertyWebkitJustifyContent: - case CSSPropertyWebkitOrder: + case CSSPropertyAlignContent: + case CSSPropertyAlignItems: + case CSSPropertyAlignSelf: + case CSSPropertyFlex: + case CSSPropertyFlexBasis: + case CSSPropertyFlexDirection: + case CSSPropertyFlexFlow: + case CSSPropertyFlexGrow: + case CSSPropertyFlexShrink: + case CSSPropertyFlexWrap: + case CSSPropertyJustifyContent: + case CSSPropertyOrder: case CSSPropertyWebkitFontSizeDelta: case CSSPropertyWebkitGridAutoColumns: case CSSPropertyWebkitGridAutoFlow: diff --git a/Source/WebCore/css/CSSPropertyNames.in b/Source/WebCore/css/CSSPropertyNames.in index 358ee2cbb..bc6f7066b 100644 --- a/Source/WebCore/css/CSSPropertyNames.in +++ b/Source/WebCore/css/CSSPropertyNames.in @@ -287,17 +287,28 @@ z-index #if defined(ENABLE_CSS_FILTERS) && ENABLE_CSS_FILTERS -webkit-filter #endif --webkit-align-content --webkit-align-items --webkit-align-self --webkit-flex --webkit-flex-basis --webkit-flex-direction --webkit-flex-flow --webkit-flex-grow --webkit-flex-shrink --webkit-flex-wrap --webkit-justify-content +align-content +-webkit-align-content = align-content +align-items +-webkit-align-items = align-items +align-self +-webkit-align-self = align-self +flex +-webkit-flex = flex +flex-basis +-webkit-flex-basis = flex-basis +flex-direction +-webkit-flex-direction = flex-direction +flex-flow +-webkit-flex-flow = flex-flow +flex-grow +-webkit-flex-grow = flex-grow +flex-shrink +-webkit-flex-shrink = flex-shrink +flex-wrap +-webkit-flex-wrap = flex-wrap +justify-content +-webkit-justify-content = justify-content -webkit-font-size-delta -webkit-grid-auto-columns -webkit-grid-auto-rows @@ -363,7 +374,8 @@ z-index -webkit-min-logical-width -webkit-min-logical-height -webkit-nbsp-mode --webkit-order +order +-webkit-order = order -webkit-padding-after -webkit-padding-before -webkit-padding-end diff --git a/Source/WebCore/css/CSSValueKeywords.in b/Source/WebCore/css/CSSValueKeywords.in index 679e736bf..dc7b34c26 100644 --- a/Source/WebCore/css/CSSValueKeywords.in +++ b/Source/WebCore/css/CSSValueKeywords.in @@ -341,7 +341,9 @@ table-cell table-caption -webkit-box -webkit-inline-box +flex -webkit-flex +inline-flex -webkit-inline-flex -webkit-grid -webkit-inline-grid diff --git a/Source/WebCore/css/DeprecatedStyleBuilder.cpp b/Source/WebCore/css/DeprecatedStyleBuilder.cpp index 1d52de322..66c5036d1 100644 --- a/Source/WebCore/css/DeprecatedStyleBuilder.cpp +++ b/Source/WebCore/css/DeprecatedStyleBuilder.cpp @@ -2269,17 +2269,17 @@ DeprecatedStyleBuilder::DeprecatedStyleBuilder() #if ENABLE(CURSOR_VISIBILITY) setPropertyHandler(CSSPropertyWebkitCursorVisibility, ApplyPropertyDefault::createHandler()); #endif - setPropertyHandler(CSSPropertyWebkitAlignContent, ApplyPropertyDefault::createHandler()); - setPropertyHandler(CSSPropertyWebkitAlignItems, ApplyPropertyDefault::createHandler()); - setPropertyHandler(CSSPropertyWebkitAlignSelf, ApplyPropertyDefault::createHandler()); - setPropertyHandler(CSSPropertyWebkitFlexBasis, ApplyPropertyLength<&RenderStyle::flexBasis, &RenderStyle::setFlexBasis, &RenderStyle::initialFlexBasis, AutoEnabled>::createHandler()); - setPropertyHandler(CSSPropertyWebkitFlexDirection, ApplyPropertyDefault::createHandler()); - setPropertyHandler(CSSPropertyWebkitFlexGrow, ApplyPropertyDefault::createHandler()); - setPropertyHandler(CSSPropertyWebkitFlexShrink, ApplyPropertyDefault::createHandler()); - setPropertyHandler(CSSPropertyWebkitFlexWrap, ApplyPropertyDefault::createHandler()); + setPropertyHandler(CSSPropertyAlignContent, ApplyPropertyDefault::createHandler()); + setPropertyHandler(CSSPropertyAlignItems, ApplyPropertyDefault::createHandler()); + setPropertyHandler(CSSPropertyAlignSelf, ApplyPropertyDefault::createHandler()); + setPropertyHandler(CSSPropertyFlexBasis, ApplyPropertyLength<&RenderStyle::flexBasis, &RenderStyle::setFlexBasis, &RenderStyle::initialFlexBasis, AutoEnabled>::createHandler()); + setPropertyHandler(CSSPropertyFlexDirection, ApplyPropertyDefault::createHandler()); + setPropertyHandler(CSSPropertyFlexGrow, ApplyPropertyDefault::createHandler()); + setPropertyHandler(CSSPropertyFlexShrink, ApplyPropertyDefault::createHandler()); + setPropertyHandler(CSSPropertyFlexWrap, ApplyPropertyDefault::createHandler()); setPropertyHandler(CSSPropertyWebkitGridAutoFlow, ApplyPropertyDefault::createHandler()); - setPropertyHandler(CSSPropertyWebkitJustifyContent, ApplyPropertyDefault::createHandler()); - setPropertyHandler(CSSPropertyWebkitOrder, ApplyPropertyDefault::createHandler()); + setPropertyHandler(CSSPropertyJustifyContent, ApplyPropertyDefault::createHandler()); + setPropertyHandler(CSSPropertyOrder, ApplyPropertyDefault::createHandler()); #if ENABLE(CSS_REGIONS) setPropertyHandler(CSSPropertyWebkitFlowFrom, ApplyPropertyString::createHandler()); setPropertyHandler(CSSPropertyWebkitFlowInto, ApplyPropertyString::createHandler()); diff --git a/Source/WebCore/css/StylePropertySet.cpp b/Source/WebCore/css/StylePropertySet.cpp index 75785bc04..a7e3555f8 100644 --- a/Source/WebCore/css/StylePropertySet.cpp +++ b/Source/WebCore/css/StylePropertySet.cpp @@ -160,10 +160,10 @@ String StylePropertySet::getPropertyValue(CSSPropertyID propertyID) const return getShorthandValue(webkitColumnRuleShorthand()); case CSSPropertyWebkitColumns: return getShorthandValue(webkitColumnsShorthand()); - case CSSPropertyWebkitFlex: - return getShorthandValue(webkitFlexShorthand()); - case CSSPropertyWebkitFlexFlow: - return getShorthandValue(webkitFlexFlowShorthand()); + case CSSPropertyFlex: + return getShorthandValue(flexShorthand()); + case CSSPropertyFlexFlow: + return getShorthandValue(flexFlowShorthand()); case CSSPropertyWebkitGridColumn: return getShorthandValue(webkitGridColumnShorthand()); case CSSPropertyWebkitGridRow: @@ -886,14 +886,14 @@ String StylePropertySet::asText() const case CSSPropertyWebkitAnimationFillMode: shorthandPropertyID = CSSPropertyWebkitAnimation; break; - case CSSPropertyWebkitFlexDirection: - case CSSPropertyWebkitFlexWrap: - shorthandPropertyID = CSSPropertyWebkitFlexFlow; + case CSSPropertyFlexDirection: + case CSSPropertyFlexWrap: + shorthandPropertyID = CSSPropertyFlexFlow; break; - case CSSPropertyWebkitFlexBasis: - case CSSPropertyWebkitFlexGrow: - case CSSPropertyWebkitFlexShrink: - shorthandPropertyID = CSSPropertyWebkitFlex; + case CSSPropertyFlexBasis: + case CSSPropertyFlexGrow: + case CSSPropertyFlexShrink: + shorthandPropertyID = CSSPropertyFlex; break; case CSSPropertyWebkitMaskPositionX: case CSSPropertyWebkitMaskPositionY: diff --git a/Source/WebCore/css/StylePropertyShorthand.cpp b/Source/WebCore/css/StylePropertyShorthand.cpp index ca4e8b2fa..be3001bf7 100644 --- a/Source/WebCore/css/StylePropertyShorthand.cpp +++ b/Source/WebCore/css/StylePropertyShorthand.cpp @@ -344,18 +344,18 @@ const StylePropertyShorthand& webkitColumnRuleShorthand() return webkitColumnRuleLonghands; } -const StylePropertyShorthand& webkitFlexFlowShorthand() +const StylePropertyShorthand& flexFlowShorthand() { - static const CSSPropertyID flexFlowProperties[] = { CSSPropertyWebkitFlexDirection, CSSPropertyWebkitFlexWrap }; - DEFINE_STATIC_LOCAL(StylePropertyShorthand, webkitFlexFlowLonghands, (flexFlowProperties, WTF_ARRAY_LENGTH(flexFlowProperties))); - return webkitFlexFlowLonghands; + static const CSSPropertyID flexFlowProperties[] = { CSSPropertyFlexDirection, CSSPropertyFlexWrap }; + DEFINE_STATIC_LOCAL(StylePropertyShorthand, flexFlowLonghands, (flexFlowProperties, WTF_ARRAY_LENGTH(flexFlowProperties))); + return flexFlowLonghands; } -const StylePropertyShorthand& webkitFlexShorthand() +const StylePropertyShorthand& flexShorthand() { - static const CSSPropertyID flexProperties[] = { CSSPropertyWebkitFlexGrow, CSSPropertyWebkitFlexShrink, CSSPropertyWebkitFlexBasis }; - DEFINE_STATIC_LOCAL(StylePropertyShorthand, webkitFlexLonghands, (flexProperties, WTF_ARRAY_LENGTH(flexProperties))); - return webkitFlexLonghands; + static const CSSPropertyID flexProperties[] = { CSSPropertyFlexGrow, CSSPropertyFlexShrink, CSSPropertyFlexBasis }; + DEFINE_STATIC_LOCAL(StylePropertyShorthand, flexLonghands, (flexProperties, WTF_ARRAY_LENGTH(flexProperties))); + return flexLonghands; } const StylePropertyShorthand& webkitMarginCollapseShorthand() @@ -532,10 +532,10 @@ const StylePropertyShorthand& shorthandForProperty(CSSPropertyID propertyID) return webkitColumnsShorthand(); case CSSPropertyWebkitColumnRule: return webkitColumnRuleShorthand(); - case CSSPropertyWebkitFlex: - return webkitFlexShorthand(); - case CSSPropertyWebkitFlexFlow: - return webkitFlexFlowShorthand(); + case CSSPropertyFlex: + return flexShorthand(); + case CSSPropertyFlexFlow: + return flexFlowShorthand(); case CSSPropertyWebkitGridColumn: return webkitGridColumnShorthand(); case CSSPropertyWebkitGridRow: diff --git a/Source/WebCore/css/StylePropertyShorthand.h b/Source/WebCore/css/StylePropertyShorthand.h index 2ae93563a..bcf0f03ec 100644 --- a/Source/WebCore/css/StylePropertyShorthand.h +++ b/Source/WebCore/css/StylePropertyShorthand.h @@ -75,6 +75,8 @@ const StylePropertyShorthand& borderStyleShorthand(); const StylePropertyShorthand& borderTopShorthand(); const StylePropertyShorthand& borderWidthShorthand(); const StylePropertyShorthand& listStyleShorthand(); +const StylePropertyShorthand& flexFlowShorthand(); +const StylePropertyShorthand& flexShorthand(); const StylePropertyShorthand& fontShorthand(); const StylePropertyShorthand& marginShorthand(); const StylePropertyShorthand& outlineShorthand(); @@ -89,8 +91,6 @@ const StylePropertyShorthand& webkitBorderEndShorthand(); const StylePropertyShorthand& webkitBorderStartShorthand(); const StylePropertyShorthand& webkitColumnsShorthand(); const StylePropertyShorthand& webkitColumnRuleShorthand(); -const StylePropertyShorthand& webkitFlexFlowShorthand(); -const StylePropertyShorthand& webkitFlexShorthand(); const StylePropertyShorthand& webkitGridColumnShorthand(); const StylePropertyShorthand& webkitGridRowShorthand(); const StylePropertyShorthand& webkitMarginCollapseShorthand(); diff --git a/Source/WebCore/css/StyleResolver.cpp b/Source/WebCore/css/StyleResolver.cpp index 2a09d30ba..b3f0cd5b1 100644 --- a/Source/WebCore/css/StyleResolver.cpp +++ b/Source/WebCore/css/StyleResolver.cpp @@ -1260,6 +1260,7 @@ static EDisplay equivalentBlockDisplay(EDisplay display, bool isFloating, bool s case TABLE: case BOX: case FLEX: + case WEBKIT_FLEX: case GRID: return display; @@ -1273,6 +1274,7 @@ static EDisplay equivalentBlockDisplay(EDisplay display, bool isFloating, bool s case INLINE_BOX: return BOX; case INLINE_FLEX: + case WEBKIT_INLINE_FLEX: return FLEX; case INLINE_GRID: return GRID; @@ -2439,8 +2441,8 @@ void StyleResolver::applyProperty(CSSPropertyID id, CSSValue* value) case CSSPropertyWebkitBorderRadius: case CSSPropertyWebkitColumns: case CSSPropertyWebkitColumnRule: - case CSSPropertyWebkitFlex: - case CSSPropertyWebkitFlexFlow: + case CSSPropertyFlex: + case CSSPropertyFlexFlow: case CSSPropertyWebkitGridColumn: case CSSPropertyWebkitGridRow: case CSSPropertyWebkitMarginCollapse: @@ -3012,16 +3014,16 @@ void StyleResolver::applyProperty(CSSPropertyID id, CSSValue* value) #if ENABLE(CURSOR_VISIBILITY) case CSSPropertyWebkitCursorVisibility: #endif - case CSSPropertyWebkitAlignContent: - case CSSPropertyWebkitAlignItems: - case CSSPropertyWebkitAlignSelf: - case CSSPropertyWebkitFlexBasis: - case CSSPropertyWebkitFlexDirection: - case CSSPropertyWebkitFlexGrow: - case CSSPropertyWebkitFlexShrink: - case CSSPropertyWebkitFlexWrap: - case CSSPropertyWebkitJustifyContent: - case CSSPropertyWebkitOrder: + case CSSPropertyAlignContent: + case CSSPropertyAlignItems: + case CSSPropertyAlignSelf: + case CSSPropertyFlexBasis: + case CSSPropertyFlexDirection: + case CSSPropertyFlexGrow: + case CSSPropertyFlexShrink: + case CSSPropertyFlexWrap: + case CSSPropertyJustifyContent: + case CSSPropertyOrder: #if ENABLE(CSS_REGIONS) case CSSPropertyWebkitFlowFrom: case CSSPropertyWebkitFlowInto: diff --git a/Source/WebCore/page/animation/CSSPropertyAnimation.cpp b/Source/WebCore/page/animation/CSSPropertyAnimation.cpp index a3d8ef8c8..197490195 100644 --- a/Source/WebCore/page/animation/CSSPropertyAnimation.cpp +++ b/Source/WebCore/page/animation/CSSPropertyAnimation.cpp @@ -927,7 +927,8 @@ private: class PropertyWrapperFlex : public AnimationPropertyWrapperBase { public: - PropertyWrapperFlex() : AnimationPropertyWrapperBase(CSSPropertyWebkitFlex) + PropertyWrapperFlex() + : AnimationPropertyWrapperBase(CSSPropertyFlex) { } diff --git a/Source/WebCore/rendering/RenderObject.cpp b/Source/WebCore/rendering/RenderObject.cpp index b93764828..655b79122 100644 --- a/Source/WebCore/rendering/RenderObject.cpp +++ b/Source/WebCore/rendering/RenderObject.cpp @@ -230,6 +230,8 @@ RenderObject* RenderObject::createObject(Element* element, RenderStyle* style) return new (arena) RenderDeprecatedFlexibleBox(element); case FLEX: case INLINE_FLEX: + case WEBKIT_FLEX: + case WEBKIT_INLINE_FLEX: return new (arena) RenderFlexibleBox(element); case GRID: case INLINE_GRID: diff --git a/Source/WebCore/rendering/style/RenderStyleConstants.h b/Source/WebCore/rendering/style/RenderStyleConstants.h index 830612e57..ef61f68c4 100644 --- a/Source/WebCore/rendering/style/RenderStyleConstants.h +++ b/Source/WebCore/rendering/style/RenderStyleConstants.h @@ -443,7 +443,7 @@ enum EDisplay { TABLE_HEADER_GROUP, TABLE_FOOTER_GROUP, TABLE_ROW, TABLE_COLUMN_GROUP, TABLE_COLUMN, TABLE_CELL, TABLE_CAPTION, BOX, INLINE_BOX, - FLEX, INLINE_FLEX, + FLEX, WEBKIT_FLEX, INLINE_FLEX, WEBKIT_INLINE_FLEX, GRID, INLINE_GRID, NONE }; -- cgit v1.2.3 From eeb5f111975e5dfba239d2476a41791f1c2780a6 Mon Sep 17 00:00:00 2001 From: Konstantin Tokarev Date: Mon, 19 Sep 2016 02:01:13 +0300 Subject: Avoid using QString when converting headers between WTF::String and QByteArray We should not convert Latin1 to UTF16 and back for each header of each HTTP request and response. In older WebKit versions String was always 16-bit, but now 8-bit is used wherever possible, and this is usually the case for HTTP headers. Change-Id: I642f65c614702aca4ad7a673f5073a8eaed5b46d Reviewed-by: Allan Sandfeld Jensen --- .../WebCore/platform/network/qt/QNetworkReplyHandler.cpp | 5 +++-- Source/WebCore/platform/network/qt/ResourceRequestQt.cpp | 16 +++++++++++----- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/Source/WebCore/platform/network/qt/QNetworkReplyHandler.cpp b/Source/WebCore/platform/network/qt/QNetworkReplyHandler.cpp index e07bc76a9..4a2121907 100644 --- a/Source/WebCore/platform/network/qt/QNetworkReplyHandler.cpp +++ b/Source/WebCore/platform/network/qt/QNetworkReplyHandler.cpp @@ -601,7 +601,8 @@ void QNetworkReplyHandler::sendResponseIfNeeded() int statusCode = m_replyWrapper->reply()->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt(); if (url.protocolIsInHTTPFamily()) { - String suggestedFilename = filenameFromHTTPContentDisposition(QString::fromLatin1(m_replyWrapper->reply()->rawHeader("Content-Disposition"))); + QByteArray contentDisposition = m_replyWrapper->reply()->rawHeader("Content-Disposition"); + String suggestedFilename = filenameFromHTTPContentDisposition(String(contentDisposition.constData(), contentDisposition.size())); if (!suggestedFilename.isEmpty()) response.setSuggestedFilename(suggestedFilename); @@ -626,7 +627,7 @@ void QNetworkReplyHandler::sendResponseIfNeeded() // Add remaining headers. foreach (const QNetworkReply::RawHeaderPair& pair, m_replyWrapper->reply()->rawHeaderPairs()) - response.setHTTPHeaderField(QString::fromLatin1(pair.first), QString::fromLatin1(pair.second)); + response.setHTTPHeaderField(String(pair.first.constData(), pair.first.size()), String(pair.second.constData(), pair.second.size())); } QUrl redirection = m_replyWrapper->reply()->attribute(QNetworkRequest::RedirectionTargetAttribute).toUrl(); diff --git a/Source/WebCore/platform/network/qt/ResourceRequestQt.cpp b/Source/WebCore/platform/network/qt/ResourceRequestQt.cpp index 46229027e..83c50062d 100644 --- a/Source/WebCore/platform/network/qt/ResourceRequestQt.cpp +++ b/Source/WebCore/platform/network/qt/ResourceRequestQt.cpp @@ -89,6 +89,13 @@ static void resolveBlobUrl(const QUrl& url, QUrl& resolvedUrl) } #endif +static inline QByteArray stringToByteArray(const String& string) +{ + if (string.is8Bit()) + return QByteArray(reinterpret_cast(string.characters8()), string.length()); + return QString(string).toLatin1(); +} + QNetworkRequest ResourceRequest::toNetworkRequest(NetworkingContext *context) const { QNetworkRequest request; @@ -105,14 +112,13 @@ QNetworkRequest ResourceRequest::toNetworkRequest(NetworkingContext *context) co const HTTPHeaderMap &headers = httpHeaderFields(); for (HTTPHeaderMap::const_iterator it = headers.begin(), end = headers.end(); it != end; ++it) { - QByteArray name = QString(it->key).toLatin1(); - QByteArray value = QString(it->value).toLatin1(); + QByteArray name = stringToByteArray(it->key); // QNetworkRequest::setRawHeader() would remove the header if the value is null // Make sure to set an empty header instead of null header. - if (!value.isNull()) - request.setRawHeader(name, value); + if (!it->value.isNull()) + request.setRawHeader(name, stringToByteArray(it->value)); else - request.setRawHeader(name, ""); + request.setRawHeader(name, QByteArrayLiteral("")); } // Make sure we always have an Accept header; some sites require this to -- cgit v1.2.3 From 0a5b725090f1db7d68b9293b11782411b7820f01 Mon Sep 17 00:00:00 2001 From: Vitaly Slobodin Date: Tue, 8 Mar 2016 13:47:53 +0300 Subject: Report JavaScript errors from Qt signals and slots Task-number: QTBUG-37899 Change-Id: Idcd92196a44cfac26c6943832bf8971ad70aec5e Reviewed-by: Allan Sandfeld Jensen --- Source/WebCore/bridge/qt/qt_runtime.cpp | 7 +++++- .../qt/tests/qobjectbridge/tst_qobjectbridge.cpp | 28 ++++++++++++++++++++++ 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/Source/WebCore/bridge/qt/qt_runtime.cpp b/Source/WebCore/bridge/qt/qt_runtime.cpp index 58259ff3e..cc1c19cf9 100644 --- a/Source/WebCore/bridge/qt/qt_runtime.cpp +++ b/Source/WebCore/bridge/qt/qt_runtime.cpp @@ -1577,7 +1577,12 @@ void QtConnectionObject::execute(void** argv) args[i] = convertQVariantToValue(m_context, m_rootObject, QVariant(argType, argv[i+1]), ignoredException); } - JSObjectCallAsFunction(m_context, m_receiverFunction, m_receiver, argc, args.data(), 0); + JSValueRef call_exception = 0; + ExecState* exec = toJS(m_context); + JSObjectCallAsFunction(m_context, m_receiverFunction, m_receiver, argc, args.data(), &call_exception); + if (call_exception) { + WebCore::reportException(exec, toJS(exec, call_exception)); + } } bool QtConnectionObject::match(JSContextRef context, QObject* sender, int signalIndex, JSObjectRef receiver, JSObjectRef receiverFunction) diff --git a/Source/WebKit/qt/tests/qobjectbridge/tst_qobjectbridge.cpp b/Source/WebKit/qt/tests/qobjectbridge/tst_qobjectbridge.cpp index 52e6422b1..18d82625c 100644 --- a/Source/WebKit/qt/tests/qobjectbridge/tst_qobjectbridge.cpp +++ b/Source/WebKit/qt/tests/qobjectbridge/tst_qobjectbridge.cpp @@ -642,6 +642,7 @@ private Q_SLOTS: void introspectQtMethods_data(); void introspectQtMethods(); void scriptablePlugin(); + void exceptionInSlot(); private: QString evalJS(const QString& s) @@ -2234,5 +2235,32 @@ void tst_QObjectBridge::scriptablePlugin() QCOMPARE(result.toString(), QLatin1String("42")); } +class WebPageWithConsoleCapture : public QWebPage +{ +public: + void javaScriptConsoleMessage(const QString &message, int, const QString &) + { + consoleMessages << message; + } + + QStringList consoleMessages; +}; + +void tst_QObjectBridge::exceptionInSlot() +{ + WebPageWithConsoleCapture page; + QWebFrame* frame = page.mainFrame(); + frame->addToJavaScriptWindowObject("myObject", m_myObject); + frame->evaluateJavaScript( + "myHandler = function() { window.gotSignal = true; throw 'exception in slot'; };" + "myObject.mySignal.connect(myHandler);" + "gotSignal = false;" + "myObject.mySignal();" + ); + QString ret = frame->evaluateJavaScript("gotSignal").toString(); + QCOMPARE(ret, sTrue); + QCOMPARE(page.consoleMessages, QStringList() << "exception in slot"); +} + QTEST_MAIN(tst_QObjectBridge) #include "tst_qobjectbridge.moc" -- cgit v1.2.3 From dbc4556842aa6541b9c8ce48fe34a36811709e64 Mon Sep 17 00:00:00 2001 From: Konstantin Tokarev Date: Fri, 30 Sep 2016 18:02:56 +0300 Subject: Fixed checkbox and radiobutton indicators When layout rect is smaller than indicator its edges may not be repainted properly. Now we center indicator repsectively to layout rect and inflate repaint rect to cover edges. Also, when layout rect is larger than indicator, QStyle code paints it at the top-left corner of given rect. Now indicator is centered, like other browser engines do. Note that when layout has auto size for checkbox or radiobutton, their sizes are adjust beforehand in RenderThemeQStyle::computeSizeBasedOnStyle(). This code path is require only when layout forces checkbox or radiobutton to be smaller than optimal indicator size. Task-number: QTBUG-56302 Change-Id: Idaefffc5775055514a430216ea265af2b3a039b4 Reviewed-by: Allan Sandfeld Jensen --- Source/WebCore/platform/qt/QStyleFacade.h | 2 + Source/WebCore/platform/qt/RenderThemeQStyle.cpp | 49 +++++++++++++++++++++- Source/WebCore/platform/qt/RenderThemeQStyle.h | 5 ++- Source/WebCore/platform/qt/RenderThemeQt.cpp | 10 +++++ Source/WebCore/platform/qt/RenderThemeQt.h | 3 ++ Source/WebKit/qt/WidgetSupport/QStyleFacadeImp.cpp | 2 + 6 files changed, 68 insertions(+), 3 deletions(-) diff --git a/Source/WebCore/platform/qt/QStyleFacade.h b/Source/WebCore/platform/qt/QStyleFacade.h index fe7ead1d0..25d3a7dce 100644 --- a/Source/WebCore/platform/qt/QStyleFacade.h +++ b/Source/WebCore/platform/qt/QStyleFacade.h @@ -38,6 +38,8 @@ class QStyleFacadeOption; class QStyleFacade { public: enum ButtonSubElement { + CheckBoxIndicator, + RadioButtonIndicator, PushButtonLayoutItem, PushButtonContents }; diff --git a/Source/WebCore/platform/qt/RenderThemeQStyle.cpp b/Source/WebCore/platform/qt/RenderThemeQStyle.cpp index 999c670c4..9f3d50a2d 100644 --- a/Source/WebCore/platform/qt/RenderThemeQStyle.cpp +++ b/Source/WebCore/platform/qt/RenderThemeQStyle.cpp @@ -62,6 +62,20 @@ namespace WebCore { using namespace HTMLNames; +static QStyleFacade::ButtonSubElement indicatorSubElement(QStyleFacade::ButtonType part) +{ + switch (part) { + case QStyleFacade::CheckBox: + return QStyleFacade::CheckBoxIndicator; + case QStyleFacade::RadioButton: + return QStyleFacade::RadioButtonIndicator; + default: + break; + } + ASSERT_NOT_REACHED(); + return QStyleFacade::CheckBoxIndicator; +} + QSharedPointer RenderThemeQStyle::getStylePainter(const PaintInfo& paintInfo) { return QSharedPointer(new StylePainterQStyle(this, paintInfo, /*RenderObject*/0)); @@ -139,6 +153,11 @@ void RenderThemeQStyle::setPaletteFromPageClientIfExists(QPalette& palette) cons palette = pageClient->palette(); } +QRect RenderThemeQStyle::indicatorRect(QStyleFacade::ButtonType part, const QRect& originalRect) const +{ + return m_qStyle->buttonSubElementRect(indicatorSubElement(part), QStyleFacade::State_Small, originalRect); +} + QRect RenderThemeQStyle::inflateButtonRect(const QRect& originalRect) const { QRect layoutRect = m_qStyle->buttonSubElementRect(QStyleFacade::PushButtonLayoutItem, QStyleFacade::State_Small, originalRect); @@ -153,6 +172,29 @@ QRect RenderThemeQStyle::inflateButtonRect(const QRect& originalRect) const return originalRect; } +template +static void inflateCheckBoxRectImpl(T& originalRect, const QRect& rect) +{ + if (!rect.isNull()) { + int dx = static_cast((rect.width() - originalRect.width()) / 2); + originalRect.setX(originalRect.x() - dx); + originalRect.setWidth(rect.width()); + int dy = static_cast((rect.height() - originalRect.height()) / 2); + originalRect.setY(originalRect.y() - dy); + originalRect.setHeight(rect.height()); + } +} + +void RenderThemeQStyle::computeControlRect(QStyleFacade::ButtonType part, QRect& originalRect) const +{ + inflateCheckBoxRectImpl(originalRect, indicatorRect(part, originalRect)); +} + +void RenderThemeQStyle::computeControlRect(QStyleFacade::ButtonType part, IntRect& originalRect) const +{ + inflateCheckBoxRectImpl(originalRect, indicatorRect(part, originalRect)); +} + int extendFixedPadding(Length oldPadding, int padding) { if (oldPadding.isFixed()) { return std::max(oldPadding.intValue(), padding); @@ -306,10 +348,13 @@ bool RenderThemeQStyle::paintButton(RenderObject* o, const PaintInfo& i, const I if (p.appearance == PushButtonPart || p.appearance == ButtonPart) { p.styleOption.rect = inflateButtonRect(p.styleOption.rect); p.paintButton(QStyleFacade::PushButton); - } else if (p.appearance == RadioPart) + } else if (p.appearance == RadioPart) { + computeControlRect(QStyleFacade::RadioButton, p.styleOption.rect); p.paintButton(QStyleFacade::RadioButton); - else if (p.appearance == CheckboxPart) + } else if (p.appearance == CheckboxPart) { + computeControlRect(QStyleFacade::CheckBox, p.styleOption.rect); p.paintButton(QStyleFacade::CheckBox); + } return false; } diff --git a/Source/WebCore/platform/qt/RenderThemeQStyle.h b/Source/WebCore/platform/qt/RenderThemeQStyle.h index 6027f16e5..781e066ae 100644 --- a/Source/WebCore/platform/qt/RenderThemeQStyle.h +++ b/Source/WebCore/platform/qt/RenderThemeQStyle.h @@ -22,7 +22,6 @@ #ifndef RenderThemeQStyle_h #define RenderThemeQStyle_h -#include "QStyleFacade.h" #include "RenderThemeQt.h" namespace WebCore { @@ -96,6 +95,8 @@ protected: virtual QSharedPointer getStylePainter(const PaintInfo&); virtual QRect inflateButtonRect(const QRect& originalRect) const; + void computeControlRect(QStyleFacade::ButtonType, QRect& originalRect) const OVERRIDE; + void computeControlRect(QStyleFacade::ButtonType, IntRect& originalRect) const OVERRIDE; virtual void setPopupPadding(RenderStyle*) const; @@ -108,6 +109,8 @@ private: void setPaletteFromPageClientIfExists(QPalette&) const; + QRect indicatorRect(QStyleFacade::ButtonType part, const QRect& originalRect) const; + #ifdef Q_OS_MAC int m_buttonFontPixelSize; #endif diff --git a/Source/WebCore/platform/qt/RenderThemeQt.cpp b/Source/WebCore/platform/qt/RenderThemeQt.cpp index 8a6232ea9..9bb1b5139 100644 --- a/Source/WebCore/platform/qt/RenderThemeQt.cpp +++ b/Source/WebCore/platform/qt/RenderThemeQt.cpp @@ -211,12 +211,22 @@ QRect RenderThemeQt::inflateButtonRect(const QRect& originalRect) const return originalRect; } +void RenderThemeQt::computeControlRect(QStyleFacade::ButtonType, QRect&) const +{ +} + +void RenderThemeQt::computeControlRect(QStyleFacade::ButtonType, IntRect&) const +{ +} + void RenderThemeQt::adjustRepaintRect(const RenderObject* o, IntRect& rect) { switch (o->style()->appearance()) { case CheckboxPart: + computeControlRect(QStyleFacade::CheckBox, rect); break; case RadioPart: + computeControlRect(QStyleFacade::RadioButton, rect); break; case PushButtonPart: case ButtonPart: { diff --git a/Source/WebCore/platform/qt/RenderThemeQt.h b/Source/WebCore/platform/qt/RenderThemeQt.h index 7d464d7ec..fb021f3d0 100644 --- a/Source/WebCore/platform/qt/RenderThemeQt.h +++ b/Source/WebCore/platform/qt/RenderThemeQt.h @@ -22,6 +22,7 @@ #ifndef RenderThemeQt_h #define RenderThemeQt_h +#include "QStyleFacade.h" #include "RenderTheme.h" #include @@ -168,6 +169,8 @@ protected: virtual String fileListNameForWidth(const FileList*, const Font&, int width, bool multipleFilesAllowed) const OVERRIDE; virtual QRect inflateButtonRect(const QRect& originalRect) const; + virtual void computeControlRect(QStyleFacade::ButtonType, QRect& originalRect) const; + virtual void computeControlRect(QStyleFacade::ButtonType, IntRect& originalRect) const; virtual void setPopupPadding(RenderStyle*) const = 0; diff --git a/Source/WebKit/qt/WidgetSupport/QStyleFacadeImp.cpp b/Source/WebKit/qt/WidgetSupport/QStyleFacadeImp.cpp index 6881d9d74..e36b5bd20 100644 --- a/Source/WebKit/qt/WidgetSupport/QStyleFacadeImp.cpp +++ b/Source/WebKit/qt/WidgetSupport/QStyleFacadeImp.cpp @@ -163,6 +163,8 @@ QRect QStyleFacadeImp::buttonSubElementRect(QStyleFacade::ButtonSubElement butto QStyle::SubElement subElement = QStyle::SE_CustomBase; switch (buttonElement) { + case CheckBoxIndicator: subElement = QStyle::SE_CheckBoxIndicator; break; + case RadioButtonIndicator: subElement = QStyle::SE_RadioButtonIndicator; break; case PushButtonLayoutItem: subElement = QStyle::SE_PushButtonLayoutItem; break; case PushButtonContents: subElement = QStyle::SE_PushButtonContents; break; default: ASSERT_NOT_REACHED(); -- cgit v1.2.3 From 45411b453d553abee71e61938c3e87af043cd044 Mon Sep 17 00:00:00 2001 From: Konstantin Tokarev Date: Mon, 10 Oct 2016 18:44:09 +0300 Subject: Added missing Q_DECL_OVERRIDEs to QtWebKitWidgets headers Change-Id: I2ab9287f17155b18f8caee3866d4125d4451a078 Reviewed-by: Allan Sandfeld Jensen --- Source/WebKit/qt/WidgetApi/qgraphicswebview.h | 54 +++++++++++------------ Source/WebKit/qt/WidgetApi/qwebframe.h | 2 +- Source/WebKit/qt/WidgetApi/qwebinspector.h | 12 ++--- Source/WebKit/qt/WidgetApi/qwebpage.h | 2 +- Source/WebKit/qt/WidgetApi/qwebview.h | 48 ++++++++++---------- Source/WebKit/qt/WidgetApi/qwebviewaccessible_p.h | 32 +++++++------- 6 files changed, 75 insertions(+), 75 deletions(-) diff --git a/Source/WebKit/qt/WidgetApi/qgraphicswebview.h b/Source/WebKit/qt/WidgetApi/qgraphicswebview.h index 0d990086f..1aa5b66c8 100644 --- a/Source/WebKit/qt/WidgetApi/qgraphicswebview.h +++ b/Source/WebKit/qt/WidgetApi/qgraphicswebview.h @@ -92,15 +92,15 @@ public: bool isTiledBackingStoreFrozen() const; void setTiledBackingStoreFrozen(bool frozen); - virtual void setGeometry(const QRectF& rect); - virtual void updateGeometry(); - virtual void paint(QPainter*, const QStyleOptionGraphicsItem* options, QWidget* widget = Q_NULLPTR); - virtual QVariant itemChange(GraphicsItemChange change, const QVariant& value); - virtual bool event(QEvent*); + void setGeometry(const QRectF& rect) Q_DECL_OVERRIDE; + void updateGeometry() Q_DECL_OVERRIDE; + void paint(QPainter*, const QStyleOptionGraphicsItem* options, QWidget* widget = Q_NULLPTR) Q_DECL_OVERRIDE; + QVariant itemChange(GraphicsItemChange change, const QVariant& value) Q_DECL_OVERRIDE; + bool event(QEvent*) Q_DECL_OVERRIDE; - virtual QSizeF sizeHint(Qt::SizeHint which, const QSizeF& constraint) const; + QSizeF sizeHint(Qt::SizeHint which, const QSizeF& constraint) const Q_DECL_OVERRIDE; - virtual QVariant inputMethodQuery(Qt::InputMethodQuery query) const; + QVariant inputMethodQuery(Qt::InputMethodQuery query) const Q_DECL_OVERRIDE; QPainter::RenderHints renderHints() const; void setRenderHints(QPainter::RenderHints); @@ -124,30 +124,30 @@ Q_SIGNALS: void linkClicked(const QUrl&); protected: - virtual void mousePressEvent(QGraphicsSceneMouseEvent*); - virtual void mouseDoubleClickEvent(QGraphicsSceneMouseEvent*); - virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent*); - virtual void mouseMoveEvent(QGraphicsSceneMouseEvent*); - virtual void hoverMoveEvent(QGraphicsSceneHoverEvent*); - virtual void hoverLeaveEvent(QGraphicsSceneHoverEvent*); + void mousePressEvent(QGraphicsSceneMouseEvent*) Q_DECL_OVERRIDE; + void mouseDoubleClickEvent(QGraphicsSceneMouseEvent*) Q_DECL_OVERRIDE; + void mouseReleaseEvent(QGraphicsSceneMouseEvent*) Q_DECL_OVERRIDE; + void mouseMoveEvent(QGraphicsSceneMouseEvent*) Q_DECL_OVERRIDE; + void hoverMoveEvent(QGraphicsSceneHoverEvent*) Q_DECL_OVERRIDE; + void hoverLeaveEvent(QGraphicsSceneHoverEvent*) Q_DECL_OVERRIDE; #ifndef QT_NO_WHEELEVENT - virtual void wheelEvent(QGraphicsSceneWheelEvent*); + void wheelEvent(QGraphicsSceneWheelEvent*) Q_DECL_OVERRIDE; #endif - virtual void keyPressEvent(QKeyEvent*); - virtual void keyReleaseEvent(QKeyEvent*); + void keyPressEvent(QKeyEvent*) Q_DECL_OVERRIDE; + void keyReleaseEvent(QKeyEvent*) Q_DECL_OVERRIDE; #ifndef QT_NO_CONTEXTMENU - virtual void contextMenuEvent(QGraphicsSceneContextMenuEvent*); + void contextMenuEvent(QGraphicsSceneContextMenuEvent*) Q_DECL_OVERRIDE; #endif - virtual void dragEnterEvent(QGraphicsSceneDragDropEvent*); - virtual void dragLeaveEvent(QGraphicsSceneDragDropEvent*); - virtual void dragMoveEvent(QGraphicsSceneDragDropEvent*); - virtual void dropEvent(QGraphicsSceneDragDropEvent*); - virtual void focusInEvent(QFocusEvent*); - virtual void focusOutEvent(QFocusEvent*); - virtual void inputMethodEvent(QInputMethodEvent*); - virtual bool focusNextPrevChild(bool next); - - virtual bool sceneEvent(QEvent*); + void dragEnterEvent(QGraphicsSceneDragDropEvent*) Q_DECL_OVERRIDE; + void dragLeaveEvent(QGraphicsSceneDragDropEvent*) Q_DECL_OVERRIDE; + void dragMoveEvent(QGraphicsSceneDragDropEvent*) Q_DECL_OVERRIDE; + void dropEvent(QGraphicsSceneDragDropEvent*) Q_DECL_OVERRIDE; + void focusInEvent(QFocusEvent*) Q_DECL_OVERRIDE; + void focusOutEvent(QFocusEvent*) Q_DECL_OVERRIDE; + void inputMethodEvent(QInputMethodEvent*) Q_DECL_OVERRIDE; + bool focusNextPrevChild(bool next) Q_DECL_OVERRIDE; + + bool sceneEvent(QEvent*) Q_DECL_OVERRIDE; private: Q_PRIVATE_SLOT(d, void _q_doLoadFinished(bool success)) diff --git a/Source/WebKit/qt/WidgetApi/qwebframe.h b/Source/WebKit/qt/WidgetApi/qwebframe.h index 619594336..1c3cb07c3 100644 --- a/Source/WebKit/qt/WidgetApi/qwebframe.h +++ b/Source/WebKit/qt/WidgetApi/qwebframe.h @@ -202,7 +202,7 @@ public: QWebHitTestResult hitTestContent(const QPoint &pos) const; - virtual bool event(QEvent *); + bool event(QEvent *) Q_DECL_OVERRIDE; QWebSecurityOrigin securityOrigin() const; QWebFrameAdapter* handle() const; diff --git a/Source/WebKit/qt/WidgetApi/qwebinspector.h b/Source/WebKit/qt/WidgetApi/qwebinspector.h index d6a4aad3c..c5f097e27 100644 --- a/Source/WebKit/qt/WidgetApi/qwebinspector.h +++ b/Source/WebKit/qt/WidgetApi/qwebinspector.h @@ -36,14 +36,14 @@ public: void setPage(QWebPage* page); QWebPage* page() const; - QSize sizeHint() const; - bool event(QEvent*); + QSize sizeHint() const Q_DECL_OVERRIDE; + bool event(QEvent*) Q_DECL_OVERRIDE; protected: - void resizeEvent(QResizeEvent* event); - void showEvent(QShowEvent* event); - void hideEvent(QHideEvent* event); - void closeEvent(QCloseEvent* event); + void resizeEvent(QResizeEvent* event) Q_DECL_OVERRIDE; + void showEvent(QShowEvent* event) Q_DECL_OVERRIDE; + void hideEvent(QHideEvent* event) Q_DECL_OVERRIDE; + void closeEvent(QCloseEvent* event) Q_DECL_OVERRIDE; private: QWebInspectorPrivate* d; diff --git a/Source/WebKit/qt/WidgetApi/qwebpage.h b/Source/WebKit/qt/WidgetApi/qwebpage.h index a9c71fd42..01e77d44b 100644 --- a/Source/WebKit/qt/WidgetApi/qwebpage.h +++ b/Source/WebKit/qt/WidgetApi/qwebpage.h @@ -312,7 +312,7 @@ public: void setPreferredContentsSize(const QSize &size) const; void setActualVisibleContentRect(const QRect& rect) const; - virtual bool event(QEvent*); + bool event(QEvent*) Q_DECL_OVERRIDE; bool focusNextPrevChild(bool next); QVariant inputMethodQuery(Qt::InputMethodQuery property) const; diff --git a/Source/WebKit/qt/WidgetApi/qwebview.h b/Source/WebKit/qt/WidgetApi/qwebview.h index ac0946773..0ed324da1 100644 --- a/Source/WebKit/qt/WidgetApi/qwebview.h +++ b/Source/WebKit/qt/WidgetApi/qwebview.h @@ -55,7 +55,7 @@ class QWEBKITWIDGETS_EXPORT QWebView : public QWidget { Q_FLAGS(QPainter::RenderHints) public: explicit QWebView(QWidget* parent = Q_NULLPTR); - virtual ~QWebView(); + ~QWebView(); QWebPage* page() const; void setPage(QWebPage* page); @@ -90,9 +90,9 @@ public: void setTextInteractionFlag(Qt::TextInteractionFlag flag); */ - QVariant inputMethodQuery(Qt::InputMethodQuery property) const; + QVariant inputMethodQuery(Qt::InputMethodQuery property) const Q_DECL_OVERRIDE; - QSize sizeHint() const; + QSize sizeHint() const Q_DECL_OVERRIDE; qreal zoomFactor() const; void setZoomFactor(qreal factor); @@ -106,7 +106,7 @@ public: bool findText(const QString& subString, QWebPage::FindFlags options = QWebPage::FindFlags()); - virtual bool event(QEvent*); + bool event(QEvent*) Q_DECL_OVERRIDE; public Q_SLOTS: void stop(); @@ -128,33 +128,33 @@ Q_SIGNALS: void urlChanged(const QUrl&); protected: - void resizeEvent(QResizeEvent*); - void paintEvent(QPaintEvent*); + void resizeEvent(QResizeEvent*) Q_DECL_OVERRIDE; + void paintEvent(QPaintEvent*) Q_DECL_OVERRIDE; virtual QWebView *createWindow(QWebPage::WebWindowType type); - virtual void changeEvent(QEvent*); - virtual void mouseMoveEvent(QMouseEvent*); - virtual void mousePressEvent(QMouseEvent*); - virtual void mouseDoubleClickEvent(QMouseEvent*); - virtual void mouseReleaseEvent(QMouseEvent*); + void changeEvent(QEvent*) Q_DECL_OVERRIDE; + void mouseMoveEvent(QMouseEvent*) Q_DECL_OVERRIDE; + void mousePressEvent(QMouseEvent*) Q_DECL_OVERRIDE; + void mouseDoubleClickEvent(QMouseEvent*) Q_DECL_OVERRIDE; + void mouseReleaseEvent(QMouseEvent*) Q_DECL_OVERRIDE; #ifndef QT_NO_CONTEXTMENU - virtual void contextMenuEvent(QContextMenuEvent*); + void contextMenuEvent(QContextMenuEvent*) Q_DECL_OVERRIDE; #endif #ifndef QT_NO_WHEELEVENT - virtual void wheelEvent(QWheelEvent*); + void wheelEvent(QWheelEvent*) Q_DECL_OVERRIDE; #endif - virtual void keyPressEvent(QKeyEvent*); - virtual void keyReleaseEvent(QKeyEvent*); - virtual void dragEnterEvent(QDragEnterEvent*); - virtual void dragLeaveEvent(QDragLeaveEvent*); - virtual void dragMoveEvent(QDragMoveEvent*); - virtual void dropEvent(QDropEvent*); - virtual void focusInEvent(QFocusEvent*); - virtual void focusOutEvent(QFocusEvent*); - virtual void inputMethodEvent(QInputMethodEvent*); - - virtual bool focusNextPrevChild(bool next); + void keyPressEvent(QKeyEvent*) Q_DECL_OVERRIDE; + void keyReleaseEvent(QKeyEvent*) Q_DECL_OVERRIDE; + void dragEnterEvent(QDragEnterEvent*) Q_DECL_OVERRIDE; + void dragLeaveEvent(QDragLeaveEvent*) Q_DECL_OVERRIDE; + void dragMoveEvent(QDragMoveEvent*) Q_DECL_OVERRIDE; + void dropEvent(QDropEvent*) Q_DECL_OVERRIDE; + void focusInEvent(QFocusEvent*) Q_DECL_OVERRIDE; + void focusOutEvent(QFocusEvent*) Q_DECL_OVERRIDE; + void inputMethodEvent(QInputMethodEvent*) Q_DECL_OVERRIDE; + + bool focusNextPrevChild(bool next) Q_DECL_OVERRIDE; private: friend class QWebPage; diff --git a/Source/WebKit/qt/WidgetApi/qwebviewaccessible_p.h b/Source/WebKit/qt/WidgetApi/qwebviewaccessible_p.h index 7cbf44870..c68cc9011 100644 --- a/Source/WebKit/qt/WidgetApi/qwebviewaccessible_p.h +++ b/Source/WebKit/qt/WidgetApi/qwebviewaccessible_p.h @@ -41,15 +41,15 @@ public: QWebFrame* frame() const; - QAccessibleInterface* parent() const; - int childCount() const; - QAccessibleInterface* child(int index) const; - int indexOfChild(const QAccessibleInterface*) const; + QAccessibleInterface* parent() const Q_DECL_OVERRIDE; + int childCount() const Q_DECL_OVERRIDE; + QAccessibleInterface* child(int index) const Q_DECL_OVERRIDE; + int indexOfChild(const QAccessibleInterface*) const Q_DECL_OVERRIDE; int navigate(QAccessible::RelationFlag, int, QAccessibleInterface** target) const; - QString text(QAccessible::Text) const; - QAccessible::Role role() const; - QAccessible::State state() const; + QString text(QAccessible::Text) const Q_DECL_OVERRIDE; + QAccessible::Role role() const Q_DECL_OVERRIDE; + QAccessible::State state() const Q_DECL_OVERRIDE; }; class QWebPageAccessible : public QAccessibleObject { @@ -58,15 +58,15 @@ public: QWebPage* page() const; - QAccessibleInterface* parent() const; - int childCount() const; - QAccessibleInterface* child(int index) const; - int indexOfChild(const QAccessibleInterface*) const; + QAccessibleInterface* parent() const Q_DECL_OVERRIDE; + int childCount() const Q_DECL_OVERRIDE; + QAccessibleInterface* child(int index) const Q_DECL_OVERRIDE; + int indexOfChild(const QAccessibleInterface*) const Q_DECL_OVERRIDE; int navigate(QAccessible::RelationFlag, int, QAccessibleInterface** target) const; - QString text(QAccessible::Text) const; - QAccessible::Role role() const; - QAccessible::State state() const; + QString text(QAccessible::Text) const Q_DECL_OVERRIDE; + QAccessible::Role role() const Q_DECL_OVERRIDE; + QAccessible::State state() const Q_DECL_OVERRIDE; }; class QWebViewAccessible : public QAccessibleWidget { @@ -75,8 +75,8 @@ public: QWebView* view() const; - int childCount() const; - QAccessibleInterface* child(int index) const; + int childCount() const Q_DECL_OVERRIDE; + QAccessibleInterface* child(int index) const Q_DECL_OVERRIDE; }; #endif -- cgit v1.2.3 From 766858f1879ed03fcc8776df3bff2cc97dd60a97 Mon Sep 17 00:00:00 2001 From: Konstantin Tokarev Date: Mon, 10 Oct 2016 20:11:44 +0300 Subject: Added missing Q_DECL_OVERRIDEs to QML API headers Change-Id: Ic8f0fc6fe055cd432aaff8e46d62c0f8d41e61f8 Reviewed-by: Allan Sandfeld Jensen --- Source/WebKit2/UIProcess/API/qt/qquickwebpage_p.h | 2 +- Source/WebKit2/UIProcess/API/qt/qquickwebview_p.h | 46 +++++++++++----------- .../WebKit2/UIProcess/API/qt/qquickwebview_p_p.h | 22 +++++------ .../UIProcess/API/qt/qwebiconimageprovider_p.h | 2 +- .../UIProcess/API/qt/qwebnavigationhistory_p.h | 6 +-- 5 files changed, 39 insertions(+), 39 deletions(-) diff --git a/Source/WebKit2/UIProcess/API/qt/qquickwebpage_p.h b/Source/WebKit2/UIProcess/API/qt/qquickwebpage_p.h index e2aaa6c38..988135877 100644 --- a/Source/WebKit2/UIProcess/API/qt/qquickwebpage_p.h +++ b/Source/WebKit2/UIProcess/API/qt/qquickwebpage_p.h @@ -44,7 +44,7 @@ public: QTransform transformToItem() const; protected: - virtual QSGNode* updatePaintNode(QSGNode*, UpdatePaintNodeData*); + QSGNode* updatePaintNode(QSGNode*, UpdatePaintNodeData*) Q_DECL_OVERRIDE; private: QQuickWebPagePrivate* d; diff --git a/Source/WebKit2/UIProcess/API/qt/qquickwebview_p.h b/Source/WebKit2/UIProcess/API/qt/qquickwebview_p.h index 1daf5db0a..c06f8f219 100644 --- a/Source/WebKit2/UIProcess/API/qt/qquickwebview_p.h +++ b/Source/WebKit2/UIProcess/API/qt/qquickwebview_p.h @@ -136,7 +136,7 @@ public: bool canGoForward() const; bool loading() const; - virtual QVariant inputMethodQuery(Qt::InputMethodQuery property) const; + QVariant inputMethodQuery(Qt::InputMethodQuery property) const Q_DECL_OVERRIDE; QPointF mapToWebContent(const QPointF&) const; QRectF mapRectToWebContent(const QRectF&) const; @@ -177,28 +177,28 @@ Q_SIGNALS: void navigationRequested(QWebNavigationRequest* request); protected: - virtual bool childMouseEventFilter(QQuickItem*, QEvent*); - virtual void geometryChanged(const QRectF&, const QRectF&); - virtual void componentComplete(); - virtual void keyPressEvent(QKeyEvent*); - virtual void keyReleaseEvent(QKeyEvent*); - virtual void inputMethodEvent(QInputMethodEvent*); - virtual void focusInEvent(QFocusEvent*); - virtual void itemChange(ItemChange change, const ItemChangeData &value); - virtual void touchEvent(QTouchEvent*); - virtual void mousePressEvent(QMouseEvent*); - virtual void mouseMoveEvent(QMouseEvent*); - virtual void mouseReleaseEvent(QMouseEvent *); - virtual void mouseDoubleClickEvent(QMouseEvent*); - virtual void wheelEvent(QWheelEvent*); - virtual void hoverEnterEvent(QHoverEvent*); - virtual void hoverMoveEvent(QHoverEvent*); - virtual void hoverLeaveEvent(QHoverEvent*); - virtual void dragMoveEvent(QDragMoveEvent*); - virtual void dragEnterEvent(QDragEnterEvent*); - virtual void dragLeaveEvent(QDragLeaveEvent*); - virtual void dropEvent(QDropEvent*); - virtual bool event(QEvent*); + bool childMouseEventFilter(QQuickItem*, QEvent*) Q_DECL_OVERRIDE; + void geometryChanged(const QRectF&, const QRectF&) Q_DECL_OVERRIDE; + void componentComplete() Q_DECL_OVERRIDE; + void keyPressEvent(QKeyEvent*) Q_DECL_OVERRIDE; + void keyReleaseEvent(QKeyEvent*) Q_DECL_OVERRIDE; + void inputMethodEvent(QInputMethodEvent*) Q_DECL_OVERRIDE; + void focusInEvent(QFocusEvent*) Q_DECL_OVERRIDE; + void itemChange(ItemChange change, const ItemChangeData &value) Q_DECL_OVERRIDE; + void touchEvent(QTouchEvent*) Q_DECL_OVERRIDE; + void mousePressEvent(QMouseEvent*) Q_DECL_OVERRIDE; + void mouseMoveEvent(QMouseEvent*) Q_DECL_OVERRIDE; + void mouseReleaseEvent(QMouseEvent *) Q_DECL_OVERRIDE; + void mouseDoubleClickEvent(QMouseEvent*) Q_DECL_OVERRIDE; + void wheelEvent(QWheelEvent*) Q_DECL_OVERRIDE; + void hoverEnterEvent(QHoverEvent*) Q_DECL_OVERRIDE; + void hoverMoveEvent(QHoverEvent*) Q_DECL_OVERRIDE; + void hoverLeaveEvent(QHoverEvent*) Q_DECL_OVERRIDE; + void dragMoveEvent(QDragMoveEvent*) Q_DECL_OVERRIDE; + void dragEnterEvent(QDragEnterEvent*) Q_DECL_OVERRIDE; + void dragLeaveEvent(QDragLeaveEvent*) Q_DECL_OVERRIDE; + void dropEvent(QDropEvent*) Q_DECL_OVERRIDE; + bool event(QEvent*) Q_DECL_OVERRIDE; private: Q_DECLARE_PRIVATE(QQuickWebView) diff --git a/Source/WebKit2/UIProcess/API/qt/qquickwebview_p_p.h b/Source/WebKit2/UIProcess/API/qt/qquickwebview_p_p.h index a7358b5cf..ea7ded46b 100644 --- a/Source/WebKit2/UIProcess/API/qt/qquickwebview_p_p.h +++ b/Source/WebKit2/UIProcess/API/qt/qquickwebview_p_p.h @@ -231,28 +231,28 @@ class QQuickWebViewLegacyPrivate : public QQuickWebViewPrivate { Q_DECLARE_PUBLIC(QQuickWebView) public: QQuickWebViewLegacyPrivate(QQuickWebView* viewport); - virtual void initialize(WKContextRef contextRef = 0, WKPageGroupRef pageGroupRef = 0); + void initialize(WKContextRef contextRef = 0, WKPageGroupRef pageGroupRef = 0) Q_DECL_OVERRIDE; - virtual void updateViewportSize(); + void updateViewportSize() Q_DECL_OVERRIDE; - qreal zoomFactor() const; - void setZoomFactor(qreal); + qreal zoomFactor() const Q_DECL_OVERRIDE; + void setZoomFactor(qreal) Q_DECL_OVERRIDE; }; class QQuickWebViewFlickablePrivate : public QQuickWebViewPrivate { Q_DECLARE_PUBLIC(QQuickWebView) public: QQuickWebViewFlickablePrivate(QQuickWebView* viewport); - virtual void initialize(WKContextRef contextRef = 0, WKPageGroupRef pageGroupRef = 0); + void initialize(WKContextRef contextRef = 0, WKPageGroupRef pageGroupRef = 0) Q_DECL_OVERRIDE; - virtual void onComponentComplete(); + void onComponentComplete() Q_DECL_OVERRIDE; - virtual void didChangeViewportProperties(const WebCore::ViewportAttributes&); - virtual WebKit::PageViewportController* viewportController() const { return m_pageViewportController.data(); } - virtual void updateViewportSize(); + void didChangeViewportProperties(const WebCore::ViewportAttributes&) Q_DECL_OVERRIDE; + WebKit::PageViewportController* viewportController() const Q_DECL_OVERRIDE { return m_pageViewportController.data(); } + void updateViewportSize() Q_DECL_OVERRIDE; - virtual void pageDidRequestScroll(const QPoint& pos); - virtual void handleMouseEvent(QMouseEvent*); + void pageDidRequestScroll(const QPoint& pos) Q_DECL_OVERRIDE; + void handleMouseEvent(QMouseEvent*) Q_DECL_OVERRIDE; private: QScopedPointer m_pageViewportController; diff --git a/Source/WebKit2/UIProcess/API/qt/qwebiconimageprovider_p.h b/Source/WebKit2/UIProcess/API/qt/qwebiconimageprovider_p.h index 10b2f697e..2d903e9cd 100644 --- a/Source/WebKit2/UIProcess/API/qt/qwebiconimageprovider_p.h +++ b/Source/WebKit2/UIProcess/API/qt/qwebiconimageprovider_p.h @@ -36,7 +36,7 @@ public: static QString identifier() { return QStringLiteral("webicon"); } QUrl iconURLForPageURLInContext(const QString& pageURL, WebKit::QtWebContext* context); - virtual QImage requestImage(const QString& id, QSize* size, const QSize& requestedSize); + QImage requestImage(const QString& id, QSize* size, const QSize& requestedSize) Q_DECL_OVERRIDE; }; #endif diff --git a/Source/WebKit2/UIProcess/API/qt/qwebnavigationhistory_p.h b/Source/WebKit2/UIProcess/API/qt/qwebnavigationhistory_p.h index 84ef867be..06a804a17 100644 --- a/Source/WebKit2/UIProcess/API/qt/qwebnavigationhistory_p.h +++ b/Source/WebKit2/UIProcess/API/qt/qwebnavigationhistory_p.h @@ -46,9 +46,9 @@ class QWEBKIT_EXPORT QWebNavigationListModel : public QAbstractListModel { public: virtual ~QWebNavigationListModel(); - int rowCount(const QModelIndex& parent = QModelIndex()) const; - QVariant data(const QModelIndex& index, int role) const; - QHash roleNames() const; + int rowCount(const QModelIndex& parent = QModelIndex()) const Q_DECL_OVERRIDE; + QVariant data(const QModelIndex& index, int role) const Q_DECL_OVERRIDE; + QHash roleNames() const Q_DECL_OVERRIDE; void reset(); private: -- cgit v1.2.3 From b9ce7cfc7f14b96b0b573f56f792fb3a55ac60f9 Mon Sep 17 00:00:00 2001 From: Konstantin Tokarev Date: Thu, 13 Oct 2016 19:24:20 +0300 Subject: Add changes for 5.7.1 Change-Id: I1f24a218c1d93306a96a1c577957530e7f5cd807 Reviewed-by: Allan Sandfeld Jensen --- dist/changes-5.7.1 | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 dist/changes-5.7.1 diff --git a/dist/changes-5.7.1 b/dist/changes-5.7.1 new file mode 100644 index 000000000..40ac2b81e --- /dev/null +++ b/dist/changes-5.7.1 @@ -0,0 +1,40 @@ +Qt 5.7.1 is a bug-fix release. It maintains both forward and backward +compatibility (source and binary) with Qt 5.7.0. + +Qt 5.7.1 contains a merge from Qt 5.6.2 and all changes in Qt 5.6.2 are +also in Qt 5.7.1. For more see changes-5.6.2. + +Qt 5.7 introduces many new features and improvements as well as bugfixes +over the 5.6.x series. For more details, refer to the online documentation +included in this distribution. The documentation is also available online: + + http://doc.qt.io/qt-5/index.html + +The Qt version 5.7 series is binary compatible with the 5.6.x series. +Applications compiled for 5.6 will continue to run with 5.7. + +Some of the changes listed in this file include issue tracking numbers +corresponding to tasks in the Qt Bug Tracker: + + https://bugreports.qt.io/ + +Each of these identifiers can be entered in the bug tracker to obtain more +information about a particular change. + +**************************************************************************** +* Library * +**************************************************************************** + +QtWebkit +-------- + - [QTBUG-37899] Report JavaScript errors from Qt signals and slots to Console + - [QTBUG-56302] Fixed painting of checkbox and radiobutton indicators + - Support unprefixed CSS3 Flexbox properties, which are required for correct + layout in some real world web content + - Backported a few fixes for CSS calc() from WebKit upstream + +**************************************************************************** +* Platform Specific Changes * +**************************************************************************** + + - Fixed build with Python 3 -- cgit v1.2.3 From 431520f1508e92272171c214b087183e71d08ec5 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Mon, 17 Oct 2016 10:57:35 +0200 Subject: simplify setup of exclusive builds the simulator_and_device CONFIG flag is now gone. this also implies that we can set the debug_and_release and build_all flags based on the same condition. Change-Id: I6203c4b7f64584c06739a9aad1fb7201f2a3628a Reviewed-by: Jake Petroules --- Tools/qmake/mkspecs/features/default_pre.prf | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Tools/qmake/mkspecs/features/default_pre.prf b/Tools/qmake/mkspecs/features/default_pre.prf index 6bb52d05a..568e80a94 100644 --- a/Tools/qmake/mkspecs/features/default_pre.prf +++ b/Tools/qmake/mkspecs/features/default_pre.prf @@ -102,9 +102,7 @@ gcc:isEqual(QT_ARCH, "arm"): CONFIG -= use_gold_linker # Pick up Qt's defaults for debug/release/debug_and_release if(win32|mac):!macx-xcode { - qtConfig(simulator_and_device): CONFIG += simulator_and_device - qtConfig(debug_and_release): CONFIG += debug_and_release - qtConfig(build_all): CONFIG += build_all + qtConfig(debug_and_release): CONFIG += debug_and_release build_all } FLEX = flex -- cgit v1.2.3 From 7c3f338f042acebe7cf56de319bfb26a16d1aca3 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Thu, 3 Nov 2016 18:26:03 +0100 Subject: remove dependencies from sync.profile MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit the CI obtains them from the qt5 super repo nowadays. Change-Id: I1a981272cff5cca5d72b22b31a8c8f13a363330d Reviewed-by: Konstantin Tokarev Reviewed-by: Jędrzej Nowacki --- Source/sync.profile | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/Source/sync.profile b/Source/sync.profile index c0f687dc0..1c5e0113d 100644 --- a/Source/sync.profile +++ b/Source/sync.profile @@ -9,20 +9,3 @@ %classnames = ( ); @ignore_for_master_contents = ( "qwebscriptworld.h", "testwindow.h", "util.h", "bytearraytestdata.h" ); - -# Module dependencies. -# Every module that is required to build this module should have one entry. -# Each of the module version specifiers can take one of the following values: -# - A specific Git revision. -# - any git symbolic ref resolvable from the module's repository (e.g. "refs/heads/master" to track master branch) -# - an empty string to use the same branch under test (dependencies will become "refs/heads/master" if we are in the master branch) -# -%dependencies = ( - "qtbase" => "", - "qtxmlpatterns" => "", - "qtdeclarative" => "", - "qtlocation" => "", - "qtmultimedia" => "", - "qtsensors" => "", - "qtwebchannel" => "", -); -- cgit v1.2.3 From d542341492a0c18058b3f03008ea8916d84ccef3 Mon Sep 17 00:00:00 2001 From: Konstantin Tokarev Date: Thu, 17 Nov 2016 22:21:00 +0300 Subject: Fixed crash in FormDataIODevice It happens that m_formElements can be null in some cases when FormDataIODevice::reset() is invoked. Change-Id: I92113588db57c9687bc20d331ba2f5ed8f9eec54 Reviewed-by: Allan Sandfeld Jensen --- Source/WebCore/platform/network/qt/QNetworkReplyHandler.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Source/WebCore/platform/network/qt/QNetworkReplyHandler.cpp b/Source/WebCore/platform/network/qt/QNetworkReplyHandler.cpp index 4a2121907..cd89aa9ec 100644 --- a/Source/WebCore/platform/network/qt/QNetworkReplyHandler.cpp +++ b/Source/WebCore/platform/network/qt/QNetworkReplyHandler.cpp @@ -70,7 +70,11 @@ bool FormDataIODevice::reset() m_currentFile->close(); m_currentDelta = 0; - m_formElements = m_formData->elements(); + + if (m_formData) + m_formElements = m_formData->elements(); + else + m_formElements.clear(); prepareCurrentElement(); return true; -- cgit v1.2.3 From ed84b8b4ff88c5affaa89edb72e6aaf481f3ccc1 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Tue, 1 Nov 2016 22:32:05 -0700 Subject: Fix QDataStreamCoder encoding and decoding of binary data This code was all wrong. The dereferencing of the pointer was missing, so QDataStreamCoder::encodeBytes was encoding pointers (cast to something, though unclear what), while the decoder was decoding them one byte at a time This clearly has never worked. So just use writeRawData and readRawData. Change-Id: Ic46ff326a6ba46bc877cfffd1483240963ec5ee0 Reviewed-by: Konstantin Tokarev Reviewed-by: Allan Sandfeld Jensen --- Source/WebCore/history/qt/HistoryItemQt.cpp | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/Source/WebCore/history/qt/HistoryItemQt.cpp b/Source/WebCore/history/qt/HistoryItemQt.cpp index 5a54516f3..89777eb72 100644 --- a/Source/WebCore/history/qt/HistoryItemQt.cpp +++ b/Source/WebCore/history/qt/HistoryItemQt.cpp @@ -81,8 +81,7 @@ QDataStreamCoder::QDataStreamCoder(QDataStream& stream) void QDataStreamCoder::encodeBytes(const uint8_t* bytes, size_t size) { m_stream << qint64(size); - for (; size > 0; --size) - m_stream << bytes++; + m_stream.writeRawData(reinterpret_cast(bytes++), size); } void QDataStreamCoder::encodeBool(bool value) @@ -129,13 +128,9 @@ bool QDataStreamCoder::decodeBytes(Vector& out) { out.clear(); qint64 count; - uint8_t byte; m_stream >> count; - out.reserveCapacity(count); - for (qint64 i = 0; i < count; ++i) { - m_stream >> byte; - out.append(byte); - } + out.resize(count); + m_stream.readRawData(reinterpret_cast(out.data()), count); return m_stream.status() == QDataStream::Ok; } -- cgit v1.2.3 From 7ae27514e4a800eb0419879dc38cfdfce897ad60 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Mon, 5 Dec 2016 12:14:32 +0100 Subject: make sure the configure system loads qt_build_config.prf otherwise it won't have access to private features like private_tests. doing it centrally also makes it unnecessary to explicitly load() it from the configure testcases themselves. Task-number: QTBUG-57431 Change-Id: I025b01f37265e90c7611e2af939ca83ac13049d2 Reviewed-by: Allan Sandfeld Jensen Reviewed-by: Thiago Macieira --- Tools/qmake/.qmake.conf | 3 +++ Tools/qmake/config.tests/icu/icu.pro | 2 -- Tools/qmake/config.tests/leveldb/leveldb.pro | 2 -- Tools/qmake/config.tests/libsqlite3/libsqlite3.pro | 2 -- Tools/qmake/config.tests/libwebp/libwebp.pro | 2 -- Tools/qmake/config.tests/libzlib/libzlib.pro | 2 -- 6 files changed, 3 insertions(+), 10 deletions(-) diff --git a/Tools/qmake/.qmake.conf b/Tools/qmake/.qmake.conf index 2f0dc8976..80b775807 100644 --- a/Tools/qmake/.qmake.conf +++ b/Tools/qmake/.qmake.conf @@ -1,2 +1,5 @@ # This file is only here to isolate the configure project # from the rest of the tree. + +# Still, we need the global Qt build configuration. +load(qt_build_config) diff --git a/Tools/qmake/config.tests/icu/icu.pro b/Tools/qmake/config.tests/icu/icu.pro index 212b7d70e..15c6bb915 100644 --- a/Tools/qmake/config.tests/icu/icu.pro +++ b/Tools/qmake/config.tests/icu/icu.pro @@ -18,5 +18,3 @@ win32 { } else { LIBS += -licui18n -licuuc -licudata } - -load(qt_build_config) diff --git a/Tools/qmake/config.tests/leveldb/leveldb.pro b/Tools/qmake/config.tests/leveldb/leveldb.pro index f28cfd155..2d64eeba9 100644 --- a/Tools/qmake/config.tests/leveldb/leveldb.pro +++ b/Tools/qmake/config.tests/leveldb/leveldb.pro @@ -1,5 +1,3 @@ SOURCES = leveldb.cpp OBJECTS_DIR = obj LIBS += -lleveldb -lmemenv - -load(qt_build_config) diff --git a/Tools/qmake/config.tests/libsqlite3/libsqlite3.pro b/Tools/qmake/config.tests/libsqlite3/libsqlite3.pro index 2c39c5266..e5ae30612 100644 --- a/Tools/qmake/config.tests/libsqlite3/libsqlite3.pro +++ b/Tools/qmake/config.tests/libsqlite3/libsqlite3.pro @@ -1,5 +1,3 @@ SOURCES = libsqlite3.cpp OBJECTS_DIR = obj LIBS += -lsqlite3 - -load(qt_build_config) diff --git a/Tools/qmake/config.tests/libwebp/libwebp.pro b/Tools/qmake/config.tests/libwebp/libwebp.pro index 700c44df6..925725270 100644 --- a/Tools/qmake/config.tests/libwebp/libwebp.pro +++ b/Tools/qmake/config.tests/libwebp/libwebp.pro @@ -1,5 +1,3 @@ SOURCES = libwebp.cpp OBJECTS_DIR = obj LIBS += -lwebp - -load(qt_build_config) diff --git a/Tools/qmake/config.tests/libzlib/libzlib.pro b/Tools/qmake/config.tests/libzlib/libzlib.pro index 2ffc15930..648e90ed0 100644 --- a/Tools/qmake/config.tests/libzlib/libzlib.pro +++ b/Tools/qmake/config.tests/libzlib/libzlib.pro @@ -6,5 +6,3 @@ else { isEmpty(ZLIB_LIBS): LIBS += zdll.lib else: LIBS += $$ZLIB_LIBS } - -load(qt_build_config) -- cgit v1.2.3 From 74ac5b0f3489f9a08d083b6c9607c9d5c2d4afd2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Kundr=C3=A1t?= Date: Wed, 14 Sep 2016 23:51:14 +0200 Subject: Remove unused check for private_tests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It turns out that qt_developer_build is never used anyway. I did some git archeology and it looks like it was nuked when doing the 5.2 merge from upstream. The original purpose was apparently to control -Werror, which is nowadays controlled by CONFIG -= production_build. This actually fixes the build, as the QT_FOR_CONFIG += core-private which would have been required for qtConfig(private_tests) is missing. Task-number: QTBUG-55950 Change-Id: Iaaaad184b29b523ce4a4ed8afec2ac527d8f93e3 Reviewed-by: Oswald Buddenhagen Reviewed-by: Konstantin Tokarev Reviewed-by: Jan Kundrát --- Tools/qmake/mkspecs/features/default_pre.prf | 4 ---- 1 file changed, 4 deletions(-) diff --git a/Tools/qmake/mkspecs/features/default_pre.prf b/Tools/qmake/mkspecs/features/default_pre.prf index 568e80a94..5c36e9313 100644 --- a/Tools/qmake/mkspecs/features/default_pre.prf +++ b/Tools/qmake/mkspecs/features/default_pre.prf @@ -62,10 +62,6 @@ win32-msvc*: MAKEFILE_NOOP_COMMAND = @echo >NUL scratchbox: PYTHON = python2.6 else: PYTHON = python -# We use private_tests to detect developer build, since the destdir will -# always be our webkit build dir. This might change as configure changes. -qtConfig(private_tests): CONFIG += qt_developer_build - # By default we enable "production build", and build-webkit, which is # used by bots and developers, will disable it, to enable warnings etc. CONFIG += production_build -- cgit v1.2.3 From c6a621dba39fdcb5d1c05eb5160e59d3ace6e179 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Mon, 12 Dec 2016 15:33:31 -0800 Subject: Fix build with MSYS Python MSYS's Python is compiled as a POSIX environment, which means subprocess.Popen cannot be passed just a single string (to be given to CreateProcess). Instead, pass the split args and let the underlying system re-merge them. This is harmless with a pure Windows Python. MSYS python also changes parameters starting with / to a pathname, so use the equivalent -directives (dumpbin.exe accepts them). Change-Id: Id50531a20e40adb71a40525cf714d05c22959fb0 Reviewed-by: Allan Sandfeld Jensen --- Tools/Scripts/generate-win32-export-forwards | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tools/Scripts/generate-win32-export-forwards b/Tools/Scripts/generate-win32-export-forwards index a160abb18..37375b77b 100755 --- a/Tools/Scripts/generate-win32-export-forwards +++ b/Tools/Scripts/generate-win32-export-forwards @@ -28,7 +28,7 @@ import sys import re def exportForwardsForLibrary(library): - dumpBin = subprocess.Popen("dumpbin /directives " + library, stdout=subprocess.PIPE, universal_newlines=True) + dumpBin = subprocess.Popen(["dumpbin.exe", "-directives", library], stdout=subprocess.PIPE, universal_newlines=True) output = dumpBin.communicate()[0] return output -- cgit v1.2.3 From 3a5ab06844fcb3d8377b5a86db4708e6da6e6537 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Tue, 3 Jan 2017 13:27:51 +0100 Subject: Bump version Change-Id: I631efa59c63f8cc414d4ef52138ce772d489a44b --- .qmake.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.qmake.conf b/.qmake.conf index b6ffe6de4..0b7cf949a 100644 --- a/.qmake.conf +++ b/.qmake.conf @@ -3,4 +3,4 @@ MODULE_QMAKE_OUTDIR = $$shadowed($$PWD/Tools/qmake) QMAKEPATH += $$PWD/Tools/qmake $$MODULE_QMAKE_OUTDIR load(qt_build_config) -MODULE_VERSION = 5.8.0 +MODULE_VERSION = 5.8.1 -- cgit v1.2.3 From 19d304e8d17fb39efe795b51e1ee0f5564a0692a Mon Sep 17 00:00:00 2001 From: Alberto Garcia Date: Sat, 18 Jan 2014 19:41:58 +0000 Subject: JavaScriptCore uses PLATFORM(MAC) when it means OS(DARWIN) https://bugs.webkit.org/show_bug.cgi?id=99683 Reviewed by Anders Carlsson. * jit/ThunkGenerators.cpp: * tools/CodeProfile.cpp: (JSC::symbolName): (JSC::CodeProfile::sample): git-svn-id: http://svn.webkit.org/repository/webkit/trunk@162266 268f45cc-cd09-0410-ab3c-d52691b4dbfc Change-Id: Ia5b36b80ba095dbf0de4430137dc8133d0c06a8e Reviewed-by: Allan Sandfeld Jensen --- Source/JavaScriptCore/jit/ThunkGenerators.cpp | 4 ++-- Source/JavaScriptCore/tools/CodeProfile.cpp | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Source/JavaScriptCore/jit/ThunkGenerators.cpp b/Source/JavaScriptCore/jit/ThunkGenerators.cpp index 9684df2d0..fde1347a0 100644 --- a/Source/JavaScriptCore/jit/ThunkGenerators.cpp +++ b/Source/JavaScriptCore/jit/ThunkGenerators.cpp @@ -508,7 +508,7 @@ double jsRound(double d) } -#if CPU(X86_64) && COMPILER(GCC) && (PLATFORM(MAC) || OS(LINUX)) +#if CPU(X86_64) && COMPILER(GCC) && (OS(DARWIN) || OS(LINUX)) #define defineUnaryDoubleOpWrapper(function) \ asm( \ @@ -524,7 +524,7 @@ double jsRound(double d) } \ static MathThunk UnaryDoubleOpWrapper(function) = &function##Thunk; -#elif CPU(X86) && COMPILER(GCC) && (PLATFORM(MAC) || OS(LINUX)) +#elif CPU(X86) && COMPILER(GCC) && (OS(DARWIN) || OS(LINUX)) #define defineUnaryDoubleOpWrapper(function) \ asm( \ ".text\n" \ diff --git a/Source/JavaScriptCore/tools/CodeProfile.cpp b/Source/JavaScriptCore/tools/CodeProfile.cpp index de86e52ef..3106eff89 100644 --- a/Source/JavaScriptCore/tools/CodeProfile.cpp +++ b/Source/JavaScriptCore/tools/CodeProfile.cpp @@ -33,7 +33,7 @@ #include #include -#if PLATFORM(MAC) +#if OS(DARWIN) #include #include #include @@ -56,7 +56,7 @@ const char* CodeProfile::s_codeTypeNames[CodeProfile::NumberOfCodeTypes] = { // Helper function, find the symbol name for a pc in JSC. static const char* symbolName(void* address) { -#if PLATFORM(MAC) +#if OS(DARWIN) Dl_info info; if (!dladdr(address, &info) || !info.dli_sname) return ""; @@ -123,7 +123,7 @@ void CodeProfile::sample(void* pc, void** framePointer) if (type != EngineFrame) return; -#if PLATFORM(MAC) && CPU(X86_64) +#if OS(DARWIN) && CPU(X86_64) // Walk up the stack. pc = framePointer[1]; framePointer = reinterpret_cast(*framePointer); -- cgit v1.2.3 From 548380af096f8277e460383c81a4ecdf2b77523f Mon Sep 17 00:00:00 2001 From: Magnus Granberg Date: Tue, 19 Aug 2014 21:25:22 +0000 Subject: TEXTREL in libjavascriptcoregtk-1.0.so.0.11.0 on x86 (or i586) https://bugs.webkit.org/show_bug.cgi?id=70610 Patch by Magnus Granberg on 2014-08-19 Reviewed by Darin Adler. Source/JavaScriptCore: Setup %ebx so we can use the plt. * jit/ThunkGenerators.cpp: Source/WTF: Add PLT if we're building with PIC. * wtf/InlineASM.h: git-svn-id: http://svn.webkit.org/repository/webkit/trunk@172759 268f45cc-cd09-0410-ab3c-d52691b4dbfc Change-Id: I7524a662f76f75f8dee0a07bf2360420d7b23d2d Reviewed-by: Allan Sandfeld Jensen --- Source/JavaScriptCore/jit/ThunkGenerators.cpp | 24 ++++++++++++++++++++++++ Source/WTF/wtf/InlineASM.h | 2 ++ 2 files changed, 26 insertions(+) diff --git a/Source/JavaScriptCore/jit/ThunkGenerators.cpp b/Source/JavaScriptCore/jit/ThunkGenerators.cpp index fde1347a0..fbf550ba4 100644 --- a/Source/JavaScriptCore/jit/ThunkGenerators.cpp +++ b/Source/JavaScriptCore/jit/ThunkGenerators.cpp @@ -524,6 +524,30 @@ double jsRound(double d) } \ static MathThunk UnaryDoubleOpWrapper(function) = &function##Thunk; +#elif CPU(X86) && COMPILER(GCC) && OS(LINUX) && defined(__PIC__) +#define defineUnaryDoubleOpWrapper(function) \ + asm( \ + ".text\n" \ + ".globl " SYMBOL_STRING(function##Thunk) "\n" \ + HIDE_SYMBOL(function##Thunk) "\n" \ + SYMBOL_STRING(function##Thunk) ":" "\n" \ + "pushl %ebx\n" \ + "subl $20, %esp\n" \ + "movsd %xmm0, (%esp) \n" \ + "call __x86.get_pc_thunk.bx\n" \ + "addl $_GLOBAL_OFFSET_TABLE_, %ebx\n" \ + "call " GLOBAL_REFERENCE(function) "\n" \ + "fstpl (%esp) \n" \ + "movsd (%esp), %xmm0 \n" \ + "addl $20, %esp\n" \ + "popl %ebx\n" \ + "ret\n" \ + );\ + extern "C" { \ + MathThunkCallingConvention function##Thunk(MathThunkCallingConvention); \ + } \ + static MathThunk UnaryDoubleOpWrapper(function) = &function##Thunk; + #elif CPU(X86) && COMPILER(GCC) && (OS(DARWIN) || OS(LINUX)) #define defineUnaryDoubleOpWrapper(function) \ asm( \ diff --git a/Source/WTF/wtf/InlineASM.h b/Source/WTF/wtf/InlineASM.h index 0a2fe78b7..2dc40ef4e 100644 --- a/Source/WTF/wtf/InlineASM.h +++ b/Source/WTF/wtf/InlineASM.h @@ -46,6 +46,8 @@ #define GLOBAL_REFERENCE(name) #name "@plt" #elif CPU(X86) && COMPILER(MINGW) #define GLOBAL_REFERENCE(name) "@" #name "@4" +#elif OS(LINUX) && CPU(X86) && defined(__PIC__) +#define GLOBAL_REFERENCE(name) SYMBOL_STRING(name) "@plt" #else #define GLOBAL_REFERENCE(name) SYMBOL_STRING(name) #endif -- cgit v1.2.3 From a0c60c53c0fe1b1f6b5ab52944e031a3684e3de1 Mon Sep 17 00:00:00 2001 From: Konstantin Tokarev Date: Mon, 15 Aug 2016 13:38:26 +0300 Subject: Imitate Safari's UA string better Some sites doing UA sniffing don't recognize our default UA string without "Version/x.y" component, corresponding to version number of Safari. Task-number: QTBUG-38211 Change-Id: Ic5082a938f639502bb2c11c7df2538584b5f77ee Reviewed-by: Allan Sandfeld Jensen --- Source/WebCore/platform/qt/UserAgentQt.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/WebCore/platform/qt/UserAgentQt.cpp b/Source/WebCore/platform/qt/UserAgentQt.cpp index 80996a223..b61331644 100644 --- a/Source/WebCore/platform/qt/UserAgentQt.cpp +++ b/Source/WebCore/platform/qt/UserAgentQt.cpp @@ -37,7 +37,7 @@ namespace WebCore { This implementation returns the following value: - "Mozilla/5.0 (%Platform%%Security%%Subplatform%) AppleWebKit/%WebKitVersion% (KHTML, like Gecko) %AppVersion Safari/%WebKitVersion%" + "Mozilla/5.0 (%Platform%%Security%%Subplatform%) AppleWebKit/%WebKitVersion% (KHTML, like Gecko) %AppVersion Version/7.0 Safari/%WebKitVersion%" In this string the following values are replaced the first time the function is called: \list @@ -58,7 +58,7 @@ String UserAgentQt::standardUserAgent(const String &applicationNameForUserAgent, if (ua.isNull()) { - ua = QLatin1String("Mozilla/5.0 (%1%2%3) AppleWebKit/%4 (KHTML, like Gecko) %99 Safari/%5"); + ua = QLatin1String("Mozilla/5.0 (%1%2%3) AppleWebKit/%4 (KHTML, like Gecko) %99 Version/7.0 Safari/%5"); // Platform. ua = ua.arg(QLatin1String( -- cgit v1.2.3 From fce06b359971d798474892fad2d56092f27b0f6b Mon Sep 17 00:00:00 2001 From: Vitaly Slobodin Date: Sat, 7 Jan 2017 17:09:42 +0300 Subject: Fix misplaced checkboxes on macOS Checkboxes without State_Active flag are missplaced on macOS. Set this flag by default to paint checkboxes in correct positions. Task-number: QTBUG-42948 Task-number: QTBUG-43070 Change-Id: Ie86f3dec156e31c90e454d8f1b41e4d4ec68c8b0 Reviewed-by: Konstantin Tokarev --- Source/WebCore/platform/qt/RenderThemeQStyle.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Source/WebCore/platform/qt/RenderThemeQStyle.cpp b/Source/WebCore/platform/qt/RenderThemeQStyle.cpp index 9f3d50a2d..59e74c282 100644 --- a/Source/WebCore/platform/qt/RenderThemeQStyle.cpp +++ b/Source/WebCore/platform/qt/RenderThemeQStyle.cpp @@ -591,6 +591,11 @@ ControlPart RenderThemeQStyle::initializeCommonQStyleOptions(QStyleFacadeOption option.state &= ~(QStyleFacade::State_HasFocus | QStyleFacade::State_MouseOver); option.state |= QStyleFacade::State_Enabled; +#ifdef Q_OS_DARWIN + // to render controls in correct positions we also should set the State_Active flag + option.state |= QStyleFacade::State_Active; +#endif + if (isReadOnlyControl(o)) // Readonly is supported on textfields. option.state |= QStyleFacade::State_ReadOnly; -- cgit v1.2.3 From dcf0d42f3de04c01ff6bfedf1a2ded863b134268 Mon Sep 17 00:00:00 2001 From: Alexander Volkov Date: Wed, 25 Jan 2017 09:59:08 +0300 Subject: Enable build of QtWebPluginProcess It is enabled when xlibAvailable() returns true, but this test function was forgotten to be ported to use qtConfig() and works incorrectly. Change-Id: I62793aeed4ffa78a68c1f35d07c88c6c9eea71cf Reviewed-by: Konstantin Tokarev --- Tools/qmake/mkspecs/features/functions.prf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tools/qmake/mkspecs/features/functions.prf b/Tools/qmake/mkspecs/features/functions.prf index dc0c78f97..2f5b87c7c 100644 --- a/Tools/qmake/mkspecs/features/functions.prf +++ b/Tools/qmake/mkspecs/features/functions.prf @@ -293,7 +293,7 @@ defineTest(linkAgainstLibrary) { } defineTest(xlibAvailable) { - contains(QT_CONFIG, xcb-xlib) { + qtConfig(xcb):qtConfig(xcb-xlib) { return(true) } else { return(false) -- cgit v1.2.3 From a4eec4118333b59d10fd6cc9f126b1af2e8f505c Mon Sep 17 00:00:00 2001 From: Andy Shaw Date: Wed, 25 Jan 2017 18:10:04 +0100 Subject: Use frameGeometry() to determine the outerWidth/Height of the window Change-Id: Ie6ca8f40a7512e37e0b2efc94706242c9f323686 Reviewed-by: Konstantin Tokarev --- Source/WebKit/qt/WidgetSupport/PageClientQt.cpp | 2 +- Source/WebKit/qt/tests/qwebview/tst_qwebview.cpp | 23 +++++++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/Source/WebKit/qt/WidgetSupport/PageClientQt.cpp b/Source/WebKit/qt/WidgetSupport/PageClientQt.cpp index 858290f6e..2dd14afc6 100644 --- a/Source/WebKit/qt/WidgetSupport/PageClientQt.cpp +++ b/Source/WebKit/qt/WidgetSupport/PageClientQt.cpp @@ -146,7 +146,7 @@ QStyle* PageClientQWidget::style() const QRectF PageClientQWidget::windowRect() const { - return QRectF(view->window()->geometry()); + return QRectF(view->window()->frameGeometry()); } void PageClientQWidget::setWidgetVisible(Widget* widget, bool visible) diff --git a/Source/WebKit/qt/tests/qwebview/tst_qwebview.cpp b/Source/WebKit/qt/tests/qwebview/tst_qwebview.cpp index a990ad0f2..dcea15912 100644 --- a/Source/WebKit/qt/tests/qwebview/tst_qwebview.cpp +++ b/Source/WebKit/qt/tests/qwebview/tst_qwebview.cpp @@ -59,6 +59,7 @@ private Q_SLOTS: void setPalette_data(); void setPalette(); #endif + void innerOuterRect(); }; // This will be called before the first test function is executed. @@ -518,6 +519,28 @@ void tst_QWebView::renderingAfterMaxAndBack() QCOMPARE(image3, reference3); } +void tst_QWebView::innerOuterRect() +{ + QUrl url = QUrl("data:text/html," + "" + "" + ""); + QWebView view; + view.page()->mainFrame()->load(url); + QVERIFY(waitForSignal(&view, SIGNAL(loadFinished(bool)))); + view.showMaximized(); + const QRect frameGeometry = view.frameGeometry(); + const QRect geometry = view.geometry(); + QVariant outerWidth = view.page()->mainFrame()->evaluateJavaScript("window.outerWidth;"); + QCOMPARE(outerWidth.toInt(), frameGeometry.width()); + QVariant innerWidth = view.page()->mainFrame()->evaluateJavaScript("window.innerWidth;"); + QCOMPARE(innerWidth.toInt(), geometry.width()); + QVariant outerHeight = view.page()->mainFrame()->evaluateJavaScript("window.outerHeight;"); + QCOMPARE(outerHeight.toInt(), frameGeometry.height()); + QVariant innerHeight = view.page()->mainFrame()->evaluateJavaScript("window.innerHeight;"); + QCOMPARE(innerHeight.toInt(), geometry.height()); +} + QTEST_MAIN(tst_QWebView) #include "tst_qwebview.moc" -- cgit v1.2.3 From c3b710c3f4de2da0fd67c858949c3f420dfd175a Mon Sep 17 00:00:00 2001 From: Konstantin Tokarev Date: Fri, 3 Feb 2017 00:28:43 +0300 Subject: Support custom items in context menu This is particularly important for Inspector, which lacks a lot of useful context menu actions without this patch. Change-Id: I8170c806028ff140206f13e5e1de0409e945e905 Reviewed-by: Konstantin Tokarev --- .../qt/WebCoreSupport/FrameLoaderClientQt.cpp | 4 +- .../WebKit/qt/WebCoreSupport/QWebPageAdapter.cpp | 17 +++++++- Source/WebKit/qt/WebCoreSupport/QWebPageAdapter.h | 4 +- Source/WebKit/qt/WidgetApi/qwebpage.cpp | 45 ++++++++++++++++++++-- Source/WebKit/qt/WidgetApi/qwebpage.h | 2 + Source/WebKit/qt/WidgetApi/qwebpage_p.h | 3 ++ 6 files changed, 68 insertions(+), 7 deletions(-) diff --git a/Source/WebKit/qt/WebCoreSupport/FrameLoaderClientQt.cpp b/Source/WebKit/qt/WebCoreSupport/FrameLoaderClientQt.cpp index 09b0aae82..0b811c8f2 100644 --- a/Source/WebKit/qt/WebCoreSupport/FrameLoaderClientQt.cpp +++ b/Source/WebKit/qt/WebCoreSupport/FrameLoaderClientQt.cpp @@ -735,8 +735,10 @@ void FrameLoaderClientQt::dispatchDidClearWindowObjectInWorld(DOMWrapperWorld* w if (world != mainThreadNormalWorld()) return; - if (m_webFrame) + if (m_webFrame) { m_webFrame->didClearWindowObject(); + m_webFrame->pageAdapter->clearCustomActions(); + } } void FrameLoaderClientQt::documentElementAvailable() diff --git a/Source/WebKit/qt/WebCoreSupport/QWebPageAdapter.cpp b/Source/WebKit/qt/WebCoreSupport/QWebPageAdapter.cpp index 554ab8927..a4e1f7464 100644 --- a/Source/WebKit/qt/WebCoreSupport/QWebPageAdapter.cpp +++ b/Source/WebKit/qt/WebCoreSupport/QWebPageAdapter.cpp @@ -874,8 +874,11 @@ void QWebPageAdapter::dynamicPropertyChangeEvent(QObject* obj, QDynamicPropertyC #define MAP_ACTION_FROM_VALUE(Name, Value) \ case Value: return QWebPageAdapter::Name -static QWebPageAdapter::MenuAction adapterActionForContextMenuAction(WebCore::ContextMenuAction action) +static int adapterActionForContextMenuAction(WebCore::ContextMenuAction action) { + if (action >= ContextMenuItemBaseCustomTag && action <= ContextMenuItemLastCustomTag) + return action; + switch (action) { FOR_EACH_MAPPED_MENU_ACTION(MAP_ACTION_FROM_VALUE, SEMICOLON_SEPARATOR); #if ENABLE(INSPECTOR) @@ -899,7 +902,7 @@ QList descriptionForPlatformMenu(const Vector& items, switch (item.type()) { case WebCore::CheckableActionType: /* fall through */ case WebCore::ActionType: { - QWebPageAdapter::MenuAction action = adapterActionForContextMenuAction(item.action()); + int action = adapterActionForContextMenuAction(item.action()); if (action > QWebPageAdapter::NoAction) { description.type = MenuItem::Action; description.action = action; @@ -1207,6 +1210,16 @@ void QWebPageAdapter::triggerAction(QWebPageAdapter::MenuAction action, QWebHitT } } +void QWebPageAdapter::triggerCustomAction(int action, const QString &title) +{ + if (action >= ContextMenuItemBaseCustomTag && action <= ContextMenuItemLastCustomTag) { + ContextMenuItem item(ActionType, static_cast(action), title); + page->contextMenuController()->contextMenuItemSelected(&item); + } else { + ASSERT_NOT_REACHED(); + } +} + QString QWebPageAdapter::contextMenuItemTagForAction(QWebPageAdapter::MenuAction action, bool* checkable) const { diff --git a/Source/WebKit/qt/WebCoreSupport/QWebPageAdapter.h b/Source/WebKit/qt/WebCoreSupport/QWebPageAdapter.h index ee4d2595a..fcdc25596 100644 --- a/Source/WebKit/qt/WebCoreSupport/QWebPageAdapter.h +++ b/Source/WebKit/qt/WebCoreSupport/QWebPageAdapter.h @@ -204,6 +204,7 @@ public: virtual void createUndoStep(QSharedPointer) = 0; virtual void updateNavigationActions() = 0; + virtual void clearCustomActions() = 0; virtual QWebFrameAdapter* mainFrameAdapter() = 0; @@ -249,7 +250,7 @@ public: Separator, SubMenu } type; - MenuAction action; + int action; enum Trait { None = 0, Enabled = 1, @@ -317,6 +318,7 @@ public: QWebHitTestResultPrivate* updatePositionDependentMenuActions(const QPoint&, QBitArray*); void updateActionInternal(MenuAction, const char* commandName, bool* enabled, bool* checked); void triggerAction(MenuAction, QWebHitTestResultPrivate*, const char* commandName, bool endToEndReload); + void triggerCustomAction(int action, const QString &title); QString contextMenuItemTagForAction(MenuAction, bool* checkable) const; QStringList supportedContentTypes() const; diff --git a/Source/WebKit/qt/WidgetApi/qwebpage.cpp b/Source/WebKit/qt/WidgetApi/qwebpage.cpp index 863621391..388456616 100644 --- a/Source/WebKit/qt/WidgetApi/qwebpage.cpp +++ b/Source/WebKit/qt/WidgetApi/qwebpage.cpp @@ -238,6 +238,8 @@ QWebPagePrivate::~QWebPagePrivate() // in order for various destruction callbacks out of WebCore to // work. deletePage(); + + clearCustomActions(); } void QWebPagePrivate::show() @@ -499,8 +501,15 @@ QMenu *createContextMenu(QWebPage* page, const QList& items, QBitArray const MenuItem &item = items.at(i); switch (item.type) { case MenuItem::Action: { - QWebPage::WebAction action = webActionForAdapterMenuAction(item.action); - QAction *a = page->action(action); + QAction* a = nullptr; + if (item.action < QWebPageAdapter::ActionCount) { + QWebPage::WebAction action = webActionForAdapterMenuAction(static_cast(item.action)); + a = page->action(action); + if (a) + visitedWebActions->setBit(action); + } else { + a = page->customAction(item.action); + } if (a) { a->setText(item.title); a->setEnabled(item.traits & MenuItem::Enabled); @@ -508,7 +517,6 @@ QMenu *createContextMenu(QWebPage* page, const QList& items, QBitArray a->setChecked(item.traits & MenuItem::Checked); menu->addAction(a); - visitedWebActions->setBit(action); } break; } @@ -562,6 +570,16 @@ void QWebPagePrivate::_q_webActionTriggered(bool checked) QWebPage::WebAction action = static_cast(a->data().toInt()); q->triggerAction(action, checked); } + +void QWebPagePrivate::_q_customActionTriggered(bool checked) +{ + Q_UNUSED(checked); + QAction* a = qobject_cast(q->sender()); + if (!a) + return; + int action = a->data().toInt(); + triggerCustomAction(action, a->text()); +} #endif // QT_NO_ACTION void QWebPagePrivate::updateAction(QWebPage::WebAction action) @@ -625,6 +643,12 @@ void QWebPagePrivate::updateNavigationActions() updateAction(QWebPage::ReloadAndBypassCache); } +void QWebPagePrivate::clearCustomActions() +{ + qDeleteAll(customActions); + customActions.clear(); +} + QObject *QWebPagePrivate::inspectorHandle() { return getOrCreateInspector(); @@ -2509,6 +2533,21 @@ QAction *QWebPage::action(WebAction action) const d->updateAction(action); return a; } + +QAction* QWebPage::customAction(int action) const +{ + auto actionIter = d->customActions.constFind(action); + if (actionIter != d->customActions.constEnd()) + return *actionIter; + + QAction* a = new QAction(d->q); + a->setData(action); + connect(a, SIGNAL(triggered(bool)), + this, SLOT(_q_customActionTriggered(bool))); + + d->customActions.insert(action, a); + return a; +} #endif // QT_NO_ACTION /*! diff --git a/Source/WebKit/qt/WidgetApi/qwebpage.h b/Source/WebKit/qt/WidgetApi/qwebpage.h index 01e77d44b..822bd2194 100644 --- a/Source/WebKit/qt/WidgetApi/qwebpage.h +++ b/Source/WebKit/qt/WidgetApi/qwebpage.h @@ -301,6 +301,7 @@ public: #ifndef QT_NO_ACTION QAction *action(WebAction action) const; + QAction *customAction(int action) const; #endif virtual void triggerAction(WebAction action, bool checked = false); @@ -443,6 +444,7 @@ private: Q_PRIVATE_SLOT(d, void _q_onLoadProgressChanged(int)) #ifndef QT_NO_ACTION Q_PRIVATE_SLOT(d, void _q_webActionTriggered(bool checked)) + Q_PRIVATE_SLOT(d, void _q_customActionTriggered(bool checked)) #endif Q_PRIVATE_SLOT(d, void _q_cleanupLeakMessages()) Q_PRIVATE_SLOT(d, void _q_updateScreen(QScreen*)) diff --git a/Source/WebKit/qt/WidgetApi/qwebpage_p.h b/Source/WebKit/qt/WidgetApi/qwebpage_p.h index 604c0a540..34cf288b4 100644 --- a/Source/WebKit/qt/WidgetApi/qwebpage_p.h +++ b/Source/WebKit/qt/WidgetApi/qwebpage_p.h @@ -120,6 +120,7 @@ public: virtual const char* editorCommandForKeyEvent(QKeyEvent*) OVERRIDE; void updateNavigationActions() OVERRIDE; + void clearCustomActions() OVERRIDE; virtual QObject* inspectorHandle() OVERRIDE; virtual void setInspectorFrontend(QObject*) OVERRIDE; @@ -145,6 +146,7 @@ public: void createMainFrame(); void _q_webActionTriggered(bool checked); + void _q_customActionTriggered(bool checked); void updateAction(QWebPage::WebAction); void updateEditorActions(); @@ -198,6 +200,7 @@ public: bool useFixedLayout; QAction *actions[QWebPage::WebActionCount]; + QHash customActions; QPointer window; QWidget* inspectorFrontend; -- cgit v1.2.3 From c176f1fbe8ed0d87c507811f4c0e4d67a71bc890 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Mon, 13 Feb 2017 09:47:56 +0100 Subject: switch to new way to refer to libdl Change-Id: I2ec38c9a2c1072127b25510cc4b3daa9e1847352 Reviewed-by: Joerg Bornemann --- Source/WebKit2/SandboxProcess.pro | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Source/WebKit2/SandboxProcess.pro b/Source/WebKit2/SandboxProcess.pro index e4b05940c..4335508c0 100644 --- a/Source/WebKit2/SandboxProcess.pro +++ b/Source/WebKit2/SandboxProcess.pro @@ -16,7 +16,8 @@ SOURCES += Shared/linux/SandboxProcess/SandboxEnvironmentLinux.cpp HEADERS += Shared/linux/SandboxProcess/SandboxEnvironmentLinux.h INSTALLS += target -LIBS += -lcap -ldl +LIBS += -lcap +QMAKE_USE += libdl isEmpty(INSTALL_BINS) { target.path = $$[QT_INSTALL_BINS] -- cgit v1.2.3