platform/graphics/BitmapImage.cpp
platform/graphics/Color.cpp
platform/graphics/CrossfadeGeneratedImage.cpp
+ platform/graphics/FractionalLayoutSize.cpp
platform/graphics/FloatPoint.cpp
platform/graphics/FloatPoint3D.cpp
platform/graphics/FloatQuad.cpp
+2012-02-17 Emil A Eklund <eae@chromium.org>
+
+ Add FractionalLayoutSize for sub-pixel layout
+ https://bugs.webkit.org/show_bug.cgi?id=78852
+
+ Reviewed by Eric Seidel.
+
+ Add FractionalLayoutUnit version of Size class and a couple of
+ conversion methods to the Int and Float versions of same.
+
+ No new tests.
+
+ * CMakeLists.txt:
+ * GNUmakefile.list.am:
+ * WebCore.gypi:
+ * WebCore.vcproj/WebCore.vcproj:
+ * WebCore.xcodeproj/project.pbxproj:
+ * platform/graphics/FloatPoint.cpp:
+ (WebCore::FloatPoint::move):
+ Add FractionalLayoutSize version of move.
+
+ * platform/graphics/FloatPoint.h:
+ * platform/graphics/FloatSize.cpp:
+ (WebCore::FloatSize::FloatSize):
+ Add FloatSize(FractionalLayoutSize) constructor.
+
+ * platform/graphics/FloatSize.h:
+ * platform/graphics/FractionalLayoutSize.cpp: Added.
+ * platform/graphics/FractionalLayoutSize.h: Added.
+
2012-02-17 Enrica Casucci <enrica@apple.com>
REGRESSION (r107606): Copy Link writes malformed WebURLsWithTitlesPboardType
Source/WebCore/platform/graphics/filters/arm/FEGaussianBlurNEON.h \
Source/WebCore/platform/graphics/filters/arm/FELightingNEON.cpp \
Source/WebCore/platform/graphics/filters/arm/FELightingNEON.h \
+ Source/WebCore/platform/graphics/FractionalLayoutSize.cpp \
+ Source/WebCore/platform/graphics/FractionalLayoutSize.h \
Source/WebCore/platform/graphics/FloatPoint3D.cpp \
Source/WebCore/platform/graphics/FloatPoint3D.h \
Source/WebCore/platform/graphics/FloatPoint.cpp \
'platform/graphics/CrossfadeGeneratedImage.cpp',
'platform/graphics/CrossfadeGeneratedImage.h',
'platform/graphics/Extensions3D.h',
+ 'platform/graphics/FractionalLayoutSize.cpp',
'platform/graphics/FloatPoint.cpp',
'platform/graphics/FloatPoint3D.cpp',
'platform/graphics/FloatQuad.cpp',
>
</File>
<File
+ RelativePath="..\platform\graphics\FractionalLayoutSize.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\platform\graphics\FractionalLayoutSize.h"
+ >
+ </File>
+ <File
RelativePath="..\platform\graphics\FloatPoint.cpp"
>
</File>
1432E8490C51493F00B1500F /* GCController.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1432E8480C51493F00B1500F /* GCController.cpp */; };
1449E24C107D4A8400B5793F /* JSCallbackData.h in Headers */ = {isa = PBXBuildFile; fileRef = 1449E24A107D4A8400B5793F /* JSCallbackData.h */; };
1449E287107D4DB400B5793F /* JSCallbackData.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1449E286107D4DB400B5793F /* JSCallbackData.cpp */; };
+ 144FCE5214EC79BC000D17A3 /* FractionalLayoutUnit.h in Headers */ = {isa = PBXBuildFile; fileRef = 144FCE5114EC79BC000D17A3 /* FractionalLayoutUnit.h */; settings = {ATTRIBUTES = (Private, ); }; };
+ 144FCE5C14EC79E7000D17A3 /* FractionalLayoutSize.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 144FCE5714EC79E7000D17A3 /* FractionalLayoutSize.cpp */; };
+ 144FCE5D14EC79E7000D17A3 /* FractionalLayoutSize.h in Headers */ = {isa = PBXBuildFile; fileRef = 144FCE5814EC79E7000D17A3 /* FractionalLayoutSize.h */; settings = {ATTRIBUTES = (Private, ); }; };
1464E06C135EC10600FDB00A /* JSMediaListCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1464E06B135EC10600FDB00A /* JSMediaListCustom.cpp */; };
1477E7760BF4134A00152872 /* PageCache.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1477E7740BF4134A00152872 /* PageCache.cpp */; };
1477E7770BF4134A00152872 /* PageCache.h in Headers */ = {isa = PBXBuildFile; fileRef = 1477E7750BF4134A00152872 /* PageCache.h */; settings = {ATTRIBUTES = (Private, ); }; };
B8DBDB4C130B0F8A00F5CDB1 /* SetSelectionCommand.h in Headers */ = {isa = PBXBuildFile; fileRef = B8DBDB48130B0F8A00F5CDB1 /* SetSelectionCommand.h */; };
B8DBDB4D130B0F8A00F5CDB1 /* SpellingCorrectionCommand.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B8DBDB49130B0F8A00F5CDB1 /* SpellingCorrectionCommand.cpp */; };
B8DBDB4E130B0F8A00F5CDB1 /* SpellingCorrectionCommand.h in Headers */ = {isa = PBXBuildFile; fileRef = B8DBDB4A130B0F8A00F5CDB1 /* SpellingCorrectionCommand.h */; };
- BAB22AD414B7A02D00D8ABA6 /* FractionalLayoutUnit.h in Headers */ = {isa = PBXBuildFile; fileRef = BAB771501444CBB400EC4C4C /* FractionalLayoutUnit.h */; settings = {ATTRIBUTES = (Private, ); }; };
BACF290113B2A0D500781F90 /* LayoutTypes.h in Headers */ = {isa = PBXBuildFile; fileRef = BACF290013B2A0D500781F90 /* LayoutTypes.h */; settings = {ATTRIBUTES = (Private, ); }; };
BC00F0040E0A185500FD04E3 /* DOMFile.h in Headers */ = {isa = PBXBuildFile; fileRef = BC00EFFE0E0A185500FD04E3 /* DOMFile.h */; };
BC00F0050E0A185500FD04E3 /* DOMFile.mm in Sources */ = {isa = PBXBuildFile; fileRef = BC00EFFF0E0A185500FD04E3 /* DOMFile.mm */; };
1432E8480C51493F00B1500F /* GCController.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = GCController.cpp; sourceTree = "<group>"; };
1449E24A107D4A8400B5793F /* JSCallbackData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSCallbackData.h; sourceTree = "<group>"; };
1449E286107D4DB400B5793F /* JSCallbackData.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSCallbackData.cpp; sourceTree = "<group>"; };
+ 144FCE5114EC79BC000D17A3 /* FractionalLayoutUnit.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FractionalLayoutUnit.h; sourceTree = "<group>"; };
+ 144FCE5714EC79E7000D17A3 /* FractionalLayoutSize.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FractionalLayoutSize.cpp; sourceTree = "<group>"; };
+ 144FCE5814EC79E7000D17A3 /* FractionalLayoutSize.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FractionalLayoutSize.h; sourceTree = "<group>"; };
1464E06B135EC10600FDB00A /* JSMediaListCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSMediaListCustom.cpp; sourceTree = "<group>"; };
1477E7740BF4134A00152872 /* PageCache.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = PageCache.cpp; sourceTree = "<group>"; };
1477E7750BF4134A00152872 /* PageCache.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = PageCache.h; sourceTree = "<group>"; };
B8DBDB48130B0F8A00F5CDB1 /* SetSelectionCommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SetSelectionCommand.h; sourceTree = "<group>"; };
B8DBDB49130B0F8A00F5CDB1 /* SpellingCorrectionCommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SpellingCorrectionCommand.cpp; sourceTree = "<group>"; };
B8DBDB4A130B0F8A00F5CDB1 /* SpellingCorrectionCommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SpellingCorrectionCommand.h; sourceTree = "<group>"; };
- BAB771501444CBB400EC4C4C /* FractionalLayoutUnit.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FractionalLayoutUnit.h; sourceTree = "<group>"; };
BACF290013B2A0D500781F90 /* LayoutTypes.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LayoutTypes.h; sourceTree = "<group>"; };
BC00EFFE0E0A185500FD04E3 /* DOMFile.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DOMFile.h; sourceTree = "<group>"; };
BC00EFFF0E0A185500FD04E3 /* DOMFile.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = DOMFile.mm; sourceTree = "<group>"; };
37202198106213C600F25C4B /* FontSmoothingMode.h */,
3784C34A0E11AA34007D8D48 /* FontTraitsMask.h */,
BCE4413512F7490B009B84B8 /* FontWidthVariant.h */,
+ 144FCE5714EC79E7000D17A3 /* FractionalLayoutSize.cpp */,
+ 144FCE5814EC79E7000D17A3 /* FractionalLayoutSize.h */,
BC23F0DA0DAFF4A4009FDC91 /* GeneratedImage.h */,
BCE04C890DAFF7A0007A0F41 /* Generator.h */,
2D2FC0561460CD6F00263633 /* GeneratorGeneratedImage.cpp */,
C57FEDE01212EE9C0097BE65 /* FileSystem.cpp */,
514B3F720C722047000530DF /* FileSystem.h */,
BC073BA90C399B1F000F5979 /* FloatConversion.h */,
- BAB771501444CBB400EC4C4C /* FractionalLayoutUnit.h */,
+ 144FCE5114EC79BC000D17A3 /* FractionalLayoutUnit.h */,
A8748BDF12CBF2DC001FBA41 /* HashTools.h */,
D6FDAEF2149C06190037B1E1 /* HistogramSupport.cpp */,
D630E2AB149BF344005B2F93 /* HistogramSupport.h */,
E1BE512E0CF6C512002EA959 /* XSLTUnicodeSort.h in Headers */,
977E2E0F12F0FC9C00C13379 /* XSSAuditor.h in Headers */,
FD537353137B651800008DCE /* ZeroPole.h in Headers */,
+ 144FCE5214EC79BC000D17A3 /* FractionalLayoutUnit.h in Headers */,
+ 144FCE5D14EC79E7000D17A3 /* FractionalLayoutSize.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
E1BE512D0CF6C512002EA959 /* XSLTUnicodeSort.cpp in Sources */,
977E2E0E12F0FC9C00C13379 /* XSSAuditor.cpp in Sources */,
FD537352137B651800008DCE /* ZeroPole.cpp in Sources */,
+ 144FCE5C14EC79E7000D17A3 /* FractionalLayoutSize.cpp in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
#include "FloatPoint.h"
#include "AffineTransform.h"
-#include "TransformationMatrix.h"
#include "FloatConversion.h"
+#include "FractionalLayoutSize.h"
#include "IntPoint.h"
+#include "TransformationMatrix.h"
#include <limits>
#include <math.h>
return sqrtf(lengthSquared());
}
+void FloatPoint::move(const FractionalLayoutSize& size)
+{
+ m_x += size.width();
+ m_y += size.height();
+}
+
FloatPoint FloatPoint::matrixTransform(const AffineTransform& transform) const
{
double newX, newY;
class TransformationMatrix;
class IntPoint;
class IntSize;
+class FractionalLayoutSize;
class FloatPoint {
public:
m_x += a.width();
m_y += a.height();
}
+ void move(const FractionalLayoutSize&);
void move(const FloatSize& a)
{
m_x += a.width();
#include "config.h"
#include "FloatSize.h"
+#include "FractionalLayoutSize.h"
#include "FloatConversion.h"
#include "IntSize.h"
#include <limits>
{
}
+FloatSize::FloatSize(const FractionalLayoutSize& size) : m_width(size.width()), m_height(size.height())
+{
+}
+
float FloatSize::diagonalLength() const
{
return sqrtf(diagonalLengthSquared());
namespace WebCore {
class IntSize;
+class FractionalLayoutSize;
class FloatSize {
public:
FloatSize() : m_width(0), m_height(0) { }
FloatSize(float width, float height) : m_width(width), m_height(height) { }
FloatSize(const IntSize&);
+ FloatSize(const FractionalLayoutSize&);
static FloatSize narrowPrecision(double width, double height);
--- /dev/null
+/*
+ * Copyright (c) 2012, Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "FractionalLayoutSize.h"
+
+#include "IntPoint.h"
+
+namespace WebCore {
+
+IntSize pixelSnappedIntSize(const FractionalLayoutSize& s, const IntPoint& p)
+{
+ return IntSize(snapSizeToPixel(s.width(), p.x()), snapSizeToPixel(s.height(), p.y()));
+}
+
+} // namespace WebCore
--- /dev/null
+/*
+ * Copyright (c) 2012, Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef FractionalLayoutSize_h
+#define FractionalLayoutSize_h
+
+#include "FloatSize.h"
+#include "FractionalLayoutUnit.h"
+#include "IntSize.h"
+
+namespace WebCore {
+
+class FractionalLayoutPoint;
+
+class FractionalLayoutSize {
+public:
+ FractionalLayoutSize() : m_width(0), m_height(0) { }
+ FractionalLayoutSize(const IntSize& size) : m_width(size.width()), m_height(size.height()) { }
+ FractionalLayoutSize(FractionalLayoutUnit width, FractionalLayoutUnit height) : m_width(width), m_height(height) { }
+
+ explicit FractionalLayoutSize(const FloatSize& size) : m_width(size.width()), m_height(size.height()) { }
+
+ FractionalLayoutUnit width() const { return m_width; }
+ FractionalLayoutUnit height() const { return m_height; }
+
+ void setWidth(FractionalLayoutUnit width) { m_width = width; }
+ void setHeight(FractionalLayoutUnit height) { m_height = height; }
+
+ bool isEmpty() const { return m_width <= 0 || m_height <= 0; }
+ bool isZero() const { return !m_width && !m_height; }
+
+ float aspectRatio() const { return static_cast<float>(m_width) / static_cast<float>(m_height); }
+
+ void expand(FractionalLayoutUnit width, FractionalLayoutUnit height)
+ {
+ m_width += width;
+ m_height += height;
+ }
+
+ void scale(float scale)
+ {
+ m_width = static_cast<int>(static_cast<float>(m_width) * scale);
+ m_height = static_cast<int>(static_cast<float>(m_height) * scale);
+ }
+
+ FractionalLayoutSize expandedTo(const FractionalLayoutSize& other) const
+ {
+ return FractionalLayoutSize(m_width > other.m_width ? m_width : other.m_width,
+ m_height > other.m_height ? m_height : other.m_height);
+ }
+
+ FractionalLayoutSize shrunkTo(const FractionalLayoutSize& other) const
+ {
+ return FractionalLayoutSize(m_width < other.m_width ? m_width : other.m_width,
+ m_height < other.m_height ? m_height : other.m_height);
+ }
+
+ void clampNegativeToZero()
+ {
+ *this = expandedTo(FractionalLayoutSize());
+ }
+
+ FractionalLayoutSize transposedSize() const
+ {
+ return FractionalLayoutSize(m_height, m_width);
+ }
+
+private:
+ FractionalLayoutUnit m_width, m_height;
+};
+
+inline FractionalLayoutSize& operator+=(FractionalLayoutSize& a, const FractionalLayoutSize& b)
+{
+ a.setWidth(a.width() + b.width());
+ a.setHeight(a.height() + b.height());
+ return a;
+}
+
+inline FractionalLayoutSize& operator-=(FractionalLayoutSize& a, const FractionalLayoutSize& b)
+{
+ a.setWidth(a.width() - b.width());
+ a.setHeight(a.height() - b.height());
+ return a;
+}
+
+inline FractionalLayoutSize operator+(const FractionalLayoutSize& a, const FractionalLayoutSize& b)
+{
+ return FractionalLayoutSize(a.width() + b.width(), a.height() + b.height());
+}
+
+inline FractionalLayoutSize operator-(const FractionalLayoutSize& a, const FractionalLayoutSize& b)
+{
+ return FractionalLayoutSize(a.width() - b.width(), a.height() - b.height());
+}
+
+inline FractionalLayoutSize operator-(const FractionalLayoutSize& size)
+{
+ return FractionalLayoutSize(-size.width(), -size.height());
+}
+
+inline bool operator==(const FractionalLayoutSize& a, const FractionalLayoutSize& b)
+{
+ return a.width() == b.width() && a.height() == b.height();
+}
+
+inline bool operator!=(const FractionalLayoutSize& a, const FractionalLayoutSize& b)
+{
+ return a.width() != b.width() || a.height() != b.height();
+}
+
+inline IntSize flooredIntSize(const FractionalLayoutSize& s)
+{
+ return IntSize(s.width().toInt(), s.height().toInt());
+}
+
+inline IntSize roundedIntSize(const FractionalLayoutSize& s)
+{
+ return IntSize(s.width().round(), s.height().round());
+}
+
+// FIXME: Change this method to take a FractionalLayoutPoint once that class has been added.
+IntSize pixelSnappedIntSize(const FractionalLayoutSize&, const IntPoint&);
+
+} // namespace WebCore
+
+#endif // FractionalLayoutSize_h