resolution independent px

Johannes Hofmann <[email protected]>
Newsgroups gmane.comp.web.dillo.devel
Message-ID <[email protected]>
Hi,

attached is a patch that would enable resolution independent
handling of px as described in [1].
It would result in roughly equally sized images on high and low
resolution devices at the cost of a higher overhead for additional
image scaling.
Is there a need for something like this?
Should it be enabled via config option or should we do it
automatically if we detect a DPI value that differs a lot from
the standard value?

Cheers,
Johannes

[1] http://www.w3.org/TR/CSS2/syndata.html#x39

_______________________________________________
Dillo-dev mailing list
[email protected]
http://lists.dillo.org/cgi-bin/mailman/listinfo/dillo-dev
resolution_independent_px.diff (text/x-diff, 3 KB)
diff -r f38eb2c74086 dw/image.cc
--- a/dw/image.cc	Thu Jan 08 23:00:26 2015 +0100
+++ b/dw/image.cc	Fri Jan 16 08:44:03 2015 +0100
@@ -172,13 +172,26 @@
    DBG_OBJ_DELETE ();
 }
 
+int Image::getRootWidth ()
+{
+   float dpmm = (float) layout->dpiX () / 25.4;
+   return buffer->getRootWidth () / dpmm / 0.26;
+}
+
+int Image::getRootHeight ()
+{
+   float dpmm = (float) layout->dpiX () / 25.4;
+   return buffer->getRootHeight () / dpmm / 0.26;
+}
+
+
 void Image::sizeRequestImpl (core::Requisition *requisition)
 {
    DBG_OBJ_ENTER0 ("resize", 0, "sizeRequestImpl");
 
    if (buffer) {
-      requisition->width = buffer->getRootWidth ();
-      requisition->ascent = buffer->getRootHeight ();
+      requisition->width = getRootWidth ();
+      requisition->ascent = getRootHeight ();
       requisition->descent = 0;
    } else {
       if (altText && altText[0]) {
@@ -222,11 +235,11 @@
       if (!widthSpecified && heightSpecified)
          requisition->width =
             (requisition->ascent + requisition->descent - boxDiffHeight ())
-            * buffer->getRootWidth () / buffer->getRootHeight ()
+            * getRootWidth () / getRootHeight ()
             + boxDiffWidth ();
       else if (widthSpecified && !heightSpecified) {
          requisition->ascent = (requisition->width + boxDiffWidth ())
-            * buffer->getRootHeight () / buffer->getRootWidth ()
+            * getRootHeight () / getRootWidth ()
             + boxOffsetY ();
          requisition->descent = boxRestHeight ();
       }
@@ -241,7 +254,7 @@
 {
    int contentWidth;
    if (buffer)
-      contentWidth = buffer->getRootWidth ();
+      contentWidth = getRootWidth ();
    else {
       if (altText && altText[0]) {
          if (altTextWidth == -1)
@@ -496,8 +509,8 @@
       this->buffer = buffer->getScaledBuf (bufWidth, bufHeight);
    } else {
       this->buffer = buffer;
-      bufWidth = buffer->getRootWidth ();
-      bufHeight = buffer->getRootHeight ();
+      bufWidth = getRootWidth ();
+      bufHeight = getRootHeight ();
       buffer->ref ();
    }
    queueResize (0, true);
diff -r f38eb2c74086 dw/image.hh
--- a/dw/image.hh	Thu Jan 08 23:00:26 2015 +0100
+++ b/dw/image.hh	Fri Jan 16 08:44:03 2015 +0100
@@ -130,6 +130,8 @@
    bool isMap;
 
 protected:
+   int getRootWidth ();
+   int getRootHeight ();
    void sizeRequestImpl (core::Requisition *requisition);
    void getExtremesImpl (core::Extremes *extremes);
    void sizeAllocateImpl (core::Allocation *allocation);
diff -r f38eb2c74086 src/styleengine.cc
--- a/src/styleengine.cc	Thu Jan 08 23:00:26 2015 +0100
+++ b/src/styleengine.cc	Fri Jan 16 08:44:03 2015 +0100
@@ -784,7 +784,7 @@
 bool StyleEngine::computeValue (int *dest, CssLength value, Font *font) {
    switch (CSS_LENGTH_TYPE (value)) {
       case CSS_LENGTH_TYPE_PX:
-         *dest = (int) CSS_LENGTH_VALUE (value);
+         *dest = roundInt (CSS_LENGTH_VALUE (value) * dpmm * 0.26);
          return true;
       case CSS_LENGTH_TYPE_MM:
          *dest = roundInt (CSS_LENGTH_VALUE (value) * dpmm);
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.